Commit 226f0c76 authored by Michael Widenius's avatar Michael Widenius

Added federatedx storage engine

Fixed compiler warnings


client/mysqladmin.cc:
  Fixed compiler warning
extra/yassl/taocrypt/src/twofish.cpp:
  Fixed compiler warning
libmysqld/Makefile.am:
  Use federatedx instead of federated
  (Should actually be removed)
mysql-test/mysql-test-run.pl:
  Fixed warning
mysql-test/valgrind.supp:
  Removed warning found on 64 bit Linux machine
storage/pbxt/src/cache_xt.cc:
  Fixed compile warning
storage/xtradb/include/buf0buf.ic:
  Fixed compiler warning
parent 664fa25e
......@@ -1043,7 +1043,7 @@ static int drop_db(MYSQL *mysql, const char *db)
printf("Do you really want to drop the '%s' database [y/N] ",db);
fflush(stdout);
if (fgets(buf,sizeof(buf)-1,stdin) == 0 ||
(*buf != 'y') && (*buf != 'Y'))
((*buf != 'y') && (*buf != 'Y')))
{
puts("\nOK, aborting database drop!");
return -1;
......
......@@ -55,6 +55,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz)
in += BLOCK_SIZE;
}
else if (mode_ == CBC)
{
if (dir_ == ENCRYPTION)
while (blocks--) {
r_[0] ^= *(word32*)in;
......@@ -82,6 +83,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE;
in += BLOCK_SIZE;
}
}
}
#endif // DO_TWOFISH_ASM
......
......@@ -124,7 +124,7 @@ handler.o: handler.cc
# found to append fileslists that collected by configure
# to the sources list
ha_federated.o:ha_federated.cc
ha_federatedx.o:ha_federatedx.cc
$(CXXCOMPILE) $(LM_CFLAGS) -c $<
ha_heap.o:ha_heap.cc
......
......@@ -127,7 +127,6 @@ my $path_config_file; # The generated config file, var/my.cnf
our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
my $DEFAULT_SUITES= "binlog,federated,main,maria,rpl,innodb,parts";
my $opt_suites;
our $opt_usage;
our $opt_list_options;
......
......@@ -9,4 +9,5 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
federated_transactions : Bug#29523 Transactions do not work
federated_server : needs fixup
......@@ -47,9 +47,10 @@ CREATE TABLE federated.t1 (
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t3';
SELECT * FROM federated.t1;
ERROR HY000: The foreign data source you are trying to reference does not exist. Data source error: error: 1146 'Table 'federated.t3' doesn't exist'
DROP TABLE federated.t1;
ERROR HY000: Can't create federated table. Foreign data src error: database: 'federated' username: 'root' hostname: '127.0.0.1'
DROP TABLE IF EXISTS federated.t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
......@@ -59,9 +60,10 @@ CREATE TABLE federated.t1 (
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://user:pass@127.0.0.1:SLAVE_PORT/federated/t1';
SELECT * FROM federated.t1;
ERROR HY000: Unable to connect to foreign data source: Access denied for user 'user'@'localhost' (using password: YES)
DROP TABLE federated.t1;
ERROR HY000: Can't create federated table. Foreign data src error: database: 'federated' username: 'user' hostname: '127.0.0.1'
DROP TABLE IF EXISTS federated.t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
......@@ -1944,15 +1946,7 @@ Bug#18287 create federated table always times out, error 1159 ' '
Test that self-references work
create table federated.t1 (a int primary key);
create table federated.t2 (a int primary key)
ENGINE=FEDERATED
connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
insert into federated.t1 (a) values (1);
select * from federated.t2;
a
1
drop table federated.t1, federated.t2;
fix LOCK_open before reenabling test for Bug#18287
CREATE TABLE federated.t1 (a INT PRIMARY KEY) DEFAULT CHARSET=utf8;
CREATE TABLE federated.t1 (a INT PRIMARY KEY)
ENGINE=FEDERATED
......@@ -1960,13 +1954,11 @@ CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'
DEFAULT CHARSET=utf8;
SELECT transactions FROM information_schema.engines WHERE engine="FEDERATED";
transactions
NO
YES
INSERT INTO federated.t1 VALUES (1);
SET autocommit=0;
INSERT INTO federated.t1 VALUES (2);
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
SET autocommit=1;
SELECT * FROM federated.t1;
a
......@@ -2157,6 +2149,6 @@ End of 5.1 tests
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
......@@ -57,6 +57,7 @@ CREATE TABLE federated.t1 (
# test non-existant table
--replace_result $SLAVE_MYPORT SLAVE_PORT
--error ER_CANT_CREATE_FEDERATED_TABLE
eval CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
......@@ -66,12 +67,11 @@ eval CREATE TABLE federated.t1 (
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t3';
--error ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST
SELECT * FROM federated.t1;
DROP TABLE federated.t1;
DROP TABLE IF EXISTS federated.t1;
# test bad user/password
--replace_result $SLAVE_MYPORT SLAVE_PORT
--error ER_CANT_CREATE_FEDERATED_TABLE
eval CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
......@@ -81,9 +81,7 @@ eval CREATE TABLE federated.t1 (
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://user:pass@127.0.0.1:$SLAVE_MYPORT/federated/t1';
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
SELECT * FROM federated.t1;
DROP TABLE federated.t1;
DROP TABLE IF EXISTS federated.t1;
# # correct connection, same named tables
--replace_result $SLAVE_MYPORT SLAVE_PORT
......@@ -1806,6 +1804,8 @@ drop table federated.t1;
--echo
--echo Test that self-references work
--echo
--echo fix LOCK_open before reenabling test for Bug#18287
--disable_parsing
connection slave;
create table federated.t1 (a int primary key);
--replace_result $SLAVE_MYPORT SLAVE_PORT
......@@ -1815,7 +1815,7 @@ eval create table federated.t2 (a int primary key)
insert into federated.t1 (a) values (1);
select * from federated.t2;
drop table federated.t1, federated.t2;
--enable_parsing
#
# BUG#29875 Disable support for transactions
#
......
......@@ -34,6 +34,6 @@ id name
DROP TABLE federated.t1;
DROP TABLE federated.archive_table;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
......@@ -25,6 +25,6 @@ foo bar
DROP TABLE federated.t1;
DROP TABLE federated.bug_13118_table;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
......@@ -48,6 +48,6 @@ SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT;
DROP TABLE federated.t1;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
connection master;
--disable_warnings
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
connection slave;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
--enable_warnings
......@@ -20,6 +20,6 @@ a b
drop table federated.t1;
drop table federated.t1;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
......@@ -178,8 +178,8 @@ INSERT INTO db_bogus.t1 VALUES ('2','this is bogus');
create server 's1' foreign data wrapper 'mysql' options
(HOST '127.0.0.1',
DATABASE 'db_legitimate',
USER 'root',
PASSWORD '',
USER 'test_fed',
PASSWORD 'foo',
PORT SLAVE_PORT,
SOCKET '',
OWNER 'root');
......
......@@ -3,6 +3,7 @@
# Slow test, don't run during staging part
-- source include/not_staging.inc
-- source include/big_test.inc
-- source federated.inc
connection slave;
......@@ -182,13 +183,17 @@ CREATE TABLE db_bogus.t1 (
;
INSERT INTO db_bogus.t1 VALUES ('2','this is bogus');
connection slave;
create user test_fed@localhost identified by 'foo';
grant all on db_legitimate.* to test_fed@localhost;
connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval create server 's1' foreign data wrapper 'mysql' options
(HOST '127.0.0.1',
DATABASE 'db_legitimate',
USER 'root',
PASSWORD '',
USER 'test_fed',
PASSWORD 'foo',
PORT $SLAVE_MYPORT,
SOCKET '',
OWNER 'root');
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
stop slave;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
DROP TABLE IF EXISTS federated.t1;
Warnings:
......
......@@ -880,3 +880,17 @@
fun:nptl_pthread_exit_hack_handler
fun:start_thread
}
#
# Problem with glibc and gethostbyaddr_r
#
{
libc_res_nsend: Conditional jump or move depends on uninitialised value
Memcheck:Cond
fun: __libc_res_nsend
fun: __libc_res_nquery
obj: /lib64/libnss_dns-*so)
obj: /lib64/libnss_dns-*so)
fun: gethostbyaddr_r
}
The files in this directory are not used by MariaDB
MariaDB uses the new federated storage engine that can be found in the
federatedx directory.
This directory is only kept around to make it easy to merge code from the
MySQL source repositories that uses the old and disabled federated code.
FederatedX
Patrick Galbraith <patg@patg.net> - Federated
Pluggable Storage Engine Skeleton setup
Brian Aker <brian@mysql.com> | <brian@tangent.org> - Original Design
Calvin Sun - Windows Support
Brian Miezejewski - Bug fixes
Antony T Curtis - Help in inital development, transactions and various help
Michael Widenius - Bug fixes and some simple early optimizations
INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
SET(FEDERATED_SOURCES ha_federatedx.cc)
MYSQL_STORAGE_ENGINE(FEDERATED)
0.2 - Thu March 8 00:00:00 EST 2008
- Fixed bug #30051 "CREATE TABLE does not connect and check existence of remote table"
Modified "real_connect" to take a share and create flag to in order to not rely
on any settings that are later instantiated and/or set by get_share
Also, put logic in the code to not attempt this if a localhost. There's an annoying
functionality that if federated tries to connect to itself during creater table, you
get 1159 error (timeout) - only when local. This prevents having this functionality
and is probably part of the reason it was removed.
0.1 - Thu Feb 1 00:00:00 EST 2008
- This is the FederatedX Storage Engine,
first release.
- Added documentation
- Added simple test and README file to explain
how to run the test
- Added FAQ
Q. What is the FederatedX pluggable storage engine?
A. It is a fork of the Federated Storage Engine that Brian Aker and I
(Patrick Galbraith) developed originally . It is a storage engine that
uses a client connection to a remote MySQL data source as its data
source instead of a local file on disk.
Q. Why did you fork from Federated?
A. To enhance the storage engine independently of the
MySQL Server release schedule. Many people have been
mentioning their dissatisfaction with the limitations
of Federated. I think the engine is a great concept and
have a sense of obligation to continue to improve it.
There are some patches already that are in dire need
of being applied and tested.
Q. What do you plan to do with FederatedX?
A. Many things need addressing:
- Outstanding bugs
- How do deal with huge result sets
- Pushdown conditions (being able to pass things like LIMIT
to the remote connection to keep from returning huge
result sets).
- Better transactional support
- Other connection mechanisms (ODBC, JDBC, native drivers
of other RDBMSs)
Q. What FederatedX is and is not?
A. FederatedX is not yet a complete "federated" solution in
the sense that other venders have developed (IBM, etc). It
is essentially a networked storage engine. It is my hope
to make it a real federated solution.
Q. In which MySQL distributions/forks/branches can I find FederateX
A. MariaDB (http://www.mariadb.com)
# Used to build Makefile.in
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
-I$(srcdir)
WRAPLIBS=
LDADD =
DEFS = @DEFS@
noinst_HEADERS = ha_federatedx.h federatedx_probes.h
EXTRA_LTLIBRARIES = ha_federatedx.la
pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@
ha_federatedx_la_LDFLAGS = -module -rpath $(pkgplugindir)
ha_federatedx_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_federatedx_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_federatedx_la_SOURCES = ha_federatedx.cc
EXTRA_LIBRARIES = libfederatedx.a
noinst_LIBRARIES = @plugin_federated_static_target@
libfederatedx_a_CXXFLAGS = $(AM_CFLAGS)
libfederatedx_a_CFLAGS = $(AM_CFLAGS)
libfederatedx_a_SOURCES= ha_federatedx.cc federatedx_txn.cc \
federatedx_io.cc federatedx_io_null.cc \
federatedx_io_mysql.cc
EXTRA_DIST = CMakeLists.txt plug.in ha_federatedx.h \
federatedx_probes.d
ha_federatedx_la_SOURCES = ha_federatedx.cc federatedx_txn.cc \
federatedx_io.cc federatedx_io_null.cc \
federatedx_io_mysql.cc $(top_srcdir)/mysys/string.c
ha_federatedx_la_LIBADD =
#DTRACE = @DTRACE@
#DTRACEFLAGS = @DTRACEFLAGS@
#DTRACEFILES = .libs/libfederatedx_engine_la-ha_federatedx.o
# #if HAVE_DTRACE
# # libfederatedx_engine_la_LIBADD += federatedx_probes.o
# #endif
# federatedx_probes.h: federatedx_probes.d
# $(DTRACE) $(DTRACEFLAGS) -h -s federatedx_probes.d
# mv federatedx_probes.h federatedx_probes.h.bak
# sed "s/#include <unistd.h>//g" federatedx_probes.h.bak > federatedx_probes.h
# rm federatedx_probes.h.bak
#federatedx_probes.o:
# $(DTRACE) $(DTRACEFLAGS) -G -s federatedx_probes.d $(DTRACEFILES)
# End
# Don't update the files from bitkeeper
%::SCCS/s.%
This is the FederatedX Storage Engine, developed as an external storage engine.
NOTE:
The following is only relevant if you use it for MySQL. MariaDB already comes
with the latest version of FederatedX.
To install, grab a copy of the mysql source code and run this:
./configure --with-mysql=/path/to/src/mysql-5.x --libdir=/usr/local/lib/mysql/
make install
And then inside of MySQL:
mysql> INSTALL PLUGIN federatedx SONAME 'libfederatedx_engine.so';
mysql> CREATE TABLE `d` (`a` varchar(125), b text, primary key(a)) ENGINE=FEDERATEDX CONNECTION="mysql://root@host/schema/table"
or
mysql> CREATE TABLE `d` (`a` varchar(125), b text, primary key(a)) ENGINE=FEDERATEDX CONNECTION="server" CHARSET=latin1;
You will probably need to edit the Makefile.am in the src/ tree if you want
to build on anything other then Linux (and the Makefile assumes that the
server was not compiled for debug). The reason for the two possible
configure lines is that libdir is dependent on where MySQL was installed. If
you run the "INSTALL PLUGIN ..." and you get a file not found, check that
your configured this directory correctly.
For Solaris you can enable DTrace probes by adding to configure
--enable-dtrace
The following files are changed in order to build a new engine on Windows:
- Update win\configure.js with
case "WITH_FEDERATEDX_STORAGE_ENGINE":
to make sure it will pass WITH_FEDERATEDX_STORAGE_ENGINE in.
- Update CMakeFiles.txt under mysql root:
IF(WITH_FEDERATEDX_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_FEDERATEDX_STORAGE_ENGINE)
SET (mysql_plugin_defs
"${mysql_plugin_defs},builtin_skeleton_plugin")
ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
and,
IF(WITH_FEDERATEDX_STORAGE_ENGINE)
ADD_SUBDIRECTORY(storage/skeleton/src)
ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
- Update CMakeFiles.txt under sql:
IF(WITH_FEDERATEDX_STORAGE_ENGINE)
TARGET_LINK_LIBRARIES(mysqld skeleton)
ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
Features
* Add Pushdown conditions
* Add other network driver interfaces
* Handle large result sets
* Auto-discovery of tables on foreign data sources
Bugs (http://bugs.mysql.com)
20026 2006-05-23 FEDERATED lacks support for auto_increment_increment and auto_increment_offset
20724 2006-06-27 FEDERATED does not honour SET INSERT_ID
28269 2007-05-06 Any FEDERATED engine fails to quote reserved words for field names
25509 2007-01-10 Federated: Failure with non-ASCII characters
26697 2007-02-27 Every query to a federated table results in a full scan of MyISAM table.
21360 2006-07-31 Microsoft Windows (Windows/Linux) mysqldump error on federated tables
34189 2008-01-31 Any ALTER TABLE t1 ENGINE=FEDERATED CONNECTION='connectionString' on MyISAM fails
31757 2007-10-22 Any Federated tables break replication Antony Curtis
33953 2008-01-21 Any mysqld dies on search federated table using nullable index with < or <= operator
34015 2008-01-23 Linux Problems with float fields using federated tables
21583 2006-08-11 Linux (Linux) Federated table returns broken strings.
33702 2008-01-05 Accessing a federated table with a non existing server returns random error code
25512 2007-01-10 Federated: CREATE failures
32426 2007-11-16 Any FEDERATED query returns corrupt results for ORDER BY on a TEXT field
25510 2007-01-10 Federated: double trigger activation
33250 2007-12-14 SELECT * FROM really_big_federated_table eats lots of virtual memory (OOM)
14874 2005-11-11 Error 2013: Lost connection to MySQL server with Federated table
25508 2007-01-10 Federated: Failure to Remove Partitioning
27180 2007-03-15 #1030 - Got error 1 from storage engine with big tables
33947 2008-01-20 Any Join on Federated tables with Unique index and IS NOT NULL crashes server
30051 (fixed) CREATE TABLE does not connect and check existence of remote table
/*
Copyright (c) 2007, Antony T Curtis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Neither the name of FederatedX nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*#define MYSQL_SERVER 1*/
#include "mysql_priv.h"
#include <mysql/plugin.h>
#include "ha_federatedx.h"
#include "m_string.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
typedef federatedx_io *(*instantiate_io_type)(MEM_ROOT *server_root,
FEDERATEDX_SERVER *server);
struct io_schemes_st
{
const char *scheme;
instantiate_io_type instantiate;
};
static const io_schemes_st federated_io_schemes[] =
{
{ "mysql", &instantiate_io_mysql },
{ "null", instantiate_io_null } /* must be last element */
};
const uint federated_io_schemes_count= array_elements(federated_io_schemes);
federatedx_io::federatedx_io(FEDERATEDX_SERVER *aserver)
: server(aserver), owner_ptr(0), txn_next(0), idle_next(0),
active(FALSE), busy(FALSE), readonly(TRUE)
{
DBUG_ENTER("federatedx_io::federatedx_io");
DBUG_ASSERT(server);
safe_mutex_assert_owner(&server->mutex);
server->io_count++;
DBUG_VOID_RETURN;
}
federatedx_io::~federatedx_io()
{
DBUG_ENTER("federatedx_io::~federatedx_io");
server->io_count--;
DBUG_VOID_RETURN;
}
bool federatedx_io::handles_scheme(const char *scheme)
{
const io_schemes_st *ptr = federated_io_schemes;
const io_schemes_st *end = ptr + array_elements(federated_io_schemes);
while (ptr != end && strcasecmp(scheme, ptr->scheme))
++ptr;
return ptr != end;
}
federatedx_io *federatedx_io::construct(MEM_ROOT *server_root,
FEDERATEDX_SERVER *server)
{
const io_schemes_st *ptr = federated_io_schemes;
const io_schemes_st *end = ptr + (array_elements(federated_io_schemes) - 1);
while (ptr != end && strcasecmp(server->scheme, ptr->scheme))
++ptr;
return ptr->instantiate(server_root, server);
}
This diff is collapsed.
/*
Copyright (c) 2007, Antony T Curtis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Neither the name of FederatedX nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*#define MYSQL_SERVER 1*/
#include "mysql_priv.h"
#include <mysql/plugin.h>
#include "ha_federatedx.h"
#include "m_string.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#define SAVEPOINT_REALIZED 1
#define SAVEPOINT_RESTRICT 2
#define SAVEPOINT_EMITTED 4
typedef struct federatedx_savepoint
{
ulong level;
uint flags;
} SAVEPT;
class federatedx_io_null :public federatedx_io
{
public:
federatedx_io_null(FEDERATEDX_SERVER *);
~federatedx_io_null();
int query(const char *buffer, uint length);
virtual FEDERATEDX_IO_RESULT *store_result();
virtual size_t max_query_size() const;
virtual my_ulonglong affected_rows() const;
virtual my_ulonglong last_insert_id() const;
virtual int error_code();
virtual const char *error_str();
void reset();
int commit();
int rollback();
int savepoint_set(ulong sp);
ulong savepoint_release(ulong sp);
ulong savepoint_rollback(ulong sp);
void savepoint_restrict(ulong sp);
ulong last_savepoint() const;
ulong actual_savepoint() const;
bool is_autocommit() const;
bool table_metadata(ha_statistics *stats, const char *table_name,
uint table_name_length, uint flag);
/* resultset operations */
virtual void free_result(FEDERATEDX_IO_RESULT *io_result);
virtual unsigned int get_num_fields(FEDERATEDX_IO_RESULT *io_result);
virtual my_ulonglong get_num_rows(FEDERATEDX_IO_RESULT *io_result);
virtual FEDERATEDX_IO_ROW *fetch_row(FEDERATEDX_IO_RESULT *io_result);
virtual ulong *fetch_lengths(FEDERATEDX_IO_RESULT *io_result);
virtual const char *get_column_data(FEDERATEDX_IO_ROW *row,
unsigned int column);
virtual bool is_column_null(const FEDERATEDX_IO_ROW *row,
unsigned int column) const;
};
federatedx_io *instantiate_io_null(MEM_ROOT *server_root,
FEDERATEDX_SERVER *server)
{
return new (server_root) federatedx_io_null(server);
}
federatedx_io_null::federatedx_io_null(FEDERATEDX_SERVER *aserver)
: federatedx_io(aserver)
{
}
federatedx_io_null::~federatedx_io_null()
{
}
void federatedx_io_null::reset()
{
}
int federatedx_io_null::commit()
{
return 0;
}
int federatedx_io_null::rollback()
{
return 0;
}
ulong federatedx_io_null::last_savepoint() const
{
return 0;
}
ulong federatedx_io_null::actual_savepoint() const
{
return 0;
}
bool federatedx_io_null::is_autocommit() const
{
return 0;
}
int federatedx_io_null::savepoint_set(ulong sp)
{
return 0;
}
ulong federatedx_io_null::savepoint_release(ulong sp)
{
return 0;
}
ulong federatedx_io_null::savepoint_rollback(ulong sp)
{
return 0;
}
void federatedx_io_null::savepoint_restrict(ulong sp)
{
}
int federatedx_io_null::query(const char *buffer, uint length)
{
return 0;
}
size_t federatedx_io_null::max_query_size() const
{
return INT_MAX;
}
my_ulonglong federatedx_io_null::affected_rows() const
{
return 0;
}
my_ulonglong federatedx_io_null::last_insert_id() const
{
return 0;
}
int federatedx_io_null::error_code()
{
return 0;
}
const char *federatedx_io_null::error_str()
{
return "";
}
FEDERATEDX_IO_RESULT *federatedx_io_null::store_result()
{
FEDERATEDX_IO_RESULT *result;
DBUG_ENTER("federatedx_io_null::store_result");
result= NULL;
DBUG_RETURN(result);
}
void federatedx_io_null::free_result(FEDERATEDX_IO_RESULT *)
{
}
unsigned int federatedx_io_null::get_num_fields(FEDERATEDX_IO_RESULT *)
{
return 0;
}
my_ulonglong federatedx_io_null::get_num_rows(FEDERATEDX_IO_RESULT *)
{
return 0;
}
FEDERATEDX_IO_ROW *federatedx_io_null::fetch_row(FEDERATEDX_IO_RESULT *)
{
return NULL;
}
ulong *federatedx_io_null::fetch_lengths(FEDERATEDX_IO_RESULT *)
{
return NULL;
}
const char *federatedx_io_null::get_column_data(FEDERATEDX_IO_ROW *,
unsigned int)
{
return "";
}
bool federatedx_io_null::is_column_null(const FEDERATEDX_IO_ROW *,
unsigned int) const
{
return true;
}
bool federatedx_io_null::table_metadata(ha_statistics *stats,
const char *table_name,
uint table_name_length, uint flag)
{
stats->records= (ha_rows) 0;
stats->mean_rec_length= (ulong) 0;
stats->data_file_length= 0;
stats->update_time= (time_t) 0;
stats->check_time= (time_t) 0;
return 0;
}
/*
* Generated by dtrace(1M).
*/
#ifndef _FEDERATED_PROBES_H
#define _FEDERATED_PROBES_H
#ifdef __cplusplus
extern "C" {
#endif
#if _DTRACE_VERSION
#define FEDERATED_CLOSE() \
__dtrace_federated___close()
#define FEDERATED_CLOSE_ENABLED() \
__dtraceenabled_federated___close()
#define FEDERATED_OPEN() \
__dtrace_federated___open()
#define FEDERATED_OPEN_ENABLED() \
__dtraceenabled_federated___open()
extern void __dtrace_federated___close(void);
extern int __dtraceenabled_federated___close(void);
extern void __dtrace_federated___open(void);
extern int __dtraceenabled_federated___open(void);
#else
#define FEDERATED_CLOSE()
#define FEDERATED_CLOSE_ENABLED() (0)
#define FEDERATED_OPEN()
#define FEDERATED_OPEN_ENABLED() (0)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _FEDERATED_PROBES_H */
/*
Copyright (c) 2007, Antony T Curtis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Neither the name of FederatedX nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*#define MYSQL_SERVER 1*/
#include "mysql_priv.h"
#include <mysql/plugin.h>
#include "ha_federatedx.h"
#include "m_string.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
federatedx_txn::federatedx_txn()
: txn_list(0), savepoint_level(0), savepoint_stmt(0), savepoint_next(0)
{
DBUG_ENTER("federatedx_txn::federatedx_txn");
DBUG_VOID_RETURN;
}
federatedx_txn::~federatedx_txn()
{
DBUG_ENTER("federatedx_txn::~federatedx_txn");
DBUG_ASSERT(!txn_list);
DBUG_VOID_RETURN;
}
void federatedx_txn::close(FEDERATEDX_SERVER *server)
{
uint count= 0;
federatedx_io *io, **iop;
DBUG_ENTER("federatedx_txn::close");
DBUG_ASSERT(!server->use_count);
DBUG_PRINT("info",("use count: %u connections: %u",
server->use_count, server->io_count));
for (iop= &txn_list; (io= *iop);)
{
if (io->server != server)
iop= &io->txn_next;
else
{
*iop= io->txn_next;
io->txn_next= NULL;
io->busy= FALSE;
io->idle_next= server->idle_list;
server->idle_list= io;
}
}
while ((io= server->idle_list))
{
server->idle_list= io->idle_next;
delete io;
count++;
}
DBUG_PRINT("info",("closed %u connections, txn_list: %s", count,
txn_list ? "active": "empty"));
DBUG_VOID_RETURN;
}
int federatedx_txn::acquire(FEDERATEDX_SHARE *share, bool readonly,
federatedx_io **ioptr)
{
federatedx_io *io;
FEDERATEDX_SERVER *server= share->s;
DBUG_ENTER("federatedx_txn::acquire");
DBUG_ASSERT(ioptr && server);
if (!(io= *ioptr))
{
/* check to see if we have an available IO connection */
for (io= txn_list; io; io= io->txn_next)
if (io->server == server)
break;
if (!io)
{
/* check to see if there are any unowned IO connections */
pthread_mutex_lock(&server->mutex);
if ((io= server->idle_list))
{
server->idle_list= io->idle_next;
io->idle_next= NULL;
}
else
io= federatedx_io::construct(&server->mem_root, server);
io->txn_next= txn_list;
txn_list= io;
pthread_mutex_unlock(&server->mutex);
}
if (io->busy)
*io->owner_ptr= NULL;
io->busy= TRUE;
io->owner_ptr= ioptr;
}
DBUG_ASSERT(io->busy && io->server == server);
io->readonly&= readonly;
DBUG_RETURN((*ioptr= io) ? 0 : -1);
}
void federatedx_txn::release(federatedx_io **ioptr)
{
federatedx_io *io;
DBUG_ENTER("federatedx_txn::release");
DBUG_ASSERT(ioptr);
if ((io= *ioptr))
{
/* mark as available for reuse in this transaction */
io->busy= FALSE;
*ioptr= NULL;
DBUG_PRINT("info", ("active: %d autocommit: %d",
io->active, io->is_autocommit()));
if (io->is_autocommit())
io->active= FALSE;
}
release_scan();
DBUG_VOID_RETURN;
}
void federatedx_txn::release_scan()
{
uint count= 0, returned= 0;
federatedx_io *io, **pio;
DBUG_ENTER("federatedx_txn::release_scan");
/* return any inactive and idle connections to the server */
for (pio= &txn_list; (io= *pio); count++)
{
if (io->active || io->busy)
pio= &io->txn_next;
else
{
FEDERATEDX_SERVER *server= io->server;
/* unlink from list of connections bound to the transaction */
*pio= io->txn_next;
io->txn_next= NULL;
/* reset some values */
io->readonly= TRUE;
pthread_mutex_lock(&server->mutex);
io->idle_next= server->idle_list;
server->idle_list= io;
pthread_mutex_unlock(&server->mutex);
returned++;
}
}
DBUG_PRINT("info",("returned %u of %u connections(s)", returned, count));
DBUG_VOID_RETURN;
}
bool federatedx_txn::txn_begin()
{
ulong level= 0;
DBUG_ENTER("federatedx_txn::txn_begin");
if (savepoint_next == 0)
{
savepoint_next++;
savepoint_level= savepoint_stmt= 0;
sp_acquire(&level);
}
DBUG_RETURN(level == 1);
}
int federatedx_txn::txn_commit()
{
int error= 0;
federatedx_io *io;
DBUG_ENTER("federatedx_txn::txn_commit");
if (savepoint_next)
{
DBUG_ASSERT(savepoint_stmt != 1);
for (io= txn_list; io; io= io->txn_next)
{
int rc= 0;
if (io->active)
rc= io->commit();
else
io->rollback();
if (io->active && rc)
error= -1;
io->reset();
}
release_scan();
savepoint_next= savepoint_stmt= savepoint_level= 0;
}
DBUG_RETURN(error);
}
int federatedx_txn::txn_rollback()
{
int error= 0;
federatedx_io *io;
DBUG_ENTER("federatedx_txn::txn_commit");
if (savepoint_next)
{
DBUG_ASSERT(savepoint_stmt != 1);
for (io= txn_list; io; io= io->txn_next)
{
int rc= io->rollback();
if (io->active && rc)
error= -1;
io->reset();
}
release_scan();
savepoint_next= savepoint_stmt= savepoint_level= 0;
}
DBUG_RETURN(error);
}
bool federatedx_txn::sp_acquire(ulong *sp)
{
bool rc= FALSE;
federatedx_io *io;
DBUG_ENTER("federatedx_txn::sp_acquire");
DBUG_ASSERT(sp && savepoint_next);
*sp= savepoint_level= savepoint_next++;
for (io= txn_list; io; io= io->txn_next)
{
if (io->readonly)
continue;
io->savepoint_set(savepoint_level);
rc= TRUE;
}
DBUG_RETURN(rc);
}
int federatedx_txn::sp_rollback(ulong *sp)
{
ulong level, new_level= savepoint_level;
federatedx_io *io;
DBUG_ENTER("federatedx_txn::sp_rollback");
DBUG_ASSERT(sp && savepoint_next && *sp && *sp <= savepoint_level);
for (io= txn_list; io; io= io->txn_next)
{
if (io->readonly)
continue;
if ((level= io->savepoint_rollback(*sp)) < new_level)
new_level= level;
}
savepoint_level= new_level;
DBUG_RETURN(0);
}
int federatedx_txn::sp_release(ulong *sp)
{
ulong level, new_level= savepoint_level;
federatedx_io *io;
DBUG_ENTER("federatedx_txn::sp_release");
DBUG_ASSERT(sp && savepoint_next && *sp && *sp <= savepoint_level);
for (io= txn_list; io; io= io->txn_next)
{
if (io->readonly)
continue;
if ((level= io->savepoint_release(*sp)) < new_level)
new_level= level;
}
savepoint_level= new_level;
*sp= 0;
DBUG_RETURN(0);
}
bool federatedx_txn::stmt_begin()
{
bool result= FALSE;
DBUG_ENTER("federatedx_txn::stmt_begin");
if (!savepoint_stmt)
{
if (!savepoint_next)
{
savepoint_next++;
savepoint_level= savepoint_stmt= 0;
}
result= sp_acquire(&savepoint_stmt);
}
DBUG_RETURN(result);
}
int federatedx_txn::stmt_commit()
{
int result= 0;
DBUG_ENTER("federatedx_txn::stmt_commit");
if (savepoint_stmt == 1)
{
savepoint_stmt= 0;
result= txn_commit();
}
else
if (savepoint_stmt)
result= sp_release(&savepoint_stmt);
DBUG_RETURN(result);
}
int federatedx_txn::stmt_rollback()
{
int result= 0;
DBUG_ENTER("federated:txn::stmt_rollback");
if (savepoint_stmt == 1)
{
savepoint_stmt= 0;
result= txn_rollback();
}
else
if (savepoint_stmt)
{
result= sp_rollback(&savepoint_stmt);
sp_release(&savepoint_stmt);
}
DBUG_RETURN(result);
}
void federatedx_txn::stmt_autocommit()
{
federatedx_io *io;
DBUG_ENTER("federatedx_txn::stmt_autocommit");
for (io= txn_list; savepoint_stmt && io; io= io->txn_next)
{
if (io->readonly)
continue;
io->savepoint_restrict(savepoint_stmt);
}
DBUG_VOID_RETURN;
}
This diff is collapsed.
This diff is collapsed.
MYSQL_STORAGE_ENGINE(federated,,[FederatedX Storage Engine],
[FederatedX Storage Engine], [max,max-no-ndb])
MYSQL_PLUGIN_DYNAMIC(federated, [ha_federatedx.la])
MYSQL_PLUGIN_STATIC(federated, [libfederatedx.a])
MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(federated, [ha_federatedx.cc])
......@@ -374,7 +374,7 @@ xtPublic void xt_ind_release_handle(XTIndHandlePtr handle, xtBool have_lock, XTT
{
DcHandleSlotPtr hs;
XTIndBlockPtr block = NULL;
u_int hash_idx = NULL;
u_int hash_idx = 0;
DcSegmentPtr seg = NULL;
XTIndBlockPtr xblock;
......@@ -1379,7 +1379,7 @@ xtPublic xtBool xt_ind_fetch(XTOpenTablePtr ot, XTIndexPtr ind, xtIndexNodeID ad
ASSERT_NS(iref->ir_xlock == 2);
#endif
if (!(block = ind_cac_fetch(ot, ind, address, &seg, TRUE)))
return NULL;
return 0;
branch_size = XT_GET_DISK_2(((XTIdxBranchDPtr) block->cb_data)->tb_size_2);
if (XT_GET_INDEX_BLOCK_LEN(branch_size) < 2 || XT_GET_INDEX_BLOCK_LEN(branch_size) > XT_INDEX_PAGE_SIZE) {
......
......@@ -1056,7 +1056,7 @@ buf_page_release(
buf_block_t* block, /* in: buffer block */
ulint rw_latch, /* in: RW_S_LATCH, RW_X_LATCH,
RW_NO_LATCH */
mtr_t* mtr) /* in: mtr */
mtr_t* mtr __attribute__((unused))) /* in: mtr */
{
ut_ad(block);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment