From 0bf531def24264986fb4cbbdcd95616641c71e16 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Sep 2012 19:19:21 +0530 Subject: [PATCH 001/273] From 7a9cf3ccb5cbb455a7f0471553f309f45cb96414 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jan 2013 18:32:42 +0100 Subject: [PATCH 002/273] From b2f7b7fcd3b6ee61cd63b0c6449e82cb87c1fa94 Mon Sep 17 00:00:00 2001 From: Sunanda Menon Date: Tue, 8 Jan 2013 07:28:41 +0100 Subject: [PATCH 003/273] Raise version number after cloning 5.5.30 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3c7056de633..a489ca65d7f 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=5 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=30 +MYSQL_VERSION_PATCH=31 MYSQL_VERSION_EXTRA= From 7a89d68f01bda710e0195ce448ea2e2fb047ca15 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Jan 2013 12:42:36 +0100 Subject: [PATCH 004/273] Raise version number after cloning 5.1.68 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index e4618f58a91..8ed6afb1559 100644 --- a/configure.in +++ b/configure.in @@ -12,7 +12,7 @@ dnl dnl When changing the major version number please also check the switch dnl statement in mysqlbinlog::check_master_version(). You may also need dnl to update version.c in ndb. -AC_INIT([MySQL Server], [5.1.68], [], [mysql]) +AC_INIT([MySQL Server], [5.1.69], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM From df5444d47ca64f4024c959913974a2a06f75ab14 Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Thu, 10 Jan 2013 10:01:50 +1100 Subject: [PATCH 005/273] Bug#13997024 SEGV IN SYNC_ARRAY_CELL_PRINT PRINTING OUT LONG SEMAPHORE WAIT DATA Backport fix from mysql-5.6. --- storage/innobase/sync/sync0arr.c | 4 ++++ storage/innodb_plugin/sync/sync0arr.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/storage/innobase/sync/sync0arr.c b/storage/innobase/sync/sync0arr.c index 60a96fe4388..33b0c8d5304 100644 --- a/storage/innobase/sync/sync0arr.c +++ b/storage/innobase/sync/sync0arr.c @@ -936,6 +936,8 @@ sync_array_print_long_waits( return(FALSE); } + sync_array_enter(sync_primary_wait_array); + for (i = 0; i < sync_primary_wait_array->n_cells; i++) { double diff; @@ -970,6 +972,8 @@ sync_array_print_long_waits( } } + sync_array_exit(sync_primary_wait_array); + if (noticed) { fprintf(stderr, "InnoDB: ###### Starts InnoDB Monitor" diff --git a/storage/innodb_plugin/sync/sync0arr.c b/storage/innodb_plugin/sync/sync0arr.c index 90ea50b641b..a9100b7003f 100644 --- a/storage/innodb_plugin/sync/sync0arr.c +++ b/storage/innodb_plugin/sync/sync0arr.c @@ -932,6 +932,8 @@ sync_array_print_long_waits( return(FALSE); } + sync_array_enter(sync_primary_wait_array); + for (i = 0; i < sync_primary_wait_array->n_cells; i++) { double diff; @@ -966,6 +968,8 @@ sync_array_print_long_waits( } } + sync_array_exit(sync_primary_wait_array); + if (noticed) { fprintf(stderr, "InnoDB: ###### Starts InnoDB Monitor" From f112ae8ee19996fccf30e243f68ec21e79413478 Mon Sep 17 00:00:00 2001 From: prabakaran thirumalai Date: Thu, 10 Jan 2013 09:00:23 +0530 Subject: [PATCH 006/273] Bug#16064876 MAIN.KILL FAILS OCCASIONALLY ON SOL10 SPARC64 Analysis: On solaris, killing a connection which waits on debug sync (waits on condition variable) is neglected. Subsequent kill connection to that thread succeeds. Debug sync code is not included in release build hence it is not an customer issue. Also verified that except this case, other cases succeed in main.kill test script. So moving this test to experimental state on solaris platform only in mysql-5.5 branch. --- mysql-test/collections/default.experimental | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index 56b8feb6739..dca07e1a388 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -6,6 +6,7 @@ binlog.binlog_multi_engine # joro : NDB tests marked as experiment funcs_1.charset_collation_1 # depends on compile-time decisions main.func_math @freebsd # Bug#11751977 2010-05-04 alik main.func_math fails on FreeBSD in PB2 +main.kill @solaris # Bug#16064876 2013-01-02 prthirum main.kill fails on sol10 sparc64 main.lock_multi_bug38499 # Bug#11755645 2009-09-19 alik main.lock_multi_bug38499 times out sporadically main.outfile_loaddata @solaris # Bug#11755168 2010-01-20 alik Test "outfile_loaddata" fails (reproducible) main.signal_demo3 @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun From 9a0f3d3d53e3ba51bb50547146d7f328d7ece399 Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Thu, 10 Jan 2013 10:28:04 +0530 Subject: [PATCH 007/273] Bug #16004999 ASSERT STATE == TRX_STATE_NOT_STARTED, UNLOCK_ROW() Problem: During the index intersect access method, the SQL layer will access one row, that satisfies a set of conditions, using an index i1. And then it will try to access the same row, with other set of conditions using the next index i2. If the fetch from i2 fails (we are talking about an error situation here and not simply an unmatched row situation), then it will unlock the row accessed via i1. This will work in all situations except deadlock error. When a deadlock happens, InnoDB will rollback the transaction. InnoDB intimates the SQL layer about this through the THD::transaction_rollback_request member. But this is not currently used by the SQL layer. Solution: When an error happens, the SQL layer must check the THD::transaction_rollback_request member, before calling handler::unlock_row(). We have also added a debug assert in ha_innobase::unlock_row() checking that it must be called only when the transaction is in active state. rb#1773 approved by Marko and Sunny. --- sql/opt_range.cc | 10 ++++++++-- storage/innobase/handler/ha_innodb.cc | 2 ++ storage/innobase/lock/lock0lock.c | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 96a27899db0..39f684e1928 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8469,9 +8469,13 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() do { + DBUG_EXECUTE_IF("innodb_quick_report_deadlock", + DBUG_SET("+d,innodb_report_deadlock");); if ((error= quick->get_next())) { - quick_with_last_rowid->file->unlock_row(); + /* On certain errors like deadlock, trx might be rolled back.*/ + if (!current_thd->transaction_rollback_request) + quick_with_last_rowid->file->unlock_row(); DBUG_RETURN(error); } quick->file->position(quick->record); @@ -8494,7 +8498,9 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() quick->file->unlock_row(); /* row not in range; unlock */ if ((error= quick->get_next())) { - quick_with_last_rowid->file->unlock_row(); + /* On certain errors like deadlock, trx might be rolled back.*/ + if (!current_thd->transaction_rollback_request) + quick_with_last_rowid->file->unlock_row(); DBUG_RETURN(error); } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 570344ecce3..b549e19307f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5596,6 +5596,8 @@ ha_innobase::unlock_row(void) { DBUG_ENTER("ha_innobase::unlock_row"); + ut_ad(prebuilt->trx->conc_state == TRX_ACTIVE); + /* Consistent read does not take any locks, thus there is nothing to unlock. */ diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index a72be540c1b..a5ce43496af 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -1997,6 +1997,8 @@ lock_rec_lock_fast( || mode - (LOCK_MODE_MASK & mode) == 0 || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP); + DBUG_EXECUTE_IF("innodb_report_deadlock", return(LOCK_REC_FAIL);); + lock = lock_rec_get_first_on_page(block); trx = thr_get_trx(thr); @@ -2074,6 +2076,8 @@ lock_rec_lock_slow( trx = thr_get_trx(thr); + DBUG_EXECUTE_IF("innodb_report_deadlock", return(DB_DEADLOCK);); + lock = lock_rec_has_expl(mode, block, heap_no, trx); if (lock) { if (lock->type_mode & LOCK_CONV_BY_OTHER) { @@ -4124,6 +4128,7 @@ lock_rec_unlock( ut_ad(trx && rec); ut_ad(block->frame == page_align(rec)); + ut_ad(trx->conc_state == TRX_ACTIVE); heap_no = page_rec_get_heap_no(rec); From 5e399d1cd023345e51fb6dbcb0078074abe039b5 Mon Sep 17 00:00:00 2001 From: Praveenkumar Hulakund Date: Thu, 10 Jan 2013 14:34:27 +0530 Subject: [PATCH 008/273] Bug#11749556: DEBUG ASSERTION WHEN ACCESSING A VIEW AND AVAILABLE MEMORY IS TOO LOW Analysis: --------- In function "mysql_make_view", "table->view" is initialized after parsing(using File_parser::parse) the view definition. If "::parse" function fails then control is moved to label "err:". Here we have assert (table->view == thd->lex). This assert fails if "::parse" function fails, as table->view is not initialized yet. File_parser::parse fails if data being parsed is incorrect/ corrupted or when memory allocation fails. In this scenario its failing because of failure in memory allocation. Fix: --------- In case of failure in function "File_parser::parse", moving to label "err:" is incorrect. Modified code to move to label "end:". --- sql/sql_view.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 965aee65d04..41521395757 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1137,9 +1137,10 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, TODO: when VIEWs will be stored in cache, table mem_root should be used here */ - if (parser->parse((uchar*)table, thd->mem_root, view_parameters, - required_view_parameters, &file_parser_dummy_hook)) - goto err; + if ((result= parser->parse((uchar*)table, thd->mem_root, + view_parameters, required_view_parameters, + &file_parser_dummy_hook))) + goto end; /* check old format view .frm @@ -1185,6 +1186,11 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, now Lex placed in statement memory */ table->view= lex= thd->lex= (LEX*) new(thd->mem_root) st_lex_local; + if (!table->view) + { + result= true; + goto end; + } { char old_db_buf[NAME_LEN+1]; From 8b41f491c82063382bc76d8a8c266b83b0ab8fe0 Mon Sep 17 00:00:00 2001 From: Chaithra Gopalareddy Date: Thu, 10 Jan 2013 16:17:13 +0530 Subject: [PATCH 009/273] Bug#11760726: LEFT JOIN OPTIMIZED INTO JOIN LEADS TO INCORRECT RESULTS This is a backport of fix for Bug#13068506. mysql-test/r/join_outer.result: Added test result for Bug#13068506 mysql-test/t/join_outer.test: Added test case for Bug#13068506 sql/item.h: Implement Item_outer_ref::not_null_tables() --- mysql-test/r/join_outer.result | 32 ++++++++++++++++++++++++++++++++ mysql-test/t/join_outer.test | 30 ++++++++++++++++++++++++++++++ sql/item.h | 2 ++ 3 files changed, 64 insertions(+) diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index d8a734a7158..f745e953331 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1485,4 +1485,36 @@ EXECUTE prep_stmt; f 1 DROP TABLE t1; +# +# Bug#13068506 - QUERY WITH GROUP BY ON NON-AGGR COLUMN RETURNS +# WRONG RESULT +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (100), (101); +CREATE TABLE t2 (i2 int, i3 int); +INSERT INTO t2 VALUES (20,1),(10,2); +CREATE TABLE t3 (i4 int(11)); +INSERT INTO t3 VALUES (1),(2); + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1;; +field1 +20 +20 + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1 GROUP BY field1;; +field1 +20 + +drop table t1,t2,t3; +# End of test for Bug#13068506 End of 5.1 tests diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 1ba29fdd4cf..13811731dad 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1067,5 +1067,35 @@ EXECUTE prep_stmt; DROP TABLE t1; +--echo # +--echo # Bug#13068506 - QUERY WITH GROUP BY ON NON-AGGR COLUMN RETURNS +--echo # WRONG RESULT +--echo # + +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (100), (101); + +CREATE TABLE t2 (i2 int, i3 int); +INSERT INTO t2 VALUES (20,1),(10,2); + +CREATE TABLE t3 (i4 int(11)); +INSERT INTO t3 VALUES (1),(2); + +let $query= SELECT ( + SELECT MAX( t2.i2 ) + FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) + WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1; + +--echo +--eval $query; +--echo +--eval $query GROUP BY field1; + +--echo +drop table t1,t2,t3; + +--echo # End of test for Bug#13068506 --echo End of 5.1 tests diff --git a/sql/item.h b/sql/item.h index 1934e005776..3a46280ed31 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2448,6 +2448,8 @@ public: { return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT; } + table_map not_null_tables() const { return 0; } + virtual Ref_Type ref_type() { return OUTER_REF; } }; From 3fa76fd05de0a72719d08cba1af4130059bb7bc7 Mon Sep 17 00:00:00 2001 From: Venkata Sidagam Date: Thu, 10 Jan 2013 16:37:20 +0530 Subject: [PATCH 010/273] Bug #14553380 MYSQL C API LIBRARY EXITS AT NET_CLEAR AT NET_SERV.CC:223 Problem description: When client loses the connection to the MySQL server or if the server gets shutdown after mysql_stmt_prepare() then the next mysql_stmt_prepare() will return an error(as expected) but consecutive call mysql_stmt_execute(), will crash the client program. The expected behavior would be, it should through an error. Analysis: The mysql_stmt_prepare() interns calls the function end_server() and net->vio and net->buff are freed and set to NULL. Then the next call mysql_stmt_execute() will interns call net_clear() where we are "net->vio" with out validating it. Fix: we are validating the net->vio, before calling net_clear(). --- libmysql/libmysql.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index ed1a85f86b4..a6bb617132f 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2107,7 +2107,14 @@ int cli_stmt_execute(MYSQL_STMT *stmt) DBUG_RETURN(1); } - net_clear(net, 1); /* Sets net->write_pos */ + if (net->vio) + net_clear(net, 1); /* Sets net->write_pos */ + else + { + set_stmt_errmsg(stmt, net); + DBUG_RETURN(1); + } + /* Reserve place for null-marker bytes */ null_count= (stmt->param_count+7) /8; if (my_realloc_str(net, null_count + 1)) From 21bdf213807e467e7638d0504e900070bb1689f5 Mon Sep 17 00:00:00 2001 From: Aditya A Date: Fri, 11 Jan 2013 16:27:37 +0530 Subject: [PATCH 011/273] Bug#15843818 PARTITIONING BY RANGE WITH TO_DAYS ALWAYS INCLUDES FIRST PARTITION WHEN PRUNING PROBLEM ------- TO_DAYS()/TO_SECONDS() can return NULL for invalid dates which was stored in the first partition ,therefore the first partition was always included for the scan when range was specified. FIX --- The fix is a small optimization which we have included ,which will prune the scanning of NULL/first partition if the dates specified in the range are valid and in the same year and month . TO_SECONDS() function is not supported in 5.1 so removed it from the fix and test scripts for mysql-5.1 version. --- sql/sql_partition.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 0b103dcbda9..41f2b00a256 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6793,6 +6793,9 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, get_endpoint_func UNINIT_VAR(get_endpoint); bool can_match_multiple_values; /* is not '=' */ uint field_len= field->pack_length_in_rec(); + MYSQL_TIME start_date; + bool check_zero_dates= false; + bool zero_in_start_date= true; part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE; if (part_info->part_type == RANGE_PARTITION) @@ -6844,6 +6847,7 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, { /* col is NOT NULL, but F(col) can return NULL, add NULL partition */ part_iter->ret_null_part= part_iter->ret_null_part_orig= TRUE; + check_zero_dates= true; } } @@ -6887,6 +6891,19 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, return 1; } part_iter->part_nums.cur= part_iter->part_nums.start; + if (check_zero_dates && !part_info->part_expr->null_value) + { + if (!(flags & NO_MAX_RANGE) && + (field->type() == MYSQL_TYPE_DATE || + field->type() == MYSQL_TYPE_DATETIME)) + { + /* Monotonic, but return NULL for dates with zeros in month/day. */ + zero_in_start_date= field->get_date(&start_date, 0); + DBUG_PRINT("info", ("zero start %u %04d-%02d-%02d", + zero_in_start_date, start_date.year, + start_date.month, start_date.day)); + } + } if (part_iter->part_nums.start == max_endpoint_val) return 0; /* No partitions */ } @@ -6900,6 +6917,27 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, store_key_image_to_rec(field, max_value, field_len); bool include_endp= !test(flags & NEAR_MAX); part_iter->part_nums.end= get_endpoint(part_info, 0, include_endp); + if (check_zero_dates && + !zero_in_start_date && + !part_info->part_expr->null_value) + { + MYSQL_TIME end_date; + bool zero_in_end_date= field->get_date(&end_date, 0); + /* + This is an optimization for TO_DAYS() to avoid scanning the NULL + partition for ranges that cannot include a date with 0 as + month/day. + */ + DBUG_PRINT("info", ("zero end %u %04d-%02d-%02d", + zero_in_end_date, + end_date.year, end_date.month, end_date.day)); + DBUG_ASSERT(!memcmp(((Item_func*) part_info->part_expr)->func_name(), + "to_days", 7)); + if (!zero_in_end_date && + start_date.month == end_date.month && + start_date.year == end_date.year) + part_iter->ret_null_part= part_iter->ret_null_part_orig= false; + } if (part_iter->part_nums.start >= part_iter->part_nums.end && !part_iter->ret_null_part) return 0; /* No partitions */ From c4afaa42423d664477ca5df6cb45f49860381bfc Mon Sep 17 00:00:00 2001 From: Nisha Gopalakrishnan Date: Sat, 12 Jan 2013 11:13:37 +0530 Subject: [PATCH 012/273] BUG#11757250: REPLACE(...) INSIDE A STORED PROCEDURE. Analysis: -------- REPLACE operation provides incorrect output when user variable is supplied as an argument and there are multiple rows on which the operation is performed. Consider the example below: SET @var='(( 00000000 ++ 00000000 ))'; SELECT REPLACE(@var, '00000000', table_name) AS a FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql'; Invalid output: +---------------------------------------+ | REPLACE(@var, '00000000', TABLE_NAME) | +---------------------------------------+ | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | ...... ...... | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | +---------------------------------------+ The user argument supplied as the string to REPLACE operation is overwritten after the first iteration to '(( columns_priv ++ columns_priv ))'. The overwritten string after the first iteration is used for the subsequent REPLACE iteration. Since the pattern string is not found, it returns invalid output as mentioned above. Fix: --- If the Alloced_length is zero, realloc() and create a copy of the string which is then used for the REPLACE operation for every iteration. --- client/sql_string.cc | 2 +- sql/sql_string.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/sql_string.cc b/client/sql_string.cc index 4a0f2df927b..010da7eb517 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -761,7 +761,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) { if (from->Alloced_length >= from_length) return from; - if (from->alloced || !to || from == to) + if ((from->alloced && (from->Alloced_length != 0)) || !to || from == to) { (void) from->realloc(from_length); return from; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 4dbc2d77206..10bd3511cd2 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -796,7 +796,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) { if (from->Alloced_length >= from_length) return from; - if (from->alloced || !to || from == to) + if ((from->alloced && (from->Alloced_length != 0)) || !to || from == to) { (void) from->realloc(from_length); return from; From 54c47527e25f7ebe8c0d995b4a9a1bea901047a9 Mon Sep 17 00:00:00 2001 From: "Krunal Bauskar krunal.bauskar@oracle.com" Date: Mon, 14 Jan 2013 10:49:51 +0530 Subject: [PATCH 013/273] - BUG#1608883: KILLING A QUERY INSIDE INNODB CAUSES IT TO EVENTUALLY CRASH WITH AN ASSERTION Recently we added check to handle kill query signal for long operating queries. While the query interruption is reported it must to ensure cursor is restore to proper state for HANDLER interface to work correctly. Normal select query will not face this problem, as on recieving interrupt, select query is aborted and new select query result in re-initialization (including cursor). rb://1836. Approved by Marko. --- storage/innobase/row/row0sel.c | 4 ++++ storage/innodb_plugin/ChangeLog | 5 +++++ storage/innodb_plugin/row/row0sel.c | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index cf3b36fbac2..2137facf638 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -33,6 +33,8 @@ Created 12/19/1997 Heikki Tuuri #include "read0read.h" #include "buf0lru.h" #include "ha_prototypes.h" +#include "m_string.h" /* for my_sys.h */ +#include "my_sys.h" /* DEBUG_SYNC_C */ /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 @@ -3758,7 +3760,9 @@ wait_table_again: } rec_loop: + DEBUG_SYNC_C("row_search_rec_loop"); if (trx_is_interrupted(trx)) { + btr_pcur_store_position(pcur, &mtr); err = DB_INTERRUPTED; goto normal_return; } diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index e9c86a85d29..6a389f618af 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,8 @@ +2013-01-11 The InnoDB Team + * row/row0sel.c: + Fix Bug#16088883 KILLING A QUERY INSIDE INNODB CAUSES IT TO + EVENTUALLY CRASH WITH AN ASSERTION + 2012-12-18 The InnoDB Team * include/univ.i: diff --git a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c index d825d799a3c..d2e83450860 100644 --- a/storage/innodb_plugin/row/row0sel.c +++ b/storage/innodb_plugin/row/row0sel.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -57,6 +57,8 @@ Created 12/19/1997 Heikki Tuuri #include "read0read.h" #include "buf0lru.h" #include "ha_prototypes.h" +#include "m_string.h" /* for my_sys.h */ +#include "my_sys.h" /* DEBUG_SYNC_C */ /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 @@ -3908,7 +3910,9 @@ wait_table_again: } rec_loop: + DEBUG_SYNC_C("row_search_rec_loop"); if (trx_is_interrupted(trx)) { + btr_pcur_store_position(pcur, &mtr); err = DB_INTERRUPTED; goto normal_return; } From 99645e5be59145bcab2fe36aefde4224e6e69961 Mon Sep 17 00:00:00 2001 From: Neeraj Bisht Date: Mon, 14 Jan 2013 14:59:48 +0530 Subject: [PATCH 014/273] BUG#14303860 - EXECUTING A SELECT QUERY WITH TOO MANY WILDCARDS CAUSES A SEGFAULT Back port from 5.6 and trunk --- include/m_ctype.h | 2 ++ regex/my_regex.h | 2 +- regex/regcomp.c | 2 +- sql/mysqld.cc | 22 ++++++++++++++----- strings/ctype-bin.c | 27 +++++++++++++++++------ strings/ctype-mb.c | 50 ++++++++++++++++++++++++++++++++---------- strings/ctype-simple.c | 26 +++++++++++++++++----- strings/ctype-uca.c | 26 ++++++++++++++++------ strings/ctype-utf8.c | 33 ++++++++++++++++++++-------- strings/ctype.c | 2 ++ 10 files changed, 145 insertions(+), 47 deletions(-) diff --git a/include/m_ctype.h b/include/m_ctype.h index d58081ec19e..b36fdbe6d68 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -132,6 +132,8 @@ enum my_lex_states struct charset_info_st; +extern int (*my_string_stack_guard)(int); + /* See strings/CHARSET_INFO.txt for information about this structure */ typedef struct my_collation_handler_st { diff --git a/regex/my_regex.h b/regex/my_regex.h index 30896e29b91..1f96b8c461e 100644 --- a/regex/my_regex.h +++ b/regex/my_regex.h @@ -28,7 +28,7 @@ typedef struct { /* === regcomp.c === */ -typedef int (*my_regex_stack_check_t)(); +typedef int (*my_regex_stack_check_t)(int); extern int my_regcomp(my_regex_t *, const char *, int, CHARSET_INFO *charset); #define REG_BASIC 0000 #define REG_EXTENDED 0001 diff --git a/regex/regcomp.c b/regex/regcomp.c index e163a9ba7f4..c0fb93917a4 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -227,7 +227,7 @@ int stop; /* character this ERE should end at */ while (MORE() && (c = PEEK()) != '|' && c != stop) { if (my_regex_enough_mem_in_stack && - my_regex_enough_mem_in_stack()) + my_regex_enough_mem_in_stack(0)) { SETERROR(REG_ESPACE); return; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3b43217dd2f..b7da50606dd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2898,14 +2898,25 @@ sizeof(load_default_groups)/sizeof(load_default_groups[0]); #ifndef EMBEDDED_LIBRARY -static -int -check_enough_stack_size() +/** + This function is used to check for stack overrun for pathological + cases of regular expressions and 'like' expressions. + The call to current_thd is quite expensive, so we try to avoid it + for the normal cases. + The size of each stack frame for the wildcmp() routines is ~128 bytes, + so checking *every* recursive call is not necessary. + */ +extern "C" int +check_enough_stack_size(int recurse_level) { uchar stack_top; + if (recurse_level % 16 != 0) + return 0; - return check_stack_overrun(current_thd, STACK_MIN_SIZE, - &stack_top); + THD *my_thd= current_thd; + if (my_thd != NULL) + return check_stack_overrun(my_thd, STACK_MIN_SIZE * 2, &stack_top); + return 0; } #endif @@ -3293,6 +3304,7 @@ static int init_common_variables(const char *conf_file_name, int argc, #ifdef USE_REGEX #ifndef EMBEDDED_LIBRARY my_regex_init(&my_charset_latin1, check_enough_stack_size); + my_string_stack_guard= check_enough_stack_size; #else my_regex_init(&my_charset_latin1, NULL); #endif diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 424549de9b2..f2d2d4a950f 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -323,13 +323,16 @@ void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)), #define INC_PTR(cs,A,B) (A)++ -int my_wildcmp_bin(CHARSET_INFO *cs, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many) +static +int my_wildcmp_bin_impl(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many, int recurse_level) { int result= -1; /* Not found, using wildcards */ - + + if (my_string_stack_guard && my_string_stack_guard(recurse_level)) + return 1; while (wildstr != wildend) { while (*wildstr != w_many && *wildstr != w_one) @@ -388,8 +391,8 @@ int my_wildcmp_bin(CHARSET_INFO *cs, if (str++ == str_end) return(-1); { - int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one, - w_many); + int tmp=my_wildcmp_bin_impl(cs,str,str_end,wildstr,wildend,escape,w_one, + w_many, recurse_level + 1); if (tmp <= 0) return(tmp); } @@ -400,6 +403,16 @@ int my_wildcmp_bin(CHARSET_INFO *cs, return(str != str_end ? 1 : 0); } +int my_wildcmp_bin(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many) +{ + return my_wildcmp_bin_impl(cs, str, str_end, + wildstr, wildend, + escape, w_one, w_many, 1); +} + static size_t my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), uchar *dest, size_t dstlen, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 76dae6762af..92d7b5f48c8 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -148,13 +148,16 @@ int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t) #define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)] -int my_wildcmp_mb(CHARSET_INFO *cs, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many) +static +int my_wildcmp_mb_impl(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many, int recurse_level) { int result= -1; /* Not found, using wildcards */ + if (my_string_stack_guard && my_string_stack_guard(recurse_level)) + return 1; while (wildstr != wildend) { while (*wildstr != w_many && *wildstr != w_one) @@ -243,8 +246,8 @@ int my_wildcmp_mb(CHARSET_INFO *cs, INC_PTR(cs,str, str_end); } { - int tmp=my_wildcmp_mb(cs,str,str_end,wildstr,wildend,escape,w_one, - w_many); + int tmp=my_wildcmp_mb_impl(cs,str,str_end,wildstr,wildend,escape,w_one, + w_many, recurse_level + 1); if (tmp <= 0) return (tmp); } @@ -255,6 +258,16 @@ int my_wildcmp_mb(CHARSET_INFO *cs, return (str != str_end ? 1 : 0); } +int my_wildcmp_mb(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many) +{ + return my_wildcmp_mb_impl(cs, str, str_end, + wildstr, wildend, + escape, w_one, w_many, 1); +} + size_t my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), const char *pos, const char *end) @@ -697,13 +710,15 @@ fill_max_and_min: } -static int my_wildcmp_mb_bin(CHARSET_INFO *cs, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many) +static int my_wildcmp_mb_bin_impl(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many, int recurse_level) { int result= -1; /* Not found, using wildcards */ + if (my_string_stack_guard && my_string_stack_guard(recurse_level)) + return 1; while (wildstr != wildend) { while (*wildstr != w_many && *wildstr != w_one) @@ -790,7 +805,9 @@ static int my_wildcmp_mb_bin(CHARSET_INFO *cs, INC_PTR(cs,str, str_end); } { - int tmp=my_wildcmp_mb_bin(cs,str,str_end,wildstr,wildend,escape,w_one,w_many); + int tmp=my_wildcmp_mb_bin_impl(cs,str,str_end, + wildstr,wildend,escape, + w_one,w_many, recurse_level+1); if (tmp <= 0) return (tmp); } @@ -801,6 +818,17 @@ static int my_wildcmp_mb_bin(CHARSET_INFO *cs, return (str != str_end ? 1 : 0); } +int +my_wildcmp_mb_bin(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many) +{ + return my_wildcmp_mb_bin_impl(cs, str, str_end, + wildstr, wildend, + escape, w_one, w_many, 1); +} + /* Data was produced from EastAsianWidth.txt diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 2193e155f1f..082868600b2 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -952,13 +952,16 @@ cnv: #define INC_PTR(cs,A,B) (A)++ -int my_wildcmp_8bit(CHARSET_INFO *cs, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many) +static +int my_wildcmp_8bit_impl(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many, int recurse_level) { int result= -1; /* Not found, using wildcards */ + if (my_string_stack_guard && my_string_stack_guard(recurse_level)) + return 1; while (wildstr != wildend) { while (*wildstr != w_many && *wildstr != w_one) @@ -1018,8 +1021,9 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, str++; if (str++ == str_end) return(-1); { - int tmp=my_wildcmp_8bit(cs,str,str_end,wildstr,wildend,escape,w_one, - w_many); + int tmp=my_wildcmp_8bit_impl(cs,str,str_end, + wildstr,wildend,escape,w_one, + w_many, recurse_level+1); if (tmp <= 0) return(tmp); } @@ -1030,6 +1034,16 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, return(str != str_end ? 1 : 0); } +int my_wildcmp_8bit(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many) +{ + return my_wildcmp_8bit_impl(cs, str, str_end, + wildstr, wildend, + escape, w_one, w_many, 1); +} + /* ** Calculate min_str and max_str that ranges a LIKE string. diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index ff97a750c8a..26a3bac7964 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -7328,10 +7328,10 @@ static int my_uca_charcmp(CHARSET_INFO *cs, my_wc_t wc1, my_wc_t wc2) */ static -int my_wildcmp_uca(CHARSET_INFO *cs, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many) +int my_wildcmp_uca_impl(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many, int recurse_level) { int result= -1; /* Not found, using wildcards */ my_wc_t s_wc, w_wc; @@ -7339,7 +7339,9 @@ int my_wildcmp_uca(CHARSET_INFO *cs, int (*mb_wc)(struct charset_info_st *, my_wc_t *, const uchar *, const uchar *); mb_wc= cs->cset->mb_wc; - + + if (my_string_stack_guard && my_string_stack_guard(recurse_level)) + return 1; while (wildstr != wildend) { while (1) @@ -7446,8 +7448,8 @@ int my_wildcmp_uca(CHARSET_INFO *cs, if (str == str_end) return -1; - result= my_wildcmp_uca(cs, str, str_end, wildstr, wildend, - escape, w_one, w_many); + result= my_wildcmp_uca_impl(cs, str, str_end, wildstr, wildend, + escape, w_one, w_many, recurse_level+1); if (result <= 0) return result; @@ -7459,6 +7461,16 @@ int my_wildcmp_uca(CHARSET_INFO *cs, return (str != str_end ? 1 : 0); } +int my_wildcmp_uca(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many) +{ + return my_wildcmp_uca_impl(cs, str, str_end, + wildstr, wildend, + escape, w_one, w_many, 1); +} + /* Collation language is implemented according to diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index a0e69feedab..004a09866aa 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1889,11 +1889,12 @@ MY_UNICASE_INFO *my_unicase_turkish[256]= ** 1 if matched with wildcard */ -int my_wildcmp_unicode(CHARSET_INFO *cs, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many, - MY_UNICASE_INFO **weights) +static +int my_wildcmp_unicode_impl(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many, + MY_UNICASE_INFO **weights, int recurse_level) { int result= -1; /* Not found, using wildcards */ my_wc_t s_wc, w_wc; @@ -1901,7 +1902,9 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, int (*mb_wc)(struct charset_info_st *, my_wc_t *, const uchar *, const uchar *); mb_wc= cs->cset->mb_wc; - + + if (my_string_stack_guard && my_string_stack_guard(recurse_level)) + return 1; while (wildstr != wildend) { while (1) @@ -2027,9 +2030,9 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, return -1; str+= scan; - result= my_wildcmp_unicode(cs, str, str_end, wildstr, wildend, - escape, w_one, w_many, - weights); + result= my_wildcmp_unicode_impl(cs, str, str_end, wildstr, wildend, + escape, w_one, w_many, + weights, recurse_level+1); if (result <= 0) return result; } @@ -2038,6 +2041,18 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, return (str != str_end ? 1 : 0); } +int +my_wildcmp_unicode(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many, + MY_UNICASE_INFO **weights) +{ + return my_wildcmp_unicode_impl(cs, str, str_end, + wildstr, wildend, + escape, w_one, w_many, weights, 1); +} + #endif diff --git a/strings/ctype.c b/strings/ctype.c index 8786eb3e889..ecb827cc778 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -41,6 +41,8 @@ */ +int (*my_string_stack_guard)(int)= NULL; + static char *mstr(char *str,const char *src,size_t l1,size_t l2) { l1= l1 Date: Mon, 14 Jan 2013 10:58:17 +0100 Subject: [PATCH 015/273] Fix for Bug#14636211 WRONG RESULT (EXTRA ROW) ON A FROM SUBQUERY WITH A VARIABLE AND ORDER BY Bug#16035412 MYSQL SERVER 5.5.29 WRONG SORTING USING COMPLEX INDEX This is a fix for a regression introduced by Bug#12667154: Bug#12667154 attempted to fix a performance problem with subqueries that did filesort. For doing filesort, the optimizer creates a quick select object to use when building the sort index. This quick select object was deleted after the first call to create_sort_index(). Thus, for queries where the subquery was executed multiple times, the quick object was only used for the first execution. For all later executions of the subquery, filesort used a complete table scan for building the sort index. The fix for Bug#12667154 tried to fix this by not deleting the quick object after the first execution of create_sort_index() so that it would be re-used for building the sort index by the following executions of the subquery. This regression introduced in Bug#12667154 is that due to not deleting the quick select object after building the sort index, the quick object could in some cases be used also during the second phase of the execution of the subquery instead of using the created sort index. This caused wrong results to be returned. The fix for this issue is to delete the reference to the select object after it has been used in create_sort_index(). In this way the select and quick objects will not be available when doing the second phase of the execution of the select operation. To ensure that the select object can be re-used for the following executions of the subquery we make a copy of the select pointer. This is used for restoring the select object after the select operation is completed. mysql-test/suite/innodb/r/innodb_mysql.result: Changed explain output: The explain now contains "Using where" since we have restored the select pointer after doing the filesort operation. sql/sql_select.cc: Change create_sort_index() so that it always sets the pointer to the select object to NULL. This is done in order to avoid that the select->quick object can be used when execution the main part of the select operation. sql/sql_select.h: New member in JOIN_TAB: saved_select. Used by create_sort_index to make a backup copy of the select pointer. --- mysql-test/suite/innodb/r/innodb_mysql.result | 6 +-- sql/sql_select.cc | 46 +++++++++++++++---- sql/sql_select.h | 16 ++++++- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 96ff02e2585..f7bffe2fc54 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -1738,7 +1738,7 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY system NULL NULL NULL NULL 1 -2 DERIVED t1 ALL c3,c2 c3 5 5 Using filesort +2 DERIVED t1 ALL c3,c2 c3 5 5 Using where; Using filesort DROP TABLE t1; CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) ENGINE=InnoDB; @@ -1752,7 +1752,7 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY system NULL NULL NULL NULL 1 -2 DERIVED t1 ALL c3,c2 c3 9 5 Using filesort +2 DERIVED t1 ALL c3,c2 c3 9 5 Using where; Using filesort DROP TABLE t1; CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), KEY (c3), KEY (c2, c3)) @@ -1767,7 +1767,7 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY system NULL NULL NULL NULL 1 -2 DERIVED t1 ALL c3,c2 c3 7 5 Using filesort +2 DERIVED t1 ALL c3,c2 c3 7 5 Using where; Using filesort DROP TABLE t1; End of 5.1 tests # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6908d313ee8..181fa6ece0a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1829,6 +1829,8 @@ JOIN::exec() { List *columns_list= &fields_list; int tmp_error; + bool sort_index_created= false; + DBUG_ENTER("JOIN::exec"); thd_proc_info(thd, "executing"); @@ -2123,6 +2125,7 @@ JOIN::exec() { DBUG_VOID_RETURN; } + sort_index_created= true; sortorder= curr_join->sortorder; } @@ -2350,6 +2353,7 @@ JOIN::exec() HA_POS_ERROR : unit->select_limit_cnt), curr_join->group_list ? TRUE : FALSE)) DBUG_VOID_RETURN; + sort_index_created= true; sortorder= curr_join->sortorder; if (curr_join->const_tables != curr_join->tables && !curr_join->join_tab[curr_join->const_tables].table->sort.io_cache) @@ -2381,6 +2385,16 @@ JOIN::exec() error= do_select(curr_join, curr_fields_list, NULL, procedure); thd->limit_found_rows= curr_join->send_records; + if (sort_index_created && curr_join->tables != curr_join->const_tables ) + { + // Restore the original "select" used by create_sort_index(): + JOIN_TAB *const tab= curr_join->join_tab + curr_join->const_tables; + if (tab->saved_select) + { + tab->select= tab->saved_select; + tab->saved_select= NULL; + } + } /* Accumulate the counts from all join iterations of all join parts. */ thd->examined_row_count+= curr_join->examined_rows; DBUG_PRINT("counts", ("thd->examined_row_count: %lu", @@ -14134,7 +14148,7 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, tab= join->join_tab + join->const_tables; table= tab->table; select= tab->select; - + tab->saved_select= NULL; /* If we have a select->quick object that is created outside of create_sort_index() and this is part of a subquery that @@ -14233,16 +14247,28 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, if (!keep_quick) { select->cleanup(); - /* - The select object should now be ready for the next use. If it - is re-used then there exists a backup copy of this join tab - which has the pointer to it. The join tab will be restored in - JOIN::reset(). So here we just delete the pointer to it. - */ - tab->select= NULL; - // If we deleted the quick select object we need to clear quick_keys + + // If we deleted the quick object we need to clear quick_keys table->quick_keys.clear_all(); } + else + { + // Need to close the index scan in order to re-use the handler + tab->select->quick->range_end(); + } + + /* + The select object is now ready for the next use. To avoid that + the select object is used when reading the records in sorted + order we set the pointer to it to NULL. The select pointer will + be restored from the saved_select pointer when this select + operation is completed (@see JOIN::exec). This ensures that it + will be re-used when filesort is used by subqueries that are + executed multiple times. + */ + tab->saved_select= tab->select; + tab->select= NULL; + // Restore the output resultset table->sort.io_cache= tablesort_result_cache; } diff --git a/sql/sql_select.h b/sql/sql_select.h index c4f5dcba115..6732eb354d6 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1,7 +1,7 @@ #ifndef SQL_SELECT_INCLUDED #define SQL_SELECT_INCLUDED -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -160,6 +160,20 @@ typedef struct st_join_table { TABLE *table; KEYUSE *keyuse; /**< pointer to first used key */ SQL_SELECT *select; + /** + When doing filesort, the select object is used for building the + sort index. After the sort index is built, the pointer to the + select object is set to NULL to avoid that it is used when reading + the result records (@see create_sort_index()). For subqueries that + do filesort and that are executed multiple times, the pointer to + the select object must be restored before the next execution both + to ensure that the select object is used and to be able to cleanup + the select object after the final execution of the subquery. In + order to be able to restore the pointer to the select object, it + is saved in saved_select in create_sort_index() and restored in + JOIN::exec() after the main select is done. + */ + SQL_SELECT *saved_select; COND *select_cond; QUICK_SELECT_I *quick; Item **on_expr_ref; /**< pointer to the associated on expression */ From 5cf1a8c2956c0bfce150a99661c9f9b09996e085 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Jan 2013 12:26:49 +0530 Subject: [PATCH 016/273] From 65af83f642374c9d9476a125af30f723f7684e2e Mon Sep 17 00:00:00 2001 From: Neeraj Bisht Date: Tue, 15 Jan 2013 14:24:35 +0530 Subject: [PATCH 017/273] Bug#11758009 - UNION EXECUTION ORDER WRONG ? Problem:- In case of blob data field, UNION ALL doesn't give correct result. Analysis:- In MyISAM table, when we dont want to check for the distinct for particular key, we set the key_map to zero. While writing record in MyISAM table, we check the distinct with the help of keys, by checking whether that key is active in key_map and then writing the record. In case of blob field, we are checking for distinct by unique constraint, where we are not checking whether that unique key is active or not in key_map. Solution:- Before checking for distinct, check whether any key is active in key_map. storage/myisam/mi_write.c: check whether key_map is active before checking distinct. --- storage/myisam/mi_write.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 81262c229ce..1bcf1b28ecf 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -90,12 +90,15 @@ int mi_write(MI_INFO *info, uchar *record) goto err2; /* Calculate and check all unique constraints */ - for (i=0 ; i < share->state.header.uniques ; i++) + if (mi_is_any_key_active(share->state.key_map)) { - if (mi_check_unique(info,share->uniqueinfo+i,record, - mi_unique_hash(share->uniqueinfo+i,record), - HA_OFFSET_ERROR)) - goto err2; + for (i= 0 ; i < share->state.header.uniques ; i++) + { + if (mi_check_unique(info, share->uniqueinfo + i, record, + mi_unique_hash(share->uniqueinfo + i, record), + HA_OFFSET_ERROR)) + goto err2; + } } /* Write all keys to indextree */ From d01b5c392ceed32f4d9a34eec13be4fdd78c1ef6 Mon Sep 17 00:00:00 2001 From: Nisha Gopalakrishnan Date: Tue, 15 Jan 2013 15:30:26 +0530 Subject: [PATCH 018/273] Bug#11757464:SERVER CRASH IN RECURSIVE CALL WHEN OOM Analysis: --------- When the server is out of memory, an error is raised to indicate the same. Handling the error requires more memory to be allocated which fails, hence the error handling loops in a recursion and causes the server to crash. Fix: --- a) Prevents pushing the 'out of memory' error condition to the diagnostic area as it requires memory allocation. GET DIAGNOSTICS, SHOW WARNINGS and SHOW ERRORS statements will not show information about this error. However the 'out of memory' error is returned to the client. b) It sets the ME_FATALERROR flag when 'out of memory' errors are reported (for places where the flag is not already set). This flag prevents activation of SP error handlers which also require memory allocation and therefore are likely to fail. --- mysys/mf_keycache.c | 3 ++- mysys/my_lockmem.c | 2 +- mysys/my_malloc.c | 12 +++++++++--- mysys/my_once.c | 2 +- sql/handler.cc | 3 ++- sql/item_sum.cc | 4 ++++ sql/sql_binlog.cc | 2 +- sql/sql_class.cc | 16 ++++++++++------ sql/sql_partition.cc | 3 ++- sql/sql_prepare.cc | 7 ++++--- sql/sql_select.cc | 2 +- storage/myisam/myisampack.c | 3 ++- 12 files changed, 39 insertions(+), 20 deletions(-) diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 7dfbf22d4b7..5829ab819f7 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -444,7 +444,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, if (blocks < 8) { my_errno= ENOMEM; - my_error(EE_OUTOFMEMORY, MYF(0), blocks * keycache->key_cache_block_size); + my_error(EE_OUTOFMEMORY, MYF(ME_FATALERROR), + blocks * keycache->key_cache_block_size); goto err; } blocks= blocks / 4*3; diff --git a/mysys/my_lockmem.c b/mysys/my_lockmem.c index 8f06192d9f8..2e036936c70 100644 --- a/mysys/my_lockmem.c +++ b/mysys/my_lockmem.c @@ -43,7 +43,7 @@ uchar *my_malloc_lock(uint size,myf MyFlags) if (!(ptr=memalign(pagesize,size))) { if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG+ME_FATALERROR), size); DBUG_RETURN(0); } success = mlock((uchar*) ptr,size); diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index fc2dc98c3c5..93eb547888f 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -41,6 +41,11 @@ void *my_malloc(size_t size, myf my_flags) free(point); point= NULL; }); + DBUG_EXECUTE_IF("simulate_persistent_out_of_memory", + { + free(point); + point= NULL; + }); if (point == NULL) { @@ -48,7 +53,8 @@ void *my_malloc(size_t size, myf my_flags) if (my_flags & MY_FAE) error_handler_hook=fatal_error_handler_hook; if (my_flags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH),size); + my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG + + ME_NOREFRESH + ME_FATALERROR),size); DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_SET("-d,simulate_out_of_memory");); if (my_flags & MY_FAE) @@ -90,7 +96,7 @@ void *my_realloc(void *oldpoint, size_t size, myf my_flags) DBUG_RETURN(oldpoint); my_errno=errno; if (my_flags & MY_FAE+MY_WME) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); + my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG + ME_FATALERROR),size); } else { @@ -106,7 +112,7 @@ void *my_realloc(void *oldpoint, size_t size, myf my_flags) DBUG_RETURN(oldpoint); my_errno=errno; if (my_flags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size); + my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG + ME_FATALERROR), size); } #endif DBUG_PRINT("exit",("ptr: %p", point)); diff --git a/mysys/my_once.c b/mysys/my_once.c index 7df9b0a1981..b9232db9b2e 100644 --- a/mysys/my_once.c +++ b/mysys/my_once.c @@ -59,7 +59,7 @@ void* my_once_alloc(size_t Size, myf MyFlags) { my_errno=errno; if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),get_size); + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG+ME_FATALERROR), get_size); return((uchar*) 0); } DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size)); diff --git a/sql/handler.cc b/sql/handler.cc index f4eb89912e9..6d022630508 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -356,7 +356,8 @@ handler *get_ha_partition(partition_info *part_info) } else { - my_error(ER_OUTOFMEMORY, MYF(0), static_cast(sizeof(ha_partition))); + my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), + static_cast(sizeof(ha_partition))); } DBUG_RETURN(((handler*) partition)); } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 75aec7918fa..81d151ffba0 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3211,8 +3211,12 @@ bool Item_func_group_concat::add() TREE_ELEMENT *el= 0; // Only for safety if (row_eligible && tree) { + DBUG_EXECUTE_IF("trigger_OOM_in_gconcat_add", + DBUG_SET("+d,simulate_persistent_out_of_memory");); el= tree_insert(tree, table->record[0] + table->s->null_bytes, 0, tree->custom_arg); + DBUG_EXECUTE_IF("trigger_OOM_in_gconcat_add", + DBUG_SET("-d,simulate_persistent_out_of_memory");); /* check if there was enough memory to insert the row */ if (!el) return 1; diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 8e7ee4f01c7..e32bafc73e4 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -107,7 +107,7 @@ void mysql_client_binlog_statement(THD* thd) rli->relay_log.description_event_for_exec && buf)) { - my_error(ER_OUTOFMEMORY, MYF(0), 1); /* needed 1 bytes */ + my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 1); /* needed 1 bytes */ goto end; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6e47dcb5795..556e7d66447 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1136,10 +1136,14 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno, query_cache_abort(&query_cache_tls); - /* When simulating OOM, skip writing to error log to avoid mtr errors */ - DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_RETURN(NULL);); - - cond= warning_info->push_warning(this, sql_errno, sqlstate, level, msg); + /* + Avoid pushing a condition for out of memory errors as this will require + memory allocation and therefore might fail. + */ + if (sql_errno != EE_OUTOFMEMORY && sql_errno != ER_OUTOFMEMORY) + { + cond= warning_info->push_warning(this, sql_errno, sqlstate, level, msg); + } DBUG_RETURN(cond); } @@ -1938,7 +1942,7 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length) key_length + 1); if (!new_table) { - my_error(EE_OUTOFMEMORY, MYF(ME_BELL), + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_FATALERROR), ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1); killed= KILL_CONNECTION; return 0; @@ -2493,7 +2497,7 @@ bool select_export::send_data(List &items) set_if_smaller(estimated_bytes, UINT_MAX32); if (cvt_str.realloc((uint32) estimated_bytes)) { - my_error(ER_OUTOFMEMORY, MYF(0), (uint32) estimated_bytes); + my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), (uint32) estimated_bytes); goto err; } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 066262c3919..8154f4cc404 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -7044,7 +7044,8 @@ void set_key_field_ptr(KEY *key_info, const uchar *new_buf, void mem_alloc_error(size_t size) { - my_error(ER_OUTOFMEMORY, MYF(0), static_cast(size)); + my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), + static_cast(size)); } #ifdef WITH_PARTITION_STORAGE_ENGINE diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2122a2badf9..f3deafc6035 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1475,7 +1475,8 @@ static int mysql_test_select(Prepared_statement *stmt, if (!lex->result && !(lex->result= new (stmt->mem_root) select_send)) { - my_error(ER_OUTOFMEMORY, MYF(0), static_cast(sizeof(select_send))); + my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), + static_cast(sizeof(select_send))); goto error; } @@ -1842,7 +1843,7 @@ static bool mysql_test_multidelete(Prepared_statement *stmt, stmt->thd->lex->current_select= &stmt->thd->lex->select_lex; if (add_item_to_list(stmt->thd, new Item_null())) { - my_error(ER_OUTOFMEMORY, MYF(0), 0); + my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 0); goto error; } @@ -3755,7 +3756,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) alloc_query(thd, (char*) expanded_query->ptr(), expanded_query->length())) { - my_error(ER_OUTOFMEMORY, 0, expanded_query->length()); + my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), expanded_query->length()); goto error; } /* diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 181fa6ece0a..7ffba371b53 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14417,7 +14417,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, } if (copy_blobs(first_field)) { - my_message(ER_OUTOFMEMORY, ER(ER_OUTOFMEMORY), MYF(0)); + my_message(ER_OUTOFMEMORY, ER(ER_OUTOFMEMORY), MYF(ME_FATALERROR)); error=0; goto err; } diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index f9f31fefcb6..97f95487d01 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -2151,7 +2151,8 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) */ if (!(packed_tree=(uint*) my_alloca(sizeof(uint)*length*2))) { - my_error(EE_OUTOFMEMORY,MYF(ME_BELL),sizeof(uint)*length*2); + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_FATALERROR), + sizeof(uint)*length*2); return 0; } From cbb4732f713bde30ebf25e5d684bb93220d1ec19 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Jan 2013 11:30:34 +0530 Subject: [PATCH 019/273] From 3930dbf75c9b1adfc066ac1accc7d217a8a30ca1 Mon Sep 17 00:00:00 2001 From: Neeraj Bisht Date: Wed, 16 Jan 2013 15:03:42 +0530 Subject: [PATCH 020/273] Bug#11751794 MYSQL GIVES THE WRONG RESULT WITH SOME SPECIAL USAGE Consider the following query: SELECT f_1,..,f_m, AGGREGATE_FN(C) FROM t1 WHERE ... GROUP BY ... Loose index scan ("Using index for group-by") can be used for this query if there is an index 'i' covering all fields in the select list, and the GROUP BY clause makes up a prefix f1,...,fn of 'i'. Furthermore, according to rule NGA2 of get_best_group_min_max(), the WHERE clause must contain a conjunction of equality predicates for all fields fn+1,...,fm. The problem in this bug was that a query with WHERE clause that broke NGA2 was not detected and therefore used loose index scan. This lead to wrong result. The query had an index covering (c1,c2) and had: "WHERE (c1 = 1 AND c2 = 'a') OR (c1 = 2 AND c2 = 'b') GROUP BY c1" or "WHERE (c1 = 1 ) OR (c1 = 2 AND c2 = 'b') GROUP BY c1" This WHERE clause cannot be transformed to a conjunction of equality predicates. The solution is to introduce another rule, NGA3, that complements NGA2. NGA3 says that if a gap field (field between those listed in GROUP BY and C in the index) has a predicate, then there can only be one range in the query. This requirement is more strict than it has to be in theory. BUG 15947433 will deal with that. sql/opt_range.cc: check for the repetition of non group field. --- sql/opt_range.cc | 98 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 17 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 6a539198d12..4e67727462c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -9219,13 +9219,15 @@ cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, NGA1.If in the index I there is a gap between the last GROUP attribute G_k, and the MIN/MAX attribute C, then NGA must consist of exactly the index attributes that constitute the gap. As a result there is a - permutation of NGA that coincides with the gap in the index - . + permutation of NGA, BA=, that coincides with the gap + in the index. NGA2.If BA <> {}, then the WHERE clause must contain a conjunction EQ of equality conditions for all NG_i of the form (NG_i = const) or (const = NG_i), such that each NG_i is referenced in exactly one conjunct. Informally, the predicates provide constants to fill the gap in the index. + NGA3.If BA <> {}, there can only be one range. TODO: This is a code + limitation and is not strictly needed. See BUG#15947433 WA1. There are no other attributes in the WHERE clause except the ones referenced in predicates RNG, PA, PC, EQ defined above. Therefore WA is subset of (GA union NGA union C) for GA,NGA,C that pass the @@ -9841,6 +9843,72 @@ check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item, } +/* + Get SEL_ARG tree, if any, for the keypart covering non grouping + attribute (NGA) field 'nga_field'. + + This function enforces the NGA3 test: If 'keypart_tree' contains a + condition for 'nga_field', there can only be one range. In the + opposite case, this function returns with error and 'cur_range' + should not be used. + + Note that the NGA1 and NGA2 requirements, like whether or not the + range predicate for 'nga_field' is equality, is not tested by this + function. + + @param[in] nga_field The NGA field we want the SEL_ARG tree for + @param[in] keypart_tree Root node of the SEL_ARG* tree for the index + @param[out] cur_range The SEL_ARG tree, if any, for the keypart + covering field 'keypart_field' + @retval true 'keypart_tree' contained a predicate for 'nga_field' but + multiple ranges exists. 'cur_range' should not be used. + @retval false otherwise +*/ + +static bool +get_sel_arg_for_keypart(Field *nga_field, + SEL_ARG *keypart_tree, + SEL_ARG **cur_range) +{ + if(keypart_tree->field->eq(nga_field)) + { + /* + Enforce NGA3: If a condition for nga_field has been found, only + a single range is allowed. + */ + if (keypart_tree->prev || keypart_tree->next) + return true; // There are multiple ranges + + *cur_range= keypart_tree; + return false; + } + + SEL_ARG *found_tree= NULL; + SEL_ARG *first_kp= keypart_tree->first(); + + for (SEL_ARG *cur_kp= first_kp; cur_kp && !found_tree; + cur_kp= cur_kp->next) + { + if (cur_kp->next_key_part) + { + if (get_sel_arg_for_keypart(nga_field, + cur_kp->next_key_part, + &found_tree)) + return true; + + } + /* + Enforce NGA3: If a condition for nga_field has been found,only + a single range is allowed. + */ + if (found_tree && first_kp->next) + return true; // There are multiple ranges + } + *cur_range= found_tree; + return false; +} + + /* Extract a sequence of constants from a conjunction of equality predicates. @@ -9855,12 +9923,13 @@ check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item, key_infix [out] Infix of constants to be used for index lookup key_infix_len [out] Lenghth of the infix first_non_infix_part [out] The first keypart after the infix (if any) - + DESCRIPTION - Test conditions (NGA1, NGA2) from get_best_group_min_max(). Namely, - for each keypart field NGF_i not in GROUP-BY, check that there is a - constant equality predicate among conds with the form (NGF_i = const_ci) or - (const_ci = NGF_i). + Test conditions (NGA1, NGA2, NGA3) from get_best_group_min_max(). Namely, + for each keypart field NG_i not in GROUP-BY, check that there is exactly one + constant equality predicate among conds with the form (NG_i = const_ci) or + (const_ci = NG_i).. In addition, there can only be one range when there is + such a gap. Thus all the NGF_i attributes must fill the 'gap' between the last group-by attribute and the MIN/MAX attribute in the index (if present). If these conditions hold, copy each constant from its corresponding predicate into @@ -9889,16 +9958,14 @@ get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree, uchar *key_ptr= key_infix; for (cur_part= first_non_group_part; cur_part != end_part; cur_part++) { + cur_range= NULL; /* Find the range tree for the current keypart. We assume that - index_range_tree points to the leftmost keypart in the index. + index_range_tree points to the first keypart in the index. */ - for (cur_range= index_range_tree; cur_range; - cur_range= cur_range->next_key_part) - { - if (cur_range->field->eq(cur_part->field)) - break; - } + if(get_sel_arg_for_keypart(cur_part->field, index_range_tree, &cur_range)) + return false; + if (!cur_range) { if (min_max_arg_part) @@ -9910,9 +9977,6 @@ get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree, } } - /* Check that the current range tree is a single point interval. */ - if (cur_range->prev || cur_range->next) - return FALSE; /* This is not the only range predicate for the field. */ if ((cur_range->min_flag & NO_MIN_RANGE) || (cur_range->max_flag & NO_MAX_RANGE) || (cur_range->min_flag & NEAR_MIN) || (cur_range->max_flag & NEAR_MAX)) From 01208b5b0f3d175408c01afc1e06b07019ca7c2f Mon Sep 17 00:00:00 2001 From: Anirudh Mangipudi Date: Wed, 16 Jan 2013 18:26:27 +0530 Subject: [PATCH 021/273] BUG#14117025: UNABLE TO RESTORE DUMP Problem: When a view, with a specific character set and collation, is created on another view with a different character set and collation the dump restoration results in an illegal mix of collations error. SOLUTION: To avoid this confusion of collations, the create table datatype being used is hardcoded as "tinyint NOT NULL". This will not matter as the table created will be dropped at runtime and specifically tinyint is used to avoid hitting the row size conflicts. --- client/mysqldump.c | 13 +++++++--- mysql-test/r/mysqldump.result | 46 +++++++++++++++++------------------ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 316c0fd174c..68d445f9a5b 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2635,14 +2635,19 @@ static uint get_table_structure(char *table, char *db, char *table_type, row= mysql_fetch_row(result); - fprintf(sql_file, " %s %s", quote_name(row[0], name_buff, 0), - row[1]); + /* + The actual column type doesn't matter anyway, since the table will + be dropped at run time. + We do tinyint to avoid hitting the row size limit. + */ + fprintf(sql_file, " %s tinyint NOT NULL", + quote_name(row[0], name_buff, 0)); while((row= mysql_fetch_row(result))) { /* col name, col type */ - fprintf(sql_file, ",\n %s %s", - quote_name(row[0], name_buff, 0), row[1]); + fprintf(sql_file, ",\n %s tinyint NOT NULL", + quote_name(row[0], name_buff, 0)); } /* diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index fac94e855a4..bc5b5095196 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1988,7 +1988,7 @@ DROP TABLE IF EXISTS `v2`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v2` ( - `a` varchar(30) + `a` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE IF EXISTS `v2`*/; @@ -2082,7 +2082,7 @@ DROP TABLE IF EXISTS `v1`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v1` ( - `a` int(11) + `a` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE IF EXISTS `v1`*/; @@ -2156,7 +2156,7 @@ DROP TABLE IF EXISTS `v2`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v2` ( - `a` varchar(30) + `a` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE IF EXISTS `v2`*/; @@ -2270,9 +2270,9 @@ DROP TABLE IF EXISTS `v1`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v1` ( - `a` int(11), - `b` int(11), - `c` varchar(30) + `a` tinyint NOT NULL, + `b` tinyint NOT NULL, + `c` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `v2`; @@ -2280,7 +2280,7 @@ DROP TABLE IF EXISTS `v2`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v2` ( - `a` int(11) + `a` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `v3`; @@ -2288,9 +2288,9 @@ DROP TABLE IF EXISTS `v3`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v3` ( - `a` int(11), - `b` int(11), - `c` varchar(30) + `a` tinyint NOT NULL, + `b` tinyint NOT NULL, + `c` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE IF EXISTS `v1`*/; @@ -3027,9 +3027,9 @@ DROP TABLE IF EXISTS `v0`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v0` ( - `a` int(11), - `b` varchar(32), - `c` varchar(32) + `a` tinyint NOT NULL, + `b` tinyint NOT NULL, + `c` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `v1`; @@ -3037,9 +3037,9 @@ DROP TABLE IF EXISTS `v1`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v1` ( - `a` int(11), - `b` varchar(32), - `c` varchar(32) + `a` tinyint NOT NULL, + `b` tinyint NOT NULL, + `c` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `v2`; @@ -3047,9 +3047,9 @@ DROP TABLE IF EXISTS `v2`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v2` ( - `a` int(11), - `b` varchar(32), - `c` varchar(32) + `a` tinyint NOT NULL, + `b` tinyint NOT NULL, + `c` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -3429,7 +3429,7 @@ DROP TABLE IF EXISTS `v1`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v1` ( - `id` int(11) + `id` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -3489,7 +3489,7 @@ USE `mysqldump_views`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `nasishnasifu` ( - `id` bigint(20) unsigned + `id` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -3882,7 +3882,7 @@ DROP TABLE IF EXISTS `v2`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v2` ( - `c` int(11) + `c` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE IF EXISTS `v2`*/; @@ -4299,7 +4299,7 @@ DROP TABLE IF EXISTS `v1`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v1` ( - `id` int(11) + `id` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; From 49adfa3d19f92a8e4bb17c2930b9bfdcbd134c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 17 Jan 2013 17:30:13 +0200 Subject: [PATCH 022/273] Bug#16138582 MTR_MEMO_RELEASE AND DYN_ARRAY TOGETHER ARE VERY INEFFICIENT Get rid of O(n^2) scan in dyn array (mtr->memo) operations, accessing the dyn array blocks directly. dyn_array_get_last_block(), dyn_array_get_next_block(), dyn_array_get_prev_block(): Define as a constness-preserving macro. Add const qualifiers to many dyn_array functions. mtr_memo_slot_release_func(): Renamed from mtr_memo_slot_release(): Make mtr_t* a debug-only parameter. Assume that slot->object != NULL. mtr_memo_pop_all(): Access the dyn_array blocks directly, replacing O(n^2) operation with O(n). mtr_memo_release(): Access the dyn_array blocks directly, replacing O(n^2) operation with O(n). This caused the performance problem. rb#1540 approved by Jimmy Yang --- storage/innobase/dyn/dyn0dyn.c | 8 +- storage/innobase/include/dyn0dyn.h | 84 +++++++++------- storage/innobase/include/dyn0dyn.ic | 141 ++++++++------------------- storage/innobase/include/mtr0mtr.h | 10 +- storage/innobase/mtr/mtr0mtr.c | 145 ++++++++++++++-------------- 5 files changed, 173 insertions(+), 215 deletions(-) diff --git a/storage/innobase/dyn/dyn0dyn.c b/storage/innobase/dyn/dyn0dyn.c index e1275f040f3..d0f50ad0c32 100644 --- a/storage/innobase/dyn/dyn0dyn.c +++ b/storage/innobase/dyn/dyn0dyn.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -35,7 +35,7 @@ UNIV_INTERN dyn_block_t* dyn_array_add_block( /*================*/ - dyn_array_t* arr) /*!< in: dyn array */ + dyn_array_t* arr) /*!< in/out: dyn array */ { mem_heap_t* heap; dyn_block_t* block; diff --git a/storage/innobase/include/dyn0dyn.h b/storage/innobase/include/dyn0dyn.h index 121a5946ac7..62ed862e82c 100644 --- a/storage/innobase/include/dyn0dyn.h +++ b/storage/innobase/include/dyn0dyn.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -47,15 +47,17 @@ UNIV_INLINE dyn_array_t* dyn_array_create( /*=============*/ - dyn_array_t* arr); /*!< in: pointer to a memory buffer of + dyn_array_t* arr) /*!< in/out memory buffer of size sizeof(dyn_array_t) */ + __attribute__((nonnull)); /************************************************************//** Frees a dynamic array. */ UNIV_INLINE void dyn_array_free( /*===========*/ - dyn_array_t* arr); /*!< in: dyn array */ + dyn_array_t* arr) /*!< in,own: dyn array */ + __attribute__((nonnull)); /*********************************************************************//** Makes room on top of a dyn array and returns a pointer to a buffer in it. After copying the elements, the caller must close the buffer using @@ -66,8 +68,9 @@ byte* dyn_array_open( /*===========*/ dyn_array_t* arr, /*!< in: dynamic array */ - ulint size); /*!< in: size in bytes of the buffer; MUST be + ulint size) /*!< in: size in bytes of the buffer; MUST be smaller than DYN_ARRAY_DATA_SIZE! */ + __attribute__((nonnull, warn_unused_result)); /*********************************************************************//** Closes the buffer returned by dyn_array_open. */ UNIV_INLINE @@ -75,7 +78,8 @@ void dyn_array_close( /*============*/ dyn_array_t* arr, /*!< in: dynamic array */ - byte* ptr); /*!< in: buffer space from ptr up was not used */ + const byte* ptr) /*!< in: end of used space */ + __attribute__((nonnull)); /*********************************************************************//** Makes room on top of a dyn array and returns a pointer to the added element. The caller must copy the element to @@ -85,8 +89,9 @@ UNIV_INLINE void* dyn_array_push( /*===========*/ - dyn_array_t* arr, /*!< in: dynamic array */ - ulint size); /*!< in: size in bytes of the element */ + dyn_array_t* arr, /*!< in/out: dynamic array */ + ulint size) /*!< in: size in bytes of the element */ + __attribute__((nonnull, warn_unused_result)); /************************************************************//** Returns pointer to an element in dyn array. @return pointer to element */ @@ -94,9 +99,10 @@ UNIV_INLINE void* dyn_array_get_element( /*==================*/ - dyn_array_t* arr, /*!< in: dyn array */ - ulint pos); /*!< in: position of element as bytes - from array start */ + const dyn_array_t* arr, /*!< in: dyn array */ + ulint pos) /*!< in: position of element + in bytes from array start */ + __attribute__((nonnull, warn_unused_result)); /************************************************************//** Returns the size of stored data in a dyn array. @return data size in bytes */ @@ -104,30 +110,33 @@ UNIV_INLINE ulint dyn_array_get_data_size( /*====================*/ - dyn_array_t* arr); /*!< in: dyn array */ + const dyn_array_t* arr) /*!< in: dyn array */ + __attribute__((nonnull, warn_unused_result, pure)); /************************************************************//** -Gets the first block in a dyn array. */ -UNIV_INLINE -dyn_block_t* -dyn_array_get_first_block( -/*======================*/ - dyn_array_t* arr); /*!< in: dyn array */ +Gets the first block in a dyn array. +@param arr dyn array +@return first block */ +#define dyn_array_get_first_block(arr) (arr) /************************************************************//** -Gets the last block in a dyn array. */ -UNIV_INLINE -dyn_block_t* -dyn_array_get_last_block( -/*=====================*/ - dyn_array_t* arr); /*!< in: dyn array */ +Gets the last block in a dyn array. +@param arr dyn array +@return last block */ +#define dyn_array_get_last_block(arr) \ + ((arr)->heap ? UT_LIST_GET_LAST((arr)->base) : (arr)) /********************************************************************//** Gets the next block in a dyn array. -@return pointer to next, NULL if end of list */ -UNIV_INLINE -dyn_block_t* -dyn_array_get_next_block( -/*=====================*/ - dyn_array_t* arr, /*!< in: dyn array */ - dyn_block_t* block); /*!< in: dyn array block */ +@param arr dyn array +@param block dyn array block +@return pointer to next, NULL if end of list */ +#define dyn_array_get_next_block(arr, block) \ + ((arr)->heap ? UT_LIST_GET_NEXT(list, block) : NULL) +/********************************************************************//** +Gets the previous block in a dyn array. +@param arr dyn array +@param block dyn array block +@return pointer to previous, NULL if end of list */ +#define dyn_array_get_prev_block(arr, block) \ + ((arr)->heap ? UT_LIST_GET_PREV(list, block) : NULL) /********************************************************************//** Gets the number of used bytes in a dyn array block. @return number of bytes used */ @@ -135,7 +144,8 @@ UNIV_INLINE ulint dyn_block_get_used( /*===============*/ - dyn_block_t* block); /*!< in: dyn array block */ + const dyn_block_t* block) /*!< in: dyn array block */ + __attribute__((nonnull, warn_unused_result, pure)); /********************************************************************//** Gets pointer to the start of data in a dyn array block. @return pointer to data */ @@ -143,16 +153,18 @@ UNIV_INLINE byte* dyn_block_get_data( /*===============*/ - dyn_block_t* block); /*!< in: dyn array block */ + const dyn_block_t* block) /*!< in: dyn array block */ + __attribute__((nonnull, warn_unused_result, pure)); /********************************************************//** Pushes n bytes to a dyn array. */ UNIV_INLINE void dyn_push_string( /*============*/ - dyn_array_t* arr, /*!< in: dyn array */ + dyn_array_t* arr, /*!< in/out: dyn array */ const byte* str, /*!< in: string to write */ - ulint len); /*!< in: string length */ + ulint len) /*!< in: string length */ + __attribute__((nonnull)); /*#################################################################*/ diff --git a/storage/innobase/include/dyn0dyn.ic b/storage/innobase/include/dyn0dyn.ic index 110e674abff..177877ed1fd 100644 --- a/storage/innobase/include/dyn0dyn.ic +++ b/storage/innobase/include/dyn0dyn.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -35,56 +35,8 @@ UNIV_INTERN dyn_block_t* dyn_array_add_block( /*================*/ - dyn_array_t* arr); /*!< in: dyn array */ - - -/************************************************************//** -Gets the first block in a dyn array. */ -UNIV_INLINE -dyn_block_t* -dyn_array_get_first_block( -/*======================*/ - dyn_array_t* arr) /*!< in: dyn array */ -{ - return(arr); -} - -/************************************************************//** -Gets the last block in a dyn array. */ -UNIV_INLINE -dyn_block_t* -dyn_array_get_last_block( -/*=====================*/ - dyn_array_t* arr) /*!< in: dyn array */ -{ - if (arr->heap == NULL) { - - return(arr); - } - - return(UT_LIST_GET_LAST(arr->base)); -} - -/********************************************************************//** -Gets the next block in a dyn array. -@return pointer to next, NULL if end of list */ -UNIV_INLINE -dyn_block_t* -dyn_array_get_next_block( -/*=====================*/ - dyn_array_t* arr, /*!< in: dyn array */ - dyn_block_t* block) /*!< in: dyn array block */ -{ - ut_ad(arr && block); - - if (arr->heap == NULL) { - ut_ad(arr == block); - - return(NULL); - } - - return(UT_LIST_GET_NEXT(list, block)); -} + dyn_array_t* arr) /*!< in/out: dyn array */ + __attribute__((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of used bytes in a dyn array block. @@ -93,7 +45,7 @@ UNIV_INLINE ulint dyn_block_get_used( /*===============*/ - dyn_block_t* block) /*!< in: dyn array block */ + const dyn_block_t* block) /*!< in: dyn array block */ { ut_ad(block); @@ -107,11 +59,11 @@ UNIV_INLINE byte* dyn_block_get_data( /*===============*/ - dyn_block_t* block) /*!< in: dyn array block */ + const dyn_block_t* block) /*!< in: dyn array block */ { ut_ad(block); - return(block->data); + return((byte*) block->data); } /*********************************************************************//** @@ -121,7 +73,7 @@ UNIV_INLINE dyn_array_t* dyn_array_create( /*=============*/ - dyn_array_t* arr) /*!< in: pointer to a memory buffer of + dyn_array_t* arr) /*!< in/out: memory buffer of size sizeof(dyn_array_t) */ { ut_ad(arr); @@ -132,10 +84,9 @@ dyn_array_create( arr->heap = NULL; arr->used = 0; -#ifdef UNIV_DEBUG - arr->buf_end = 0; - arr->magic_n = DYN_BLOCK_MAGIC_N; -#endif + ut_d(arr->buf_end = 0); + ut_d(arr->magic_n = DYN_BLOCK_MAGIC_N); + return(arr); } @@ -151,9 +102,7 @@ dyn_array_free( mem_heap_free(arr->heap); } -#ifdef UNIV_DEBUG - arr->magic_n = 0; -#endif + ut_d(arr->magic_n = 0); } /*********************************************************************//** @@ -164,7 +113,7 @@ UNIV_INLINE void* dyn_array_push( /*===========*/ - dyn_array_t* arr, /*!< in: dynamic array */ + dyn_array_t* arr, /*!< in/out: dynamic array */ ulint size) /*!< in: size in bytes of the element */ { dyn_block_t* block; @@ -176,24 +125,23 @@ dyn_array_push( ut_ad(size); block = arr; - used = block->used; - if (used + size > DYN_ARRAY_DATA_SIZE) { + if (block->used + size > DYN_ARRAY_DATA_SIZE) { /* Get the last array block */ block = dyn_array_get_last_block(arr); - used = block->used; - if (used + size > DYN_ARRAY_DATA_SIZE) { + if (block->used + size > DYN_ARRAY_DATA_SIZE) { block = dyn_array_add_block(arr); - used = block->used; } } + used = block->used; + block->used = used + size; ut_ad(block->used <= DYN_ARRAY_DATA_SIZE); - return((block->data) + used); + return(block->data + used); } /*********************************************************************//** @@ -210,7 +158,6 @@ dyn_array_open( smaller than DYN_ARRAY_DATA_SIZE! */ { dyn_block_t* block; - ulint used; ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); @@ -218,28 +165,23 @@ dyn_array_open( ut_ad(size); block = arr; - used = block->used; - if (used + size > DYN_ARRAY_DATA_SIZE) { + if (block->used + size > DYN_ARRAY_DATA_SIZE) { /* Get the last array block */ block = dyn_array_get_last_block(arr); - used = block->used; - if (used + size > DYN_ARRAY_DATA_SIZE) { + if (block->used + size > DYN_ARRAY_DATA_SIZE) { block = dyn_array_add_block(arr); - used = block->used; ut_a(size <= DYN_ARRAY_DATA_SIZE); } } ut_ad(block->used <= DYN_ARRAY_DATA_SIZE); -#ifdef UNIV_DEBUG ut_ad(arr->buf_end == 0); + ut_d(arr->buf_end = block->used + size); - arr->buf_end = used + size; -#endif - return((block->data) + used); + return(block->data + block->used); } /*********************************************************************//** @@ -248,8 +190,8 @@ UNIV_INLINE void dyn_array_close( /*============*/ - dyn_array_t* arr, /*!< in: dynamic array */ - byte* ptr) /*!< in: buffer space from ptr up was not used */ + dyn_array_t* arr, /*!< in/out: dynamic array */ + const byte* ptr) /*!< in: end of used space */ { dyn_block_t* block; @@ -264,9 +206,7 @@ dyn_array_close( ut_ad(block->used <= DYN_ARRAY_DATA_SIZE); -#ifdef UNIV_DEBUG - arr->buf_end = 0; -#endif + ut_d(arr->buf_end = 0); } /************************************************************//** @@ -276,12 +216,11 @@ UNIV_INLINE void* dyn_array_get_element( /*==================*/ - dyn_array_t* arr, /*!< in: dyn array */ - ulint pos) /*!< in: position of element as bytes - from array start */ + const dyn_array_t* arr, /*!< in: dyn array */ + ulint pos) /*!< in: position of element + in bytes from array start */ { - dyn_block_t* block; - ulint used; + const dyn_block_t* block; ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); @@ -290,21 +229,23 @@ dyn_array_get_element( block = dyn_array_get_first_block(arr); if (arr->heap != NULL) { - used = dyn_block_get_used(block); + for (;;) { + ulint used = dyn_block_get_used(block); + + if (pos < used) { + break; + } - while (pos >= used) { pos -= used; block = UT_LIST_GET_NEXT(list, block); ut_ad(block); - - used = dyn_block_get_used(block); } } ut_ad(block); ut_ad(dyn_block_get_used(block) >= pos); - return(block->data + pos); + return((byte*) block->data + pos); } /************************************************************//** @@ -314,10 +255,10 @@ UNIV_INLINE ulint dyn_array_get_data_size( /*====================*/ - dyn_array_t* arr) /*!< in: dyn array */ + const dyn_array_t* arr) /*!< in: dyn array */ { - dyn_block_t* block; - ulint sum = 0; + const dyn_block_t* block; + ulint sum = 0; ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); @@ -344,7 +285,7 @@ UNIV_INLINE void dyn_push_string( /*============*/ - dyn_array_t* arr, /*!< in: dyn array */ + dyn_array_t* arr, /*!< in/out: dyn array */ const byte* str, /*!< in: string to write */ ulint len) /*!< in: string length */ { diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index 46f1ff9310c..88ac3c138de 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -295,9 +295,10 @@ UNIV_INTERN void mtr_memo_release( /*=============*/ - mtr_t* mtr, /*!< in: mtr */ + mtr_t* mtr, /*!< in/out: mini-transaction */ void* object, /*!< in: object */ - ulint type); /*!< in: object type: MTR_MEMO_S_LOCK, ... */ + ulint type) /*!< in: object type: MTR_MEMO_S_LOCK, ... */ + __attribute__((nonnull)); #ifdef UNIV_DEBUG # ifndef UNIV_HOTBACKUP /**********************************************************//** @@ -309,7 +310,8 @@ mtr_memo_contains( /*==============*/ mtr_t* mtr, /*!< in: mtr */ const void* object, /*!< in: object to search */ - ulint type); /*!< in: type of object */ + ulint type) /*!< in: type of object */ + __attribute__((warn_unused_result, nonnull)); /**********************************************************//** Checks if memo contains the given page. diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.c index d852ed6f496..a5c98761523 100644 --- a/storage/innobase/mtr/mtr0mtr.c +++ b/storage/innobase/mtr/mtr0mtr.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -39,72 +39,81 @@ Created 11/26/1995 Heikki Tuuri # include "log0recv.h" /*****************************************************************//** Releases the item in the slot given. */ -static +static __attribute__((nonnull)) void -mtr_memo_slot_release( -/*==================*/ - mtr_t* mtr, /*!< in: mtr */ +mtr_memo_slot_release_func( +/*=======================*/ +#ifdef UNIV_DEBUG + mtr_t* mtr, /*!< in/out: mini-transaction */ +#endif /* UNIV_DEBUG */ mtr_memo_slot_t* slot) /*!< in: memo slot */ { - void* object; - ulint type; - - ut_ad(mtr); - ut_ad(slot); - -#ifndef UNIV_DEBUG - UT_NOT_USED(mtr); -#endif /* UNIV_DEBUG */ - - object = slot->object; - type = slot->type; - - if (UNIV_LIKELY(object != NULL)) { - if (type <= MTR_MEMO_BUF_FIX) { - buf_page_release((buf_block_t*)object, type); - } else if (type == MTR_MEMO_S_LOCK) { - rw_lock_s_unlock((rw_lock_t*)object); -#ifdef UNIV_DEBUG - } else if (type != MTR_MEMO_X_LOCK) { - ut_ad(type == MTR_MEMO_MODIFY); - ut_ad(mtr_memo_contains(mtr, object, - MTR_MEMO_PAGE_X_FIX)); -#endif /* UNIV_DEBUG */ - } else { - rw_lock_x_unlock((rw_lock_t*)object); - } - } - + void* object = slot->object; slot->object = NULL; + + /* slot release is a local operation for the current mtr. + We must not be holding the flush_order mutex while + doing this. */ + ut_ad(!log_flush_order_mutex_own()); + + switch (slot->type) { + case MTR_MEMO_PAGE_S_FIX: + case MTR_MEMO_PAGE_X_FIX: + case MTR_MEMO_BUF_FIX: + buf_page_release((buf_block_t*) object, slot->type); + break; + case MTR_MEMO_S_LOCK: + rw_lock_s_unlock((rw_lock_t*) object); + break; + case MTR_MEMO_X_LOCK: + rw_lock_x_unlock((rw_lock_t*) object); + break; +#ifdef UNIV_DEBUG + default: + ut_ad(slot->type == MTR_MEMO_MODIFY); + ut_ad(mtr_memo_contains(mtr, object, MTR_MEMO_PAGE_X_FIX)); +#endif /* UNIV_DEBUG */ + } } +#ifdef UNIV_DEBUG +# define mtr_memo_slot_release(mtr, slot) mtr_memo_slot_release_func(mtr, slot) +#else /* UNIV_DEBUG */ +# define mtr_memo_slot_release(mtr, slot) mtr_memo_slot_release_func(slot) +#endif /* UNIV_DEBUG */ + /**********************************************************//** Releases the mlocks and other objects stored in an mtr memo. They are released in the order opposite to which they were pushed to the memo. */ -static +static __attribute__((nonnull)) void mtr_memo_pop_all( /*=============*/ - mtr_t* mtr) /*!< in: mtr */ + mtr_t* mtr) /*!< in/out: mini-transaction */ { - mtr_memo_slot_t* slot; - dyn_array_t* memo; - ulint offset; + const dyn_block_t* block; - ut_ad(mtr); ut_ad(mtr->magic_n == MTR_MAGIC_N); ut_ad(mtr->state == MTR_COMMITTING); /* Currently only used in commit */ - memo = &(mtr->memo); - offset = dyn_array_get_data_size(memo); + for (block = dyn_array_get_last_block(&mtr->memo); + block; + block = dyn_array_get_prev_block(&mtr->memo, block)) { + const mtr_memo_slot_t* start + = (mtr_memo_slot_t*) dyn_block_get_data(block); + mtr_memo_slot_t* slot + = (mtr_memo_slot_t*) (dyn_block_get_data(block) + + dyn_block_get_used(block)); - while (offset > 0) { - offset -= sizeof(mtr_memo_slot_t); - slot = dyn_array_get_element(memo, offset); + ut_ad(!(dyn_block_get_used(block) % sizeof(mtr_memo_slot_t))); - mtr_memo_slot_release(mtr, slot); + while (slot-- != start) { + if (slot->object != NULL) { + mtr_memo_slot_release(mtr, slot); + } + } } } @@ -288,42 +297,36 @@ UNIV_INTERN void mtr_memo_release( /*=============*/ - mtr_t* mtr, /*!< in: mtr */ + mtr_t* mtr, /*!< in/out: mini-transaction */ void* object, /*!< in: object */ ulint type) /*!< in: object type: MTR_MEMO_S_LOCK, ... */ { - mtr_memo_slot_t* slot; - dyn_array_t* memo; - ulint offset; + const dyn_block_t* block; - ut_ad(mtr); ut_ad(mtr->magic_n == MTR_MAGIC_N); ut_ad(mtr->state == MTR_ACTIVE); + /* We cannot release a page that has been written to in the + middle of a mini-transaction. */ + ut_ad(!mtr->modifications || type != MTR_MEMO_PAGE_X_FIX); - memo = &(mtr->memo); + for (block = dyn_array_get_last_block(&mtr->memo); + block; + block = dyn_array_get_prev_block(&mtr->memo, block)) { + const mtr_memo_slot_t* start + = (mtr_memo_slot_t*) dyn_block_get_data(block); + mtr_memo_slot_t* slot + = (mtr_memo_slot_t*) (dyn_block_get_data(block) + + dyn_block_get_used(block)); - offset = dyn_array_get_data_size(memo); + ut_ad(!(dyn_block_get_used(block) % sizeof(mtr_memo_slot_t))); - log_flush_order_mutex_enter(); - while (offset > 0) { - offset -= sizeof(mtr_memo_slot_t); - - slot = dyn_array_get_element(memo, offset); - - if (object == slot->object && type == slot->type) { - - /* We cannot release a page that has been written - to in the middle of a mini-transaction. */ - - ut_ad(!(mtr->modifications - && slot->type == MTR_MEMO_PAGE_X_FIX)); - - mtr_memo_slot_release(mtr, slot); - - break; + while (slot-- != start) { + if (object == slot->object && type == slot->type) { + mtr_memo_slot_release(mtr, slot); + return; + } } } - log_flush_order_mutex_exit(); } #endif /* !UNIV_HOTBACKUP */ From 9b904d35afc83aadd2deafe066ea1689ce0a7100 Mon Sep 17 00:00:00 2001 From: Astha Pareek Date: Fri, 18 Jan 2013 12:32:37 +0530 Subject: [PATCH 023/273] Description The test, binlog.binlog_spurious_ddl_errors was failing on pb2 at the statement "UNINSTALL PLUGIN example;" with this warning: "Warning 1620 Plugin is busy and will be uninstalled on shutdown " Fix Spurious warnings occur in the test since we do not empty the Query cache, used by the example plugin at the time of creating tables using the plugin. Hence, the query chache is flushed before uninstalling the plugin. Also, as part of running the test across platforms, the plugin installation script is changed. --- mysql-test/suite/binlog/r/binlog_spurious_ddl_errors.result | 1 + mysql-test/suite/binlog/t/binlog_spurious_ddl_errors.test | 4 +++- mysql-test/suite/binlog/t/disabled.def | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_spurious_ddl_errors.result b/mysql-test/suite/binlog/r/binlog_spurious_ddl_errors.result index 17a473ff062..1a81eee1a58 100644 --- a/mysql-test/suite/binlog/r/binlog_spurious_ddl_errors.result +++ b/mysql-test/suite/binlog/r/binlog_spurious_ddl_errors.result @@ -48,6 +48,7 @@ DROP TABLE t_stmt; ################################################################################ # CLEAN UP # ################################################################################ +flush tables; UNINSTALL PLUGIN example; SET @@global.binlog_format = @old_binlog_format; SET @@session.binlog_format = @old_binlog_format; diff --git a/mysql-test/suite/binlog/t/binlog_spurious_ddl_errors.test b/mysql-test/suite/binlog/t/binlog_spurious_ddl_errors.test index 6514ff1f712..d8d2b932f48 100644 --- a/mysql-test/suite/binlog/t/binlog_spurious_ddl_errors.test +++ b/mysql-test/suite/binlog/t/binlog_spurious_ddl_errors.test @@ -26,7 +26,8 @@ --source include/have_log_bin.inc SET @old_binlog_format= @@global.binlog_format; -INSTALL PLUGIN example SONAME 'ha_example.so'; +--replace_regex /\.dll/.so/ +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; --echo ################################################################################ --echo # Verifies if ER_BINLOG_STMT_MODE_AND_ROW_ENGINE happens by setting the binlog @@ -90,6 +91,7 @@ DROP TABLE t_stmt; --echo ################################################################################ --echo # CLEAN UP # --echo ################################################################################ +flush tables; UNINSTALL PLUGIN example; SET @@global.binlog_format = @old_binlog_format; SET @@session.binlog_format = @old_binlog_format; diff --git a/mysql-test/suite/binlog/t/disabled.def b/mysql-test/suite/binlog/t/disabled.def index 1abc9951322..c1bc7842a4d 100644 --- a/mysql-test/suite/binlog/t/disabled.def +++ b/mysql-test/suite/binlog/t/disabled.def @@ -10,4 +10,3 @@ # ############################################################################## binlog_truncate_innodb : BUG#11764459 2010-10-20 anitha Originally disabled due to BUG#42643. Product bug fixed, but test changes needed -binlog_spurious_ddl_errors : BUG#11761680 2010-06-03 alik binlog_spurious_ddl_errors.test fails, thus disabled From 008bc7e102899d4ecd52101659dbec6454fc7cb0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jan 2013 14:13:59 +0200 Subject: [PATCH 024/273] From c8de0f9aec5e61a126409444d1e62b63e74f4416 Mon Sep 17 00:00:00 2001 From: Astha Pareek Date: Fri, 18 Jan 2013 18:26:02 +0530 Subject: [PATCH 025/273] BUG#11761680 disabled binlog_spurious_ddl_errors on mysql-5.5 --- mysql-test/suite/binlog/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/binlog/t/disabled.def b/mysql-test/suite/binlog/t/disabled.def index c1bc7842a4d..424e5549541 100644 --- a/mysql-test/suite/binlog/t/disabled.def +++ b/mysql-test/suite/binlog/t/disabled.def @@ -10,3 +10,4 @@ # ############################################################################## binlog_truncate_innodb : BUG#11764459 2010-10-20 anitha Originally disabled due to BUG#42643. Product bug fixed, but test changes needed +binlog_spurious_ddl_errors : BUG#11761680 2013-01-18 astha Fixed on mysql-5.6 and trunk From bc21e8cd6946e77ed0c594113d5b47949c89659b Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Sat, 19 Jan 2013 06:01:46 +0530 Subject: [PATCH 026/273] Bug#11752707-SLAVE CRASHES IF RBR HAS AS DESTINATION A VIEW RATHER THAN A TABLE Problem: In RBR, If a table is converted into a view at slave, (i.e., "drop table 'object1'" & "create view 'object1'"), then any DML operations on the table at master are causing crash at slave. Analysis: Slave prepares tables to be opened for DML list when it receives Table_map_log_event(s). And the same list will be sent to open_table function. Open_table logic assumes that if the list contains a view object, it also contains "select_lex" object of that view. In the above special case, the table object does not contain 'select_lex' as it is base table at master. Since it is a view at slave, open_table logic goes to 'mysql_make_view()' function which assumes that 'select_lex' exists for the object. Fix: While preparing 'tables to be opened' list, we should make sure that table required type is 'base table'. If it is not base table while opening the object, mysql_make_view will throw an error similar to 'object is not a base table' sql/log_event.cc: Restrict that all table_map_log_event's objects should be base tables @ slave also. --- sql/log_event.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/log_event.cc b/sql/log_event.cc index 63770e340b0..542b5e2dc60 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -8573,6 +8573,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) table_list->next_global= table_list->next_local= 0; table_list->table_id= DBUG_EVALUATE_IF("inject_tblmap_same_id_maps_diff_table", 0, m_table_id); table_list->updating= 1; + table_list->required_type= FRMTYPE_TABLE; strmov(table_list->db, rpl_filter->get_rewrite_db(m_dbnam, &dummy_len)); strmov(table_list->table_name, m_tblnam); DBUG_PRINT("debug", ("table: %s is mapped to %u", table_list->table_name, table_list->table_id)); From e7283ceaf034072dcd9ad01b2377ee2101eb1b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 21 Jan 2013 14:59:49 +0200 Subject: [PATCH 027/273] Bug#16067973 DROP TABLE SLOW WHEN IT DECOMPRESS COMPRESSED-ONLY PAGES buf_page_get_gen(): Do not attempt to decompress a compressed-only page when mode == BUF_PEEK_IF_IN_POOL. This mode is only being used by btr_search_drop_page_hash_when_freed(). There cannot be any adaptive hash index pointing to a page that does not exist in uncompressed format in the buffer pool. innodb_buffer_pool_evict_update(): New function for debug builds, to handle SET GLOBAL innodb_buffer_pool_evicted='uncompressed' by evicting all uncompressed page frames of compressed tablespaces from the buffer pool. rb#1873 approved by Jimmy Yang --- .../r/innodb_buffer_pool_evict_basic.result | 7 +++ .../t/innodb_buffer_pool_evict_basic.test | 10 +++ storage/innodb_plugin/ChangeLog | 8 ++- storage/innodb_plugin/buf/buf0buf.c | 11 +++- storage/innodb_plugin/handler/ha_innodb.cc | 61 ++++++++++++++++++- 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/sys_vars/r/innodb_buffer_pool_evict_basic.result create mode 100644 mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test diff --git a/mysql-test/suite/sys_vars/r/innodb_buffer_pool_evict_basic.result b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_evict_basic.result new file mode 100644 index 00000000000..459ad95bdc6 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_evict_basic.result @@ -0,0 +1,7 @@ +SELECT @@global.innodb_buffer_pool_evict; +@@global.innodb_buffer_pool_evict + +SET GLOBAL innodb_buffer_pool_evict = 'uncompressed'; +SELECT @@global.innodb_buffer_pool_evict; +@@global.innodb_buffer_pool_evict + diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test new file mode 100644 index 00000000000..2350d55c57b --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test @@ -0,0 +1,10 @@ +-- source include/have_innodb_plugin.inc +# This is a debug variable for now +-- source include/have_debug.inc + +SELECT @@global.innodb_buffer_pool_evict; + +SET GLOBAL innodb_buffer_pool_evict = 'uncompressed'; + +# Should always be empty. +SELECT @@global.innodb_buffer_pool_evict; diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 6a389f618af..d1953ec6d61 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,9 @@ +2013-01-21 The InnoDB Team + + * buf/buf0buf.cc, handler/ha_innodb.cc: + Fix Bug#16067973 DROP TABLE IS SLOW WHEN IT DECOMPRESSES + COMPRESSED-ONLY PAGES + 2013-01-11 The InnoDB Team * row/row0sel.c: Fix Bug#16088883 KILLING A QUERY INSIDE INNODB CAUSES IT TO @@ -6,7 +12,7 @@ 2012-12-18 The InnoDB Team * include/univ.i: - Fix Bug#Bug#13463493 INNODB PLUGIN WERE CHANGED, BUT STILL USE THE + Fix Bug#13463493 INNODB PLUGIN WERE CHANGED, BUT STILL USE THE SAME VERSION NUMBER 1.0.17 2012-12-13 The InnoDB Team diff --git a/storage/innodb_plugin/buf/buf0buf.c b/storage/innodb_plugin/buf/buf0buf.c index e7e60fb2b2a..504718f6e08 100644 --- a/storage/innodb_plugin/buf/buf0buf.c +++ b/storage/innodb_plugin/buf/buf0buf.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -1664,6 +1664,7 @@ loop2: if (must_read && (mode == BUF_GET_IF_IN_POOL || mode == BUF_PEEK_IF_IN_POOL)) { /* The page is only being read to buffer */ +null_exit: buf_pool_mutex_exit(); return(NULL); @@ -1678,6 +1679,14 @@ loop2: case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_DIRTY: + if (mode == BUF_PEEK_IF_IN_POOL) { + /* This mode is only used for dropping an + adaptive hash index. There cannot be an + adaptive hash index for a compressed-only + page, so do not bother decompressing the page. */ + goto null_exit; + } + bpage = &block->page; /* Protect bpage->buf_fix_count. */ mutex_enter(&buf_pool_zip_mutex); diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index 51068d26eff..229e7fe71e5 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. @@ -10926,6 +10926,55 @@ innodb_change_buffering_update( *static_cast(save); } +#ifndef DBUG_OFF +static char* srv_buffer_pool_evict; + +/****************************************************************//** +Called on SET GLOBAL innodb_buffer_pool_evict=... +Handles some values specially, to evict pages from the buffer pool. +SET GLOBAL innodb_buffer_pool_evict='uncompressed' +evicts all uncompressed page frames of compressed tablespaces. */ +static +void +innodb_buffer_pool_evict_update( +/*============================*/ + THD* thd, /*!< in: thread handle */ + struct st_mysql_sys_var*var, /*!< in: pointer to system variable */ + void* var_ptr,/*!< out: ignored */ + const void* save) /*!< in: immediate result + from check function */ +{ + if (const char* op = *static_cast(save)) { + if (!strcmp(op, "uncompressed")) { + /* Evict all uncompressed pages of compressed + tables from the buffer pool. Keep the compressed + pages in the buffer pool. */ + + buf_pool_mutex_enter(); + + for (buf_block_t* block = UT_LIST_GET_LAST( + buf_pool->unzip_LRU); + block != NULL; ) { + + buf_block_t* prev_block + = UT_LIST_GET_PREV(unzip_LRU, block); + ut_ad(buf_block_get_state(block) + == BUF_BLOCK_FILE_PAGE); + ut_ad(block->in_unzip_LRU_list); + ut_ad(block->page.in_LRU_list); + + mutex_enter(&block->mutex); + buf_LRU_free_block(&block->page, FALSE); + mutex_exit(&block->mutex); + block = prev_block; + } + + buf_pool_mutex_exit(); + } + } +} +#endif /* !DBUG_OFF */ + static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff) { innodb_export_status(); @@ -11128,6 +11177,13 @@ static MYSQL_SYSVAR_ULONG(autoextend_increment, srv_auto_extend_increment, "Data file autoextend increment in megabytes", NULL, NULL, 8L, 1L, 1000L, 0); +#ifndef DBUG_OFF +static MYSQL_SYSVAR_STR(buffer_pool_evict, srv_buffer_pool_evict, + PLUGIN_VAR_RQCMDARG, + "Evict pages from the InnoDB buffer pool.", + NULL, innodb_buffer_pool_evict_update, ""); +#endif /* !DBUG_OFF */ + static MYSQL_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.", @@ -11300,6 +11356,9 @@ static MYSQL_SYSVAR_BOOL(trx_purge_view_update_only_debug, static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(additional_mem_pool_size), MYSQL_SYSVAR(autoextend_increment), +#ifndef DBUG_OFF + MYSQL_SYSVAR(buffer_pool_evict), +#endif /* !DBUG_OFF */ MYSQL_SYSVAR(buffer_pool_size), MYSQL_SYSVAR(checksums), MYSQL_SYSVAR(commit_concurrency), From 19ea7c031d9d58dd2f5f9b41ae50b96795132213 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Wed, 23 Jan 2013 09:51:50 +0400 Subject: [PATCH 028/273] Bug #11827369: ASSERTION FAILED: !THD->LEX->CONTEXT_ANALYSIS_ONLY Some queries with the "SELECT ... FROM DUAL" nested subqueries failed with an assertion on debug builds. Non-debug builds were not affected. There were a few different issues with similar assertion failures on different queries: 1. The first problem was related to the incomplete propagation of the "non-constant" item status from underlying subquery items to the outer item tree: in some cases non-constants were interpreted as constants and evaluated at the preparation stage (val_int() calls withing fix_fields() etc). Thus, the default implementation of Item_ref::const_item() from the Item parent class didn't take into account the "const_item" status of the referenced item tree -- it used the insufficient "used_tables() == 0" check instead. This worked in most cases since our "non-constant" functions like RAND() and SLEEP() set the RAND_TABLE_BIT in the used table map, so they aren't non-constant from Item_ref's "point of view". However, the "SELECT ... FROM DUAL" subquery may have an empty map of used tables, but at the same time subqueries are never "constant" at the context analysis stage (preparation, view creation etc). So, the non-contantness of such subqueries was missed. Fix: the Item_ref::const_item() function has been overloaded to take into account both (*ref)->const_item() status and tricky Item_ref::used_tables() return values, since the only (*ref)->const_item() call is not enough there. 2. In some cases instead of the const_item() call we check a value of the Item::with_subselect field to recognize items with nested subqueries. However, the Item_ref class didn't propagate this value from the referenced item tree. Fix: Item::has_subquery() and Item_ref::has_subquery() functions have been backported from 5.6. All direct references to the with_subselect fields of nested items have been with the has_subquery() function call. 3. The Item_func_regex class didn't propagate with_subselect as well, since it overloads the Item_func::fix_fields() function with insufficient fix_fields() implementation. Fix: the Item_func_regex::fix_fields() function has been modified to gather "constant" statuses from inner items. 4. The Item_func_isnull::update_used_tables() function has a special branch for the underlying item where the maybe_null value is false: in this case it marks the Item_func_isnull as a "const_item" and sets the cached_value to false. However, the Item_func_isnull::val_int() was not in sync with update_used_tables(): it didn't take into account neither const_item_cache nor cached_value for the case of "args[0]->maybe_null == false optimization". As far as such an Item_func_isnull has "const_item() == true", it's ok to call Item_func_isnull::val_int() etc from outer items on preparation stage. In this case the server tried to call Item_func_isnull::args[0]->isnull(), and if the args[0] item contained a nested not-nullable subquery, it failed with an assertion. Fix: take the value of Item_func_isnull::const_item_cache into account in the val_int() function. 5. The auxiliary Item_is_not_null_test class has a similar optimization in the update_used_tables() function as the Item_func_isnull class has, and the same issue in the val_int() function. In addition to that the Item_is_not_null_test::update_used_tables() doesn't update the const_item_cache value, so the "maybe_null" optimization is useless there. Thus, we missed some optimizations of cases like these (before and after the fix): < (a), --- > ((a)), or < having ((a) and (a)) --- > having 1 etc. Fix: update Item_is_not_null_test::const_item_cache in update_used_tables() and take in into account in val_int(). --- sql/item.cc | 4 ++-- sql/item.h | 18 +++++++++++++++++- sql/item_cmpfunc.cc | 12 ++++++++---- sql/item_func.cc | 4 ++-- sql/sql_select.cc | 4 ++-- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 63215179ac6..6038ea7fde6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -428,7 +428,7 @@ Item::Item(THD *thd, Item *item): fixed(item->fixed), is_autogenerated_name(item->is_autogenerated_name), collation(item->collation), - with_subselect(item->with_subselect), + with_subselect(item->has_subquery()), cmp_context(item->cmp_context) { next= thd->free_list; // Put in free list diff --git a/sql/item.h b/sql/item.h index 3a46280ed31..57a01b7d92d 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1054,6 +1054,11 @@ public: { return Field::GEOM_GEOMETRY; }; String *check_well_formed_result(String *str, bool send_error= 0); bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs); + + /** + Checks if this item or any of its decendents contains a subquery. + */ + virtual bool has_subquery() const { return with_subselect; } }; @@ -2264,6 +2269,10 @@ public: Field *get_tmp_table_field() { return result_field ? result_field : (*ref)->get_tmp_table_field(); } Item *get_tmp_table_item(THD *thd); + bool const_item() const + { + return (*ref)->const_item() && (used_tables() == 0); + } table_map used_tables() const { return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); @@ -2332,6 +2341,13 @@ public: return (*ref)->get_time(ltime); } + /** + Checks if the item tree that ref points to contains a subquery. + */ + virtual bool has_subquery() const + { + return (*ref)->has_subquery(); + } }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 6e8fa9a5f75..9775cf732f5 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4257,7 +4257,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) const_item_cache= FALSE; } with_sum_func= with_sum_func || item->with_sum_func; - with_subselect|= item->with_subselect; + with_subselect|= item->has_subquery(); if (item->maybe_null) maybe_null=1; } @@ -4582,7 +4582,7 @@ longlong Item_func_isnull::val_int() Handle optimization if the argument can't be null This has to be here because of the test in update_used_tables(). */ - if (!used_tables_cache && !with_subselect) + if (const_item_cache) return cached_value; return args[0]->is_null() ? 1: 0; } @@ -4591,7 +4591,7 @@ longlong Item_is_not_null_test::val_int() { DBUG_ASSERT(fixed == 1); DBUG_ENTER("Item_is_not_null_test::val_int"); - if (!used_tables_cache && !with_subselect) + if (const_item_cache) { owner->was_null|= (!cached_value); DBUG_PRINT("info", ("cached: %ld", (long) cached_value)); @@ -4612,10 +4612,12 @@ longlong Item_is_not_null_test::val_int() */ void Item_is_not_null_test::update_used_tables() { + const_item_cache= false; if (!args[0]->maybe_null) { used_tables_cache= 0; /* is always true */ cached_value= (longlong) 1; + const_item_cache= true; } else { @@ -4624,6 +4626,7 @@ void Item_is_not_null_test::update_used_tables() { /* Remember if the value is always NULL or never NULL */ cached_value= (longlong) !args[0]->is_null(); + const_item_cache= true; } } } @@ -4879,6 +4882,7 @@ Item_func_regex::fix_fields(THD *thd, Item **ref) args[1]->fix_fields(thd, args + 1)) || args[1]->check_cols(1)) return TRUE; /* purecov: inspected */ with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func; + with_subselect= args[0]->has_subquery() || args[1]->has_subquery(); max_length= 1; decimals= 0; diff --git a/sql/item_func.cc b/sql/item_func.cc index 21efaf83aa8..55cace0e941 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -198,7 +198,7 @@ Item_func::fix_fields(THD *thd, Item **ref) used_tables_cache|= item->used_tables(); not_null_tables_cache|= item->not_null_tables(); const_item_cache&= item->const_item(); - with_subselect|= item->with_subselect; + with_subselect|= item->has_subquery(); } } fix_length_and_dec(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index de9f0ead7a3..89567bd1f5e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -7321,7 +7321,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, *simple_order=0; // Must do a temp table to sort else if (!(order_tables & not_const_tables)) { - if (order->item[0]->with_subselect && + if (order->item[0]->has_subquery() && !(join->select_lex->options & SELECT_DESCRIBE)) order->item[0]->val_str(&order->item[0]->str_value); DBUG_PRINT("info",("removing: %s", order->item[0]->full_name())); From 65cb30b3b94d1a0cca207623519f711d7ff11d17 Mon Sep 17 00:00:00 2001 From: Yasufumi Kinoshita Date: Wed, 23 Jan 2013 14:59:36 +0900 Subject: [PATCH 029/273] Bug #16089381 : POSSIBLE NUMBER UNDERFLOW AROUND CALLING PAGE_ZIP_EMPTY_SIZE() some callers for page_zip_empty_size() ignored possibility its returning 0, and could cause underflow. rb#1837 approved by Marko --- storage/innodb_plugin/btr/btr0cur.c | 43 +++++++++++++---------- storage/innodb_plugin/dict/dict0dict.c | 11 ++++-- storage/innodb_plugin/include/page0zip.ic | 6 ++-- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0cur.c index e38b8a9bf53..4392fc16a5b 100644 --- a/storage/innodb_plugin/btr/btr0cur.c +++ b/storage/innodb_plugin/btr/btr0cur.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -1146,27 +1146,13 @@ btr_cur_optimistic_insert( Subtract one byte for the encoded heap_no in the modification log. */ ulint free_space_zip = page_zip_empty_size( - cursor->index->n_fields, zip_size) - 1; + cursor->index->n_fields, zip_size); ulint n_uniq = dict_index_get_n_unique_in_tree(index); ut_ad(dict_table_is_comp(index->table)); - /* There should be enough room for two node pointer - records on an empty non-leaf page. This prevents - infinite page splits. */ - - if (UNIV_LIKELY(entry->n_fields >= n_uniq) - && UNIV_UNLIKELY(REC_NODE_PTR_SIZE - + rec_get_converted_size_comp_prefix( - index, entry->fields, n_uniq, - NULL) - /* On a compressed page, there is - a two-byte entry in the dense - page directory for every record. - But there is no record header. */ - - (REC_N_NEW_EXTRA_BYTES - 2) - > free_space_zip / 2)) { - + if (free_space_zip == 0) { +too_big: if (big_rec_vec) { dtuple_convert_back_big_rec( index, entry, big_rec_vec); @@ -1174,6 +1160,27 @@ btr_cur_optimistic_insert( return(DB_TOO_BIG_RECORD); } + + /* Subtract one byte for the encoded heap_no in the + modification log. */ + free_space_zip--; + + /* There should be enough room for two node pointer + records on an empty non-leaf page. This prevents + infinite page splits. */ + + if (entry->n_fields >= n_uniq + && (REC_NODE_PTR_SIZE + + rec_get_converted_size_comp_prefix( + index, entry->fields, n_uniq, NULL) + /* On a compressed page, there is + a two-byte entry in the dense + page directory for every record. + But there is no record header. */ + - (REC_N_NEW_EXTRA_BYTES - 2) + > free_space_zip / 2)) { + goto too_big; + } } LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page), diff --git a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c index 56c71cefa05..9cd0f51d72b 100644 --- a/storage/innodb_plugin/dict/dict0dict.c +++ b/storage/innodb_plugin/dict/dict0dict.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1415,6 +1415,10 @@ dict_index_too_big_for_tree( /* maximum allowed size of a node pointer record */ ulint page_ptr_max; + DBUG_EXECUTE_IF( + "ib_force_create_table", + return(FALSE);); + comp = dict_table_is_comp(table); zip_size = dict_table_zip_size(table); @@ -1429,7 +1433,10 @@ dict_index_too_big_for_tree( number in the page modification log. The maximum allowed node pointer size is half that. */ page_rec_max = page_zip_empty_size(new_index->n_fields, - zip_size) - 1; + zip_size); + if (page_rec_max) { + page_rec_max--; + } page_ptr_max = page_rec_max / 2; /* On a compressed page, there is a two-byte entry in the dense page directory for every record. But there diff --git a/storage/innodb_plugin/include/page0zip.ic b/storage/innodb_plugin/include/page0zip.ic index 75cc7a9fcc4..b5480604bdf 100644 --- a/storage/innodb_plugin/include/page0zip.ic +++ b/storage/innodb_plugin/include/page0zip.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -188,8 +188,8 @@ page_zip_rec_needs_ext( one record on an empty leaf page. Subtract 1 byte for the encoded heap number. Check also the available space on the uncompressed page. */ - return(rec_size - (REC_N_NEW_EXTRA_BYTES - 2) - >= (page_zip_empty_size(n_fields, zip_size) - 1) + return(rec_size - (REC_N_NEW_EXTRA_BYTES - 2 - 1) + >= page_zip_empty_size(n_fields, zip_size) || rec_size >= page_get_free_space_of_empty(TRUE) / 2); } From f31611c4c585d916697131446d2ad2928d4ad36f Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Thu, 24 Jan 2013 10:35:07 +0530 Subject: [PATCH 030/273] BUG#14798572: REMOVE UNUSED VARIABLE BINLOG_CAN_BE_CORRUPTED FROM MYSQL_BINLOG_SEND As part Bug #11747416 A DISK FULL MAKES BINARY LOG CORRUPT, reading the variable "binlog_can_be_corrupted" was removed In the existing code the value of this variable is only set, never read. And also this issue causing compiler warnings. So the variable is completely redundant and should be removed. sql/sql_repl.cc: Removing dead code --- sql/sql_repl.cc | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index e16ce15e512..15d0d5c90d5 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -452,7 +452,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, mysql_mutex_t *log_lock; mysql_cond_t *log_cond; - bool binlog_can_be_corrupted= FALSE; #ifndef DBUG_OFF int left_events = max_binlog_dump_events; #endif @@ -621,8 +620,6 @@ impossible position"; (*packet)[EVENT_TYPE_OFFSET+ev_offset])); if ((*packet)[EVENT_TYPE_OFFSET+ev_offset] == FORMAT_DESCRIPTION_EVENT) { - binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+ev_offset] & - LOG_EVENT_BINLOG_IN_USE_F); (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F; /* mark that this event with "log_pos=0", so the slave @@ -711,34 +708,8 @@ impossible position"; }); if (event_type == FORMAT_DESCRIPTION_EVENT) { - binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+ev_offset] & - LOG_EVENT_BINLOG_IN_USE_F); (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F; } - else if (event_type == STOP_EVENT) - binlog_can_be_corrupted= FALSE; - - /* - Introduced this code to make the gcc 4.6.1 compiler happy. When - warnings are converted to errors, the compiler complains about - the fact that binlog_can_be_corrupted is defined but never used. - - We need to check if this is a dead code or if someone removed any - code by mistake. - - /Alfranio - */ - if (binlog_can_be_corrupted) - { - /* - Don't try to print out warning messages because this generates - erroneous messages in the error log and causes performance - problems. - - /Alfranio - */ - } - pos = my_b_tell(&log); if (RUN_HOOK(binlog_transmit, before_send_event, (thd, flags, packet, log_file_name, pos))) From 776df0a3660ebc724754b56a007345b3961e8a36 Mon Sep 17 00:00:00 2001 From: Venkata Sidagam Date: Thu, 24 Jan 2013 14:02:54 +0530 Subject: [PATCH 031/273] Bug #11752803 SERVER CRASHES IF MAX_CONNECTIONS DECREASED BELOW CERTAIN LEVEL Problem description: mysqld crashes when we update the max_connections variable to lesser value than the number of currently open connections. Analysis: The "alarm_queue.max_elements" size will be decided at the server start time and it will get modified if we change max_connections value. In the current scenario the value of "alarm_queue.max_elements" is decremented when the max_connections is set to 2. When updating the "alarm_queue.max_elements" value we are not updating "max_used_alarms" value. Hence, instead of getting the warning "thr_alarm queue is full" it is ending up in asserting the server at the time of inserting new elements in the queue. Fix: the fix is to dynamically increase the size of the alarm_queue. In order to do that, queue_insert_safe() should be used instead if queue_insert(). --- mysys/thr_alarm.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 6541fab138b..e2fc54c487e 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -52,6 +52,8 @@ static QUEUE alarm_queue; static uint max_used_alarms=0; pthread_t alarm_thread; +#define MY_THR_ALARM_QUEUE_EXTENT 10 + #ifdef USE_ALARM_THREAD static void *alarm_handler(void *arg); #define reschedule_alarms() pthread_cond_signal(&COND_alarm) @@ -74,8 +76,8 @@ void init_thr_alarm(uint max_alarms) DBUG_ENTER("init_thr_alarm"); alarm_aborted=0; next_alarm_expire_time= ~ (time_t) 0; - init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0, - compare_ulong,NullS); + init_queue_ex(&alarm_queue, max_alarms + 1, offsetof(ALARM,expire_time), 0, + compare_ulong, NullS, MY_THR_ALARM_QUEUE_EXTENT); sigfillset(&full_signal_set); /* Neaded to block signals */ pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST); pthread_cond_init(&COND_alarm,NULL); @@ -127,7 +129,10 @@ void resize_thr_alarm(uint max_alarms) than max_alarms */ if (alarm_queue.elements < max_alarms) + { resize_queue(&alarm_queue,max_alarms+1); + max_used_alarms= alarm_queue.elements; + } pthread_mutex_unlock(&LOCK_alarm); } @@ -182,17 +187,6 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data) if (alarm_queue.elements >= max_used_alarms) { - if (alarm_queue.elements == alarm_queue.max_elements) - { - DBUG_PRINT("info", ("alarm queue full")); - fprintf(stderr,"Warning: thr_alarm queue is full\n"); - *alrm= 0; /* No alarm */ - pthread_mutex_unlock(&LOCK_alarm); -#ifndef USE_ONE_SIGNAL_HAND - pthread_sigmask(SIG_SETMASK,&old_mask,NULL); -#endif - DBUG_RETURN(1); - } max_used_alarms=alarm_queue.elements+1; } reschedule= (ulong) next_alarm_expire_time > (ulong) now + sec; @@ -216,7 +210,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data) alarm_data->alarmed=0; alarm_data->thread= current_my_thread_var->pthread_self; alarm_data->thread_id= current_my_thread_var->id; - queue_insert(&alarm_queue,(uchar*) alarm_data); + queue_insert_safe(&alarm_queue, (uchar*) alarm_data); /* Reschedule alarm if the current one has more than sec left */ if (reschedule) From 26f662be1c12b6cfddc33a88b33d2986f3d0da0f Mon Sep 17 00:00:00 2001 From: Venkata Sidagam Date: Thu, 24 Jan 2013 14:56:12 +0530 Subject: [PATCH 032/273] BUG#11908153 CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE Backporting bug patch from 5.5 to 5.1. This fix is applicable to BUG#14362617 as well --- sql/field.h | 8 +++++++- sql/field_conv.cc | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sql/field.h b/sql/field.h index ca23702fd8c..cc709bc0c9c 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1824,7 +1824,13 @@ public: int store(longlong nr, bool unsigned_val); int store_decimal(const my_decimal *); uint size_of() const { return sizeof(*this); } - int reset(void) { return !maybe_null() || Field_blob::reset(); } + + /** + Non-nullable GEOMETRY types cannot have defaults, + but the underlying blob must still be reset. + */ + int reset(void) { return Field_blob::reset() || !maybe_null(); } + geometry_type get_geometry_type() { return geom_type; }; }; #endif /*HAVE_SPATIAL*/ diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 782d41fc8f1..b97061be147 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -179,7 +179,10 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions) ((Field_timestamp*) field)->set_time(); return 0; // Ok to set time to NULL } + + // Note: we ignore any potential failure of reset() here. field->reset(); + if (field == field->table->next_number_field) { field->table->auto_increment_field_not_null= FALSE; From 08a22ba1c9b0513d9a32509bbfe5b49261ee7676 Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Sat, 26 Jan 2013 15:03:01 +0530 Subject: [PATCH 033/273] Bug#16056813-MEMORY LEAK ON FILTERED SLAVE Due to not resetting a member (last_added) of Deferred events class inside a clean up function (Deferred_log_events::rewind), there is a memory leak on filtered slaves. Fix: Resetting last_added to NULL in rewind() function. sql/rpl_utility.cc: Resetting last_added to NULL to avoid memory leak --- sql/rpl_utility.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 8efb376b5b6..2643f2d6059 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -1117,6 +1117,7 @@ void Deferred_log_events::rewind() Log_event *ev= *(Log_event **) dynamic_array_ptr(&array, i); delete ev; } + last_added= NULL; if (array.elements > array.max_element) freeze_size(&array); reset_dynamic(&array); From 7e0901b97fa087e4458f32ffd165103f31a1fef8 Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Mon, 28 Jan 2013 14:41:54 +0530 Subject: [PATCH 034/273] Bug#16084594 USER_VAR ITEM IN 'LOAD FILE QUERY' WAS NOT PROPERLY QUOTED IN BINLOG FILE Problem: In load data file query, User variables are allowed inside "Into_list" and "Set_list". These user variables used inside these two lists are not properly guarded with backticks while server is writting into binlog. Hence user variable names like a` cannot be used in this context. Fix: Properly quote these variables while writting into binlog mysql-test/r/func_compress.result: changing result file mysql-test/r/variables.result: changing result file mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result: changing result file sql/item_func.cc: Quote the user variable items --- mysql-test/r/func_compress.result | 4 ++-- mysql-test/r/variables.result | 2 +- mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result | 4 ++-- sql/item_func.cc | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result index b4e61d0e4fc..37f7c475148 100644 --- a/mysql-test/r/func_compress.result +++ b/mysql-test/r/func_compress.result @@ -11,7 +11,7 @@ explain extended select uncompress(compress(@test_compress_string)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select uncompress(compress((@test_compress_string))) AS `uncompress(compress(@test_compress_string))` +Note 1003 select uncompress(compress((@`test_compress_string`))) AS `uncompress(compress(@test_compress_string))` select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string); uncompressed_length(compress(@test_compress_string))=length(@test_compress_string) 1 @@ -19,7 +19,7 @@ explain extended select uncompressed_length(compress(@test_compress_string))=len id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select (uncompressed_length(compress((@test_compress_string))) = length((@test_compress_string))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)` +Note 1003 select (uncompressed_length(compress((@`test_compress_string`))) = length((@`test_compress_string`))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)` select uncompressed_length(compress(@test_compress_string)); uncompressed_length(compress(@test_compress_string)) 117 diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 8cff6e99d4f..858c2baf1d4 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -77,7 +77,7 @@ explain extended select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@t1) AS `@t1`,(@t2) AS `@t2`,(@t3) AS `@t3` +Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@`t1`) AS `@t1`,(@`t2`) AS `@t2`,(@`t3`) AS `@t3` select @t5; @t5 1.23456 diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result index d2f47e56c61..7f92744180c 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result @@ -631,7 +631,7 @@ master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# master-bin.000001 # Intvar # # INSERT_ID=10 -master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`=((@b) + `bug27417`(2)) ;file_id=# +master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=((@`b`) + `bug27417`(2)) ;file_id=# master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; drop trigger trg_del_t2; @@ -869,7 +869,7 @@ master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci -master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`=((@b) + `bug27417`(2)) ;file_id=# +master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=((@`b`) + `bug27417`(2)) ;file_id=# master-bin.000001 # Query # # ROLLBACK drop trigger trg_del_t2; drop table t1,t2,t3,t4,t5; diff --git a/sql/item_func.cc b/sql/item_func.cc index 21efaf83aa8..6cf78a38ded 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4725,7 +4725,7 @@ enum Item_result Item_func_get_user_var::result_type() const void Item_func_get_user_var::print(String *str, enum_query_type query_type) { str->append(STRING_WITH_LEN("(@")); - str->append(name.str,name.length); + append_identifier(current_thd, str, name.str, name.length); str->append(')'); } @@ -4826,7 +4826,7 @@ my_decimal* Item_user_var_as_out_param::val_decimal(my_decimal *decimal_buffer) void Item_user_var_as_out_param::print(String *str, enum_query_type query_type) { str->append('@'); - str->append(name.str,name.length); + append_identifier(current_thd, str, name.str, name.length); } From d63f54c67d033968127319ec08d35f493684bccd Mon Sep 17 00:00:00 2001 From: Satya Bodapati Date: Mon, 28 Jan 2013 20:13:44 +0530 Subject: [PATCH 035/273] Bug#16183892 - INNODB PURGE BUFFERING IS NOT CRASH-SAFE With innodb_change_buffering enabled, Innodb buffers all modifications to secondary index leaf pages when the leaf pages are not in buffer pool. Crash InnoDB while an IBUF_OP_DELETE is being applied. Restart and note that the same record can be applied again which may lead to crash. Mark the change buffer record processed, so that it will not be merged again in case the server crashes between the following mtr_commit() and the subsequent mtr_commit() of deleting the change buffer record. Testcase: No testcase because it is difficult to get the timing right with the two asyncronous task purge and change buffering Approved by Marko. rb#1893 --- storage/innobase/ibuf/ibuf0ibuf.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index 70af56b99f2..11505121fa2 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -4685,6 +4685,16 @@ loop: == page_no); ut_ad(ibuf_rec_get_space(&mtr, rec) == space); + /* Mark the change buffer record processed, + so that it will not be merged again in case + the server crashes between the following + mtr_commit() and the subsequent mtr_commit() + of deleting the change buffer record. */ + + btr_cur_set_deleted_flag_for_ibuf( + btr_pcur_get_rec(&pcur), NULL, + TRUE, &mtr); + btr_pcur_store_position(&pcur, &mtr); ibuf_btr_pcur_commit_specify_mtr(&pcur, &mtr); From d1378565bba59726ae3f4d47d0709e68d77110ed Mon Sep 17 00:00:00 2001 From: Nuno Carvalho Date: Mon, 28 Jan 2013 19:05:09 +0000 Subject: [PATCH 036/273] BUG#16200555: EMPTY NAME FOR USER VARIABLE IS ALLOWED AND BREAKS STATEMENT BINARY LOGGING On a previous fix, user variables with zero length name were incorrectly considered as event corruption, despite that them are allowed by server. Fix this wrong assumption by allowing again user variables with zero length on binary log. --- sql/log_event.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 542b5e2dc60..8abd95bba0a 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -5729,10 +5729,9 @@ User_var_log_event(const char* buf, uint event_len, /* We don't know yet is_null value, so we must assume that name_len may have the bigger value possible, is_null= True and there is no - payload for val. + payload for val, or even that name_len is 0. */ - if (0 == name_len || - !valid_buffer_range(name_len, buf_start, name, + if (!valid_buffer_range(name_len, buf_start, name, event_len - UV_VAL_IS_NULL)) { error= true; From 265814f2ae1ddf8eb089ce703a58b9a43b2bc1f9 Mon Sep 17 00:00:00 2001 From: Neeraj Bisht Date: Tue, 29 Jan 2013 10:05:00 +0530 Subject: [PATCH 037/273] Bug#16208709 - CRASH IN GET_SEL_ARG_FOR_KEYPART ON SELECT DISTINCT ON COL WITH COMPOSITE INDEX This problem is caused by the patch for the bug#11751794. While checking for the keypart covering non grouping attribute. we are not checking whether the root node of the SEL_ARG* tree for the index have any cvalue or not. --- sql/opt_range.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 4e67727462c..ae6878c6756 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -9870,6 +9870,8 @@ get_sel_arg_for_keypart(Field *nga_field, SEL_ARG *keypart_tree, SEL_ARG **cur_range) { + if(keypart_tree == NULL) + return false; if(keypart_tree->field->eq(nga_field)) { /* From ed15e9c2700f81529f7e223e22c28065d103d6de Mon Sep 17 00:00:00 2001 From: "Krunal Bauskar krunal.bauskar@oracle.com" Date: Wed, 30 Jan 2013 08:17:24 +0530 Subject: [PATCH 038/273] - BUG#1608883: KILLING A QUERY INSIDE INNODB CAUSES IT TO EVENTUALLY CRASH WITH AN ASSERTION Correcting the build failure that was caused because of changes checked-in to below mentioned revision. (Changes: DEBUG_SYNC_C should be disabled for innodb_plugin under Windows enviornment. Note: only for innodb_plugin.) revno: 3915 revision-id: krunal.bauskar@oracle.com-20130114051951-ang92lkirop37431 parent: nisha.gopalakrishnan@oracle.com-20130112054337-gk5pmzf30d2imuw7 committer: Krunal Bauskar krunal.bauskar@oracle.com branch nick: mysql-5.1 timestamp: Mon 2013-01-14 10:49:51 +0530 --- storage/innodb_plugin/row/row0sel.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c index d2e83450860..3b1934edc62 100644 --- a/storage/innodb_plugin/row/row0sel.c +++ b/storage/innodb_plugin/row/row0sel.c @@ -57,8 +57,13 @@ Created 12/19/1997 Heikki Tuuri #include "read0read.h" #include "buf0lru.h" #include "ha_prototypes.h" +#ifdef __WIN__ +/* error LNK2001: unresolved external symbol _debug_sync_C_callback_ptr */ +# define DEBUG_SYNC_C(dummy) ((void) 0) +#else #include "m_string.h" /* for my_sys.h */ #include "my_sys.h" /* DEBUG_SYNC_C */ +#endif /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 From db107cb36b9d2e0057188a887a220a859c756be1 Mon Sep 17 00:00:00 2001 From: Aditya A Date: Wed, 30 Jan 2013 10:53:43 +0530 Subject: [PATCH 039/273] Bug#14756795 SELECT FROM NEW INNODB I_S TABLES CRASHES SERVER WITH --SKIP-INNODB Description ----------- If the server is started with skip-innodb or InnoDB otherwise fails to start, any one of these queries will crash the server: For (5.5) SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE; SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU; SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS; In (5.6+) ,following queries will also crash the server. SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_DATAFILES; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES; FIX ---- When Innodb is not active we must prevent it from processing these tables,so we return a warning saying that innodb is not active. Approved by marko (http://rb.no.oracle.com/rb/r/1891) --- storage/innobase/handler/i_s.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index f4916b48641..7be881b8d90 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -2295,6 +2295,7 @@ i_s_innodb_buffer_stats_fill_table( buf_pool_info_t* pool_info; DBUG_ENTER("i_s_innodb_buffer_fill_general"); + RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); /* Only allow the PROCESS privilege holder to access the stats */ if (check_global_access(thd, PROCESS_ACL)) { @@ -2911,6 +2912,7 @@ i_s_innodb_fill_buffer_pool( mem_heap_t* heap; DBUG_ENTER("i_s_innodb_fill_buffer_pool"); + RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); heap = mem_heap_create(10000); @@ -3480,6 +3482,7 @@ i_s_innodb_fill_buffer_lru( ulint lru_len; DBUG_ENTER("i_s_innodb_fill_buffer_lru"); + RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); /* Obtain buf_pool mutex before allocate info_buffer, since UT_LIST_GET_LEN(buf_pool->LRU) could change */ From 16bf552e3eb2cd28306fc84c3406875ece708495 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2013 14:32:52 +0530 Subject: [PATCH 040/273] From e1ee9581cb4a4cac085d0ad6eedadb73de187deb Mon Sep 17 00:00:00 2001 From: Chaithra Gopalareddy Date: Thu, 31 Jan 2013 06:39:15 +0530 Subject: [PATCH 041/273] Bug#14096619: UNABLE TO RESTORE DATABASE DUMP Backport of Bug#13581962 mysql-test/r/cast.result: Added test result for Bug#13581962,Bug#14096619 mysql-test/t/cast.test: Added test case for Bug#13581962,Bug#14096619 sql/item_func.h: limit max length by MY_INT64_NUM_DECIMAL_DIGITS --- mysql-test/r/cast.result | 18 ++++++++++++++++++ mysql-test/t/cast.test | 13 +++++++++++++ sql/item_func.h | 17 ++++++++++------- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index d7a7503707b..fc0d79e9568 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -477,4 +477,22 @@ WHERE CAST(a as BINARY)=x'62736D697468' AND CAST(a AS BINARY)=x'65736D697468'; a DROP TABLE t1; +# +# Bug#13581962 HIGH MEMORY USAGE ATTEMPT, THEN CRASH WITH +# LONGTEXT, UNION, USER VARIABLE +# Bug#14096619 UNABLE TO RESTORE DATABASE DUMP +# +CREATE TABLE t1 AS SELECT CONCAT(CAST(REPEAT('9', 1000) AS SIGNED)), +CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED)); +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999' +Warning 1292 Truncated incorrect INTEGER value: '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CONCAT(CAST(REPEAT('9', 1000) AS SIGNED))` varbinary(21) NOT NULL DEFAULT '', + `CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED))` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# End of test for Bug#13581962, Bug#14096619 End of 5.1 tests diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 4474736200c..27eb5e88c54 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -309,4 +309,17 @@ WHERE CAST(a as BINARY)=x'62736D697468' DROP TABLE t1; +--echo # +--echo # Bug#13581962 HIGH MEMORY USAGE ATTEMPT, THEN CRASH WITH +--echo # LONGTEXT, UNION, USER VARIABLE +--echo # Bug#14096619 UNABLE TO RESTORE DATABASE DUMP +--echo # + +CREATE TABLE t1 AS SELECT CONCAT(CAST(REPEAT('9', 1000) AS SIGNED)), + CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED)); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # End of test for Bug#13581962, Bug#14096619 + --echo End of 5.1 tests diff --git a/sql/item_func.h b/sql/item_func.h index ec410ed3d3d..d769ceb0179 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -403,12 +403,17 @@ public: class Item_func_signed :public Item_int_func { public: - Item_func_signed(Item *a) :Item_int_func(a) {} + Item_func_signed(Item *a) :Item_int_func(a) + { + unsigned_flag= 0; + } const char *func_name() const { return "cast_as_signed"; } longlong val_int(); longlong val_int_from_str(int *error); void fix_length_and_dec() - { max_length=args[0]->max_length; unsigned_flag=0; } + { + max_length= min(args[0]->max_length,MY_INT64_NUM_DECIMAL_DIGITS); + } virtual void print(String *str, enum_query_type query_type); uint decimal_precision() const { return args[0]->decimal_precision(); } }; @@ -417,13 +422,11 @@ public: class Item_func_unsigned :public Item_func_signed { public: - Item_func_unsigned(Item *a) :Item_func_signed(a) {} - const char *func_name() const { return "cast_as_unsigned"; } - void fix_length_and_dec() + Item_func_unsigned(Item *a) :Item_func_signed(a) { - max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2); - unsigned_flag=1; + unsigned_flag= 1; } + const char *func_name() const { return "cast_as_unsigned"; } longlong val_int(); virtual void print(String *str, enum_query_type query_type); }; From c3d2803c43d4076428763c50632217cb70c751d5 Mon Sep 17 00:00:00 2001 From: Yasufumi Kinoshita Date: Thu, 31 Jan 2013 12:42:43 +0900 Subject: [PATCH 042/273] Bug #16220051 : INNODB_BUG12400341 FAILS ON VALGRIND WITH TOO MANY ACTIVE CONCURRENT TRANSACTION innodb_bug12400341.test is disabled for valgrind daily test. It might be affected by the previous test's undo slots existing, because of slower execution. --- mysql-test/suite/innodb/t/innodb_bug12400341.test | 4 ++++ mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/mysql-test/suite/innodb/t/innodb_bug12400341.test b/mysql-test/suite/innodb/t/innodb_bug12400341.test index 2ab1be81f6d..ab69e20c495 100644 --- a/mysql-test/suite/innodb/t/innodb_bug12400341.test +++ b/mysql-test/suite/innodb/t/innodb_bug12400341.test @@ -7,6 +7,10 @@ if (`select count(*)=0 from information_schema.global_variables where variable_n --skip Test requires InnoDB built with UNIV_DEBUG definition. } +# Don't test under valgrind, undo slots of the previous test might exist still +# and cause unstable result. +--source include/not_valgrind.inc + call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too"); --disable_query_log diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test b/mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test index b9e40e0dff3..2ecf30edfa7 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test +++ b/mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test @@ -7,6 +7,10 @@ if (`select count(*)=0 from information_schema.global_variables where variable_n --skip Test requires InnoDB built with UNIV_DEBUG definition. } +# Don't test under valgrind, undo slots of the previous test might exist still +# and cause unstable result. +--source include/not_valgrind.inc + call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too"); --disable_query_log From 8500944765487e8fa3f9d635e63b190dc076950e Mon Sep 17 00:00:00 2001 From: Nisha Gopalakrishnan Date: Fri, 1 Feb 2013 09:49:27 +0530 Subject: [PATCH 043/273] BUG#16207679: MISSING ERROR WHEN RESIGNAL TO MYSQL_ERROR=5 Analysis: -------- As part of the fix for Bug#11757464, the 'out of memory' error condition was not pushed to the diagnostic area as it requires memory allocation. However in cases of SIGNAL/RESIGNAL 'out of memory' error, the server may not be out of memory. Hence it would be good to report the error in such cases. Fix: --- Push only non fatal 'out of memory' errors to the diagnostic area. Since SIGNAL/RESIGNAL of 'out of memory' error may not be fatal, the error is reported. --- sql/sql_class.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 556e7d66447..effdfc4d6d6 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1137,10 +1137,12 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno, query_cache_abort(&query_cache_tls); /* - Avoid pushing a condition for out of memory errors as this will require - memory allocation and therefore might fail. + Avoid pushing a condition for fatal out of memory errors as this will + require memory allocation and therefore might fail. Non fatal out of + memory errors can occur if raised by SIGNAL/RESIGNAL statement. */ - if (sql_errno != EE_OUTOFMEMORY && sql_errno != ER_OUTOFMEMORY) + if (!(is_fatal_error && (sql_errno == EE_OUTOFMEMORY || + sql_errno == ER_OUTOFMEMORY))) { cond= warning_info->push_warning(this, sql_errno, sqlstate, level, msg); } From 49e4ed1fde3be9a1c6063a4099e42df4947412ca Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Feb 2013 19:53:20 +0530 Subject: [PATCH 044/273] BUG #16190704 - MTR STILL LOSES THE FAILED RUN LOGS AT RETRY-FAIL --- mysql-test/mysql-test-run.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 0221bb61e8c..1cde5548999 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -697,9 +697,11 @@ sub run_test_server ($$$) { mtr_report("\nRetrying test $tname, ". "attempt($retries/$opt_retry)...\n"); #saving the log file as filename.failed in case of retry - my $worker_logdir= $result->{savedir}; - my $log_file_name=dirname($worker_logdir)."/".$result->{shortname}.".log"; - rename $log_file_name,$log_file_name.".failed"; + if ( $result->is_failed() ) { + my $worker_logdir= $result->{savedir}; + my $log_file_name=dirname($worker_logdir)."/".$result->{shortname}.".log"; + rename $log_file_name,$log_file_name.".failed"; + } delete($result->{result}); $result->{retries}= $retries+1; $result->write_test($sock, 'TESTCASE'); From 50c27a1492e149c2e5a2865ee71ae084230b0b9d Mon Sep 17 00:00:00 2001 From: Inaam Rana Date: Fri, 1 Feb 2013 09:47:16 -0500 Subject: [PATCH 045/273] Bug#16249505 INNODB REPORTS THAT IT'S GOING TO WAIT FOR I/O BUT THE I/O IS ASYNC rb://1934 approved by: Mikael Ronstrom (over email) When submitting AIO read request don't signal that the thread is about to wait on DISKIO --- storage/innobase/buf/buf0rea.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/innobase/buf/buf0rea.c b/storage/innobase/buf/buf0rea.c index 40550186191..d12fd3fce31 100644 --- a/storage/innobase/buf/buf0rea.c +++ b/storage/innobase/buf/buf0rea.c @@ -177,7 +177,10 @@ buf_read_page_low( ut_ad(buf_page_in_file(bpage)); - thd_wait_begin(NULL, THD_WAIT_DISKIO); + if (sync) { + thd_wait_begin(NULL, THD_WAIT_DISKIO); + } + if (zip_size) { *err = fil_io(OS_FILE_READ | wake_later, sync, space, zip_size, offset, 0, zip_size, @@ -189,7 +192,10 @@ buf_read_page_low( sync, space, 0, offset, 0, UNIV_PAGE_SIZE, ((buf_block_t*) bpage)->frame, bpage); } - thd_wait_end(NULL); + + if (sync) { + thd_wait_end(NULL); + } if (*err == DB_TABLESPACE_DELETED) { buf_read_page_handle_error(bpage); From e15a51363dec2c7b92fef406190e33dbb453bad3 Mon Sep 17 00:00:00 2001 From: Thayumanavar Date: Tue, 5 Feb 2013 11:06:38 +0530 Subject: [PATCH 046/273] BUG#16196591 - CLIENTS CANNOT CONNECT TO MYSQL PROBLEM: When large number of connections are continuously made with wait_timeout of 600 seconds for some hours, some connections remain after wait_timeout expired and also new connections get struck under the configuration and the scenario reported in bug#16196591. FIX: The cause of this bug is the issue identified and fixed in the BUG#16088658 in 5.6.Also LOCK_thread_count contention issue fixed in BUG#15921866 in 5.6 need to be in 5.5 as well. Since the issue is not reproducible, it has been verified at customer configuration the issue could not be reproduced after a 48-hour test with a non-debug build which includes the above two fixes backported. --- sql/mysqld.cc | 9 ++++++++- sql/mysqld.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index fb3832d438a..db283324761 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -640,6 +640,7 @@ SHOW_COMP_OPTION have_profiling; pthread_key(MEM_ROOT**,THR_MALLOC); pthread_key(THD*, THR_THD); +mysql_mutex_t LOCK_thread_created; mysql_mutex_t LOCK_thread_count; mysql_mutex_t LOCK_status, LOCK_error_log, LOCK_uuid_generator, @@ -1574,6 +1575,7 @@ static void clean_up_mutexes() { mysql_rwlock_destroy(&LOCK_grant); mysql_mutex_destroy(&LOCK_thread_count); + mysql_mutex_destroy(&LOCK_thread_created); mysql_mutex_destroy(&LOCK_status); mysql_mutex_destroy(&LOCK_delayed_insert); mysql_mutex_destroy(&LOCK_delayed_status); @@ -3542,6 +3544,7 @@ You should consider changing lower_case_table_names to 1 or 2", static int init_thread_environment() { + mysql_mutex_init(key_LOCK_thread_created, &LOCK_thread_created, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_thread_count, &LOCK_thread_count, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_delayed_insert, @@ -4950,7 +4953,9 @@ static bool read_init_file(char *file_name) */ void inc_thread_created(void) { + mysql_mutex_lock(&LOCK_thread_created); thread_created++; + mysql_mutex_unlock(&LOCK_thread_created); } #ifndef EMBEDDED_LIBRARY @@ -7815,6 +7820,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_LOCK_error_messages, key_LOG_INFO_lock, key_LOCK_thread_count, key_PARTITION_LOCK_auto_inc; PSI_mutex_key key_RELAYLOG_LOCK_index; +PSI_mutex_key key_LOCK_thread_created; static PSI_mutex_info all_server_mutexes[]= { @@ -7867,7 +7873,8 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_error_messages, "LOCK_error_messages", PSI_FLAG_GLOBAL}, { &key_LOG_INFO_lock, "LOG_INFO::lock", 0}, { &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL}, - { &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0} + { &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0}, + { &key_LOCK_thread_created, "LOCK_thread_created", PSI_FLAG_GLOBAL } }; PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger, diff --git a/sql/mysqld.h b/sql/mysqld.h index 632bcfe975f..2857094dba3 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -257,6 +257,7 @@ extern PSI_mutex_key key_RELAYLOG_LOCK_index; extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger, key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave, key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock; +extern PSI_mutex_key key_LOCK_thread_created; #ifdef HAVE_MMAP extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool; From 6823ac913e1a3afa43952f37124a59e4dce2ecb9 Mon Sep 17 00:00:00 2001 From: Ravinder Thakur Date: Wed, 6 Feb 2013 13:52:32 +0530 Subject: [PATCH 047/273] Bug#14711808 MSI INSTALLATION / UPGRADE CAN CORRUPT EXISTING INSTALLATION Currently MySQL MSI installer on Windows installs MySQL in "per user" mode. It means that if a Windows machine has multiple users, they each can install MySQL independently. However the default path of MySQL is "C:\Program Files (x86)\MySQL\" and when two users install MySQL on same machine, the installation by second user just overwrites the MySQL files. This default shared location leads to the issue where if the second user uninstalls MySQL, the installation files are removed for the first user as well. In this fix, we are now making the default installation "per machine". It means that when MySQL is installed with defaults options, all users can see the shortcuts for MySQL in start menu(since installations is for all users). Also when any user relaunches the installer, it will consider that action uninstallation rather than installation for that user. There are command line options in installer that can be used to undo the "per machine" installation but will not consider that scenario.MySQL is a server product and it does not make a lot of sense to install it differently for each user. --- packaging/WiX/mysql_server.wxs.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packaging/WiX/mysql_server.wxs.in b/packaging/WiX/mysql_server.wxs.in index 370830d82db..4c2a856782c 100644 --- a/packaging/WiX/mysql_server.wxs.in +++ b/packaging/WiX/mysql_server.wxs.in @@ -34,8 +34,9 @@ Languages='1033' Compressed='yes' SummaryCodepage='1252' - Platform='@Platform@'/> - + Platform='@Platform@' + InstallScope="perMachine"/> + From 6f83811d251406530fd0ff844c639d22fa3db126 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Feb 2013 13:49:56 -0600 Subject: [PATCH 048/273] Bug#16263506 - INNODB; USE ABORT() ON ALL PLATFORMS INSTEAD OF DEREFERENCING UT_DBG_NULL_PTR The abort() call is standard C but InnoDB only uses it in GCC environments. UT_DBG_USE_ABORT is not defined the code crashed by dereferencing a null pointer instead of calling abort(). Other code throughout MySQL including ndb, sql, mysys and other places call abort() directly. This bug also affects innodb.innodb_bug14147491.test which fails randomly on windows because of this issue. Approved by marko in http://rb.no.oracle.com/rb/r/1936/ --- storage/innobase/include/ut0dbg.h | 40 ------------------------------- storage/innobase/sync/sync0arr.c | 4 ---- storage/innobase/ut/ut0dbg.c | 32 ------------------------- 3 files changed, 76 deletions(-) diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index 07730176d81..4913b357768 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -55,47 +55,8 @@ ut_dbg_assertion_failed( ulint line) /*!< in: line number of the assertion */ UNIV_COLD __attribute__((nonnull(2))); -#if defined(__WIN__) || defined(__INTEL_COMPILER) -# undef UT_DBG_USE_ABORT -#elif defined(__GNUC__) && (__GNUC__ > 2) -# define UT_DBG_USE_ABORT -#endif - -#ifndef UT_DBG_USE_ABORT -/** A null pointer that will be dereferenced to trigger a memory trap */ -extern ulint* ut_dbg_null_ptr; -#endif - -#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT) -/** If this is set to TRUE by ut_dbg_assertion_failed(), all threads -will stop at the next ut_a() or ut_ad(). */ -extern ibool ut_dbg_stop_threads; - -/*************************************************************//** -Stop a thread after assertion failure. */ -UNIV_INTERN -void -ut_dbg_stop_thread( -/*===============*/ - const char* file, - ulint line); -#endif - -#ifdef UT_DBG_USE_ABORT /** Abort the execution. */ # define UT_DBG_PANIC abort() -/** Stop threads (null operation) */ -# define UT_DBG_STOP do {} while (0) -#else /* UT_DBG_USE_ABORT */ -/** Abort the execution. */ -# define UT_DBG_PANIC \ - if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL -/** Stop threads in ut_a(). */ -# define UT_DBG_STOP do \ - if (UNIV_UNLIKELY(ut_dbg_stop_threads)) { \ - ut_dbg_stop_thread(__FILE__, (ulint) __LINE__); \ - } while (0) -#endif /* UT_DBG_USE_ABORT */ /** Abort execution if EXPR does not evaluate to nonzero. @param EXPR assertion expression that should hold */ @@ -105,7 +66,6 @@ ut_dbg_stop_thread( __FILE__, (ulint) __LINE__); \ UT_DBG_PANIC; \ } \ - UT_DBG_STOP; \ } while (0) /** Abort execution. */ diff --git a/storage/innobase/sync/sync0arr.c b/storage/innobase/sync/sync0arr.c index b0c337dc9d7..b2778184335 100644 --- a/storage/innobase/sync/sync0arr.c +++ b/storage/innobase/sync/sync0arr.c @@ -604,10 +604,6 @@ sync_array_deadlock_step( new = sync_array_find_thread(arr, thread); if (UNIV_UNLIKELY(new == start)) { - /* Stop running of other threads */ - - ut_dbg_stop_threads = TRUE; - /* Deadlock */ fputs("########################################\n" "DEADLOCK of threads detected!\n", stderr); diff --git a/storage/innobase/ut/ut0dbg.c b/storage/innobase/ut/ut0dbg.c index 53ed4a53044..a440b72d32a 100644 --- a/storage/innobase/ut/ut0dbg.c +++ b/storage/innobase/ut/ut0dbg.c @@ -35,16 +35,6 @@ Created 1/30/1994 Heikki Tuuri UNIV_INTERN ulint ut_dbg_zero = 0; #endif -#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT) -/** If this is set to TRUE by ut_dbg_assertion_failed(), all threads -will stop at the next ut_a() or ut_ad(). */ -UNIV_INTERN ibool ut_dbg_stop_threads = FALSE; -#endif -#ifndef UT_DBG_USE_ABORT -/** A null pointer that will be dereferenced to trigger a memory trap */ -UNIV_INTERN ulint* ut_dbg_null_ptr = NULL; -#endif - /*************************************************************//** Report a failed assertion. */ UNIV_INTERN @@ -80,30 +70,8 @@ ut_dbg_assertion_failed( "InnoDB: corruption in the InnoDB tablespace. Please refer to\n" "InnoDB: " REFMAN "forcing-innodb-recovery.html\n" "InnoDB: about forcing recovery.\n", stderr); -#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT) - ut_dbg_stop_threads = TRUE; -#endif } -#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT) -/*************************************************************//** -Stop a thread after assertion failure. */ -UNIV_INTERN -void -ut_dbg_stop_thread( -/*===============*/ - const char* file, - ulint line) -{ -#ifndef UNIV_HOTBACKUP - fprintf(stderr, "InnoDB: Thread %lu stopped in file %s line %lu\n", - os_thread_pf(os_thread_get_curr_id()), - innobase_basename(file), line); - os_thread_sleep(1000000000); -#endif /* !UNIV_HOTBACKUP */ -} -#endif - #ifdef UNIV_COMPILE_TEST_FUNCS #include From 2df2e2617cc75ad532e59a294672f3aab071defe Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 4 Feb 2013 14:09:48 +0100 Subject: [PATCH 049/273] post-push test result update for bug#14521864. --- ...ition_change_from_range_to_hash_key.result | 24 ++--- .../engines/funcs/r/tc_partition_key.result | 96 +++++++++---------- .../funcs/r/tc_partition_linear_key.result | 96 +++++++++---------- .../r/tc_partition_reorg_hash_key.result | 96 +++++++++---------- 4 files changed, 156 insertions(+), 156 deletions(-) diff --git a/mysql-test/suite/engines/funcs/r/tc_partition_change_from_range_to_hash_key.result b/mysql-test/suite/engines/funcs/r/tc_partition_change_from_range_to_hash_key.result index bbaaeea8af7..07010138d40 100644 --- a/mysql-test/suite/engines/funcs/r/tc_partition_change_from_range_to_hash_key.result +++ b/mysql-test/suite/engines/funcs/r/tc_partition_change_from_range_to_hash_key.result @@ -412,7 +412,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -434,7 +434,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -475,7 +475,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -497,7 +497,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -538,7 +538,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -560,7 +560,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -601,7 +601,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -623,7 +623,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -664,7 +664,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -686,7 +686,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -727,7 +727,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -749,7 +749,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; diff --git a/mysql-test/suite/engines/funcs/r/tc_partition_key.result b/mysql-test/suite/engines/funcs/r/tc_partition_key.result index 309ddfe2bd9..0bd1df6d995 100644 --- a/mysql-test/suite/engines/funcs/r/tc_partition_key.result +++ b/mysql-test/suite/engines/funcs/r/tc_partition_key.result @@ -9,7 +9,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -24,7 +24,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -39,7 +39,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -54,7 +54,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -69,7 +69,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -84,7 +84,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -99,7 +99,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -114,7 +114,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -129,7 +129,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -144,7 +144,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -159,7 +159,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -174,7 +174,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -189,7 +189,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -204,7 +204,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -219,7 +219,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -234,7 +234,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -249,7 +249,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -264,7 +264,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -279,7 +279,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -294,7 +294,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -309,7 +309,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -324,7 +324,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -339,7 +339,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -354,7 +354,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -369,7 +369,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -384,7 +384,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -399,7 +399,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -414,7 +414,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -429,7 +429,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -444,7 +444,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -459,7 +459,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -474,7 +474,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -489,7 +489,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -504,7 +504,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -519,7 +519,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -534,7 +534,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -549,7 +549,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -564,7 +564,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -579,7 +579,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -594,7 +594,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -609,7 +609,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -624,7 +624,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -639,7 +639,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -654,7 +654,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -669,7 +669,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -684,7 +684,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -699,7 +699,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -714,7 +714,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; diff --git a/mysql-test/suite/engines/funcs/r/tc_partition_linear_key.result b/mysql-test/suite/engines/funcs/r/tc_partition_linear_key.result index ae543da271c..791787ac581 100644 --- a/mysql-test/suite/engines/funcs/r/tc_partition_linear_key.result +++ b/mysql-test/suite/engines/funcs/r/tc_partition_linear_key.result @@ -9,7 +9,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -24,7 +24,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -39,7 +39,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -54,7 +54,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -69,7 +69,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -84,7 +84,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -99,7 +99,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -114,7 +114,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -129,7 +129,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -144,7 +144,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -159,7 +159,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -174,7 +174,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -189,7 +189,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -204,7 +204,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -219,7 +219,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -234,7 +234,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -249,7 +249,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -264,7 +264,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -279,7 +279,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -294,7 +294,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -309,7 +309,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -324,7 +324,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -339,7 +339,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -354,7 +354,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -369,7 +369,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -384,7 +384,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -399,7 +399,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -414,7 +414,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -429,7 +429,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -444,7 +444,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -459,7 +459,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -474,7 +474,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -489,7 +489,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -504,7 +504,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -519,7 +519,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -534,7 +534,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -549,7 +549,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -564,7 +564,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -579,7 +579,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -594,7 +594,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -609,7 +609,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -624,7 +624,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -639,7 +639,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -654,7 +654,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -669,7 +669,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -684,7 +684,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -699,7 +699,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -714,7 +714,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; diff --git a/mysql-test/suite/engines/funcs/r/tc_partition_reorg_hash_key.result b/mysql-test/suite/engines/funcs/r/tc_partition_reorg_hash_key.result index 3556bcf1e4f..083bbdebabb 100644 --- a/mysql-test/suite/engines/funcs/r/tc_partition_reorg_hash_key.result +++ b/mysql-test/suite/engines/funcs/r/tc_partition_reorg_hash_key.result @@ -487,7 +487,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -509,7 +509,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -531,7 +531,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -539,7 +539,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -565,7 +565,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -587,7 +587,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -609,7 +609,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -617,7 +617,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -643,7 +643,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -665,7 +665,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -687,7 +687,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -695,7 +695,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -721,7 +721,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -743,7 +743,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -765,7 +765,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -773,7 +773,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -799,7 +799,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -821,7 +821,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -843,7 +843,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -851,7 +851,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -877,7 +877,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -899,7 +899,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -921,7 +921,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -929,7 +929,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (c1) +/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -955,7 +955,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -977,7 +977,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -999,7 +999,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1007,7 +1007,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1033,7 +1033,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1055,7 +1055,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1077,7 +1077,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1085,7 +1085,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1111,7 +1111,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1133,7 +1133,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1155,7 +1155,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1163,7 +1163,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1189,7 +1189,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1211,7 +1211,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1233,7 +1233,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1241,7 +1241,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1267,7 +1267,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1289,7 +1289,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1311,7 +1311,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1319,7 +1319,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1345,7 +1345,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1367,7 +1367,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1389,7 +1389,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1397,7 +1397,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY (c1) +/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; From ddb60a719b219980c5ac1103d687f475f734db26 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2013 20:25:30 +0530 Subject: [PATCH 050/273] Bug #16190704: MTR STILL LOSES THE FAILED RUN LOGS AT RETRY-FAIL --- mysql-test/mysql-test-run.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 2f545b05c3c..11280f70161 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -617,9 +617,11 @@ sub run_test_server ($$$) { mtr_report("\nRetrying test $tname, ". "attempt($retries/$opt_retry)...\n"); #saving the log file as filename.failed in case of retry - my $worker_logdir= $result->{savedir}; - my $log_file_name=dirname($worker_logdir)."/".$result->{shortname}.".log"; - rename $log_file_name,$log_file_name.".failed"; + if ( $result->is_failed() ) { + my $worker_logdir= $result->{savedir}; + my $log_file_name=dirname($worker_logdir)."/".$result->{shortname}.".log"; + rename $log_file_name,$log_file_name.".failed"; + } delete($result->{result}); $result->{retries}= $retries+1; $result->write_test($sock, 'TESTCASE'); From a2be7d26a8c69e6068f32b2152099edc0194839e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Feb 2013 11:58:21 +0530 Subject: [PATCH 051/273] BUG #13625278 - PB2 SHOULD PROVIDE MORE USEFUL INFORMATION FOR TIMEOUTS --- mysql-test/mysql-test-run.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 11280f70161..4b29fba9120 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3622,6 +3622,7 @@ sub run_testcase ($) { my $test= start_mysqltest($tinfo); # Set only when we have to keep waiting after expectedly died server my $keep_waiting_proc = 0; + my $print_timeout= start_timer($print_freq * 60); while (1) { @@ -3646,7 +3647,22 @@ sub run_testcase ($) { } if (! $keep_waiting_proc) { - $proc= My::SafeProcess->wait_any_timeout($test_timeout); + if($test_timeout > $print_timeout) + { + $proc= My::SafeProcess->wait_any_timeout($print_timeout); + if ( $proc->{timeout} ) + { + #print out that the test is still on + mtr_print("Test still running: $tinfo->{name}"); + #reset the timer + $print_timeout= start_timer($print_freq * 60); + next; + } + } + else + { + $proc= My::SafeProcess->wait_any_timeout($test_timeout); + } } # Will be restored if we need to keep waiting From 3d7f52255b0d09191ac975c843a5e8fd6add2217 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Feb 2013 13:02:14 +0530 Subject: [PATCH 052/273] BUG #13625278 - PB2 SHOULD PROVIDE MORE USEFUL INFORMATION FOR TIMEOUTS --- mysql-test/mysql-test-run.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 4b29fba9120..44d86bbae68 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3467,6 +3467,7 @@ my %old_env; sub run_testcase ($) { my $tinfo= shift; + my $print_freq=20; mtr_verbose("Running test:", $tinfo->{name}); From 06400b63e70963a9ebaab8222d678609a5cb2009 Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Thu, 7 Feb 2013 17:23:37 +0530 Subject: [PATCH 053/273] Bug#16247322- MTR NOT RUNNING SYS_VARS TEST SUITE FOR 5.1 SYS_VARS suite is not enabled in MTR by default run. Enabling it with this check-in. mysql-test/suite/sys_vars/t/disabled.def: Till the bugs are fixed, disabling the failed test scripts --- mysql-test/mysql-test-run.pl | 4 ++-- mysql-test/suite/sys_vars/t/disabled.def | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 44d86bbae68..fbfbd7e2198 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl # -*- cperl -*- -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -157,7 +157,7 @@ my $path_config_file; # The generated config file, var/my.cnf # executables will be used by the test suite. our $opt_vs_config = $ENV{'MTR_VS_CONFIG'}; -my $DEFAULT_SUITES= "main,binlog,federated,rpl,rpl_ndb,ndb,innodb,innodb_plugin"; +my $DEFAULT_SUITES= "main,sys_vars,binlog,federated,rpl,rpl_ndb,ndb,innodb,innodb_plugin"; my $opt_suites; our $opt_verbose= 0; # Verbose output, enable with --verbose diff --git a/mysql-test/suite/sys_vars/t/disabled.def b/mysql-test/suite/sys_vars/t/disabled.def index 866172fb51a..c0a343c92ef 100644 --- a/mysql-test/suite/sys_vars/t/disabled.def +++ b/mysql-test/suite/sys_vars/t/disabled.def @@ -9,5 +9,15 @@ # Do not use any TAB characters for whitespace. # ############################################################################## -sys_vars.max_binlog_cache_size_basic_64 : bug#11763668 2010-08-31 Horst -sys_vars.max_binlog_cache_size_basic_32 : bug#11763668 2010-08-31 Horst +sys_vars.max_allowed_packet_basic : bug#16295372 2013-02-09 veduggir +sys_vars.max_allowed_packet_func : bug#16295372 2013-02-09 veduggir +sys_vars.net_buffer_length_basic : bug#16295372 2013-02-09 veduggir +sys_vars.insert_id_basic : bug#16295418 2013-02-09 veduggir +sys_vars.key_cache_age_threshold_basic_64 : bug#16295418 2013-02-09 veduggir +sys_vars.key_cache_block_size_basic_64 : bug#16295418 2013-02-09 veduggir +sys_vars.key_cache_division_limit_basic_64 : bug#16295418 2013-02-09 veduggir +sys_vars.identity_basic : bug#16295418 2013-02-09 veduggir +sys_vars.key_buffer_size_basic_64 : bug#16295418 2013-02-09 veduggir +sys_vars.key_buffer_size_func : bug#16295418 2013-02-09 veduggir +sys_vars.timestamp_basic_64 : bug#16295457 2013-02-09 veduggir +sys_vars.rpl_init_slave_func : bug#16295518 2013-02-09 veduggir From e908e9bc7e341b8c6a1f154aacd0736f5026ec37 Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Thu, 7 Feb 2013 17:05:07 +0100 Subject: [PATCH 054/273] Bug#16192219 CRASH IN TEST_IF_SKIP_SORT_ORDER ON SELECT DISTINCT WITH ORDER BY This is a backport of the fix for: Bug#13633549 HANDLE_FATAL_SIGNAL IN TEST_IF_SKIP_SORT_ORDER/CREATE_SORT_INDEX Don't invoke the range optimizer for a NULL select. --- sql/sql_select.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 89567bd1f5e..12143c739f7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13753,7 +13753,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, if (best_key >= 0) { - if (table->quick_keys.is_set(best_key) && best_key != ref_key) + if (select && + table->quick_keys.is_set(best_key) && best_key != ref_key) { key_map map; map.clear_all(); // Force the creation of quick select From b7cfe73fa5f02dff4b92493e880161e27051dbdf Mon Sep 17 00:00:00 2001 From: Igor Solodovnikov Date: Thu, 7 Feb 2013 19:46:08 +0200 Subject: [PATCH 055/273] bug#14163155 COM_CHANGE_USER DOESN'T WORK WITH CHARACTER-SET-SERVER=UCS2 IN 5.1 SERVER Problem was caused by the COM_CHANGE_USER parsing code. That code ignored character set number passed in COM_CHANGE_USER packet. Instead character_set_client values was used. User name was not converted at all. Fixed by using passed character set number to convert both db and user names. If COM_CHANGE_USER does not contain character set number then character_set_client is used to convert both names. --- sql/sql_parse.cc | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6c376d2c0da..457be355f81 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1109,6 +1109,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, char *user= (char*) packet, *packet_end= packet + packet_length; /* Safe because there is always a trailing \0 at the end of the packet */ char *passwd= strend(user)+1; + uint user_length= passwd - user - 1; thd->change_user(); thd->clear_error(); // if errors from rollback @@ -1122,6 +1123,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, for *passwd > 127 and become 2**32-127 after casting to uint. */ char db_buff[NAME_LEN+1]; // buffer to store db in utf8 + char user_buff[USERNAME_LENGTH + 1]; // buffer to store user in utf8 char *db= passwd; char *save_db; /* @@ -1172,15 +1174,31 @@ bool dispatch_command(enum enum_server_command command, THD *thd, my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client", cs->csname); break; - } + } + + if (cs_number) + { + /* + We have checked charset earlier, + so thd_init_client_charset cannot fail. + */ + if (thd_init_client_charset(thd, cs_number)) + DBUG_ASSERT(0); + thd->update_charset(); + } } - /* Convert database name to utf8 */ + /* Convert database and user names to utf8 */ db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, system_charset_info, db, db_length, thd->charset(), &dummy_errors)]= 0; db= db_buff; + user_buff[copy_and_convert(user_buff,sizeof(user_buff)-1, + system_charset_info, user, user_length, + thd->charset(), &dummy_errors)]= 0; + user= user_buff; + /* Save user and privileges */ save_db_length= thd->db_length; save_db= thd->db; @@ -1215,17 +1233,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, #endif /* NO_EMBEDDED_ACCESS_CHECKS */ x_free(save_db); x_free(save_security_ctx.user); - - if (cs_number) - { - /* - We have checked charset earlier, - so thd_init_client_charset cannot fail. - */ - if (thd_init_client_charset(thd, cs_number)) - DBUG_ASSERT(0); - thd->update_charset(); - } } break; } From a6fb71e249f2b8e21f1c365e5acf531f6fd2577a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 8 Feb 2013 09:22:46 +0200 Subject: [PATCH 056/273] Bug#16292043 RACE CONDITION IN SRV_EXPORT_INNODB_STATUS() WHEN ACCESSING PURGE_SYS->VIEW srv_export_innodb_status(): Read the purge_sys fields while holding purge_sys->latch. Approved by Sunny Bains --- storage/innobase/srv/srv0srv.c | 39 ++++++++++++++++---------- storage/innodb_plugin/srv/srv0srv.c | 43 ++++++++++++++++++----------- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 3240b7515f8..e5619abbe45 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -1922,21 +1922,32 @@ srv_export_innodb_status(void) export_vars.innodb_rows_deleted = srv_n_rows_deleted; #ifdef UNIV_DEBUG - if (ut_dulint_cmp(trx_sys->max_trx_id, purge_sys->done_trx_no) < 0) { - export_vars.innodb_purge_trx_id_age = 0; - } else { - export_vars.innodb_purge_trx_id_age = - ut_dulint_minus(trx_sys->max_trx_id, purge_sys->done_trx_no); - } + { + dulint done_trx_no; + dulint up_limit_id; - if (!purge_sys->view - || ut_dulint_cmp(trx_sys->max_trx_id, - purge_sys->view->up_limit_id) < 0) { - export_vars.innodb_purge_view_trx_id_age = 0; - } else { - export_vars.innodb_purge_view_trx_id_age = - ut_dulint_minus(trx_sys->max_trx_id, - purge_sys->view->up_limit_id); + rw_lock_s_lock(&purge_sys->latch); + done_trx_no = purge_sys->done_trx_no; + up_limit_id = purge_sys->view + ? purge_sys->view->up_limit_id + : ut_dulint_zero; + rw_lock_s_unlock(&purge_sys->latch); + + if (ut_dulint_cmp(trx_sys->max_trx_id, done_trx_no) < 0) { + export_vars.innodb_purge_trx_id_age = 0; + } else { + export_vars.innodb_purge_trx_id_age = ut_dulint_minus( + trx_sys->max_trx_id, done_trx_no); + } + + if (ut_dulint_is_zero(up_limit_id) + || ut_dulint_cmp(trx_sys->max_trx_id, up_limit_id) < 0) { + export_vars.innodb_purge_view_trx_id_age = 0; + } else { + export_vars.innodb_purge_view_trx_id_age = + ut_dulint_minus(trx_sys->max_trx_id, + up_limit_id); + } } #endif /* UNIV_DEBUG */ diff --git a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c index 4ddd0a4603d..4e626003f4f 100644 --- a/storage/innodb_plugin/srv/srv0srv.c +++ b/storage/innodb_plugin/srv/srv0srv.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. @@ -257,7 +257,7 @@ UNIV_INTERN ulint srv_data_read = 0; /* Internal setting for "innodb_stats_method". Decides how InnoDB treats NULL value when collecting statistics. By default, it is set to SRV_STATS_NULLS_EQUAL(0), ie. all NULL value are treated equal */ -ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL; +UNIV_INTERN ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL; /* here we count the amount of data written in total (in bytes) */ UNIV_INTERN ulint srv_data_written = 0; @@ -1978,21 +1978,32 @@ srv_export_innodb_status(void) export_vars.innodb_rows_deleted = srv_n_rows_deleted; #ifdef UNIV_DEBUG - if (ut_dulint_cmp(trx_sys->max_trx_id, purge_sys->done_trx_no) < 0) { - export_vars.innodb_purge_trx_id_age = 0; - } else { - export_vars.innodb_purge_trx_id_age = - ut_dulint_minus(trx_sys->max_trx_id, purge_sys->done_trx_no); - } + { + dulint done_trx_no; + dulint up_limit_id; - if (!purge_sys->view - || ut_dulint_cmp(trx_sys->max_trx_id, - purge_sys->view->up_limit_id) < 0) { - export_vars.innodb_purge_view_trx_id_age = 0; - } else { - export_vars.innodb_purge_view_trx_id_age = - ut_dulint_minus(trx_sys->max_trx_id, - purge_sys->view->up_limit_id); + rw_lock_s_lock(&purge_sys->latch); + done_trx_no = purge_sys->done_trx_no; + up_limit_id = purge_sys->view + ? purge_sys->view->up_limit_id + : ut_dulint_zero; + rw_lock_s_unlock(&purge_sys->latch); + + if (ut_dulint_cmp(trx_sys->max_trx_id, done_trx_no) < 0) { + export_vars.innodb_purge_trx_id_age = 0; + } else { + export_vars.innodb_purge_trx_id_age = ut_dulint_minus( + trx_sys->max_trx_id, done_trx_no); + } + + if (ut_dulint_is_zero(up_limit_id) + || ut_dulint_cmp(trx_sys->max_trx_id, up_limit_id) < 0) { + export_vars.innodb_purge_view_trx_id_age = 0; + } else { + export_vars.innodb_purge_view_trx_id_age = + ut_dulint_minus(trx_sys->max_trx_id, + up_limit_id); + } } #endif /* UNIV_DEBUG */ From c65dabaf8e2378258698f0c8d83eb94ea777e588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 8 Feb 2013 09:23:12 +0200 Subject: [PATCH 057/273] Add missing linkage specifiers, so that ha_innodb_plugin.so will not export internal symbols. --- storage/innodb_plugin/handler/ha_innodb.cc | 1 + storage/innodb_plugin/trx/trx0sys.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index 229e7fe71e5..e0339b727ea 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -1067,6 +1067,7 @@ mysqld.cc. We do a dirty read because for one there is no synchronization object and secondly there is little harm in doing so even if we get a torn read. @return value of lower_case_table_names */ +static ulint innobase_get_lower_case_table_names(void) /*=====================================*/ diff --git a/storage/innodb_plugin/trx/trx0sys.c b/storage/innodb_plugin/trx/trx0sys.c index daa65bfcef0..6b44db14af7 100644 --- a/storage/innodb_plugin/trx/trx0sys.c +++ b/storage/innodb_plugin/trx/trx0sys.c @@ -129,7 +129,7 @@ static const ulint FILE_FORMAT_NAME_N #ifdef UNIV_DEBUG /* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ -uint trx_rseg_n_slots_debug = 0; +UNIV_INTERN uint trx_rseg_n_slots_debug = 0; #endif #ifndef UNIV_HOTBACKUP From 7557fc6c0fe36d2b73d7bbb6778d90368f1bf3c9 Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Fri, 8 Feb 2013 15:41:18 +0530 Subject: [PATCH 058/273] BUG#16247322-MTR NOT RUNNING SYS_VARS TEST SUITE FOR 5.1 Problem: Sys_vars suite is disabled in mysql-5.1 branch. Fix: To enable sys_vars suite in mysql-5.1, add it in mysql-test-run.pl file and also sys_vars suite should be added to Makefile.am inorder to get that test directory --- mysql-test/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 10b1ade81c2..d3e43996c9f 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -103,7 +103,8 @@ TEST_DIRS = t r include std_data std_data/parts collections \ suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \ suite/engines/funcs/r suite/engines/funcs/t suite/engines/iuds/r \ suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \ - suite/engines/rr_trx/t + suite/engines/rr_trx/t \ + suite/sys_vars # Used by dist-hook and install-data-local to copy all # test files into either dist or install directory From b0f78ea2780858ef8e4501b40611c20efb9e5f9f Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Fri, 8 Feb 2013 16:34:32 +0530 Subject: [PATCH 059/273] BUG#16247322-MTR NOT RUNNING SYS_VARS TEST SUITE FOR 5.1 Reverting back the previous changes as they are causing issues in PB2. --- mysql-test/Makefile.am | 3 +-- mysql-test/mysql-test-run.pl | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index d3e43996c9f..9cb9ca8a275 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -103,8 +103,7 @@ TEST_DIRS = t r include std_data std_data/parts collections \ suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \ suite/engines/funcs/r suite/engines/funcs/t suite/engines/iuds/r \ suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \ - suite/engines/rr_trx/t \ - suite/sys_vars + suite/engines/rr_trx/t # Used by dist-hook and install-data-local to copy all # test files into either dist or install directory diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index fbfbd7e2198..bcc43a97cdf 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -157,7 +157,7 @@ my $path_config_file; # The generated config file, var/my.cnf # executables will be used by the test suite. our $opt_vs_config = $ENV{'MTR_VS_CONFIG'}; -my $DEFAULT_SUITES= "main,sys_vars,binlog,federated,rpl,rpl_ndb,ndb,innodb,innodb_plugin"; +my $DEFAULT_SUITES= "main,binlog,federated,rpl,rpl_ndb,ndb,innodb,innodb_plugin"; my $opt_suites; our $opt_verbose= 0; # Verbose output, enable with --verbose From 8aecb30cdd1eea3517684dfc8d9d598b59396316 Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Tue, 12 Feb 2013 14:52:48 +0530 Subject: [PATCH 060/273] Bug #11753153 INNODB GENERATES SYMBOLS THAT ARE TOO LONG, INVALID DDL FROM SHOW CREATE Problem: The length of the internally generated foreign key name is not checked. Solution: The length of the internally generated foreign key name is checked. If it is greater than the allowed limit, an error message is reported. Also, the constraint name is printed in the same manner as the table name, using the system charset information. rb://1969 approved by Marko. --- storage/innobase/dict/dict0crea.c | 9 +++ storage/innobase/dict/dict0dict.c | 6 +- storage/innobase/handler/ha_innodb.cc | 63 +++++++++++++++++++ storage/innobase/include/db0err.h | 1 + storage/innobase/include/ha_prototypes.h | 22 +++++++ storage/innodb_plugin/dict/dict0crea.c | 9 +++ storage/innodb_plugin/dict/dict0dict.c | 5 +- storage/innodb_plugin/handler/ha_innodb.cc | 34 ++++++++++ storage/innodb_plugin/include/db0err.h | 1 + storage/innodb_plugin/include/ha_prototypes.h | 11 ++++ 10 files changed, 159 insertions(+), 2 deletions(-) diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c index 4116230347d..5e0fac8b411 100644 --- a/storage/innobase/dict/dict0crea.c +++ b/storage/innobase/dict/dict0crea.c @@ -25,6 +25,7 @@ Created 1/8/1996 Heikki Tuuri #include "trx0roll.h" #include "usr0sess.h" #include "ut0vec.h" +#include "ha_prototypes.h" /********************************************************************* Based on a table object, this function builds the entry to be inserted @@ -1350,12 +1351,20 @@ dict_create_add_foreign_to_dictionary( pars_info_t* info = pars_info_create(); if (foreign->id == NULL) { + char* stripped_name; /* Generate a new constraint id */ ulint namelen = strlen(table->name); char* id = mem_heap_alloc(foreign->heap, namelen + 20); /* no overflow if number < 1e13 */ sprintf(id, "%s_ibfk_%lu", table->name, (ulong) (*id_nr)++); foreign->id = id; + + stripped_name = strchr(foreign->id, '/') + 1; + if (innobase_check_identifier_length(stripped_name)) { + fprintf(stderr, "InnoDB: Generated foreign key " + "name (%s) is too long\n", foreign->id); + return(DB_IDENTIFIER_TOO_LONG); + } } pars_info_add_str_literal(info, "id", foreign->id); diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 7139eb5db95..a38b7224551 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -31,6 +31,7 @@ Created 1/8/1996 Heikki Tuuri #ifndef UNIV_HOTBACKUP # include "m_ctype.h" /* my_isspace() */ #endif /* !UNIV_HOTBACKUP */ +#include "ha_prototypes.h" #include @@ -4107,6 +4108,7 @@ dict_print_info_on_foreign_key_in_create_format( dict_foreign_t* foreign, /* in: foreign key constraint */ ibool add_newline) /* in: whether to add a newline */ { + char constraint_name[MAX_TABLE_NAME_LEN]; const char* stripped_id; ulint i; @@ -4128,7 +4130,9 @@ dict_print_info_on_foreign_key_in_create_format( } fputs(" CONSTRAINT ", file); - ut_print_name(file, trx, FALSE, stripped_id); + innobase_convert_to_system_charset(constraint_name, stripped_id, + MAX_TABLE_NAME_LEN); + ut_print_name(file, trx, FALSE, constraint_name); fputs(" FOREIGN KEY (", file); for (i = 0;;) { diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 194a7eea795..0f373476efb 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -791,6 +791,11 @@ convert_error_code_to_mysql( } else if (error == DB_UNSUPPORTED) { return(HA_ERR_UNSUPPORTED); + + } else if (error == DB_IDENTIFIER_TOO_LONG) { + + return(HA_ERR_INTERNAL_ERROR); + } else if (error == DB_INTERRUPTED) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); @@ -894,6 +899,37 @@ innobase_convert_from_table_id( &my_charset_filename, to, (uint) len, &errors); } +/********************************************************************** +Check if the length of the identifier exceeds the maximum allowed. +The input to this function is an identifier in charset my_charset_filename. +return true when length of identifier is too long. */ +extern "C" +my_bool +innobase_check_identifier_length( +/*=============================*/ + const char* id) /* in: identifier to check. it must belong + to charset my_charset_filename */ +{ + char tmp[MAX_TABLE_NAME_LEN + 10]; + uint errors; + uint len; + int well_formed_error = 0; + CHARSET_INFO *cs1 = &my_charset_filename; + CHARSET_INFO *cs2 = thd_charset(current_thd); + + len = strconvert(cs1, id, cs2, tmp, MAX_TABLE_NAME_LEN + 10, &errors); + + uint res = cs2->cset->well_formed_len(cs2, tmp, tmp + len, + NAME_CHAR_LEN, + &well_formed_error); + + if (well_formed_error || res != len) { + my_error(ER_TOO_LONG_IDENT, MYF(0), tmp); + return(true); + } + return(false); +} + /********************************************************************** Converts an identifier to UTF-8. @@ -913,6 +949,33 @@ innobase_convert_from_id( system_charset_info, to, (uint) len, &errors); } +/********************************************************************** +Converts an identifier from my_charset_filename to UTF-8 charset. */ +extern "C" +uint +innobase_convert_to_system_charset( +/*===============================*/ + char* to, /* out: converted identifier */ + const char* from, /* in: identifier to convert */ + ulint len) /* in: length of 'to', in bytes */ +{ + uint errors; + uint rlen; + CHARSET_INFO* cs1 = &my_charset_filename; + CHARSET_INFO* cs2 = system_charset_info; + + rlen = strconvert(cs1, from, cs2, to, len, &errors); + + if (errors) { + fprintf(stderr, " InnoDB: There was a problem in converting" + "'%s' in charset %s to charset %s", from, cs1->name, + cs2->name); + } + + return(rlen); +} + + /********************************************************************** Compares NUL-terminated UTF-8 strings case insensitively. diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index 1514b19639c..73bb1876b3a 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -84,6 +84,7 @@ Created 5/24/1996 Heikki Tuuri foreign keys as its prefix columns */ #define DB_TABLE_IN_FK_CHECK 53 /* table is being used in foreign key check */ +#define DB_IDENTIFIER_TOO_LONG 54 /* Identifier name too long */ /* The following are partial failure codes */ #define DB_FAIL 1000 diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index ce790814818..0ad3c82fffd 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -75,5 +75,27 @@ thd_is_select( /* out: true if thd is executing SELECT */ const void* thd); /* in: thread handle (THD*) */ +/********************************************************************** +Check if the length of the identifier exceeds the maximum allowed. +The input to this function is an identifier in charset my_charset_filename. +return true when length of identifier is too long. */ + +my_bool +innobase_check_identifier_length( +/*=============================*/ + const char* id); /* in: identifier to check. it must belong + to charset my_charset_filename */ + +/********************************************************************** +Converts an identifier from my_charset_filename to UTF-8 charset. */ + +uint +innobase_convert_to_system_charset( +/*===============================*/ + char* to, /* out: converted identifier */ + const char* from, /* in: identifier to convert */ + ulint len); /* in: length of 'to', in bytes */ + + #endif #endif diff --git a/storage/innodb_plugin/dict/dict0crea.c b/storage/innodb_plugin/dict/dict0crea.c index a57b2eca9e2..957a7f822b9 100644 --- a/storage/innodb_plugin/dict/dict0crea.c +++ b/storage/innodb_plugin/dict/dict0crea.c @@ -42,6 +42,7 @@ Created 1/8/1996 Heikki Tuuri #include "trx0roll.h" #include "usr0sess.h" #include "ut0vec.h" +#include "ha_prototypes.h" /*****************************************************************//** Based on a table object, this function builds the entry to be inserted @@ -1429,12 +1430,20 @@ dict_create_add_foreign_to_dictionary( pars_info_t* info = pars_info_create(); if (foreign->id == NULL) { + char* stripped_name; /* Generate a new constraint id */ ulint namelen = strlen(table->name); char* id = mem_heap_alloc(foreign->heap, namelen + 20); /* no overflow if number < 1e13 */ sprintf(id, "%s_ibfk_%lu", table->name, (ulong) (*id_nr)++); foreign->id = id; + + stripped_name = strchr(foreign->id, '/') + 1; + if (innobase_check_identifier_length(stripped_name)) { + fprintf(stderr, "InnoDB: Generated foreign key " + "name (%s) is too long\n", foreign->id); + return(DB_IDENTIFIER_TOO_LONG); + } } pars_info_add_str_literal(info, "id", foreign->id); diff --git a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c index 9cd0f51d72b..4219f83df4a 100644 --- a/storage/innodb_plugin/dict/dict0dict.c +++ b/storage/innodb_plugin/dict/dict0dict.c @@ -4602,6 +4602,7 @@ dict_print_info_on_foreign_key_in_create_format( dict_foreign_t* foreign, /*!< in: foreign key constraint */ ibool add_newline) /*!< in: whether to add a newline */ { + char constraint_name[MAX_TABLE_NAME_LEN]; const char* stripped_id; ulint i; @@ -4623,7 +4624,9 @@ dict_print_info_on_foreign_key_in_create_format( } fputs(" CONSTRAINT ", file); - ut_print_name(file, trx, FALSE, stripped_id); + innobase_convert_from_id(&my_charset_filename, constraint_name, + stripped_id, MAX_TABLE_NAME_LEN); + ut_print_name(file, trx, FALSE, constraint_name); fputs(" FOREIGN KEY (", file); for (i = 0;;) { diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index e0339b727ea..d24aca5325a 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -931,6 +931,9 @@ convert_error_code_to_mysql( return(HA_ERR_UNSUPPORTED); case DB_OUT_OF_MEMORY: return(HA_ERR_OUT_OF_MEM); + case DB_IDENTIFIER_TOO_LONG: + my_error(ER_TOO_LONG_IDENT, MYF(0)); + return(HA_ERR_INTERNAL_ERROR); } } @@ -1009,6 +1012,37 @@ innobase_convert_from_table_id( strconvert(cs, from, &my_charset_filename, to, (uint) len, &errors); } +/********************************************************************** +Check if the length of the identifier exceeds the maximum allowed. +The input to this function is an identifier in charset my_charset_filename. +return true when length of identifier is too long. */ +extern "C" UNIV_INTERN +my_bool +innobase_check_identifier_length( +/*=============================*/ + const char* id) /* in: identifier to check. it must belong + to charset my_charset_filename */ +{ + char tmp[MAX_TABLE_NAME_LEN + 10]; + uint errors; + uint len; + int well_formed_error = 0; + CHARSET_INFO* cs1 = &my_charset_filename; + CHARSET_INFO* cs2 = thd_charset(current_thd); + + len = strconvert(cs1, id, cs2, tmp, MAX_TABLE_NAME_LEN + 10, &errors); + + uint res = cs2->cset->well_formed_len(cs2, tmp, tmp + len, + NAME_CHAR_LEN, + &well_formed_error); + + if (well_formed_error || res != len) { + my_error(ER_TOO_LONG_IDENT, MYF(0), tmp); + return(true); + } + return(false); +} + /******************************************************************//** Converts an identifier to UTF-8. */ extern "C" UNIV_INTERN diff --git a/storage/innodb_plugin/include/db0err.h b/storage/innodb_plugin/include/db0err.h index e4a3844cd22..a195c1a1359 100644 --- a/storage/innodb_plugin/include/db0err.h +++ b/storage/innodb_plugin/include/db0err.h @@ -99,6 +99,7 @@ enum db_err { maximum allowed depth */ DB_TABLE_IN_FK_CHECK, /* table is being used in foreign key check */ + DB_IDENTIFIER_TOO_LONG, /* Identifier name too long */ /* The following are partial failure codes */ DB_FAIL = 1000, diff --git a/storage/innodb_plugin/include/ha_prototypes.h b/storage/innodb_plugin/include/ha_prototypes.h index e897a233a6a..cc3e5f64634 100644 --- a/storage/innodb_plugin/include/ha_prototypes.h +++ b/storage/innodb_plugin/include/ha_prototypes.h @@ -268,4 +268,15 @@ thd_lock_wait_timeout( void* thd); /*!< in: thread handle (THD*), or NULL to query the global innodb_lock_wait_timeout */ +/********************************************************************** +Check if the length of the identifier exceeds the maximum allowed. +The input to this function is an identifier in charset my_charset_filename. +return true when length of identifier is too long. */ +UNIV_INTERN +my_bool +innobase_check_identifier_length( +/*=============================*/ + const char* id); /* in: identifier to check. it must belong + to charset my_charset_filename */ + #endif From 5d47242dde0e9d1d019d3a644373e0114a24f882 Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Thu, 14 Feb 2013 16:33:31 +0530 Subject: [PATCH 061/273] For the error code ER_TOO_LONG_IDENT, the identifier is expected in the my_error call. So removing this line from here. --- storage/innodb_plugin/handler/ha_innodb.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index d24aca5325a..5424c4af68c 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -932,7 +932,6 @@ convert_error_code_to_mysql( case DB_OUT_OF_MEMORY: return(HA_ERR_OUT_OF_MEM); case DB_IDENTIFIER_TOO_LONG: - my_error(ER_TOO_LONG_IDENT, MYF(0)); return(HA_ERR_INTERNAL_ERROR); } } From e96182824dd85a1a77fcf58d293d17451d003135 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Thu, 14 Feb 2013 17:03:49 +0100 Subject: [PATCH 062/273] Bug#16274455: CAN NOT ACESS PARTITIONED TABLES WHEN DOWNGRADED FROM 5.6.11 TO 5.6.10 Problem was new syntax not accepted by previous version. Fixed by adding version comment of /*!50531 around the new syntax. Like this in the .frm file: 'PARTITION BY KEY /*!50611 ALGORITHM = 2 */ () PARTITIONS 3' and also changing the output from SHOW CREATE TABLE to: CREATE TABLE t1 (a INT) /*!50100 PARTITION BY KEY */ /*!50611 ALGORITHM = 1 */ /*!50100 () PARTITIONS 3 */ It will always add the ALGORITHM into the .frm for KEY [sub]partitioned tables, but for SHOW CREATE TABLE it will only add it in case it is the non default ALGORITHM = 1. Also notice that for 5.5, it will say /*!50531 instead of /*!50611, which will make upgrade from 5.5 > 5.5.31 to 5.6 < 5.6.11 fail! If one downgrades an fixed version to the same major version (5.5 or 5.6) the bug 14521864 will be visible again, but unless the .frm is updated, it will work again when upgrading again. Also fixed so that the .frm does not get updated version if a single partition check passes. --- mysql-test/r/partition.result | 42 +++--- mysql-test/r/partition_column.result | 2 +- mysql-test/r/partition_innodb.result | 6 +- mysql-test/r/partition_mgm_err.result | 2 +- mysql-test/r/partition_myisam.result | 2 +- ...ition_change_from_range_to_hash_key.result | 24 +-- .../engines/funcs/r/tc_partition_key.result | 96 ++++++------ .../funcs/r/tc_partition_linear_key.result | 96 ++++++------ .../r/tc_partition_reorg_hash_key.result | 96 ++++++------ .../r/partition_alter1_1_2_innodb.result | 42 +++--- .../r/partition_alter1_1_2_myisam.result | 12 +- .../parts/r/partition_alter1_1_innodb.result | 24 +-- .../parts/r/partition_alter1_1_myisam.result | 12 +- .../parts/r/partition_alter1_2_innodb.result | 60 ++++---- .../parts/r/partition_alter1_2_myisam.result | 24 +-- .../r/partition_alter2_1_1_innodb.result | 30 ++-- .../r/partition_alter2_1_2_innodb.result | 30 ++-- .../parts/r/partition_alter2_1_myisam.result | 36 ++--- .../r/partition_alter2_2_1_innodb.result | 30 ++-- .../r/partition_alter2_2_2_innodb.result | 30 ++-- .../parts/r/partition_alter2_2_myisam.result | 36 ++--- .../parts/r/partition_alter3_innodb.result | 22 +-- .../parts/r/partition_alter3_myisam.result | 22 +-- .../parts/r/partition_alter4_innodb.result | 138 +++++++++--------- .../parts/r/partition_alter4_myisam.result | 138 +++++++++--------- .../parts/r/partition_basic_innodb.result | 48 +++--- .../parts/r/partition_basic_myisam.result | 24 +-- .../r/partition_basic_symlink_myisam.result | 26 ++-- .../suite/parts/r/partition_bit_innodb.result | 18 +-- .../suite/parts/r/partition_bit_myisam.result | 18 +-- .../parts/r/partition_char_innodb.result | 24 +-- .../parts/r/partition_char_myisam.result | 24 +-- .../parts/r/partition_datetime_innodb.result | 32 ++-- .../parts/r/partition_datetime_myisam.result | 32 ++-- .../parts/r/partition_decimal_innodb.result | 8 +- .../parts/r/partition_decimal_myisam.result | 8 +- .../parts/r/partition_float_innodb.result | 8 +- .../parts/r/partition_float_myisam.result | 8 +- .../suite/parts/r/partition_int_innodb.result | 30 ++-- .../suite/parts/r/partition_int_myisam.result | 30 ++-- .../parts/r/partition_mgm_lc0_archive.result | 8 +- .../parts/r/partition_mgm_lc0_innodb.result | 8 +- .../parts/r/partition_mgm_lc0_memory.result | 8 +- .../parts/r/partition_mgm_lc0_myisam.result | 8 +- .../parts/r/partition_mgm_lc1_archive.result | 8 +- .../parts/r/partition_mgm_lc1_innodb.result | 8 +- .../parts/r/partition_mgm_lc1_memory.result | 8 +- .../parts/r/partition_mgm_lc1_myisam.result | 8 +- .../parts/r/partition_mgm_lc2_archive.result | 8 +- .../parts/r/partition_mgm_lc2_innodb.result | 8 +- .../parts/r/partition_mgm_lc2_memory.result | 8 +- .../parts/r/partition_mgm_lc2_myisam.result | 8 +- .../parts/r/partition_special_innodb.result | 8 +- .../parts/r/partition_special_myisam.result | 8 +- .../rpl/r/rpl_extra_col_slave_innodb.result | 4 +- .../rpl/r/rpl_extra_col_slave_myisam.result | 4 +- .../rpl/r/rpl_row_basic_8partition.result | 12 +- sql/ha_partition.cc | 3 +- sql/handler.cc | 3 + sql/partition_info.cc | 18 ++- sql/sql_partition.cc | 85 +++++++---- sql/sql_partition.h | 5 +- sql/sql_show.cc | 34 +++-- sql/sql_table.cc | 11 +- 64 files changed, 868 insertions(+), 813 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index dbc212a0222..af90387c6b6 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -81,7 +81,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL, `b` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 2 */ SELECT * FROM t1; a b @@ -175,7 +175,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`ID`,`aaaa,aaaaa`,`ddddddddd`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (ID) -SUBPARTITION BY LINEAR KEY ALGORITHM = 2 (ID,`aaaa,aaaaa`) +SUBPARTITION BY LINEAR KEY (ID,`aaaa,aaaaa`) SUBPARTITIONS 2 (PARTITION p01 VALUES LESS THAN (100) ENGINE = MyISAM, PARTITION p11 VALUES LESS THAN (200) ENGINE = MyISAM, @@ -722,7 +722,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) (PARTITION p0 VALUES LESS THAN (1) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (2) ENGINE = MyISAM) */ alter table t1 reorganize partition p1 into (partition p1 values less than (3)); @@ -732,7 +732,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) (PARTITION p0 VALUES LESS THAN (1) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (3) ENGINE = MyISAM) */ drop table t1; @@ -753,7 +753,7 @@ t1 CREATE TABLE `t1` ( `c` int(11) NOT NULL, PRIMARY KEY (`a`,`b`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) */ +/*!50100 PARTITION BY KEY (a) */ drop table t1; CREATE TABLE t1 ( a int not null, @@ -1074,7 +1074,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MyISAM, PARTITION p1 ENGINE = MyISAM) */ alter table t1; @@ -1083,7 +1083,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MyISAM, PARTITION p1 ENGINE = MyISAM) */ alter table t1 engine=myisam; @@ -1092,7 +1092,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MyISAM, PARTITION p1 ENGINE = MyISAM) */ alter table t1 engine=heap; @@ -1101,7 +1101,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MEMORY, PARTITION p1 ENGINE = MEMORY) */ alter table t1 remove partitioning; @@ -1121,7 +1121,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MyISAM, PARTITION p1 ENGINE = MyISAM) */ alter table t1 add column b int remove partitioning; @@ -1141,7 +1141,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MyISAM, PARTITION p1 ENGINE = MyISAM) */ alter table t1 @@ -1154,7 +1154,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MEMORY, PARTITION p1 ENGINE = MEMORY) */ alter table t1 engine=myisam, add column c int remove partitioning; @@ -1176,7 +1176,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) DEFAULT NULL, `c` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MEMORY, PARTITION p1 ENGINE = MEMORY) */ alter table t1 @@ -1189,7 +1189,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) DEFAULT NULL, `c` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MEMORY, PARTITION p1 ENGINE = MEMORY) */ alter table t1 @@ -1203,7 +1203,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) DEFAULT NULL, `c` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MEMORY, PARTITION p1 ENGINE = MEMORY) */ alter table t1 @@ -1373,14 +1373,14 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) */ +/*!50100 PARTITION BY KEY (a) */ alter table t1 add partition (partition p1); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MyISAM, PARTITION p1 ENGINE = MyISAM) */ drop table t1; @@ -1480,7 +1480,7 @@ t2 CREATE TABLE `t2` ( `c` char(10) DEFAULT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='no comment' -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) */ +/*!50100 PARTITION BY KEY (a) */ drop table t2; create table t1 (f1 int) partition by hash (f1) as select 1; drop table t1; @@ -1715,7 +1715,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION p0) */ set session sql_mode=''; drop table t1; @@ -1731,7 +1731,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(1) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) */ +/*!50100 PARTITION BY KEY (a) */ drop table t1; CREATE TABLE t1 (a int) ENGINE = MYISAM PARTITION BY KEY(a); INSERT into t1 values (1), (2); @@ -1804,7 +1804,7 @@ t1 CREATE TABLE `t1` ( `a` bigint(20) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 10 */ insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result index d7cd0beb35f..a494656a6a6 100644 --- a/mysql-test/r/partition_column.result +++ b/mysql-test/r/partition_column.result @@ -454,7 +454,7 @@ t1 CREATE TABLE `t1` ( `d` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50500 PARTITION BY RANGE COLUMNS(a,b,c) -SUBPARTITION BY KEY ALGORITHM = 2 (c,d) +SUBPARTITION BY KEY (c,d) SUBPARTITIONS 3 (PARTITION p0 VALUES LESS THAN (1,'abc','abc') ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (2,'abc','abc') ENGINE = MyISAM, diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index aca7060bba4..516d824b343 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -425,7 +425,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) */ +/*!50100 PARTITION BY KEY (a) */ drop table t1; create table t1 (a int) engine = innodb @@ -518,7 +518,7 @@ t1 CREATE TABLE `t1` ( `char_column` char(5) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (int_column) -SUBPARTITION BY KEY ALGORITHM = 2 (char_column) +SUBPARTITION BY KEY (char_column) SUBPARTITIONS 2 (PARTITION p1 VALUES LESS THAN (5) ENGINE = MyISAM) */ drop table t1; @@ -565,7 +565,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 2 */ SELECT * FROM t1; a b diff --git a/mysql-test/r/partition_mgm_err.result b/mysql-test/r/partition_mgm_err.result index 50f8f39cc71..a13278d724e 100644 --- a/mysql-test/r/partition_mgm_err.result +++ b/mysql-test/r/partition_mgm_err.result @@ -145,7 +145,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 2 */ DROP TABLE t1; CREATE TABLE t1 (a INT) PARTITION BY HASH(a); diff --git a/mysql-test/r/partition_myisam.result b/mysql-test/r/partition_myisam.result index 6b85bac3908..97bcc11495c 100644 --- a/mysql-test/r/partition_myisam.result +++ b/mysql-test/r/partition_myisam.result @@ -150,7 +150,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`a`) ) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) */ +/*!50100 PARTITION BY KEY (a) */ INSERT INTO t1 VALUES (NULL); SELECT * FROM t1; a diff --git a/mysql-test/suite/engines/funcs/r/tc_partition_change_from_range_to_hash_key.result b/mysql-test/suite/engines/funcs/r/tc_partition_change_from_range_to_hash_key.result index 07010138d40..bbaaeea8af7 100644 --- a/mysql-test/suite/engines/funcs/r/tc_partition_change_from_range_to_hash_key.result +++ b/mysql-test/suite/engines/funcs/r/tc_partition_change_from_range_to_hash_key.result @@ -412,7 +412,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -434,7 +434,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -475,7 +475,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -497,7 +497,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -538,7 +538,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -560,7 +560,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -601,7 +601,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -623,7 +623,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -664,7 +664,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -686,7 +686,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; @@ -727,7 +727,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ ALTER TABLE t1 COALESCE PARTITION 2; SELECT * FROM t1 ORDER BY c1; @@ -749,7 +749,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 3 */ DROP TABLE t1; SHOW TABLES; diff --git a/mysql-test/suite/engines/funcs/r/tc_partition_key.result b/mysql-test/suite/engines/funcs/r/tc_partition_key.result index 0bd1df6d995..309ddfe2bd9 100644 --- a/mysql-test/suite/engines/funcs/r/tc_partition_key.result +++ b/mysql-test/suite/engines/funcs/r/tc_partition_key.result @@ -9,7 +9,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -24,7 +24,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -39,7 +39,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -54,7 +54,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -69,7 +69,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -84,7 +84,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -99,7 +99,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -114,7 +114,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -129,7 +129,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -144,7 +144,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -159,7 +159,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -174,7 +174,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -189,7 +189,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -204,7 +204,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -219,7 +219,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -234,7 +234,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -249,7 +249,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -264,7 +264,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -279,7 +279,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -294,7 +294,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -309,7 +309,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -324,7 +324,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -339,7 +339,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -354,7 +354,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -369,7 +369,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -384,7 +384,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -399,7 +399,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -414,7 +414,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -429,7 +429,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -444,7 +444,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -459,7 +459,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -474,7 +474,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -489,7 +489,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -504,7 +504,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -519,7 +519,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -534,7 +534,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -549,7 +549,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -564,7 +564,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -579,7 +579,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -594,7 +594,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -609,7 +609,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -624,7 +624,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -639,7 +639,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -654,7 +654,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -669,7 +669,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -684,7 +684,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -699,7 +699,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -714,7 +714,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; diff --git a/mysql-test/suite/engines/funcs/r/tc_partition_linear_key.result b/mysql-test/suite/engines/funcs/r/tc_partition_linear_key.result index 791787ac581..ae543da271c 100644 --- a/mysql-test/suite/engines/funcs/r/tc_partition_linear_key.result +++ b/mysql-test/suite/engines/funcs/r/tc_partition_linear_key.result @@ -9,7 +9,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -24,7 +24,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -39,7 +39,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -54,7 +54,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -69,7 +69,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -84,7 +84,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -99,7 +99,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -114,7 +114,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -129,7 +129,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -144,7 +144,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -159,7 +159,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -174,7 +174,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -189,7 +189,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -204,7 +204,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -219,7 +219,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -234,7 +234,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -249,7 +249,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -264,7 +264,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -279,7 +279,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -294,7 +294,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -309,7 +309,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -324,7 +324,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -339,7 +339,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -354,7 +354,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 4 */ DROP TABLE t1; SHOW TABLES; @@ -369,7 +369,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -384,7 +384,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -399,7 +399,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -414,7 +414,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -429,7 +429,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -444,7 +444,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -459,7 +459,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -474,7 +474,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -489,7 +489,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -504,7 +504,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -519,7 +519,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -534,7 +534,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 5 */ DROP TABLE t1; SHOW TABLES; @@ -549,7 +549,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -564,7 +564,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -579,7 +579,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -594,7 +594,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -609,7 +609,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -624,7 +624,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) DEFAULT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -639,7 +639,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -654,7 +654,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -669,7 +669,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -684,7 +684,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -699,7 +699,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; @@ -714,7 +714,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 99 */ DROP TABLE t1; SHOW TABLES; diff --git a/mysql-test/suite/engines/funcs/r/tc_partition_reorg_hash_key.result b/mysql-test/suite/engines/funcs/r/tc_partition_reorg_hash_key.result index 083bbdebabb..3556bcf1e4f 100644 --- a/mysql-test/suite/engines/funcs/r/tc_partition_reorg_hash_key.result +++ b/mysql-test/suite/engines/funcs/r/tc_partition_reorg_hash_key.result @@ -487,7 +487,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -509,7 +509,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -531,7 +531,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -539,7 +539,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -565,7 +565,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -587,7 +587,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -609,7 +609,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -617,7 +617,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -643,7 +643,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -665,7 +665,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -687,7 +687,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -695,7 +695,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -721,7 +721,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -743,7 +743,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -765,7 +765,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -773,7 +773,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -799,7 +799,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -821,7 +821,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -843,7 +843,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -851,7 +851,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -877,7 +877,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -899,7 +899,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -921,7 +921,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -929,7 +929,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -955,7 +955,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -977,7 +977,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -999,7 +999,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1007,7 +1007,7 @@ t1 CREATE TABLE `t1` ( `c1` tinyint(4) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1033,7 +1033,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1055,7 +1055,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1077,7 +1077,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1085,7 +1085,7 @@ t1 CREATE TABLE `t1` ( `c1` smallint(6) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1111,7 +1111,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1133,7 +1133,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1155,7 +1155,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1163,7 +1163,7 @@ t1 CREATE TABLE `t1` ( `c1` mediumint(9) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1189,7 +1189,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1211,7 +1211,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1233,7 +1233,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1241,7 +1241,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1267,7 +1267,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1289,7 +1289,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1311,7 +1311,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1319,7 +1319,7 @@ t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; @@ -1345,7 +1345,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 10 */ ALTER TABLE t1 ADD PARTITION PARTITIONS 10; SELECT * FROM t1 ORDER BY c1; @@ -1367,7 +1367,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 20 */ ALTER TABLE t1 COALESCE PARTITION 18; SELECT * FROM t1 ORDER BY c1; @@ -1389,7 +1389,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ SHOW CREATE TABLE t1; Table Create Table @@ -1397,7 +1397,7 @@ t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` char(5) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LINEAR KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY LINEAR KEY (c1) PARTITIONS 2 */ DROP TABLE t1; SHOW TABLES; diff --git a/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result b/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result index 94194cd6ce6..3ef62f2b050 100644 --- a/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result @@ -567,7 +567,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -2575,7 +2575,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3593,7 +3593,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -4581,7 +4581,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -6589,7 +6589,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -7607,7 +7607,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -8612,7 +8612,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -10684,7 +10684,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -11734,7 +11734,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -12754,7 +12754,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -14826,7 +14826,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -15876,7 +15876,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -16883,7 +16883,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`), UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -18895,7 +18895,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -19915,7 +19915,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -20905,7 +20905,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`), UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -22917,7 +22917,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -23937,7 +23937,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -24927,7 +24927,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`), UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -26939,7 +26939,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -27959,7 +27959,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result b/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result index 1d264febcf5..887ac403cdb 100644 --- a/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result @@ -592,7 +592,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -2738,7 +2738,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -3830,7 +3830,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -4882,7 +4882,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -7028,7 +7028,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -8120,7 +8120,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_alter1_1_innodb.result b/mysql-test/suite/parts/r/partition_alter1_1_innodb.result index d7d9e5b4356..66d84768b5e 100644 --- a/mysql-test/suite/parts/r/partition_alter1_1_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter1_1_innodb.result @@ -885,7 +885,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -2895,7 +2895,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3913,7 +3913,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -4901,7 +4901,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -6911,7 +6911,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -7929,7 +7929,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -8934,7 +8934,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -11008,7 +11008,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -12058,7 +12058,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -13078,7 +13078,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -15152,7 +15152,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -16202,7 +16202,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_alter1_1_myisam.result b/mysql-test/suite/parts/r/partition_alter1_1_myisam.result index 4030d09981a..9f616d04df3 100644 --- a/mysql-test/suite/parts/r/partition_alter1_1_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter1_1_myisam.result @@ -751,7 +751,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -2899,7 +2899,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -3991,7 +3991,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -5043,7 +5043,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -7191,7 +7191,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -8283,7 +8283,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_alter1_2_innodb.result b/mysql-test/suite/parts/r/partition_alter1_2_innodb.result index f0d69fc4c41..f1a1aeecb66 100644 --- a/mysql-test/suite/parts/r/partition_alter1_2_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter1_2_innodb.result @@ -513,7 +513,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -2315,7 +2315,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3229,7 +3229,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -4113,7 +4113,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -5915,7 +5915,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -6829,7 +6829,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -7729,7 +7729,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -9595,7 +9595,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -10541,7 +10541,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -11445,7 +11445,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -13245,7 +13245,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -14159,7 +14159,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -15043,7 +15043,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -16843,7 +16843,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -17757,7 +17757,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -18658,7 +18658,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -20522,7 +20522,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -21468,7 +21468,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -22384,7 +22384,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -24248,7 +24248,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -25194,7 +25194,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -26095,7 +26095,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -27895,7 +27895,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -28809,7 +28809,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -29693,7 +29693,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -31493,7 +31493,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -32407,7 +32407,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -33307,7 +33307,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -35171,7 +35171,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -36117,7 +36117,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_alter1_2_myisam.result b/mysql-test/suite/parts/r/partition_alter1_2_myisam.result index 06dd211706c..087262f5f89 100644 --- a/mysql-test/suite/parts/r/partition_alter1_2_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter1_2_myisam.result @@ -537,7 +537,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -2477,7 +2477,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -3465,7 +3465,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -4417,7 +4417,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -6355,7 +6355,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -7343,7 +7343,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -8291,7 +8291,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -10229,7 +10229,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -11217,7 +11217,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -12165,7 +12165,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -14103,7 +14103,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -15091,7 +15091,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result b/mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result index d687f58eca2..314044044bb 100644 --- a/mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result @@ -530,7 +530,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -2396,7 +2396,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3342,7 +3342,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -4296,7 +4296,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -6306,7 +6306,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -7324,7 +7324,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -8312,7 +8312,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -10322,7 +10322,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -11340,7 +11340,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -12345,7 +12345,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -14419,7 +14419,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -15469,7 +15469,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -16489,7 +16489,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -18563,7 +18563,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -19613,7 +19613,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result b/mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result index 782ae78b13a..e824cf45ce9 100644 --- a/mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result @@ -526,7 +526,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -2390,7 +2390,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3336,7 +3336,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -4290,7 +4290,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -6298,7 +6298,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -7316,7 +7316,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -8304,7 +8304,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -10312,7 +10312,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -11330,7 +11330,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -12335,7 +12335,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -14407,7 +14407,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -15457,7 +15457,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -16477,7 +16477,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -18549,7 +18549,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -19599,7 +19599,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_alter2_1_myisam.result b/mysql-test/suite/parts/r/partition_alter2_1_myisam.result index 0abb1631d1f..f2a13497159 100644 --- a/mysql-test/suite/parts/r/partition_alter2_1_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter2_1_myisam.result @@ -539,7 +539,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -2479,7 +2479,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -3467,7 +3467,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -4469,7 +4469,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -6617,7 +6617,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -7709,7 +7709,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -8761,7 +8761,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -10909,7 +10909,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -12001,7 +12001,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -13005,7 +13005,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -14943,7 +14943,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -15931,7 +15931,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -16933,7 +16933,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -19079,7 +19079,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -20171,7 +20171,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -21223,7 +21223,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -23369,7 +23369,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -24461,7 +24461,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result b/mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result index e2c6cd53c5b..faba21b41f7 100644 --- a/mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result @@ -532,7 +532,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -2404,7 +2404,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3352,7 +3352,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -4309,7 +4309,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -6325,7 +6325,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -7345,7 +7345,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -8337,7 +8337,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -10353,7 +10353,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -11373,7 +11373,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -12382,7 +12382,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -14462,7 +14462,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -15514,7 +15514,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -16538,7 +16538,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -18618,7 +18618,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -19670,7 +19670,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result b/mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result index e96b2caa33b..2557cd5a219 100644 --- a/mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result @@ -528,7 +528,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -2408,7 +2408,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3362,7 +3362,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -4322,7 +4322,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -6346,7 +6346,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -7372,7 +7372,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -8366,7 +8366,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -10390,7 +10390,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -11416,7 +11416,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -12427,7 +12427,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -14515,7 +14515,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -15573,7 +15573,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -16599,7 +16599,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ # check prerequisites-1 success: 1 @@ -18687,7 +18687,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -19745,7 +19745,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_alter2_2_myisam.result b/mysql-test/suite/parts/r/partition_alter2_2_myisam.result index 69bcdc29e30..70e869f48fb 100644 --- a/mysql-test/suite/parts/r/partition_alter2_2_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter2_2_myisam.result @@ -541,7 +541,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -2487,7 +2487,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -3477,7 +3477,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -4483,7 +4483,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -6637,7 +6637,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -7731,7 +7731,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -8787,7 +8787,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -10941,7 +10941,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -12035,7 +12035,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -13043,7 +13043,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -14997,7 +14997,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -15993,7 +15993,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -17001,7 +17001,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -19163,7 +19163,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -20263,7 +20263,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int1`,`f_int2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -21321,7 +21321,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL, UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -23483,7 +23483,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -24583,7 +24583,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_alter3_innodb.result b/mysql-test/suite/parts/r/partition_alter3_innodb.result index 7e91ae4c7e7..7825a2350b0 100644 --- a/mysql-test/suite/parts/r/partition_alter3_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter3_innodb.result @@ -419,7 +419,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) */ +/*!50100 PARTITION BY KEY (f_int1) */ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; @@ -444,7 +444,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB, PARTITION part7 ENGINE = InnoDB) */ @@ -467,7 +467,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB, PARTITION part7 ENGINE = InnoDB, @@ -491,7 +491,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB, PARTITION part7 ENGINE = InnoDB, @@ -526,7 +526,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB, PARTITION part7 ENGINE = InnoDB, @@ -552,7 +552,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB, PARTITION part7 ENGINE = InnoDB, @@ -577,7 +577,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB, PARTITION part7 ENGINE = InnoDB, @@ -601,7 +601,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB, PARTITION part7 ENGINE = InnoDB, @@ -624,7 +624,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB, PARTITION part7 ENGINE = InnoDB) */ @@ -646,7 +646,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB, PARTITION part1 ENGINE = InnoDB) */ t1.frm @@ -667,7 +667,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = InnoDB) */ t1.frm t1.par diff --git a/mysql-test/suite/parts/r/partition_alter3_myisam.result b/mysql-test/suite/parts/r/partition_alter3_myisam.result index 7b681d6ffc1..a5dec48e85c 100644 --- a/mysql-test/suite/parts/r/partition_alter3_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter3_myisam.result @@ -511,7 +511,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) */ +/*!50100 PARTITION BY KEY (f_int1) */ t1#P#p0.MYD t1#P#p0.MYI t1.frm @@ -538,7 +538,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM, PARTITION part7 ENGINE = MyISAM) */ @@ -567,7 +567,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM, PARTITION part7 ENGINE = MyISAM, @@ -599,7 +599,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM, PARTITION part7 ENGINE = MyISAM, @@ -650,7 +650,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM, PARTITION part7 ENGINE = MyISAM, @@ -690,7 +690,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM, PARTITION part7 ENGINE = MyISAM, @@ -727,7 +727,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM, PARTITION part7 ENGINE = MyISAM, @@ -761,7 +761,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM, PARTITION part7 ENGINE = MyISAM, @@ -792,7 +792,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM, PARTITION part7 ENGINE = MyISAM) */ @@ -820,7 +820,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM) */ t1#P#p0.MYD @@ -845,7 +845,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p0 ENGINE = MyISAM) */ t1#P#p0.MYD t1#P#p0.MYI diff --git a/mysql-test/suite/parts/r/partition_alter4_innodb.result b/mysql-test/suite/parts/r/partition_alter4_innodb.result index 0bd17bf26e2..46f3ed3c974 100644 --- a/mysql-test/suite/parts/r/partition_alter4_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter4_innodb.result @@ -534,7 +534,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -2412,7 +2412,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3362,7 +3362,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -4284,7 +4284,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -6162,7 +6162,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -7112,7 +7112,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -8034,7 +8034,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -9912,7 +9912,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -10862,7 +10862,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -11784,7 +11784,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -13662,7 +13662,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -14612,7 +14612,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -15534,7 +15534,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -17412,7 +17412,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -18362,7 +18362,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -19287,7 +19287,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -21165,7 +21165,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -22115,7 +22115,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -23037,7 +23037,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -24915,7 +24915,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -25865,7 +25865,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -26787,7 +26787,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -28665,7 +28665,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -29615,7 +29615,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -30537,7 +30537,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -32415,7 +32415,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -33365,7 +33365,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -34287,7 +34287,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -36165,7 +36165,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -37115,7 +37115,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -38042,7 +38042,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -39924,7 +39924,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -40876,7 +40876,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -41800,7 +41800,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -43682,7 +43682,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -44634,7 +44634,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -45556,7 +45556,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -47434,7 +47434,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -48384,7 +48384,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -49306,7 +49306,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -51184,7 +51184,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -52134,7 +52134,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -53058,7 +53058,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -54940,7 +54940,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -55892,7 +55892,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -56813,7 +56813,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -58683,7 +58683,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -59629,7 +59629,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -60547,7 +60547,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -62417,7 +62417,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -63363,7 +63363,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -64601,7 +64601,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -66471,7 +66471,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -67417,7 +67417,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -68342,7 +68342,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -70220,7 +70220,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -71170,7 +71170,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -72092,7 +72092,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -73970,7 +73970,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -74920,7 +74920,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -75842,7 +75842,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -77720,7 +77720,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -78670,7 +78670,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -79592,7 +79592,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -81470,7 +81470,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -82420,7 +82420,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, @@ -83342,7 +83342,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = InnoDB, PARTITION part_2 ENGINE = InnoDB, PARTITION part_3 ENGINE = InnoDB, @@ -85220,7 +85220,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -86170,7 +86170,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = InnoDB, PARTITION part_2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_alter4_myisam.result b/mysql-test/suite/parts/r/partition_alter4_myisam.result index 49cdc22f836..c74a105306c 100644 --- a/mysql-test/suite/parts/r/partition_alter4_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter4_myisam.result @@ -543,7 +543,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -2495,7 +2495,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -3487,7 +3487,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -4441,7 +4441,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -6393,7 +6393,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -7385,7 +7385,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -8339,7 +8339,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -10291,7 +10291,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -11283,7 +11283,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -12237,7 +12237,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -14189,7 +14189,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -15181,7 +15181,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -16135,7 +16135,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -18087,7 +18087,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -19079,7 +19079,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -20036,7 +20036,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -21988,7 +21988,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -22980,7 +22980,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -23934,7 +23934,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -25886,7 +25886,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -26878,7 +26878,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -27832,7 +27832,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -29784,7 +29784,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -30776,7 +30776,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -31730,7 +31730,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -33682,7 +33682,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -34674,7 +34674,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -35628,7 +35628,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -37580,7 +37580,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -38572,7 +38572,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -39529,7 +39529,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -41481,7 +41481,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -42473,7 +42473,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -43427,7 +43427,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -45379,7 +45379,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -46371,7 +46371,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -47325,7 +47325,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -49277,7 +49277,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -50269,7 +50269,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -51223,7 +51223,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -53175,7 +53175,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -54167,7 +54167,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -55121,7 +55121,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -57073,7 +57073,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -58065,7 +58065,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -59018,7 +59018,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -60962,7 +60962,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -61950,7 +61950,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -62900,7 +62900,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -64844,7 +64844,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -65832,7 +65832,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -67102,7 +67102,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -69046,7 +69046,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -70034,7 +70034,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -70991,7 +70991,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -72943,7 +72943,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -73935,7 +73935,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -74889,7 +74889,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -76841,7 +76841,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -77833,7 +77833,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -78787,7 +78787,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -80739,7 +80739,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -81731,7 +81731,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -82685,7 +82685,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -84637,7 +84637,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -85629,7 +85629,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, @@ -86583,7 +86583,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION part_1 ENGINE = MyISAM, PARTITION part_2 ENGINE = MyISAM, PARTITION part_3 ENGINE = MyISAM, @@ -88535,7 +88535,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -89527,7 +89527,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0) ENGINE = MyISAM, PARTITION part_2 VALUES IN (1) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_basic_innodb.result b/mysql-test/suite/parts/r/partition_basic_innodb.result index e60a63bcde2..ea5a53fc5f4 100644 --- a/mysql-test/suite/parts/r/partition_basic_innodb.result +++ b/mysql-test/suite/parts/r/partition_basic_innodb.result @@ -528,7 +528,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -2390,7 +2390,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -3338,7 +3338,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -4253,7 +4253,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -6113,7 +6113,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -7057,7 +7057,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -8015,7 +8015,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`), UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -10025,7 +10025,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -11047,7 +11047,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -12035,7 +12035,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`), UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -14045,7 +14045,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -15067,7 +15067,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -16071,7 +16071,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`), UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -18145,7 +18145,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -19199,7 +19199,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -20208,7 +20208,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int2`,`f_int1`), UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -22216,7 +22216,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -23234,7 +23234,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -24222,7 +24222,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`f_int1`,`f_int2`), UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -26230,7 +26230,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -27248,7 +27248,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, @@ -28252,7 +28252,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`), UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -30324,7 +30324,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), @@ -31374,7 +31374,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_basic_myisam.result b/mysql-test/suite/parts/r/partition_basic_myisam.result index 3898d853f4a..f70dae13bb6 100644 --- a/mysql-test/suite/parts/r/partition_basic_myisam.result +++ b/mysql-test/suite/parts/r/partition_basic_myisam.result @@ -533,7 +533,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -2453,7 +2453,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -3435,7 +3435,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -4374,7 +4374,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -6292,7 +6292,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -7270,7 +7270,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -8268,7 +8268,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`), UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5 */ unified filelist @@ -10400,7 +10400,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -11488,7 +11488,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, @@ -12537,7 +12537,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`), UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5 */ unified filelist @@ -14667,7 +14667,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), @@ -15751,7 +15751,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = MyISAM, PARTITION part2 VALUES IN (1) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result b/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result index 5548c20552f..146b3d361fb 100644 --- a/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result +++ b/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result @@ -563,7 +563,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION p3 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, @@ -2573,7 +2573,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, SUBPARTITION subpart12 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM), @@ -3613,7 +3613,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION part2 VALUES IN (1) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, @@ -4596,7 +4596,7 @@ t1 CREATE TABLE `t1` ( `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) (PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION p3 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, @@ -6604,7 +6604,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, SUBPARTITION subpart12 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM), @@ -7644,7 +7644,7 @@ t1 CREATE TABLE `t1` ( `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION part2 VALUES IN (1) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, @@ -8686,7 +8686,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`), UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1) +/*!50100 PARTITION BY KEY (f_int1) (PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION p3 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, @@ -10908,7 +10908,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, SUBPARTITION subpart12 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM), @@ -12054,7 +12054,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION part2 VALUES IN (1) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, @@ -13147,7 +13147,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx1` (`f_int1`,`f_int2`), UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (f_int1,f_int2) +/*!50100 PARTITION BY KEY (f_int1,f_int2) (PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION p3 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, @@ -15367,7 +15367,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, SUBPARTITION subpart12 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM), @@ -16513,7 +16513,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int2) +SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, PARTITION part2 VALUES IN (1) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM, @@ -19782,7 +19782,7 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `uidx2` (`f_int2`,`f_int1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) -SUBPARTITION BY KEY ALGORITHM = 2 (f_int1) +SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = MyISAM, SUBPARTITION subpart12 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = MyISAM), diff --git a/mysql-test/suite/parts/r/partition_bit_innodb.result b/mysql-test/suite/parts/r/partition_bit_innodb.result index ae5b567cb9a..a9ae917f13d 100644 --- a/mysql-test/suite/parts/r/partition_bit_innodb.result +++ b/mysql-test/suite/parts/r/partition_bit_innodb.result @@ -9,7 +9,7 @@ t1 CREATE TABLE `t1` ( `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) */ +/*!50100 PARTITION BY KEY (a) */ drop table t1; create table t1 (a bit(0), primary key (a)) engine='INNODB' partition by key (a) ( @@ -21,7 +21,7 @@ t1 CREATE TABLE `t1` ( `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 ENGINE = InnoDB, PARTITION pa2 ENGINE = InnoDB) */ drop table t1; @@ -33,7 +33,7 @@ t1 CREATE TABLE `t1` ( `a` bit(64) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 2 */ insert into t1 values (b'1111111111111111111111111111111111111111111111111111111111111111'), @@ -61,7 +61,7 @@ t1 CREATE TABLE `t1` ( `a` bit(64) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -91,7 +91,7 @@ t2 CREATE TABLE `t2` ( `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 4 */ insert into t2 values (b'0'), (b'1'); select hex(a) from t2; @@ -104,7 +104,7 @@ Table Create Table t2 CREATE TABLE `t2` ( `a` bit(1) NOT NULL DEFAULT b'0' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 4 */ select hex(a) from t2; hex(a) @@ -117,7 +117,7 @@ t2 CREATE TABLE `t2` ( `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 4 */ select hex(a) from t2; hex(a) @@ -137,7 +137,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 2 (PARTITION pa1 VALUES LESS THAN (3) ENGINE = InnoDB, PARTITION pa2 VALUES LESS THAN (16) ENGINE = InnoDB, @@ -420,7 +420,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 2 (PARTITION pa1 VALUES IN (0,1,2,3) ENGINE = InnoDB, PARTITION pa2 VALUES IN (4,5,6,7,8,9,10,11,12,13,14,15,16) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_bit_myisam.result b/mysql-test/suite/parts/r/partition_bit_myisam.result index e6a85247907..680845c9971 100644 --- a/mysql-test/suite/parts/r/partition_bit_myisam.result +++ b/mysql-test/suite/parts/r/partition_bit_myisam.result @@ -9,7 +9,7 @@ t1 CREATE TABLE `t1` ( `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) */ +/*!50100 PARTITION BY KEY (a) */ drop table t1; create table t1 (a bit(0), primary key (a)) engine='MyISAM' partition by key (a) ( @@ -21,7 +21,7 @@ t1 CREATE TABLE `t1` ( `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 ENGINE = MyISAM, PARTITION pa2 ENGINE = MyISAM) */ drop table t1; @@ -33,7 +33,7 @@ t1 CREATE TABLE `t1` ( `a` bit(64) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 2 */ insert into t1 values (b'1111111111111111111111111111111111111111111111111111111111111111'), @@ -61,7 +61,7 @@ t1 CREATE TABLE `t1` ( `a` bit(64) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -91,7 +91,7 @@ t2 CREATE TABLE `t2` ( `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 4 */ insert into t2 values (b'0'), (b'1'); select hex(a) from t2; @@ -104,7 +104,7 @@ Table Create Table t2 CREATE TABLE `t2` ( `a` bit(1) NOT NULL DEFAULT b'0' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 4 */ select hex(a) from t2; hex(a) @@ -117,7 +117,7 @@ t2 CREATE TABLE `t2` ( `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 4 */ select hex(a) from t2; hex(a) @@ -137,7 +137,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 2 (PARTITION pa1 VALUES LESS THAN (3) ENGINE = MyISAM, PARTITION pa2 VALUES LESS THAN (16) ENGINE = MyISAM, @@ -420,7 +420,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 2 (PARTITION pa1 VALUES IN (0,1,2,3) ENGINE = MyISAM, PARTITION pa2 VALUES IN (4,5,6,7,8,9,10,11,12,13,14,15,16) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_char_innodb.result b/mysql-test/suite/parts/r/partition_char_innodb.result index e385d6bc427..dc7d259c2af 100644 --- a/mysql-test/suite/parts/r/partition_char_innodb.result +++ b/mysql-test/suite/parts/r/partition_char_innodb.result @@ -11,7 +11,7 @@ t1 CREATE TABLE `t1` ( `a` char(255) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -42,7 +42,7 @@ t2 CREATE TABLE `t2` ( `a` char(255) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ 26 inserts; insert into t2 values (repeat(char(ascii('a')+0),26+54)); @@ -116,7 +116,7 @@ t1 CREATE TABLE `t1` ( `a` binary(255) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -150,7 +150,7 @@ t2 CREATE TABLE `t2` ( `a` binary(255) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ 26 inserts; insert into t2 values (repeat(char(ascii('a')+0),26+54)); @@ -224,7 +224,7 @@ t1 CREATE TABLE `t1` ( `a` varchar(767) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -255,7 +255,7 @@ t2 CREATE TABLE `t2` ( `a` varchar(767) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ 26 inserts; insert into t2 values (repeat(char(ascii('a')+0),26*26)); @@ -329,7 +329,7 @@ t1 CREATE TABLE `t1` ( `a` varbinary(767) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -360,7 +360,7 @@ t2 CREATE TABLE `t2` ( `a` varbinary(767) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 30 */ 26 inserts; insert into t2 values (repeat(char(ascii('a')+0),26*26)); @@ -434,7 +434,7 @@ t1 CREATE TABLE `t1` ( `a` enum('A','B','C','D','E','F','G','H','I','J','K','L') NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -476,7 +476,7 @@ t2 CREATE TABLE `t2` ( `a` enum('1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z') NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ 0 inserts; insert into t2 values (char(ascii('A')+26)); @@ -563,7 +563,7 @@ t1 CREATE TABLE `t1` ( `a` set('A','B','C','D','E','F','G','H','I','J','K','L') NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -605,7 +605,7 @@ t2 CREATE TABLE `t2` ( `a` set('1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z') NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ insert into t2 values ('A'),('B'),('C'),('D'),('E'),('F'),('G'),('H'),('I'),('K'),('L'),('M'),('N'),('O'),('P'),('Q'),('S'),('T'),('U'),('V'),('X'),('Y'),('Z'); insert into t2 values ('A,B'),('B,C'),('C,D'),('D,E'),('E,F'),('F,G'),('G,H'),('H,I'),('I,J'),('K,L'),('L,M'),('M,N'),('N,O'),('O,P'),('P,Q'),('Q,R'),('S,T'),('T,U'),('U,V'),('V,W'),('X,Y'),('Y,Z'),('Z,A'); diff --git a/mysql-test/suite/parts/r/partition_char_myisam.result b/mysql-test/suite/parts/r/partition_char_myisam.result index 9f8c306b9f4..80f738c4b7b 100644 --- a/mysql-test/suite/parts/r/partition_char_myisam.result +++ b/mysql-test/suite/parts/r/partition_char_myisam.result @@ -11,7 +11,7 @@ t1 CREATE TABLE `t1` ( `a` char(255) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -42,7 +42,7 @@ t2 CREATE TABLE `t2` ( `a` char(255) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ 26 inserts; insert into t2 values (repeat(char(ascii('a')+0),26+54)); @@ -116,7 +116,7 @@ t1 CREATE TABLE `t1` ( `a` binary(255) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -150,7 +150,7 @@ t2 CREATE TABLE `t2` ( `a` binary(255) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ 26 inserts; insert into t2 values (repeat(char(ascii('a')+0),26+54)); @@ -224,7 +224,7 @@ t1 CREATE TABLE `t1` ( `a` varchar(767) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -255,7 +255,7 @@ t2 CREATE TABLE `t2` ( `a` varchar(767) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ 26 inserts; insert into t2 values (repeat(char(ascii('a')+0),26*26)); @@ -329,7 +329,7 @@ t1 CREATE TABLE `t1` ( `a` varbinary(767) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -360,7 +360,7 @@ t2 CREATE TABLE `t2` ( `a` varbinary(767) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 30 */ 26 inserts; insert into t2 values (repeat(char(ascii('a')+0),26*26)); @@ -434,7 +434,7 @@ t1 CREATE TABLE `t1` ( `a` enum('A','B','C','D','E','F','G','H','I','J','K','L') NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -476,7 +476,7 @@ t2 CREATE TABLE `t2` ( `a` enum('1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z') NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ 0 inserts; insert into t2 values (char(ascii('A')+26)); @@ -563,7 +563,7 @@ t1 CREATE TABLE `t1` ( `a` set('A','B','C','D','E','F','G','H','I','J','K','L') NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -605,7 +605,7 @@ t2 CREATE TABLE `t2` ( `a` set('1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z') NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 27 */ insert into t2 values ('A'),('B'),('C'),('D'),('E'),('F'),('G'),('H'),('I'),('K'),('L'),('M'),('N'),('O'),('P'),('Q'),('S'),('T'),('U'),('V'),('X'),('Y'),('Z'); insert into t2 values ('A,B'),('B,C'),('C,D'),('D,E'),('E,F'),('F,G'),('G,H'),('H,I'),('I,J'),('K,L'),('L,M'),('M,N'),('N,O'),('O,P'),('P,Q'),('Q,R'),('S,T'),('T,U'),('U,V'),('V,W'),('X,Y'),('Y,Z'),('Z,A'); diff --git a/mysql-test/suite/parts/r/partition_datetime_innodb.result b/mysql-test/suite/parts/r/partition_datetime_innodb.result index 0b878578188..48af3343d9a 100644 --- a/mysql-test/suite/parts/r/partition_datetime_innodb.result +++ b/mysql-test/suite/parts/r/partition_datetime_innodb.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -40,7 +40,7 @@ t2 CREATE TABLE `t2` ( `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16'); select * from t2; @@ -196,7 +196,7 @@ t1 CREATE TABLE `t1` ( `a` date NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -226,7 +226,7 @@ t2 CREATE TABLE `t2` ( `a` date NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('1975-01-01'), ('2020-12-31'), ('1980-10-14'), ('2000-06-15'); select * from t2; @@ -435,7 +435,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (month(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION quarter2 VALUES LESS THAN (7) ENGINE = InnoDB, @@ -487,7 +487,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (month(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3) ENGINE = InnoDB, PARTITION quarter2 VALUES IN (4,5,6) ENGINE = InnoDB, @@ -536,7 +536,7 @@ t1 CREATE TABLE `t1` ( `a` time NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -566,7 +566,7 @@ t2 CREATE TABLE `t2` ( `a` time NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('0:1:1'), ('10:11:12'), ('13:14:15'), ('14:15:16'); select * from t2; @@ -725,7 +725,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (second(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (16) ENGINE = InnoDB, PARTITION quarter2 VALUES LESS THAN (31) ENGINE = InnoDB, @@ -871,7 +871,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (second(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ENGINE = InnoDB, PARTITION quarter2 VALUES IN (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB, @@ -1014,7 +1014,7 @@ t1 CREATE TABLE `t1` ( `a` datetime NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -1044,7 +1044,7 @@ t2 CREATE TABLE `t2` ( `a` datetime NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16'); select * from t2; @@ -1203,7 +1203,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (month(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION quarter2 VALUES LESS THAN (7) ENGINE = InnoDB, @@ -1255,7 +1255,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (month(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3) ENGINE = InnoDB, PARTITION quarter2 VALUES IN (4,5,6) ENGINE = InnoDB, @@ -1304,7 +1304,7 @@ t1 CREATE TABLE `t1` ( `a` year(4) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -1334,7 +1334,7 @@ t2 CREATE TABLE `t2` ( `a` year(4) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('1975'), ('2020'), ('1980'), ('2000'); select * from t2; diff --git a/mysql-test/suite/parts/r/partition_datetime_myisam.result b/mysql-test/suite/parts/r/partition_datetime_myisam.result index 5c87096f373..146f291546e 100644 --- a/mysql-test/suite/parts/r/partition_datetime_myisam.result +++ b/mysql-test/suite/parts/r/partition_datetime_myisam.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -40,7 +40,7 @@ t2 CREATE TABLE `t2` ( `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16'); select * from t2; @@ -196,7 +196,7 @@ t1 CREATE TABLE `t1` ( `a` date NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -226,7 +226,7 @@ t2 CREATE TABLE `t2` ( `a` date NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('1975-01-01'), ('2020-12-31'), ('1980-10-14'), ('2000-06-15'); select * from t2; @@ -435,7 +435,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (month(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION quarter2 VALUES LESS THAN (7) ENGINE = MyISAM, @@ -487,7 +487,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (month(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3) ENGINE = MyISAM, PARTITION quarter2 VALUES IN (4,5,6) ENGINE = MyISAM, @@ -536,7 +536,7 @@ t1 CREATE TABLE `t1` ( `a` time NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -566,7 +566,7 @@ t2 CREATE TABLE `t2` ( `a` time NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('0:1:1'), ('10:11:12'), ('13:14:15'), ('14:15:16'); select * from t2; @@ -725,7 +725,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (second(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (16) ENGINE = MyISAM, PARTITION quarter2 VALUES LESS THAN (31) ENGINE = MyISAM, @@ -871,7 +871,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (second(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ENGINE = MyISAM, PARTITION quarter2 VALUES IN (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) ENGINE = MyISAM, @@ -1014,7 +1014,7 @@ t1 CREATE TABLE `t1` ( `a` datetime NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -1044,7 +1044,7 @@ t2 CREATE TABLE `t2` ( `a` datetime NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16'); select * from t2; @@ -1203,7 +1203,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (month(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION quarter2 VALUES LESS THAN (7) ENGINE = MyISAM, @@ -1255,7 +1255,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (month(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3) ENGINE = MyISAM, PARTITION quarter2 VALUES IN (4,5,6) ENGINE = MyISAM, @@ -1304,7 +1304,7 @@ t1 CREATE TABLE `t1` ( `a` year(4) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -1334,7 +1334,7 @@ t2 CREATE TABLE `t2` ( `a` year(4) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 12 */ insert into t2 values ('1975'), ('2020'), ('1980'), ('2000'); select * from t2; diff --git a/mysql-test/suite/parts/r/partition_decimal_innodb.result b/mysql-test/suite/parts/r/partition_decimal_innodb.result index 8c7617aa54e..c69c880cc6f 100644 --- a/mysql-test/suite/parts/r/partition_decimal_innodb.result +++ b/mysql-test/suite/parts/r/partition_decimal_innodb.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `a` decimal(10,4) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -54,7 +54,7 @@ t2 CREATE TABLE `t2` ( `a` decimal(18,9) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 10 */ insert into t2 values (999999999.999999999), (-999999999.999999999), (-1.5), (-1), (0), (1.5), (1234.567), (-1234.567); select * from t2; @@ -101,7 +101,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (floor(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 2 (PARTITION pa2 VALUES LESS THAN (2) ENGINE = InnoDB, PARTITION pa4 VALUES LESS THAN (4) ENGINE = InnoDB, @@ -155,7 +155,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ceiling(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 2 (PARTITION pa2 VALUES IN (1,2) ENGINE = InnoDB, PARTITION pa4 VALUES IN (3,4) ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_decimal_myisam.result b/mysql-test/suite/parts/r/partition_decimal_myisam.result index 54392cfaf40..cdafb721ea4 100644 --- a/mysql-test/suite/parts/r/partition_decimal_myisam.result +++ b/mysql-test/suite/parts/r/partition_decimal_myisam.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `a` decimal(10,4) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -54,7 +54,7 @@ t2 CREATE TABLE `t2` ( `a` decimal(18,9) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 10 */ insert into t2 values (999999999.999999999), (-999999999.999999999), (-1.5), (-1), (0), (1.5), (1234.567), (-1234.567); select * from t2; @@ -101,7 +101,7 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (floor(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 2 (PARTITION pa2 VALUES LESS THAN (2) ENGINE = MyISAM, PARTITION pa4 VALUES LESS THAN (4) ENGINE = MyISAM, @@ -155,7 +155,7 @@ t4 CREATE TABLE `t4` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ceiling(a)) -SUBPARTITION BY KEY ALGORITHM = 2 (a) +SUBPARTITION BY KEY (a) SUBPARTITIONS 2 (PARTITION pa2 VALUES IN (1,2) ENGINE = MyISAM, PARTITION pa4 VALUES IN (3,4) ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_float_innodb.result b/mysql-test/suite/parts/r/partition_float_innodb.result index a80606d42ac..d2f04a68629 100644 --- a/mysql-test/suite/parts/r/partition_float_innodb.result +++ b/mysql-test/suite/parts/r/partition_float_innodb.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `a` float NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -46,7 +46,7 @@ t2 CREATE TABLE `t2` ( `a` float NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 10 */ insert into t2 values (-3.402823466E+38), (-3.402823466E+37), (-123.456), (0), (1234546.789), (123.456), (1.5); select * from t2; @@ -100,7 +100,7 @@ t1 CREATE TABLE `t1` ( `a` double NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -138,7 +138,7 @@ t2 CREATE TABLE `t2` ( `a` double NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 10 */ insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208); select * from t2; diff --git a/mysql-test/suite/parts/r/partition_float_myisam.result b/mysql-test/suite/parts/r/partition_float_myisam.result index 035cdd7424d..2d52d095989 100644 --- a/mysql-test/suite/parts/r/partition_float_myisam.result +++ b/mysql-test/suite/parts/r/partition_float_myisam.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `a` float NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -46,7 +46,7 @@ t2 CREATE TABLE `t2` ( `a` float NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 10 */ insert into t2 values (-3.402823466E+38), (-3.402823466E+37), (-123.456), (0), (1234546.789), (123.456), (1.5); select * from t2; @@ -100,7 +100,7 @@ t1 CREATE TABLE `t1` ( `a` double NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -138,7 +138,7 @@ t2 CREATE TABLE `t2` ( `a` double NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 10 */ insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208); select * from t2; diff --git a/mysql-test/suite/parts/r/partition_int_innodb.result b/mysql-test/suite/parts/r/partition_int_innodb.result index b419f5d627e..7a51b80d5d7 100644 --- a/mysql-test/suite/parts/r/partition_int_innodb.result +++ b/mysql-test/suite/parts/r/partition_int_innodb.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `a` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -46,7 +46,7 @@ t2 CREATE TABLE `t2` ( `a` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (255), (254), (253), (252); select * from t2; @@ -78,7 +78,7 @@ t3 CREATE TABLE `t3` ( `a` tinyint(4) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (127), (126), (125), (124), (-128), (-127), (1), (-1), (0); select * from t3; @@ -119,7 +119,7 @@ t1 CREATE TABLE `t1` ( `a` smallint(5) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -155,7 +155,7 @@ t2 CREATE TABLE `t2` ( `a` smallint(5) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (65535), (65534), (65533), (65532); select * from t2; @@ -187,7 +187,7 @@ t3 CREATE TABLE `t3` ( `a` smallint(6) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (32767), (32766), (32765), (32764), (-32768), (-32767), (1), (-1), (0); select * from t3; @@ -228,7 +228,7 @@ t1 CREATE TABLE `t1` ( `a` int(10) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -264,7 +264,7 @@ t2 CREATE TABLE `t2` ( `a` int(10) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (4294967295), (4294967294), (4294967293), (4294967292); select * from t2; @@ -296,7 +296,7 @@ t3 CREATE TABLE `t3` ( `a` int(11) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (2147483647), (2147483646), (2147483645), (2147483644), (-2147483648), (-2147483647), (1), (-1), (0); select * from t3; @@ -337,7 +337,7 @@ t1 CREATE TABLE `t1` ( `a` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -373,7 +373,7 @@ t2 CREATE TABLE `t2` ( `a` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (16777215), (16777214), (16777213), (16777212); select * from t2; @@ -405,7 +405,7 @@ t3 CREATE TABLE `t3` ( `a` mediumint(9) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (8388607), (8388606), (8388605), (8388604), (-8388608), (-8388607), (1), (-1), (0); select * from t3; @@ -446,7 +446,7 @@ t1 CREATE TABLE `t1` ( `a` bigint(20) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -494,7 +494,7 @@ t2 CREATE TABLE `t2` ( `a` bigint(20) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t2; @@ -526,7 +526,7 @@ t3 CREATE TABLE `t3` ( `a` bigint(20) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (9223372036854775807), (9223372036854775806), (9223372036854775805), (9223372036854775804), (-9223372036854775808), (-9223372036854775807), (1), (-1), (0); select * from t3; diff --git a/mysql-test/suite/parts/r/partition_int_myisam.result b/mysql-test/suite/parts/r/partition_int_myisam.result index a7520e8f3e3..4387bbfdd78 100644 --- a/mysql-test/suite/parts/r/partition_int_myisam.result +++ b/mysql-test/suite/parts/r/partition_int_myisam.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `a` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -46,7 +46,7 @@ t2 CREATE TABLE `t2` ( `a` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (255), (254), (253), (252); select * from t2; @@ -78,7 +78,7 @@ t3 CREATE TABLE `t3` ( `a` tinyint(4) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (127), (126), (125), (124), (-128), (-127), (1), (-1), (0); select * from t3; @@ -119,7 +119,7 @@ t1 CREATE TABLE `t1` ( `a` smallint(5) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -155,7 +155,7 @@ t2 CREATE TABLE `t2` ( `a` smallint(5) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (65535), (65534), (65533), (65532); select * from t2; @@ -187,7 +187,7 @@ t3 CREATE TABLE `t3` ( `a` smallint(6) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (32767), (32766), (32765), (32764), (-32768), (-32767), (1), (-1), (0); select * from t3; @@ -228,7 +228,7 @@ t1 CREATE TABLE `t1` ( `a` int(10) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -264,7 +264,7 @@ t2 CREATE TABLE `t2` ( `a` int(10) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (4294967295), (4294967294), (4294967293), (4294967292); select * from t2; @@ -296,7 +296,7 @@ t3 CREATE TABLE `t3` ( `a` int(11) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (2147483647), (2147483646), (2147483645), (2147483644), (-2147483648), (-2147483647), (1), (-1), (0); select * from t3; @@ -337,7 +337,7 @@ t1 CREATE TABLE `t1` ( `a` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -373,7 +373,7 @@ t2 CREATE TABLE `t2` ( `a` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (16777215), (16777214), (16777213), (16777212); select * from t2; @@ -405,7 +405,7 @@ t3 CREATE TABLE `t3` ( `a` mediumint(9) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (8388607), (8388606), (8388605), (8388604), (-8388608), (-8388607), (1), (-1), (0); select * from t3; @@ -446,7 +446,7 @@ t1 CREATE TABLE `t1` ( `a` bigint(20) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -494,7 +494,7 @@ t2 CREATE TABLE `t2` ( `a` bigint(20) unsigned NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 8 */ insert into t2 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t2; @@ -526,7 +526,7 @@ t3 CREATE TABLE `t3` ( `a` bigint(20) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) PARTITIONS 7 */ insert into t3 values (9223372036854775807), (9223372036854775806), (9223372036854775805), (9223372036854775804), (-9223372036854775808), (-9223372036854775807), (1), (-1), (0); select * from t3; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result index d5a4adc298c..f4d76874b4c 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */ @@ -199,7 +199,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result index 5c933a3ebab..19f16780d13 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */ @@ -199,7 +199,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result index 3cc03cc3e5e..69a43b64d87 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */ @@ -199,7 +199,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result index 98f39b0fcec..9b4e85be9d0 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */ @@ -199,7 +199,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result index 79aad61bbec..1113e7dcb0c 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */ @@ -192,7 +192,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */ diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result index 399230237ad..952f4136cb6 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */ @@ -192,7 +192,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */ diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result index c6b9edd9ff5..435a0d8313e 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */ @@ -192,7 +192,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */ diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result index 9a7231e99e7..3a90ce4d73c 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */ @@ -192,7 +192,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */ diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result index 42e59f724f4..e71803fcac9 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */ @@ -192,7 +192,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */ diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result index 302ef7a7b2a..8e42bc9eb62 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */ @@ -192,7 +192,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */ diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result index 21124e3fed7..24047912ab1 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */ @@ -192,7 +192,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */ diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result index a77f44191a5..7a61a811ea3 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result @@ -56,7 +56,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, @@ -84,7 +84,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */ @@ -120,7 +120,7 @@ Table Create Table TableA CREATE TABLE `TableA` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */ @@ -192,7 +192,7 @@ Table Create Table tablea CREATE TABLE `tablea` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a) +/*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */ diff --git a/mysql-test/suite/parts/r/partition_special_innodb.result b/mysql-test/suite/parts/r/partition_special_innodb.result index 1b793b8c7df..c1213e86afc 100644 --- a/mysql-test/suite/parts/r/partition_special_innodb.result +++ b/mysql-test/suite/parts/r/partition_special_innodb.result @@ -13,7 +13,7 @@ t1 CREATE TABLE `t1` ( `d` enum('m','w') NOT NULL DEFAULT 'm', PRIMARY KEY (`a`,`b`,`c`,`d`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a,b,c,d) +/*!50100 PARTITION BY KEY (a,b,c,d) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -55,7 +55,7 @@ t1 CREATE TABLE `t1` ( `i` char(255) DEFAULT NULL, PRIMARY KEY (`a`,`b`,`c`,`d`,`e`,`f`,`g`,`h`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a,b,c,d,e,f,g,h) +/*!50100 PARTITION BY KEY (a,b,c,d,e,f,g,h) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -105,7 +105,7 @@ t1 CREATE TABLE `t1` ( `i` char(255) DEFAULT NULL, PRIMARY KEY (`a`,`b`,`c`,`d`,`e`,`f`,`g`,`h`,`a1`,`b1`,`c1`,`d1`,`e1`,`f1`,`g1`,`h1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1) +/*!50100 PARTITION BY KEY (a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, @@ -178,7 +178,7 @@ t1 CREATE TABLE `t1` ( `i` char(255) DEFAULT NULL, PRIMARY KEY (`a`,`b`,`c`,`d`,`e`,`f`,`g`,`h`,`a1`,`b1`,`c1`,`d1`,`e1`,`f1`,`g1`,`h1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a,b,c,d,e,f,g,h) +/*!50100 PARTITION BY KEY (a,b,c,d,e,f,g,h) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, diff --git a/mysql-test/suite/parts/r/partition_special_myisam.result b/mysql-test/suite/parts/r/partition_special_myisam.result index 9c11201733f..bc8036ba861 100644 --- a/mysql-test/suite/parts/r/partition_special_myisam.result +++ b/mysql-test/suite/parts/r/partition_special_myisam.result @@ -13,7 +13,7 @@ t1 CREATE TABLE `t1` ( `d` enum('m','w') NOT NULL DEFAULT 'm', PRIMARY KEY (`a`,`b`,`c`,`d`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a,b,c,d) +/*!50100 PARTITION BY KEY (a,b,c,d) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -55,7 +55,7 @@ t1 CREATE TABLE `t1` ( `i` char(255) DEFAULT NULL, PRIMARY KEY (`a`,`b`,`c`,`d`,`e`,`f`,`g`,`h`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a,b,c,d,e,f,g,h) +/*!50100 PARTITION BY KEY (a,b,c,d,e,f,g,h) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -105,7 +105,7 @@ t1 CREATE TABLE `t1` ( `i` char(255) DEFAULT NULL, PRIMARY KEY (`a`,`b`,`c`,`d`,`e`,`f`,`g`,`h`,`a1`,`b1`,`c1`,`d1`,`e1`,`f1`,`g1`,`h1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1) +/*!50100 PARTITION BY KEY (a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, @@ -178,7 +178,7 @@ t1 CREATE TABLE `t1` ( `i` char(255) DEFAULT NULL, PRIMARY KEY (`a`,`b`,`c`,`d`,`e`,`f`,`g`,`h`,`a1`,`b1`,`c1`,`d1`,`e1`,`f1`,`g1`,`h1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (a,b,c,d,e,f,g,h) +/*!50100 PARTITION BY KEY (a,b,c,d,e,f,g,h) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, diff --git a/mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result b/mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result index 232e0055162..c63ba401085 100644 --- a/mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result +++ b/mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result @@ -550,7 +550,7 @@ t16 CREATE TABLE `t16` ( `c5` char(5) DEFAULT NULL, PRIMARY KEY (`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ *** Show table on Slave **** SHOW CREATE TABLE t16; @@ -565,7 +565,7 @@ t16 CREATE TABLE `t16` ( `c7` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ *** DROP TABLE t16 *** DROP TABLE t16; diff --git a/mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result b/mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result index d99f9e6a66b..4e483da72e4 100644 --- a/mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result +++ b/mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result @@ -550,7 +550,7 @@ t16 CREATE TABLE `t16` ( `c5` char(5) DEFAULT NULL, PRIMARY KEY (`c1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ *** Show table on Slave **** SHOW CREATE TABLE t16; @@ -565,7 +565,7 @@ t16 CREATE TABLE `t16` ( `c7` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`c1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 (c1) +/*!50100 PARTITION BY KEY (c1) PARTITIONS 4 */ *** DROP TABLE t16 *** DROP TABLE t16; diff --git a/mysql-test/suite/rpl/r/rpl_row_basic_8partition.result b/mysql-test/suite/rpl/r/rpl_row_basic_8partition.result index 4585e0628c9..c7241c52353 100644 --- a/mysql-test/suite/rpl/r/rpl_row_basic_8partition.result +++ b/mysql-test/suite/rpl/r/rpl_row_basic_8partition.result @@ -509,7 +509,7 @@ t1 CREATE TABLE `t1` ( `t` date DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 () +/*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- On slave --- SHOW CREATE TABLE t1; @@ -526,7 +526,7 @@ t1 CREATE TABLE `t1` ( `t` date DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 () +/*!50100 PARTITION BY KEY () PARTITIONS 4 */ "--- Insert into t1 --" as ""; --- Select from t1 on master --- @@ -582,7 +582,7 @@ t1 CREATE TABLE `t1` ( `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 () +/*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- On slave --- SHOW CREATE TABLE t1; @@ -599,7 +599,7 @@ t1 CREATE TABLE `t1` ( `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 () +/*!50100 PARTITION BY KEY () PARTITIONS 4 */ "--- Insert into t1 --" as ""; --- Select from t1 on master --- @@ -655,7 +655,7 @@ t1 CREATE TABLE `t1` ( `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 () +/*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- On slave --- SHOW CREATE TABLE t1; @@ -672,7 +672,7 @@ t1 CREATE TABLE `t1` ( `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY ALGORITHM = 2 () +/*!50100 PARTITION BY KEY () PARTITIONS 4 */ "--- Insert into t1 --" as ""; --- Select from t1 on master --- diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 4afae052b76..859b3891b25 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -7968,6 +7968,7 @@ int ha_partition::check_for_upgrade(HA_CHECK_OPT *check_opt) true, true, NULL, + NULL, NULL)) || /* Also check that the length is smaller than the output field! */ (part_buf_len + db_name.length() + table_name.length()) >= @@ -7991,8 +7992,8 @@ int ha_partition::check_for_upgrade(HA_CHECK_OPT *check_opt) part_buf); } m_part_info->key_algorithm= old_algorithm; + DBUG_RETURN(error); } - break; default: /* Not affected! */ ; diff --git a/sql/handler.cc b/sql/handler.cc index dc4fc9ce210..98d6e8fb103 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3324,6 +3324,9 @@ int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt) } if ((error= check(thd, check_opt))) return error; + /* Skip updating frm version if not main handler. */ + if (table->file != this) + return error; return update_frm_version(table); } diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 5a7d0bf0c43..056676503dd 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -2302,6 +2302,16 @@ bool partition_info::has_same_partitioning(partition_info *new_part_info) { DBUG_ENTER("partition_info::has_same_partitioning"); + DBUG_ASSERT(part_field_array && part_field_array[0]); + + /* + Only consider pre 5.5.3 .frm's to have same partitioning as + a new one with KEY ALGORITHM = 1 (). + */ + + if (part_field_array[0]->table->s->mysql_version >= 50503) + DBUG_RETURN(false); + if (!new_part_info || part_type != new_part_info->part_type || num_parts != new_part_info->num_parts || @@ -2495,12 +2505,10 @@ bool partition_info::has_same_partitioning(partition_info *new_part_info) /* Only if key_algorithm was not specified before and it is now set, - consider this as nothing was changed! - But if already set, consider it as a change, and force rebuild! + consider this as nothing was changed, and allow change without rebuild! */ - DBUG_ASSERT(new_part_info->key_algorithm != - partition_info::KEY_ALGORITHM_NONE); - if (key_algorithm != partition_info::KEY_ALGORITHM_NONE) + if (key_algorithm != partition_info::KEY_ALGORITHM_NONE || + new_part_info->key_algorithm == partition_info::KEY_ALGORITHM_NONE) DBUG_RETURN(false); DBUG_RETURN(true); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index a64520a298d..6850f5ada63 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2412,6 +2412,58 @@ end: return err; } + +/** + Add 'KEY' word, with optional 'ALGORTIHM = N'. + + @param fptr File to write to. + @param part_info partition_info holding the used key_algorithm + @param current_comment_start NULL, or comment string encapsulating the + PARTITION BY clause. + + @return Operation status. + @retval 0 Success + @retval != 0 Failure +*/ + +static int add_key_with_algorithm(File fptr, partition_info *part_info, + const char *current_comment_start) +{ + int err= 0; + err+= add_part_key_word(fptr, partition_keywords[PKW_KEY].str); + + /* + current_comment_start is given when called from SHOW CREATE TABLE, + Then only add ALGORITHM = 1, not the default 2 or non-set 0! + For .frm current_comment_start is NULL, then add ALGORITHM if != 0. + */ + if (part_info->key_algorithm == partition_info::KEY_ALGORITHM_51 || // SHOW + (!current_comment_start && // .frm + (part_info->key_algorithm != partition_info::KEY_ALGORITHM_NONE))) + { + /* If we already are within a comment, end that comment first. */ + if (current_comment_start) + err+= add_string(fptr, "*/ "); + err+= add_string(fptr, "/*!50531 "); + err+= add_part_key_word(fptr, partition_keywords[PKW_ALGORITHM].str); + err+= add_equal(fptr); + err+= add_space(fptr); + err+= add_int(fptr, part_info->key_algorithm); + err+= add_space(fptr); + err+= add_string(fptr, "*/ "); + if (current_comment_start) + { + /* Skip new line. */ + if (current_comment_start[0] == '\n') + current_comment_start++; + err+= add_string(fptr, current_comment_start); + err+= add_space(fptr); + } + } + return err; +} + + /* Generate the partition syntax from the partition data structure. Useful for support of generating defaults, SHOW CREATE TABLES @@ -2456,7 +2508,8 @@ char *generate_partition_syntax(partition_info *part_info, bool use_sql_alloc, bool show_partition_options, HA_CREATE_INFO *create_info, - Alter_info *alter_info) + Alter_info *alter_info, + const char *current_comment_start) { uint i,j, tot_num_parts, num_subparts; partition_element *part_elem; @@ -2490,18 +2543,8 @@ char *generate_partition_syntax(partition_info *part_info, err+= add_string(fptr, partition_keywords[PKW_LINEAR].str); if (part_info->list_of_part_fields) { - err+= add_part_key_word(fptr, partition_keywords[PKW_KEY].str); - if (part_info->key_algorithm != partition_info::KEY_ALGORITHM_NONE) - { - /* - Can't add a !50530 comment, since we are already within a comment! - */ - err+= add_part_key_word(fptr, partition_keywords[PKW_ALGORITHM].str); - err+= add_equal(fptr); - err+= add_space(fptr); - err+= add_int(fptr, part_info->key_algorithm); - err+= add_space(fptr); - } + err+= add_key_with_algorithm(fptr, part_info, + current_comment_start); err+= add_part_field_list(fptr, part_info->part_field_list); } else @@ -2541,19 +2584,9 @@ char *generate_partition_syntax(partition_info *part_info, err+= add_string(fptr, partition_keywords[PKW_LINEAR].str); if (part_info->list_of_subpart_fields) { - add_part_key_word(fptr, partition_keywords[PKW_KEY].str); - if (part_info->key_algorithm != partition_info::KEY_ALGORITHM_NONE) - { - /* - Can't add a !50530 comment, since we are already within a comment! - */ - err+= add_part_key_word(fptr, partition_keywords[PKW_ALGORITHM].str); - err+= add_equal(fptr); - err+= add_space(fptr); - err+= add_int(fptr, part_info->key_algorithm); - err+= add_space(fptr); - } - add_part_field_list(fptr, part_info->subpart_field_list); + err+= add_key_with_algorithm(fptr, part_info, + current_comment_start); + err+= add_part_field_list(fptr, part_info->subpart_field_list); } else err+= add_part_key_word(fptr, partition_keywords[PKW_HASH].str); diff --git a/sql/sql_partition.h b/sql/sql_partition.h index 998e4b25f0b..f232eaa0629 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -1,7 +1,7 @@ #ifndef SQL_PARTITION_INCLUDED #define SQL_PARTITION_INCLUDED -/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -268,7 +268,8 @@ char *generate_partition_syntax(partition_info *part_info, uint *buf_length, bool use_sql_alloc, bool show_partition_options, HA_CREATE_INFO *create_info, - Alter_info *alter_info); + Alter_info *alter_info, + const char *current_comment_start); #endif void create_partition_name(char *out, const char *in1, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 326f09e7955..4a6568b605a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1528,24 +1528,30 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, } #ifdef WITH_PARTITION_STORAGE_ENGINE { - /* - Partition syntax for CREATE TABLE is at the end of the syntax. - */ - uint part_syntax_len; - char *part_syntax; if (table->part_info && - (!table->part_info->is_auto_partitioned) && - ((part_syntax= generate_partition_syntax(table->part_info, + !((table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION) && + table->part_info->is_auto_partitioned)) + { + /* + Partition syntax for CREATE TABLE is at the end of the syntax. + */ + uint part_syntax_len; + char *part_syntax; + String comment_start; + table->part_info->set_show_version_string(&comment_start); + if ((part_syntax= generate_partition_syntax(table->part_info, &part_syntax_len, FALSE, show_table_options, - NULL, NULL)))) - { - table->part_info->set_show_version_string(packet); - if (packet->append(part_syntax, part_syntax_len) || - packet->append(STRING_WITH_LEN(" */"))) - error= 1; - my_free(part_syntax); + NULL, NULL, + comment_start.c_ptr()))) + { + packet->append(comment_start); + if (packet->append(part_syntax, part_syntax_len) || + packet->append(STRING_WITH_LEN(" */"))) + error= 1; + my_free(part_syntax); + } } } #endif diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8bbe29cb3cf..cf4d7a9d955 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1694,7 +1694,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) &syntax_len, TRUE, TRUE, lpt->create_info, - lpt->alter_info))) + lpt->alter_info, + NULL))) { DBUG_RETURN(TRUE); } @@ -1787,7 +1788,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) &syntax_len, TRUE, TRUE, lpt->create_info, - lpt->alter_info))) + lpt->alter_info, + NULL))) { error= 1; goto err; @@ -4082,7 +4084,8 @@ bool mysql_create_table_no_lock(THD *thd, &syntax_len, TRUE, TRUE, create_info, - alter_info))) + alter_info, + NULL))) goto err; part_info->part_info_string= part_syntax_buf; part_info->part_info_len= syntax_len; From eb3814b0b346a57a3ed0b79e10f2fe18515b8494 Mon Sep 17 00:00:00 2001 From: Shivji Kumar Jha Date: Fri, 15 Feb 2013 00:38:42 +0530 Subject: [PATCH 063/273] BUG#12359942- REPLICATION TEST FROM ENGINE SUITE RPL_ROW_UNTIL TIMES OUT post push fix: rpl_stm_until.test was disabled because of this bug. Enabled and fixed it. Removed a part of the test that was obsolete. It tested replication from 4.0 master to 5.0 slave. --- mysql-test/suite/rpl/r/rpl_stm_until.result | 11 -------- mysql-test/suite/rpl/t/disabled.def | 1 - mysql-test/suite/rpl/t/rpl_stm_until.test | 30 --------------------- 3 files changed, 42 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_stm_until.result b/mysql-test/suite/rpl/r/rpl_stm_until.result index a71746d7fba..00d54ae9f9d 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_until.result +++ b/mysql-test/suite/rpl/r/rpl_stm_until.result @@ -93,15 +93,4 @@ one 1 drop table t1; start slave; -include/rpl_reset.inc -flush logs; -stop slave; -reset slave; -start slave until master_log_file='master-bin.000001', master_log_pos=294 /* to stop right before DROP */; -include/wait_for_slave_sql_to_stop.inc -show tables /* t1 must exist */; -Tables_in_test -t1 -drop table t1; -stop slave; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index d33f85091ff..86ecbb09594 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -12,5 +12,4 @@ rpl_row_create_table : Bug#11759274 Feb 27 2010 andrei failed different way than earlier with bug#45576 rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock -rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out rpl_row_until @macosx : BUG#15965353 RPL.RPL_ROW_UNTIL FAILS ON PB2 , PLATFORM= MACOSX10.6 X86_64 MAX diff --git a/mysql-test/suite/rpl/t/rpl_stm_until.test b/mysql-test/suite/rpl/t/rpl_stm_until.test index 7f041ae5123..7a534be7335 100644 --- a/mysql-test/suite/rpl/t/rpl_stm_until.test +++ b/mysql-test/suite/rpl/t/rpl_stm_until.test @@ -183,36 +183,6 @@ connection slave; start slave; sync_with_master; - # Bug #47142 "slave start until" stops 1 event too late in 4.1 to 5.0 replication -# -# testing fixes that refine the start position of prior-5.0 master's event -# and by that provide correct execution of -# START SLAVE UNTIL ... master_log_pos= x; -# Keep the test at the end of the file because it manipulates with binlog files -# to substitute the genuine one with a prepared on 4.1 server. -# - ---source include/rpl_reset.inc - -connection master; -flush logs; -let $MYSQLD_DATADIR= `select @@datadir`; ---remove_file $MYSQLD_DATADIR/master-bin.000001 ---copy_file $MYSQL_TEST_DIR/std_data/bug47142_master-bin.000001 $MYSQLD_DATADIR/master-bin.000001 - -connection slave; -stop slave; -reset slave; -start slave until master_log_file='master-bin.000001', master_log_pos=294 /* to stop right before DROP */; ---source include/wait_for_slave_sql_to_stop.inc - -show tables /* t1 must exist */; - -# clean-up of Bug #47142 testing - -drop table t1; # drop on slave only, master does not have t1. -stop slave; - # End of tests --let $rpl_only_running_threads= 1 --source include/rpl_end.inc From 795b8acc2a50e9d47945841ce2c3f08d4ad9db03 Mon Sep 17 00:00:00 2001 From: Harin Vadodaria Date: Fri, 15 Feb 2013 12:35:54 +0530 Subject: [PATCH 064/273] Bug#16218104: MYSQL YASSL - LUCKY THIRTEEN: BREAKING THE TLS AND DTLS RECORD PROTOCOLS Description: In yassl, decryption phase in TLS protocol depends on type of padding. This patch removes this dependancy and makes error generation/decryption process independent of padding type. --- extra/yassl/include/yassl_error.hpp | 3 +- extra/yassl/include/yassl_types.hpp | 6 +- extra/yassl/src/handshake.cpp | 35 +++++ extra/yassl/src/yassl_error.cpp | 4 + extra/yassl/src/yassl_imp.cpp | 192 ++++++++++++++++++++++++---- 5 files changed, 215 insertions(+), 25 deletions(-) diff --git a/extra/yassl/include/yassl_error.hpp b/extra/yassl/include/yassl_error.hpp index 8efc7f72e87..5ce70c3ca70 100644 --- a/extra/yassl/include/yassl_error.hpp +++ b/extra/yassl/include/yassl_error.hpp @@ -53,7 +53,8 @@ enum YasslError { badVersion_error = 117, compress_error = 118, decompress_error = 119, - pms_version_error = 120 + pms_version_error = 120, + sanityCipher_error = 121 // !!!! add error message to .cpp !!!! diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index a9e22833eb1..14b33eb9129 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -220,7 +220,11 @@ const int DEFAULT_TIMEOUT = 500; // Default Session timeout in seconds const int MAX_RECORD_SIZE = 16384; // 2^14, max size by standard const int COMPRESS_EXTRA = 1024; // extra compression possible addition const int SESSION_FLUSH_COUNT = 256; // when to flush session cache - +const int MAX_PAD_SIZE = 256; // max TLS padding size +const int COMPRESS_CONSTANT = 13; // compression calculation constant +const int COMPRESS_UPPER = 55; // compression calculation numerator +const int COMPRESS_LOWER = 64; // compression calculation denominator +const int COMPRESS_DUMMY_SIZE = 64; // compression dummy round size typedef uint8 Cipher; // first byte is always 0x00 for SSLv3 & TLS diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index c7dbaf86071..4b1ed3d7fef 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -221,12 +221,45 @@ void buildSHA(SSL& ssl, Finished& fin, const opaque* sender) } +// sanity checks on encrypted message size +static int sanity_check_message(SSL& ssl, uint msgSz) +{ + uint minSz = 0; + + if (ssl.getSecurity().get_parms().cipher_type_ == block) { + uint blockSz = ssl.getCrypto().get_cipher().get_blockSize(); + if (msgSz % blockSz) + return -1; + + minSz = ssl.getSecurity().get_parms().hash_size_ + 1; // pad byte too + if (blockSz > minSz) + minSz = blockSz; + + if (ssl.isTLSv1_1()) + minSz += blockSz; // explicit IV + } + else { // stream + minSz = ssl.getSecurity().get_parms().hash_size_; + } + + if (msgSz < minSz) + return -1; + + return 0; +} + + // decrypt input message in place, store size in case needed later void decrypt_message(SSL& ssl, input_buffer& input, uint sz) { input_buffer plain(sz); opaque* cipher = input.get_buffer() + input.get_current(); + if (sanity_check_message(ssl, sz) != 0) { + ssl.SetError(sanityCipher_error); + return; + } + ssl.useCrypto().use_cipher().decrypt(plain.get_buffer(), cipher, sz); memcpy(cipher, plain.get_buffer(), sz); ssl.useSecurity().use_parms().encrypt_size_ = sz; @@ -774,6 +807,8 @@ int DoProcessReply(SSL& ssl) return 0; } decrypt_message(ssl, buffer, hdr.length_); + if (ssl.GetError()) + return 0; } mySTL::auto_ptr msg(mf.CreateObject(hdr.type_)); diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index b9fccf782f0..2cefd27d428 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -144,6 +144,10 @@ void SetErrorString(YasslError error, char* buffer) strncpy(buffer, "bad PreMasterSecret version error", max); break; + case sanityCipher_error : + strncpy(buffer, "sanity check on cipher text size error", max); + break; + // openssl errors case SSL_ERROR_WANT_READ : strncpy(buffer, "the read operation would block", max); diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index 66a173bece8..692190d3a75 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -972,30 +972,193 @@ output_buffer& operator<<(output_buffer& output, const Data& data) } +// check all bytes for equality +static int constant_compare(const byte* a, const byte* b, int len) +{ + int good = 0; + int bad = 0; + + for (int i = 0; i < len; i++) { + if (a[i] == b[i]) + good++; + else + bad++; + } + + if (good == len) + return 0; + else + return 0 - bad; // failure +} + + +// check bytes for pad value +static int pad_check(const byte* input, byte pad, int len) +{ + int good = 0; + int bad = 0; + + for (int i = 0; i < len; i++) { + if (input[i] == pad) + good++; + else + bad++; + } + + if (good == len) + return 0; + else + return 0 - bad; // failure +} + + +// get number of compression rounds +static inline int get_rounds(int pLen, int padLen, int t) +{ + int roundL1 = 1; // round ups + int roundL2 = 1; + + int L1 = COMPRESS_CONSTANT + pLen - t; + int L2 = COMPRESS_CONSTANT + pLen - padLen - 1 - t; + + L1 -= COMPRESS_UPPER; + L2 -= COMPRESS_UPPER; + + if ( (L1 % COMPRESS_LOWER) == 0) + roundL1 = 0; + if ( (L2 % COMPRESS_LOWER) == 0) + roundL2 = 0; + + L1 /= COMPRESS_LOWER; + L2 /= COMPRESS_LOWER; + + L1 += roundL1; + L2 += roundL2; + + return L1 - L2; +} + + +// do compression rounds on dummy data +static inline void compress_rounds(SSL& ssl, int rounds, const byte* dummy) +{ + if (rounds) { + Digest* digest = NULL; + + MACAlgorithm ma = ssl.getSecurity().get_parms().mac_algorithm_; + if (ma == sha) + digest = NEW_YS SHA; + else if (ma == md5) + digest = NEW_YS MD5; + else if (ma == rmd) + digest = NEW_YS RMD; + else + return; + + for (int i = 0; i < rounds; i++) + digest->update(dummy, COMPRESS_LOWER); + + ysDelete(digest); + } +} + + +// timing resistant pad verification +static int timing_verify(SSL& ssl, const byte* input, int padLen, int t, + int pLen) +{ + byte verify[SHA_LEN]; + byte dummy[MAX_PAD_SIZE]; + + memset(dummy, 1, sizeof(dummy)); + + if ( (t + padLen + 1) > pLen) { + pad_check(dummy, (byte)padLen, MAX_PAD_SIZE); + if (ssl.isTLS()) + TLS_hmac(ssl, verify, input, pLen - t, application_data, 1); + else + hmac(ssl, verify, input, pLen - t, application_data, 1); + constant_compare(verify, input + pLen - t, t); + + return -1; + } + + if (pad_check(input + pLen - (padLen + 1), (byte)padLen, padLen + 1) != 0) { + pad_check(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1); + if (ssl.isTLS()) + TLS_hmac(ssl, verify, input, pLen - t, application_data, 1); + else + hmac(ssl, verify, input, pLen - t, application_data, 1); + constant_compare(verify, input + pLen - t, t); + + return -1; + } + + pad_check(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1); + if (ssl.isTLS()) + TLS_hmac(ssl, verify, input, pLen - padLen - 1 - t, application_data,1); + else + hmac(ssl, verify, input, pLen - padLen - 1 - t, application_data, 1); + + compress_rounds(ssl, get_rounds(pLen, padLen, t), dummy); + + if (constant_compare(verify, input + (pLen - padLen - 1 - t), t) != 0) + return -1; + + return 0; +} + + // Process handler for Data void Data::Process(input_buffer& input, SSL& ssl) { int msgSz = ssl.getSecurity().get_parms().encrypt_size_; int pad = 0, padSz = 0; int ivExtra = 0; + int digestSz = ssl.getCrypto().get_digest().get_digestSize(); + const byte* rawData = input.get_buffer() + input.get_current(); + opaque verify[SHA_LEN]; if (ssl.getSecurity().get_parms().cipher_type_ == block) { if (ssl.isTLSv1_1()) // IV ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); pad = *(input.get_buffer() + input.get_current() + msgSz -ivExtra - 1); padSz = 1; + + if (ssl.isTLS()) { + if (timing_verify(ssl, rawData, pad,digestSz, msgSz-ivExtra) != 0) { + ssl.SetError(verify_error); + return; + } + } + else { // SSLv3, some don't do this padding right + int sz3 = msgSz - digestSz - pad - 1; + hmac(ssl, verify, rawData, sz3, application_data, true); + if (constant_compare(verify, rawData + sz3, digestSz) != 0) { + ssl.SetError(verify_error); + return; + } + } } - int digestSz = ssl.getCrypto().get_digest().get_digestSize(); + else { // stream + int streamSz = msgSz - digestSz; + if (ssl.isTLS()) + TLS_hmac(ssl, verify, rawData, streamSz, application_data, true); + else + hmac(ssl, verify, rawData, streamSz, application_data, true); + if (constant_compare(verify, rawData + streamSz, digestSz) != 0) { + ssl.SetError(verify_error); + return; + } + } + int dataSz = msgSz - ivExtra - digestSz - pad - padSz; - opaque verify[SHA_LEN]; if (dataSz < 0) { ssl.SetError(bad_input); return; } - const byte* rawData = input.get_buffer() + input.get_current(); - // read data if (dataSz) { // could be compressed if (ssl.CompressionOn()) { @@ -1013,27 +1176,10 @@ void Data::Process(input_buffer& input, SSL& ssl) input.read(data->get_buffer(), dataSz); data->add_size(dataSz); } - - if (ssl.isTLS()) - TLS_hmac(ssl, verify, rawData, dataSz, application_data, true); - else - hmac(ssl, verify, rawData, dataSz, application_data, true); } - // read mac and skip fill - opaque mac[SHA_LEN]; - input.read(mac, digestSz); - input.set_current(input.get_current() + pad + padSz); - - // verify - if (dataSz) { - if (memcmp(mac, verify, digestSz)) { - ssl.SetError(verify_error); - return; - } - } - else - ssl.get_SEQIncrement(true); // even though no data, increment verify + // advance past mac and fill + input.set_current(input.get_current() + digestSz + pad + padSz); } From 776b5697958381d751bc8c45ab7413cece2ed7f7 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Fri, 15 Feb 2013 16:01:37 +0400 Subject: [PATCH 065/273] Bug#16056537: MYSQLD CRASHES IN ITEM_FUNC_GET_USER_VAR::FIX_LENGTH_AND_DEC() The technical problem was that THD::user_var_events_alloc was reset to NULL from a valid value when a stored program is executed during the PREPARE statement. The user visible problem was that the server crashed if user issued a PREPARE statement using some combination of stored functions and user variables. The fix is to restore THD::user_var_events_alloc to the original value. This is a minimal fix for 5.5. More proper patch has been already implemented for 5.6+. It avoids evaluation of stored functions for the PREPARE phase. From the user point of view, this bug is a regression, introduced by the patch for WL2649 (Number-to-string conversions), revid: bar@mysql.com-20100211041725-ijbox021olab82nv However, the code resetting THD::user_var_events_alloc exists even in 5.1. The WL just changed the way arguments are converted to strings and the bug became visible. --- sql/sp_head.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index f20c205886d..552a44c7a96 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1427,6 +1427,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success) Will write this SP statement into binlog separately. TODO: consider changing the condition to "not inside event union". */ + MEM_ROOT *user_var_events_alloc_saved= thd->user_var_events_alloc; if (thd->locked_tables_mode <= LTM_LOCK_TABLES) thd->user_var_events_alloc= thd->mem_root; @@ -1442,7 +1443,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success) if (thd->locked_tables_mode <= LTM_LOCK_TABLES) { reset_dynamic(&thd->user_var_events); - thd->user_var_events_alloc= NULL;//DEBUG + thd->user_var_events_alloc= user_var_events_alloc_saved; } /* we should cleanup free_list and memroot, used by instruction */ From 7e8c887786dc76c0057acb5a73ff4355a4ea87b1 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Fri, 15 Feb 2013 21:57:35 +0000 Subject: [PATCH 066/273] BUG#13545447: RPL_ROTATE_LOGS FAILS DUE TO CONCURRENCY ISSUES IN REP. CODE In method mysql_binlog_send, right after detecting a EOF in the read event loop, and before deciding if we should change to a new binlog file there is a execution window where new events can be written to the binlog and a rotation can happen. When reaching the test, the function will then change to a new binlog file ignoring all the events written in this window. This will result in events not being replicated. Only when the binlog is detected as deactivated in the event loop of the dump thread, can we really know that no more events remain. For this reason, this test is now made under the log lock in the beginning of the event loop when reading the events. --- sql/log_event.cc | 8 +++++++- sql/log_event.h | 30 ++++++++++++++++++++++++++++-- sql/sql_repl.cc | 21 +++++++++++++++++---- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 8abd95bba0a..7d2a80fdaf9 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1012,7 +1012,9 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length) */ int Log_event::read_log_event(IO_CACHE* file, String* packet, - pthread_mutex_t* log_lock) + pthread_mutex_t* log_lock, + const char *log_file_name_arg, + bool* is_binlog_active) { ulong data_len; int result=0; @@ -1021,6 +1023,10 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet, if (log_lock) pthread_mutex_lock(log_lock); + + if (log_file_name_arg) + *is_binlog_active= mysql_bin_log.is_active(log_file_name_arg); + if (my_b_read(file, (uchar*) buf, sizeof(buf))) { /* diff --git a/sql/log_event.h b/sql/log_event.h index 4c8580eb2fd..4fabb83aac7 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -945,8 +945,34 @@ public: pthread_mutex_t* log_lock, const Format_description_log_event *description_event); + + /** + Reads an event from a binlog or relay log. Used by the dump thread + this method reads the event into a raw buffer without parsing it. + + @Note If mutex is 0, the read will proceed without mutex. + + @Note If a log name is given than the method will check if the + given binlog is still active. + + @param[in] file log file to be read + @param[out] packet packet to hold the event + @param[in] lock the lock to be used upon read + @param[in] log_file_name_arg the log's file name + @param[out] is_binlog_active is the current log still active + + @retval 0 success + @retval LOG_READ_EOF end of file, nothing was read + @retval LOG_READ_BOGUS malformed event + @retval LOG_READ_IO io error while reading + @retval LOG_READ_MEM packet memory allocation failed + @retval LOG_READ_TRUNC only a partial event could be read + @retval LOG_READ_TOO_LARGE event too large + */ static int read_log_event(IO_CACHE* file, String* packet, - pthread_mutex_t* log_lock); + pthread_mutex_t* log_lock, + const char *log_file_name_arg= NULL, + bool* is_binlog_active= false); /* init_show_field_list() prepares the column names and types for the output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index c15382c669e..6894eaa48b5 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -548,7 +548,10 @@ impossible position"; while (!net->error && net->vio != 0 && !thd->killed) { my_off_t prev_pos= pos; - while (!(error = Log_event::read_log_event(&log, packet, log_lock))) + bool is_active_binlog= false; + while (!(error= Log_event::read_log_event(&log, packet, log_lock, + log_file_name, + &is_active_binlog))) { prev_pos= my_b_tell(&log); #ifndef DBUG_OFF @@ -624,6 +627,13 @@ impossible position"; error=LOG_READ_EOF; } + DBUG_EXECUTE_IF("wait_after_binlog_EOF", + { + const char act[]= "now wait_for signal.rotate_finished"; + DBUG_ASSERT(!debug_sync_set_action(current_thd, + STRING_WITH_LEN(act))); + };); + /* TODO: now that we are logging the offset, check to make sure the recorded offset and the actual match. @@ -634,8 +644,11 @@ impossible position"; if (test_for_non_eof_log_read_errors(error, &errmsg)) goto err; - if (!(flags & BINLOG_DUMP_NON_BLOCK) && - mysql_bin_log.is_active(log_file_name)) + /* + We should only move to the next binlog when the last read event + came from a already deactivated binlog. + */ + if (!(flags & BINLOG_DUMP_NON_BLOCK) && is_active_binlog) { /* Block until there is more data in the log From 5fcf40a2aa28850ec84ed26f44aa8258c9f7bf9b Mon Sep 17 00:00:00 2001 From: Shivji Kumar Jha Date: Sun, 17 Feb 2013 01:42:28 +0530 Subject: [PATCH 067/273] BUG#15965353- RPL.RPL_ROW_UNTIL FAILS ON PB2, PLATFORM= MACOSX10.6 X86_64 MAX Problem: The test was failing on pb2's mac machine because it was not cleaned up properly. The test checks if the command 'start slave until' throws a proper error when issued with a wrong number/type of parameters. After this,the replication stream was stopped using the include file 'rpl_end.inc'. The errors thrown earlier left the slave in an inconsistent state to be closed by the include file which was caught by the mac machine. Fix: Started slave by invoking start_slave.inc to have a working slave before calling rpl_reset.inc Problem: The test file was not in a good shape. It tested start slave until relay log file/pos combination wrongly. A couple of commands were executed at master and replicated at slave. Next, the coordinates in terms of relay log file and pos were noted down followed by reset slave and start slave until saved relay log file/pos. Reset slave deletes all relay log files and makes the slave forget its replication position. So, using the saved coordiantes after reset slave is wrong. Fix: Split the test in two parts: a) Test for start slave until master log file/pos and checking for correct errors in the failure scenarios. b) Test for start slave until relay log file/pos. Problem: The variables auto_increment_increment and auto_increment_offset were set in the the include file rpl_init.inc. This was only configured for some connections that are rarely used by test cases, so likely that it will cause confusion. If replication tests want to setup these variables they should do so explicitly. Fix: a) Removed code to set the variables auto_increment_increment and auto_increment_offset in the include file. b) Updated tests files using the same. --- mysql-test/include/rpl_init.inc | 3 - .../rpl/r/rpl_circular_for_4_hosts.result | 12 +++ mysql-test/suite/rpl/r/rpl_row_until.result | 22 ++++-- mysql-test/suite/rpl/t/disabled.def | 1 - .../suite/rpl/t/rpl_circular_for_4_hosts.test | 12 +++ mysql-test/suite/rpl/t/rpl_row_until.test | 75 +++++++++++++------ 6 files changed, 90 insertions(+), 35 deletions(-) diff --git a/mysql-test/include/rpl_init.inc b/mysql-test/include/rpl_init.inc index 3cf78dc2979..8325b2937b6 100644 --- a/mysql-test/include/rpl_init.inc +++ b/mysql-test/include/rpl_init.inc @@ -7,7 +7,6 @@ # well as extra connections server_1_1, server_2_1, ..., # server_N_1. server_I and server_I_1 are connections to the same # server. -# - Sets up @@auto_increment_increment and @@auto_increment_increment. # - Verifies that @@server_id of all servers are different. # - Calls RESET MASTER, RESET SLAVE, USE test, CHANGE MASTER, START SLAVE. # - Sets the connection to server_1 before exiting. @@ -179,8 +178,6 @@ while ($_rpl_server) RESET MASTER; RESET SLAVE; } - eval SET auto_increment_increment= $rpl_server_count; - eval SET auto_increment_offset= $_rpl_server; --dec $_rpl_server } diff --git a/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result index 412021d6446..66974762ebc 100644 --- a/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result +++ b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result @@ -1,6 +1,18 @@ *** Set up circular replication on four servers *** include/rpl_init.inc [topology=1->2->3->4->1] +[connection server_4] +SET auto_increment_increment= 4; +SET auto_increment_offset= 4; +[connection server_3] +SET auto_increment_increment= 4; +SET auto_increment_offset= 3; +[connection server_2] +SET auto_increment_increment= 4; +SET auto_increment_offset= 2; +[connection server_1] +SET auto_increment_increment= 4; +SET auto_increment_offset= 1; *** Preparing data *** CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b VARCHAR(100), c INT NOT NULL, PRIMARY KEY(a)) ENGINE=MyISAM; CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT, b VARCHAR(100), c INT NOT NULL, PRIMARY KEY(a)) ENGINE=InnoDB; diff --git a/mysql-test/suite/rpl/r/rpl_row_until.result b/mysql-test/suite/rpl/r/rpl_row_until.result index be8f17c6f01..5ab39a00946 100644 --- a/mysql-test/suite/rpl/r/rpl_row_until.result +++ b/mysql-test/suite/rpl/r/rpl_row_until.result @@ -27,12 +27,6 @@ n 3 4 include/check_slave_param.inc [Exec_Master_Log_Pos] -include/wait_for_slave_sql_to_stop.inc -SELECT * FROM t2; -n -1 -2 -include/check_slave_param.inc [Exec_Master_Log_Pos] START SLAVE; include/wait_for_slave_to_start.inc include/stop_slave.inc @@ -54,6 +48,18 @@ START SLAVE; START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=MASTER_LOG_POS; Warnings: Note 1254 Slave is already running -include/stop_slave.inc -RESET SLAVE; +include/start_slave.inc +Warnings: +Note 1254 Slave is already running +include/rpl_reset.inc +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +include/stop_slave_sql.inc +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +include/sync_slave_io_with_master.inc +include/wait_for_slave_sql_to_stop.inc +include/assert.inc [table t1 should have two rows.] +include/start_slave.inc +DROP TABLE t1; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index 86ecbb09594..d3339c1bfe8 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -12,4 +12,3 @@ rpl_row_create_table : Bug#11759274 Feb 27 2010 andrei failed different way than earlier with bug#45576 rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock -rpl_row_until @macosx : BUG#15965353 RPL.RPL_ROW_UNTIL FAILS ON PB2 , PLATFORM= MACOSX10.6 X86_64 MAX diff --git a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test index 1380b3d97cf..f1d42089869 100644 --- a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test +++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test @@ -20,6 +20,18 @@ --source include/rpl_init.inc --echo +#set auto inc variables at each server +--let $_rpl_server= $rpl_server_count +while ($_rpl_server) +{ + --let $rpl_connection_name= server_$_rpl_server + --source include/rpl_connection.inc + eval SET auto_increment_increment= $rpl_server_count; + eval SET auto_increment_offset= $_rpl_server; + + --dec $_rpl_server +} + # Preparing data. --echo *** Preparing data *** --connection server_1 diff --git a/mysql-test/suite/rpl/t/rpl_row_until.test b/mysql-test/suite/rpl/t/rpl_row_until.test index eaa99c29694..1e5bc341b1a 100644 --- a/mysql-test/suite/rpl/t/rpl_row_until.test +++ b/mysql-test/suite/rpl/t/rpl_row_until.test @@ -2,7 +2,13 @@ -- source include/have_binlog_format_row.inc -- source include/master-slave.inc -# Note: The test is dependent on binlog positions +############################################################################## +# The test is dependent on binlog positions. The test is divided into two +# sections. The first section checks START SLAVE UNTIL MASTER_LOG_FILE = +# 'log_name', MASTER_LOG_POS = log_pos followed by a couple of failure +# scenarios. The second section checks START SLAVE UNTIL RELAY_LOG_FILE = +# 'log_name', RELAY_LOG_POS = log_pos. +############################################################################## # Create some events on master connection master; @@ -22,14 +28,8 @@ let $master_pos_create_t2= query_get_value(SHOW BINLOG EVENTS, Pos, 8); INSERT INTO t2 VALUES (1),(2); save_master_pos; # Save master log position for query INSERT INTO t2 VALUES (1),(2); -let $master_pos_insert1_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 12); -sync_slave_with_master; +let $master_pos_insert1_t2= query_get_value(SHOW MASTER STATUS, Position, 1); -# Save relay log position for query INSERT INTO t2 VALUES (1),(2); -let $relay_log_file= query_get_value(show slave status, Relay_Log_File,1); -let $relay_pos_insert1_t2= query_get_value(show slave status, Relay_Log_Pos, 1); - -connection master; INSERT INTO t2 VALUES (3),(4); DROP TABLE t2; # Save master log position for query INSERT INTO t2 VALUES (1),(2); @@ -68,17 +68,6 @@ SELECT * FROM t1; --let $slave_param_value= $master_pos_drop_t1 --source include/check_slave_param.inc -# Try replicate all up to and not including the second insert to t2; ---disable_query_log -eval START SLAVE UNTIL RELAY_LOG_FILE='$relay_log_file', RELAY_LOG_POS=$relay_pos_insert1_t2; ---enable_query_log ---source include/wait_for_slave_sql_to_stop.inc -SELECT * FROM t2; - ---let $slave_param= Exec_Master_Log_Pos ---let $slave_param_value= $master_pos_insert1_t2 ---source include/check_slave_param.inc - # clean up START SLAVE; --source include/wait_for_slave_to_start.inc @@ -119,9 +108,49 @@ START SLAVE; --replace_result 740 MASTER_LOG_POS START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=740; ---source include/stop_slave.inc -# Clear slave IO error. -RESET SLAVE; +--source include/start_slave.inc ---let $rpl_only_running_threads= 1 +############################################################################## +# The second section - checks START SLAVE UNTIL RELAY_LOG_FILE =# 'log_name', +# RELAY_LOG_POS = log_pos. This section of the test does the following: +# 1) At master, create a table and inserts a value. Let slave replicate this. +# 2) Stop slave sql thread. +# 3) Insert some more values at master. Note that io thread copies this insert +# 4) Use start slave until to start the sql thread and check if it +# stops at the correct position. +############################################################################## + +--source include/rpl_reset.inc + +--connection master +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); + +--sync_slave_with_master +--source include/stop_slave_sql.inc + +--connection master +INSERT INTO t1 VALUES (2); +--let $master_log_pos= query_get_value(SHOW MASTER STATUS, Position, 1) +INSERT INTO t1 VALUES (3); + +--source include/sync_slave_io_with_master.inc + +--let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File,1) +--source include/get_relay_log_pos.inc + +--disable_query_log +--eval start slave until relay_log_file='$relay_log_file', relay_log_pos=$relay_log_pos +--enable_query_log +--source include/wait_for_slave_sql_to_stop.inc + +--let $assert_cond= COUNT(*) = 2 FROM t1 +--let $assert_text= table t1 should have two rows. +--source include/assert.inc + +#cleanup +--source include/start_slave.inc +--connection master +DROP TABLE t1; +--sync_slave_with_master --source include/rpl_end.inc From 66eeaad6b8406105c6bef41f0b42c719587c1ffd Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Feb 2013 11:13:48 +0530 Subject: [PATCH 068/273] From f144e0fead306c31a4bf3767dad6efd4b404afbd Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Mon, 18 Feb 2013 11:12:24 +0100 Subject: [PATCH 069/273] =?UTF-8?q?BUG#13545447:=20RPL=5FROTATE=5FLOGS=20F?= =?UTF-8?q?AILS=20DUE=20TO=20CONCURRENCY=20ISSUES=20IN=20REP.=20CODE=20Pos?= =?UTF-8?q?t-push=20fix,=20broken=20build:=20sql/rpl=5Fmaster.cc:1049:70:?= =?UTF-8?q?=20error:=20converting=20=E2=80=98false=E2=80=99=20to=20pointer?= =?UTF-8?q?=20type=20=E2=80=98bool*=E2=80=99=20[-Werror=3Dconversion-null]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/log_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/log_event.h b/sql/log_event.h index 72a269304ca..84564877974 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1024,7 +1024,7 @@ public: static int read_log_event(IO_CACHE* file, String* packet, mysql_mutex_t* log_lock, const char *log_file_name_arg= NULL, - bool* is_binlog_active= false); + bool* is_binlog_active= NULL); /* init_show_field_list() prepares the column names and types for the output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG From 4061d719ec81d366ec054990c0e1850e830046fc Mon Sep 17 00:00:00 2001 From: Anirudh Mangipudi Date: Mon, 18 Feb 2013 19:13:06 +0530 Subject: [PATCH 070/273] Bug #12546953 "SHOW VARIABLES LIKE 'DATADIR';" RETURN EMPTY. Problem: =========================================================== If mysqld daemon is started without a --datadir option option, and we issue the SHOW VARIABLES LIKE 'DATADIR';SQL command at the client it returns an empty path. This is because mysql_real_data_home_ptr is being reset to NULL by Sys_var_charptr constructor call when the datadir is not given either through configuration file (no-defaults) or through mysqld parameters. Solution: =========================================================== mysql_real_data_home is an array which stores the path of the datadir and mysql_real_data_home_ptr is the pointer to it. The pointer is being set to NULL at the Sys_datadir, which is of type Sys_var_charptr, constructor call. This is because at Sys_datadir call the def_val parameter was being passed with DEFAULT(0) which is now replaced with DEFAULT(mysql_real_data_home). The patch has been tested manually as it is not possible to start mtr without a default config file. --- sql/sys_vars.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 9e79cdcb6f3..2430a54ffd7 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -659,7 +659,7 @@ static Sys_var_ulong Sys_connect_timeout( static Sys_var_charptr Sys_datadir( "datadir", "Path to the database root directory", READ_ONLY GLOBAL_VAR(mysql_real_data_home_ptr), - CMD_LINE(REQUIRED_ARG, 'h'), IN_FS_CHARSET, DEFAULT(0)); + CMD_LINE(REQUIRED_ARG, 'h'), IN_FS_CHARSET, DEFAULT(mysql_real_data_home)); #ifndef DBUG_OFF static Sys_var_dbug Sys_dbug( From e8e63d463fb55c8ad8ae6772aeb5432653d56ca3 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 18 Feb 2013 17:02:26 +0000 Subject: [PATCH 071/273] BUG#13545447: RPL_ROTATE_LOGS FAILS DUE TO CONCURRENCY ISSUES IN REP. CODE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post-push fix, broken build: sql/rpl_master.cc:1049:70: error: converting ‘false’ to pointer type ‘bool*’ [-Werror=conversion-null] --- sql/log_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/log_event.h b/sql/log_event.h index 4fabb83aac7..63b31454011 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -972,7 +972,7 @@ public: static int read_log_event(IO_CACHE* file, String* packet, pthread_mutex_t* log_lock, const char *log_file_name_arg= NULL, - bool* is_binlog_active= false); + bool* is_binlog_active= NULL); /* init_show_field_list() prepares the column names and types for the output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG From 85c299dd985e22d74a52b071f0577e39b338bc79 Mon Sep 17 00:00:00 2001 From: Shivji Kumar Jha Date: Tue, 19 Feb 2013 01:58:57 +0530 Subject: [PATCH 072/273] BUG#15965353- RPL.RPL_ROW_UNTIL FAILS ON PB2, PLATFORM= MACOSX10.6 X86_64 MAX post push fix --- mysql-test/suite/rpl/r/rpl_row_until.result | 2 ++ mysql-test/suite/rpl/t/rpl_row_until.test | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_row_until.result b/mysql-test/suite/rpl/r/rpl_row_until.result index 26f858c3d56..a09d44227a3 100644 --- a/mysql-test/suite/rpl/r/rpl_row_until.result +++ b/mysql-test/suite/rpl/r/rpl_row_until.result @@ -45,6 +45,8 @@ ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UN START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=MASTER_LOG_POS; ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=MASTER_LOG_POS; +include/stop_slave.inc +RESET SLAVE; include/start_slave.inc include/rpl_reset.inc CREATE TABLE t1 (a INT); diff --git a/mysql-test/suite/rpl/t/rpl_row_until.test b/mysql-test/suite/rpl/t/rpl_row_until.test index 22571000dd4..6b8f6183cc7 100644 --- a/mysql-test/suite/rpl/t/rpl_row_until.test +++ b/mysql-test/suite/rpl/t/rpl_row_until.test @@ -108,6 +108,8 @@ START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=561; --replace_result 740 MASTER_LOG_POS START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=740; +--source include/stop_slave.inc +RESET SLAVE; --source include/start_slave.inc ############################################################################## From 8ea6ed92eba894ae297c11f345614cfd69225603 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Feb 2013 10:55:55 +0530 Subject: [PATCH 073/273] From c40136542310982fd365e53f927b5a929f564b3e Mon Sep 17 00:00:00 2001 From: Harin Vadodaria Date: Tue, 19 Feb 2013 12:17:31 +0530 Subject: [PATCH 074/273] Bug#16235681: TURN OFF DEFAULT COMPRESSION WHILE USING OPENSSL Description: Specify preference to disable compression while using OpenSSL library. OpenSSL uses zlib compression by default which may lead to some problems. --- vio/viossl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vio/viossl.c b/vio/viossl.c index 0651fd8b7a3..143d108d3d7 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -198,6 +198,9 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout, SSL_clear(ssl); SSL_SESSION_set_timeout(SSL_get_session(ssl), timeout); SSL_set_fd(ssl, vio->sd); +#ifndef HAVE_YASSL + SSL_set_options(ssl, SSL_OP_NO_COMPRESSION); +#endif if (connect_accept_func(ssl) < 1) { From 4d494b17264eb93068b02b239c2f76b51920e0c4 Mon Sep 17 00:00:00 2001 From: Sujatha Sivakumar Date: Tue, 19 Feb 2013 14:31:11 +0530 Subject: [PATCH 075/273] Bug#11746817:MYSQL_INSTALL_DB CREATES WILDCARD GRANTS WHEN HOST HAS '_' IN THE HOSTNAME Problem: ======= '_' and '%' are treated as a wildcards by the ACL code and this is documented in the manual. The problem with mysql_install_db is that it does not take this into account when creating the initial GRANT tables: --- cut --- REPLACE INTO tmp_user SELECT @current_hostname,'root','','Y', 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','', 0,0,0,0 FROM dual WHERE LOWER( @current_hostname) != 'localhost'; --- cut --- If @current_hostname contains any wildcard characters, then a wildcard entry will be defined for the 'root' user, which is a flaw. Analysis: ======== As per the bug description when we have a hostname with a wildcard character in it, it allows clients from several other hosts with similar name pattern to connect to the server as root. For example, if the hostname is like 'host_.com' then the same name is logged in mysql.user table. This allows 'root' users from other hosts like 'host1.com', 'host2.com' ... to connect to the server as root user. While creating the intial GRANT tables we do not have a check for wildcard characters in hostname. Fix: === As part of fix escape character "\" is added before wildcard character to make it a plain character, so that the one and only host with the exact name will be able to connect to the server. scripts/mysql_system_tables_data.sql: while creating default users get the hostname and replace the wildcard characters within the hostname after escaping them. --- scripts/mysql_system_tables_data.sql | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/mysql_system_tables_data.sql b/scripts/mysql_system_tables_data.sql index e82d5412d75..7203e250656 100644 --- a/scripts/mysql_system_tables_data.sql +++ b/scripts/mysql_system_tables_data.sql @@ -1,4 +1,4 @@ --- Copyright (c) 2007 MySQL AB, 2008 Sun Microsystems, Inc. +-- Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. -- Use is subject to license terms. -- -- This program is free software; you can redistribute it and/or modify @@ -21,7 +21,12 @@ -- When setting up a "cross bootstrap" database (e.g., creating data on a Unix -- host which will later be included in a Windows zip file), any lines -- containing "@current_hostname" are filtered out by mysql_install_db. -set @current_hostname= @@hostname; + +-- Get the hostname, if the hostname has any wildcard character like "_" or "%" +-- add escape character in front of wildcard character to convert "_" or "%" to +-- a plain character +SET @get_hostname= @@hostname; +SELECT REPLACE((SELECT REPLACE(@get_hostname,'_','\_')),'%','\%') INTO @current_hostname; -- Fill "db" table with default grants for anyone to @@ -33,10 +38,9 @@ INSERT INTO db SELECT * FROM tmp_db WHERE @had_db_table=0; DROP TABLE tmp_db; --- Fill "users" table with default users allowing root access --- from local machine if "users" table didn't exist before +-- Fill "user" table with default users allowing root access +-- from local machine if "user" table didn't exist before CREATE TEMPORARY TABLE tmp_user LIKE user; -set @current_hostname= @@hostname; INSERT INTO tmp_user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); REPLACE INTO tmp_user SELECT @current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0 FROM dual WHERE LOWER( @current_hostname) != 'localhost'; REPLACE INTO tmp_user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); From 6ca27ddec034eeb7f169b3959207a8c4dd1691ee Mon Sep 17 00:00:00 2001 From: Satya Bodapati Date: Wed, 20 Feb 2013 18:25:18 +0530 Subject: [PATCH 076/273] Testcase fix for BUG#14147491 The random failure will be fixed by Bug#16263506 and this patch Approved by Marko. rb#1988 --- .../suite/innodb/r/innodb_bug14147491.result | 19 ++++++-- .../suite/innodb/t/innodb_bug14147491.test | 46 +++++++++++++++---- storage/innobase/buf/buf0buf.c | 4 ++ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb_bug14147491.result b/mysql-test/suite/innodb/r/innodb_bug14147491.result index 6279f85f676..ea7c303624b 100644 --- a/mysql-test/suite/innodb/r/innodb_bug14147491.result +++ b/mysql-test/suite/innodb/r/innodb_bug14147491.result @@ -4,14 +4,25 @@ CALL mtr.add_suppression("InnoDB: Warning: database page corruption or a failed" CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB; INSERT INTO t1 (b) VALUES ('corrupt me'); INSERT INTO t1 (b) VALUES ('corrupt me'); -# Restart server to flush buffers +# Write file to make mysql-test-run.pl expect the "crash", but don't +# start it until it's told to +# We give 30 seconds to do a clean shutdown because we do not want +# to redo apply the pages of t1.ibd at the time of recovery. +# We want SQL to initiate the first access to t1.ibd. +# Wait until disconnected. +# Backup the t1.ibd before corrupting # Corrupt the table Munged a string. Munged a string. -# Write file to make mysql-test-run.pl expect crash and restart +# Write file to make mysql-test-run.pl start up the server again +SET DEBUG = '+d,innodb_page_corruption_retries'; +# Write file to make mysql-test-run.pl expect the "crash", but don't +# start it until it's told to +# The below SELECT query will crash the server because some pages +# on the disk are corrupted SELECT * FROM t1; ERROR HY000: Lost connection to MySQL server during query -# Turn on reconnect -# Wait for server to fully start +# Restore the original t1.ibd +# Write file to make mysql-test-run.pl start up the server again # Cleanup DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb_bug14147491.test b/mysql-test/suite/innodb/t/innodb_bug14147491.test index ee3519c53fc..8758631c344 100644 --- a/mysql-test/suite/innodb/t/innodb_bug14147491.test +++ b/mysql-test/suite/innodb/t/innodb_bug14147491.test @@ -10,6 +10,8 @@ source include/not_crashrep.inc; source include/not_embedded.inc; # Require InnoDB source include/have_innodb.inc; +# Require Debug for SET DEBUG +source include/have_debug.inc; CALL mtr.add_suppression("InnoDB: Error: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts"); CALL mtr.add_suppression("InnoDB: Warning: database page corruption or a failed"); @@ -27,13 +29,26 @@ while ($i) --enable_query_log INSERT INTO t1 (b) VALUES ('corrupt me'); ---echo # Restart server to flush buffers -source include/restart_mysqld.inc; - ---echo # Corrupt the table let $MYSQLD_DATADIR=`select @@datadir`; let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd; +--echo # Write file to make mysql-test-run.pl expect the "crash", but don't +--echo # start it until it's told to +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # We give 30 seconds to do a clean shutdown because we do not want +--echo # to redo apply the pages of t1.ibd at the time of recovery. +--echo # We want SQL to initiate the first access to t1.ibd. +shutdown_server 30; + +--echo # Wait until disconnected. +--source include/wait_until_disconnected.inc + +--echo # Backup the t1.ibd before corrupting +--copy_file $t1_IBD $MYSQLD_DATADIR/test/t1.ibd.backup + +--echo # Corrupt the table + perl; use strict; use warnings; @@ -59,17 +74,32 @@ while ($len = sysread IBD_FILE, $chunk, 1024) close IBD_FILE; EOF ---echo # Write file to make mysql-test-run.pl expect crash and restart +--echo # Write file to make mysql-test-run.pl start up the server again --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--enable_reconnect +--source include/wait_until_connected_again.inc +SET DEBUG = '+d,innodb_page_corruption_retries'; + +--echo # Write file to make mysql-test-run.pl expect the "crash", but don't +--echo # start it until it's told to +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # The below SELECT query will crash the server because some pages +--echo # on the disk are corrupted --error 2013 SELECT * FROM t1; ---echo # Turn on reconnect ---enable_reconnect +--echo # Restore the original t1.ibd +--move_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd ---echo # Wait for server to fully start +--echo # Write file to make mysql-test-run.pl start up the server again +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--enable_reconnect --source include/wait_until_connected_again.inc +# Note SET DEBUG = '-d,innodb_page_corruption_retries' is not required +# because the session information is lost after server restart + --echo # Cleanup DROP TABLE t1; diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index 75bd546d2cf..31be914afa0 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -2322,6 +2322,10 @@ loop2: retries = 0; } else if (retries < BUF_PAGE_READ_MAX_RETRIES) { ++retries; + DBUG_EXECUTE_IF( + "innodb_page_corruption_retries", + retries = BUF_PAGE_READ_MAX_RETRIES; + ); } else { fprintf(stderr, "InnoDB: Error: Unable" " to read tablespace %lu page no" From 8b129a8b41d26f2013d580c8216774c2e959e0ae Mon Sep 17 00:00:00 2001 From: Satya Bodapati Date: Thu, 21 Feb 2013 12:16:59 +0530 Subject: [PATCH 077/273] Testcase fix for Bug#14147491 move_file fails randomly on windows if the destination file exists. Using remove_file before move_file mtr test command. --- mysql-test/suite/innodb/t/innodb_bug14147491.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/innodb/t/innodb_bug14147491.test b/mysql-test/suite/innodb/t/innodb_bug14147491.test index 8758631c344..7c653268c64 100644 --- a/mysql-test/suite/innodb/t/innodb_bug14147491.test +++ b/mysql-test/suite/innodb/t/innodb_bug14147491.test @@ -91,6 +91,7 @@ SET DEBUG = '+d,innodb_page_corruption_retries'; SELECT * FROM t1; --echo # Restore the original t1.ibd +--remove_file $MYSQLD_DATADIR/test/t1.ibd --move_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd --echo # Write file to make mysql-test-run.pl start up the server again From f325fc42e83baebd8420449cd3e80974a6bb9ee0 Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Wed, 20 Feb 2013 11:24:16 +0100 Subject: [PATCH 078/273] Bug#14300733 CMAKE DOES NOT CHECK FOR ZLIB VERSION Add check for compressBound() and deflateBound() Keep existing functionality: fallback to bundled zlib if functions not found. --- cmake/zlib.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 3ede3aba228..83597357aba 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -57,13 +57,17 @@ MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) INCLUDE(CheckFunctionExists) SET(CMAKE_REQUIRED_LIBRARIES z) CHECK_FUNCTION_EXISTS(crc32 HAVE_CRC32) + CHECK_FUNCTION_EXISTS(compressBound HAVE_COMPRESSBOUND) + CHECK_FUNCTION_EXISTS(deflateBound HAVE_DEFLATEBOUND) SET(CMAKE_REQUIRED_LIBRARIES) - IF(HAVE_CRC32) + IF(HAVE_CRC32 AND HAVE_COMPRESSBOUND AND HAVE_DEFLATEBOUND) SET(ZLIB_LIBRARY z CACHE INTERNAL "System zlib library") - SET(WITH_ZLIB "system" CACHE STRING "Which zlib to use (possible values are 'bundled' or 'system')") + SET(WITH_ZLIB "system" CACHE STRING + "Which zlib to use (possible values are 'bundled' or 'system')") SET(ZLIB_SOURCES "") ELSE() SET(ZLIB_FOUND FALSE CACHE INTERNAL "Zlib found but not usable") + MESSAGE(STATUS "system zlib found but not usable") ENDIF() ENDIF() IF(NOT ZLIB_FOUND) From 286a7490c7d6de6c731b760737ecc7c3aec397eb Mon Sep 17 00:00:00 2001 From: Daniel Fischer Date: Wed, 20 Feb 2013 12:41:43 +0100 Subject: [PATCH 079/273] Bug #13071597: MYSQL SERVER COMMUNITY TO ADVANCED USING MSI THE INSTALLER Cross-upgrades between GPL and commercial versions should be allowed by the MSI package even when both packages are the same version. Fixed by allowing upgrades to the same numeric version. --- packaging/WiX/mysql_server.wxs.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packaging/WiX/mysql_server.wxs.in b/packaging/WiX/mysql_server.wxs.in index 4c2a856782c..752dc15304e 100644 --- a/packaging/WiX/mysql_server.wxs.in +++ b/packaging/WiX/mysql_server.wxs.in @@ -45,11 +45,13 @@ Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0" IncludeMinimum="yes" Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@" + IncludeMaximum="yes" Property="OLDERVERSIONBEINGUPGRADED" MigrateFeatures="yes" /> From dc6969734afbd6598035c81a3e0a7f139083ed65 Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Fri, 22 Feb 2013 14:56:17 +0530 Subject: [PATCH 080/273] Bug #14211565 CRASH WHEN ATTEMPTING TO SET SYSTEM VARIABLE TO RESULT OF VALUES() Problem: When the VALUES() function is inappropriately used in the SET stmt the server exits. set port = values(v); This happens because the values(v) will be parsed as an Item_insert_value by the parser. Both Item_field and Item_insert_value return the type as FIELD_ITEM. But for Item_insert_value the field_name member is NULL. In set_var constructor, when the type of the item is FIELD_ITEM we try to access the non-existent field_name. The class hierarchy is as follows: Item -> Item_ident -> Item_field -> Item_insert_value The Item_ident::field_name is NULL for Item_insert_value. Solution: In the parsing stage, in the set_var constructor if the item type is FIELD_ITEM and if the field_name is non-existent, then it is probably the Item_insert_value. So leave it as it is for later evaluation. rb://2004 approved by Roy and Norvald. --- sql/set_var.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sql/set_var.h b/sql/set_var.h index 97e3c74593b..7b1dbcddb96 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -1326,13 +1326,23 @@ public: if (value_arg && value_arg->type() == Item::FIELD_ITEM) { Item_field *item= (Item_field*) value_arg; - if (!(value=new Item_string(item->field_name, - (uint) strlen(item->field_name), - item->collation.collation))) - value=value_arg; /* Give error message later */ + if (item->field_name) + { + if (!(value= new Item_string(item->field_name, + (uint) strlen(item->field_name), + item->collation.collation))) + value= value_arg; /* Give error message later */ + } + else + { + /* Both Item_field and Item_insert_value will return the type as + Item::FIELD_ITEM. If the item->field_name is NULL, we assume the + object to be Item_insert_value. */ + value= value_arg; + } } else - value=value_arg; + value= value_arg; } int check(THD *thd); int update(THD *thd); From 04780043ef2bc42780d923c1535051cbe2f3bca9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Feb 2013 15:22:15 +0100 Subject: [PATCH 081/273] Bug #13619394 - MAKE TEST FAILS ON MY_VSNPRINTF --- unittest/mysys/my_vsnprintf-t.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unittest/mysys/my_vsnprintf-t.c b/unittest/mysys/my_vsnprintf-t.c index 06f6878826a..349e7469141 100644 --- a/unittest/mysys/my_vsnprintf-t.c +++ b/unittest/mysys/my_vsnprintf-t.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -154,8 +154,10 @@ int main(void) test1("conn 1 to: '(null)' user: '(null)' host: '(null)' ((null))", "conn %ld to: '%-.64s' user: '%-.32s' host: '%-.64s' (%-.64s)", 1L, NULL, NULL, NULL, NULL); +#if defined (__GNUC__) test1("Hello string `I am a string`", "Hello string %`s", "I am a string"); +#endif test1("Hello TEST", "Hello %05s", "TEST"); test1("My `Q` test", From 57674d6342f9755baf38f74fbd74fba06135f65a Mon Sep 17 00:00:00 2001 From: Satya Bodapati Date: Sat, 23 Feb 2013 00:16:36 +0530 Subject: [PATCH 082/273] Testcase fix for Bug#14147491 Sleep 1sec before remove_file to solve windows pb2 issues. We hope that after sleep, the access to the file will not be denied. --- mysql-test/suite/innodb/t/innodb_bug14147491.test | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/suite/innodb/t/innodb_bug14147491.test b/mysql-test/suite/innodb/t/innodb_bug14147491.test index 7c653268c64..5224e1402e1 100644 --- a/mysql-test/suite/innodb/t/innodb_bug14147491.test +++ b/mysql-test/suite/innodb/t/innodb_bug14147491.test @@ -90,6 +90,11 @@ SET DEBUG = '+d,innodb_page_corruption_retries'; --error 2013 SELECT * FROM t1; +# The below mtr command --remove_file fails randomly on windows with +# error number 13 which is permission denied on nix systems. We sleep +# 1 second hoping that any process holding lock on t1.ibd is released. +SLEEP 1; + --echo # Restore the original t1.ibd --remove_file $MYSQLD_DATADIR/test/t1.ibd --move_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd From 50f3a2474652db833bf2ee773f550acbd12c604d Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 23 Feb 2013 10:38:28 +0100 Subject: [PATCH 083/273] From 4cd374a1111942832b2c40727d0f5c56398e9761 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 23 Feb 2013 10:40:23 +0100 Subject: [PATCH 084/273] From 436d8402a15d7b84de620ab68f73abfc565018b4 Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Mon, 25 Feb 2013 10:28:25 +0530 Subject: [PATCH 085/273] Bug #16044655 CRASH: SETTING DEFAULT VALUE FOR SOME VARIABLES Problem: When a system variable is being set to the DEFAULT value, the server segfaults if there is no 'default' defined for that system variable. For example, for the following statements server segfaults. set session rand_seed1=DEFAULT; set session rand_seed2=DEFAULT; Analysis: The class sys_var represents one system variable. The class set_var represents one system variable that is to be updated. The class set_var contains two pieces of information, the system variable to object (set_var::var) member and the value to be updated (set_var::value). When the given value is 'default', the set_var::value will be NULL. To update a system variable the member set_var::update() will be called, which in turn will call sys_var::update() or sys_var::set_default() depending on whether a value has been provided or not. If the sys_var::set_default() is called, then the default value is obtained either from the session scope or the global scope. This default value is stored in a local temporary set_var object and then passed on to the sys_var::update() call. A local temporary set_var object is needed because sys_var::set_default() does not take set_var as an argument. In the given scenario, the set_var::update() called sys_var::set_default(). And this sys_var::set_default() obtains the default value and then calls sys_var::update(). To pass this value to sys_var::update() a local set_var object is being created. While creating this local set_var object, its member set_var::var was incorrectly left as 0. Solution: Instead of creating a local set_var object, the sys_var::set_default() can take the set_var object as an argument just like sys_var::update(). rb://1996 approved by Nirbhay and Ramil. --- sql/set_var.cc | 17 +++++++---------- sql/set_var.h | 10 ++++++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index 231fbb47d35..75387b974f1 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2013 Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -256,17 +256,14 @@ uchar *sys_var::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) return session_value_ptr(thd, base); } -bool sys_var::set_default(THD *thd, enum_var_type type) +bool sys_var::set_default(THD *thd, set_var* var) { - LEX_STRING empty={0,0}; - set_var var(type, 0, &empty, 0); - - if (type == OPT_GLOBAL || scope() == GLOBAL) - global_save_default(thd, &var); + if (var->type == OPT_GLOBAL || scope() == GLOBAL) + global_save_default(thd, var); else - session_save_default(thd, &var); + session_save_default(thd, var); - return check(thd, &var) || update(thd, &var); + return check(thd, var) || update(thd, var); } void sys_var::do_deprecated_warning(THD *thd) @@ -668,7 +665,7 @@ int set_var::light_check(THD *thd) */ int set_var::update(THD *thd) { - return value ? var->update(thd, this) : var->set_default(thd, type); + return value ? var->update(thd, this) : var->set_default(thd, this); } diff --git a/sql/set_var.h b/sql/set_var.h index fc0c5004b5b..c03733f6f82 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -1,6 +1,6 @@ #ifndef SET_VAR_INCLUDED #define SET_VAR_INCLUDED -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2013 Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -107,7 +107,13 @@ public: bool check(THD *thd, set_var *var); uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); - bool set_default(THD *thd, enum_var_type type); + + /** + Update the system variable with the default value from either + session or global scope. The default value is stored in the + 'var' argument. Return false when successful. + */ + bool set_default(THD *thd, set_var *var); bool update(THD *thd, set_var *var); SHOW_TYPE show_type() { return show_val_type; } From 698d2f1005833e4e8c24c1f604c2681cb9d35c37 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Feb 2013 13:45:00 +0100 Subject: [PATCH 086/273] From 13058fd53f435a95b40e744dc804ed32fc958bd4 Mon Sep 17 00:00:00 2001 From: Akhila Maddukuri Date: Mon, 25 Feb 2013 19:37:46 +0530 Subject: [PATCH 087/273] Bug#16103072 TEST MYSQL_PLUGIN USES UNSAFE WRITE_FILE TO WRITE TO EXPECT FILE --- mysql-test/t/mysql_plugin.test | 66 +++++++++------------------------- 1 file changed, 16 insertions(+), 50 deletions(-) diff --git a/mysql-test/t/mysql_plugin.test b/mysql-test/t/mysql_plugin.test index a05b5a624d9..10bc03e0f06 100644 --- a/mysql-test/t/mysql_plugin.test +++ b/mysql-test/t/mysql_plugin.test @@ -110,13 +110,8 @@ SELECT * FROM mysql.plugin WHERE dl like 'libdaemon%' ORDER BY name; --echo # --echo # Enable the plugin... --echo # -let $expect_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; -# MTR will remove this file later, but this might be too late. ---error 0,1 ---remove_file $expect_file ---write_file $expect_file -wait -EOF + +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server 10 --source include/wait_until_disconnected.inc @@ -132,9 +127,8 @@ EOF # # Restart the server # ---append_file $expect_file -restart -EOF + +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -155,12 +149,7 @@ eval INSERT INTO mysql.plugin VALUES ('wonky', '$DAEMONEXAMPLE'); --replace_regex /\.dll/.so/ SELECT * FROM mysql.plugin WHERE dl like 'libdaemon%' ORDER BY name; -# MTR will remove this file later, but this might be too late. ---error 0,1 ---remove_file $expect_file ---write_file $expect_file -wait -EOF +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server 10 --source include/wait_until_disconnected.inc @@ -177,9 +166,7 @@ EOF # # Restart the server # ---append_file $expect_file -restart -EOF +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -189,12 +176,7 @@ EOF --replace_regex /\.dll/.so/ SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name; -# MTR will remove this file later, but this might be too late. ---error 0,1 ---remove_file $expect_file ---write_file $expect_file -wait -EOF +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server 10 --source include/wait_until_disconnected.inc @@ -211,9 +193,7 @@ let $DAEMON_RELOAD = lib$DAEMONEXAMPLE; # # Restart the server # ---append_file $expect_file -restart -EOF +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -226,12 +206,8 @@ SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name; --echo # --echo # Disable the plugin... --echo # -# MTR will remove this file later, but this might be too late. ---error 0,1 ---remove_file $expect_file ---write_file $expect_file -wait -EOF + +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server 10 --source include/wait_until_disconnected.inc @@ -248,9 +224,7 @@ EOF # # Restart the server # ---append_file $expect_file -restart -EOF +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -262,13 +236,8 @@ SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name; # # Stop the server for error conditions # -let $expect_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; -# MTR will remove this file later, but this might be too late. ---error 0,1 ---remove_file $expect_file ---write_file $expect_file -wait -EOF + +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server 10 --source include/wait_until_disconnected.inc @@ -382,17 +351,14 @@ replace_result $MYSQL_PLUGIN mysql_plugin; # # Restart the server # ---append_file $expect_file -restart -EOF +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc # # Cleanup -# MTR will remove this file later, but this might be too late. ---error 0,1 ---remove_file $expect_file + +--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Cleanup the share folder in the binary path. --remove_file $MYSQLD_BASEDIR/share/errmsg.sys From 460852b318e9f6862cfa9935506e1f4217b10090 Mon Sep 17 00:00:00 2001 From: Aditya A Date: Tue, 26 Feb 2013 17:57:05 +0530 Subject: [PATCH 088/273] Bug#14653504 CRASH WHEN TRUNCATING PARTITIONS FROM A VIEW! ANALYSIS -------- When we open the view using open_new_frm() ,it doesnt set the table-list->table variable and any access to table_list->table will cause a crash. FIX --- Added a check during execution of the alter partition to return error if table is view. [http://rb.no.oracle.com/rb/r/2001/ Approved by Mattias J ] --- sql/sql_partition_admin.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 4edd47de855..b9bf3dbc217 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -141,7 +141,9 @@ bool Alter_table_truncate_partition_statement::execute(THD *thd) TODO: Add support for TRUNCATE PARTITION for NDB and other engines supporting native partitioning. */ - if (first_table->table->s->db_type() != partition_hton) + + if (!first_table->table || first_table->view || + first_table->table->s->db_type() != partition_hton) { my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0)); DBUG_RETURN(TRUE); From 97a74e5b102628309b6c58b55016446bc86f869f Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Mon, 25 Feb 2013 10:42:40 +0100 Subject: [PATCH 089/273] Bug#16062056 REMOVE THE "DUMMY.BAK" FILE FROM THE TEST DATABASE, AND ADD DB.OPT 1. remove dummy.bak 2. create a db.opt file containing two lines: --- default-character-set=latin1 default-collation=latin1_swedish_ci --- sql/CMakeLists.txt | 12 +++--------- sql/db.opt | 2 ++ 2 files changed, 5 insertions(+), 9 deletions(-) create mode 100644 sql/db.opt diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index d79b732005b..d4db337d765 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -261,15 +261,9 @@ ADD_CUSTOM_TARGET(distclean IF(INSTALL_LAYOUT STREQUAL "STANDALONE") -# We need to create empty directories (data/test) the installation. -# This does not work with current CPack due to http://www.cmake.org/Bug/view.php?id=8767 -# Avoid completely empty directories and install dummy file instead. -# Use a file extension so that it will be deleted in case someone does -# 'drop database test' -# See deletable_extentions. -SET(DUMMY_FILE ${CMAKE_CURRENT_BINARY_DIR}/dummy.bak ) -FILE(WRITE ${DUMMY_FILE} "") -INSTALL(FILES ${DUMMY_FILE} DESTINATION data/test COMPONENT DataFiles) +# Copy db.opt into data/test/ +SET(DBOPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/db.opt ) +INSTALL(FILES ${DBOPT_FILE} DESTINATION data/test COMPONENT DataFiles) # Install initial database on windows IF(NOT CMAKE_CROSSCOMPILING) diff --git a/sql/db.opt b/sql/db.opt new file mode 100644 index 00000000000..d8429c4e0de --- /dev/null +++ b/sql/db.opt @@ -0,0 +1,2 @@ +default-character-set=latin1 +default-collation=latin1_swedish_ci From 053d7e775c3b369debbb71e26244fc4c76688f48 Mon Sep 17 00:00:00 2001 From: Murthy Narkedimilli Date: Mon, 25 Feb 2013 15:26:00 +0100 Subject: [PATCH 090/273] Updated/added copyright headers. --- BUILD/Makefile.am | 2 +- BUILD/autorun.sh | 2 +- BUILD/compile-alpha-ccc | 2 +- BUILD/compile-alpha-cxx | 2 +- BUILD/compile-alpha-debug | 2 +- BUILD/compile-amd64-debug-max | 2 +- BUILD/compile-amd64-max | 2 +- BUILD/compile-darwin-mwcc | 2 +- BUILD/compile-hpux11-parisc2-aCC | 2 +- BUILD/compile-ia64-debug-max | 2 +- BUILD/compile-irix-mips64-mipspro | 2 +- BUILD/compile-pentium | 2 +- BUILD/compile-pentium-debug-max-no-embedded | 2 +- BUILD/compile-pentium-debug-openssl | 2 +- BUILD/compile-pentium-debug-yassl | 2 +- BUILD/compile-pentium-max | 2 +- BUILD/compile-pentium-pgcc | 2 +- BUILD/compile-ppc-debug | 2 +- BUILD/compile-ppc-debug-max | 2 +- BUILD/compile-ppc-debug-max-no-ndb | 2 +- BUILD/compile-ppc-max | 2 +- BUILD/compile-solaris-sparc-debug | 2 +- BUILD/compile-solaris-sparc-purify | 2 +- CMakeLists.txt | 2 +- Docs/Makefile.am | 2 +- Makefile.am | 2 +- client/completion_hash.cc | 2 +- client/completion_hash.h | 2 +- client/echo.c | 2 +- client/get_password.c | 2 +- client/mysqldump.c | 2 +- client/sql_string.cc | 2 +- cmd-line-utils/Makefile.am | 2 +- dbug/CMakeLists.txt | 2 +- extra/CMakeLists.txt | 2 +- extra/Makefile.am | 2 +- extra/charset2html.c | 2 +- extra/yassl/CMakeLists.txt | 2 +- extra/yassl/Makefile.am | 2 +- extra/yassl/examples/client/client.cpp | 2 +- extra/yassl/examples/echoclient/echoclient.cpp | 2 +- extra/yassl/examples/echoserver/echoserver.cpp | 2 +- extra/yassl/examples/server/server.cpp | 2 +- extra/yassl/include/buffer.hpp | 2 +- extra/yassl/include/cert_wrapper.hpp | 3 +-- extra/yassl/include/lock.hpp | 2 +- extra/yassl/include/openssl/prefix_ssl.h | 3 +-- extra/yassl/include/socket_wrapper.hpp | 2 +- extra/yassl/include/yassl_error.hpp | 3 +-- extra/yassl/include/yassl_imp.hpp | 3 +-- extra/yassl/include/yassl_int.hpp | 2 +- extra/yassl/include/yassl_types.hpp | 3 +-- extra/yassl/src/buffer.cpp | 3 +-- extra/yassl/src/cert_wrapper.cpp | 3 +-- extra/yassl/src/crypto_wrapper.cpp | 2 +- extra/yassl/src/handshake.cpp | 3 +-- extra/yassl/src/lock.cpp | 2 +- extra/yassl/src/make.bat | 2 +- extra/yassl/src/socket_wrapper.cpp | 2 +- extra/yassl/src/ssl.cpp | 3 +-- extra/yassl/src/template_instnt.cpp | 2 +- extra/yassl/src/yassl.cpp | 2 +- extra/yassl/src/yassl_error.cpp | 2 +- extra/yassl/taocrypt/Makefile.am | 2 +- extra/yassl/taocrypt/benchmark/benchmark.cpp | 2 +- extra/yassl/taocrypt/benchmark/make.bat | 2 +- extra/yassl/taocrypt/include/aes.hpp | 2 +- extra/yassl/taocrypt/include/asn.hpp | 3 +-- extra/yassl/taocrypt/include/block.hpp | 3 +-- extra/yassl/taocrypt/include/blowfish.hpp | 2 +- extra/yassl/taocrypt/include/des.hpp | 2 +- extra/yassl/taocrypt/include/hash.hpp | 2 +- extra/yassl/taocrypt/include/hc128.hpp | 2 +- extra/yassl/taocrypt/include/integer.hpp | 2 +- extra/yassl/taocrypt/include/kernelc.hpp | 2 +- extra/yassl/taocrypt/include/misc.hpp | 2 +- extra/yassl/taocrypt/include/modes.hpp | 3 +-- extra/yassl/taocrypt/include/pwdbased.hpp | 2 +- extra/yassl/taocrypt/include/rabbit.hpp | 2 +- extra/yassl/taocrypt/include/rsa.hpp | 2 +- extra/yassl/taocrypt/include/runtime.hpp | 2 +- extra/yassl/taocrypt/include/types.hpp | 2 +- extra/yassl/taocrypt/mySTL/stdexcept.hpp | 2 +- extra/yassl/taocrypt/mySTL/vector.hpp | 2 +- extra/yassl/taocrypt/src/Makefile.am | 2 +- extra/yassl/taocrypt/src/aes.cpp | 2 +- extra/yassl/taocrypt/src/aestables.cpp | 2 +- extra/yassl/taocrypt/src/algebra.cpp | 2 +- extra/yassl/taocrypt/src/arc4.cpp | 2 +- extra/yassl/taocrypt/src/blowfish.cpp | 2 +- extra/yassl/taocrypt/src/coding.cpp | 2 +- extra/yassl/taocrypt/src/dsa.cpp | 2 +- extra/yassl/taocrypt/src/hash.cpp | 2 +- extra/yassl/taocrypt/src/hc128.cpp | 2 +- extra/yassl/taocrypt/src/make.bat | 2 +- extra/yassl/taocrypt/src/md4.cpp | 2 +- extra/yassl/taocrypt/src/md5.cpp | 2 +- extra/yassl/taocrypt/src/misc.cpp | 2 +- extra/yassl/taocrypt/src/rabbit.cpp | 2 +- extra/yassl/taocrypt/src/random.cpp | 2 +- extra/yassl/taocrypt/src/ripemd.cpp | 2 +- extra/yassl/taocrypt/src/rsa.cpp | 2 +- extra/yassl/taocrypt/src/sha.cpp | 2 +- extra/yassl/taocrypt/src/template_instnt.cpp | 2 +- extra/yassl/taocrypt/src/twofish.cpp | 2 +- extra/yassl/taocrypt/test/make.bat | 2 +- extra/yassl/taocrypt/test/memory.cpp | 2 +- extra/yassl/taocrypt/test/test.cpp | 2 +- extra/yassl/testsuite/make.bat | 2 +- extra/yassl/testsuite/test.hpp | 2 +- extra/yassl/testsuite/testsuite.cpp | 2 +- include/base64.h | 2 +- include/errmsg.h | 2 +- include/ft_global.h | 2 +- include/help_end.h | 2 +- include/help_start.h | 2 +- include/keycache.h | 2 +- include/m_ctype.h | 2 +- include/m_string.h | 2 +- include/my_aes.h | 2 +- include/my_alloc.h | 2 +- include/my_attribute.h | 2 +- include/my_base.h | 3 +-- include/my_compiler.h | 2 +- include/my_dir.h | 2 +- include/my_libwrap.h | 2 +- include/my_list.h | 2 +- include/my_md5.h | 2 +- include/my_net.h | 2 +- include/my_nosys.h | 2 +- include/my_sys.h | 2 +- include/my_tree.h | 2 +- include/my_trie.h | 2 +- include/my_user.h | 2 +- include/my_vle.h | 2 +- include/my_xml.h | 2 +- include/myisampack.h | 2 +- include/mysql_time.h | 2 +- include/mysql_version.h.in | 2 +- include/queues.h | 2 +- include/rijndael.h | 2 +- include/sslopt-case.h | 2 +- include/sslopt-vars.h | 2 +- include/thr_alarm.h | 2 +- include/typelib.h | 2 +- include/violite.h | 3 +-- include/welcome_copyright_notice.h | 2 +- libmysql/Makefile.am | 3 +-- libmysql/client_settings.h | 2 +- libmysql/conf_to_src.c | 2 +- libmysql/dll.c | 2 +- libmysql/errmsg.c | 2 +- libmysql/get_password.c | 2 +- libmysql/manager.c | 3 +-- libmysql_r/Makefile.am | 2 +- libmysqld/emb_qcache.cc | 2 +- libmysqld/examples/CMakeLists.txt | 3 +-- libmysqld/examples/Makefile.am | 2 +- mysql-test/include/default_my.cnf | 2 +- mysql-test/include/default_mysqld.cnf | 2 +- mysql-test/lib/My/Find.pm | 2 +- mysql-test/lib/My/SafeProcess/CMakeLists.txt | 2 +- mysql-test/lib/My/SafeProcess/safe_process.cc | 2 +- mysql-test/lib/mtr_cases.pm | 2 +- mysql-test/lib/mtr_match.pm | 2 +- mysql-test/lib/v1/mysql-test-run.pl | 2 +- mysys/array.c | 2 +- mysys/checksum.c | 2 +- mysys/default_modify.c | 2 +- mysys/errors.c | 2 +- mysys/list.c | 2 +- mysys/make-conf.c | 2 +- mysys/md5.c | 2 +- mysys/mf_brkhant.c | 2 +- mysys/mf_cache.c | 2 +- mysys/mf_dirname.c | 2 +- mysys/mf_fn_ext.c | 2 +- mysys/mf_format.c | 2 +- mysys/mf_getdate.c | 2 +- mysys/mf_iocache2.c | 3 +-- mysys/mf_keycaches.c | 2 +- mysys/mf_path.c | 2 +- mysys/mf_qsort.c | 2 +- mysys/mf_radix.c | 2 +- mysys/mf_same.c | 2 +- mysys/mf_sort.c | 2 +- mysys/mf_soundex.c | 2 +- mysys/mf_tempfile.c | 2 +- mysys/mf_unixpath.c | 2 +- mysys/mf_wcomp.c | 2 +- mysys/mulalloc.c | 2 +- mysys/my_access.c | 2 +- mysys/my_aes.c | 2 +- mysys/my_append.c | 2 +- mysys/my_bit.c | 2 +- mysys/my_chsize.c | 2 +- mysys/my_clock.c | 2 +- mysys/my_compress.c | 2 +- mysys/my_conio.c | 2 +- mysys/my_crc32.c | 2 +- mysys/my_create.c | 2 +- mysys/my_delete.c | 2 +- mysys/my_div.c | 2 +- mysys/my_dup.c | 2 +- mysys/my_error.c | 3 +-- mysys/my_fopen.c | 2 +- mysys/my_getpagesize.c | 2 +- mysys/my_handler_errors.h | 3 +-- mysys/my_init.c | 2 +- mysys/my_largepage.c | 2 +- mysys/my_libwrap.c | 2 +- mysys/my_lock.c | 2 +- mysys/my_lockmem.c | 2 +- mysys/my_memmem.c | 2 +- mysys/my_messnc.c | 2 +- mysys/my_mkdir.c | 2 +- mysys/my_mmap.c | 2 +- mysys/my_netware.c | 2 +- mysys/my_new.cc | 2 +- mysys/my_once.c | 2 +- mysys/my_open.c | 2 +- mysys/my_pthread.c | 2 +- mysys/my_quick.c | 2 +- mysys/my_read.c | 2 +- mysys/my_realloc.c | 2 +- mysys/my_rename.c | 2 +- mysys/my_sleep.c | 2 +- mysys/my_static.h | 2 +- mysys/my_symlink2.c | 2 +- mysys/my_vle.c | 2 +- mysys/my_windac.c | 2 +- mysys/my_winthread.c | 2 +- mysys/my_write.c | 3 +-- mysys/mysys_priv.h | 2 +- mysys/ptr_cmp.c | 2 +- mysys/queues.c | 2 +- mysys/rijndael.c | 2 +- mysys/stacktrace.c | 2 +- mysys/test_charset.c | 2 +- mysys/test_dir.c | 2 +- mysys/test_fn.c | 2 +- mysys/test_xml.c | 2 +- mysys/testhash.c | 2 +- mysys/thr_alarm.c | 2 +- mysys/thr_rwlock.c | 2 +- mysys/tree.c | 2 +- mysys/trie.c | 2 +- netware/mysql_fix_privilege_tables.pl | 2 +- netware/mysql_secure_installation.pl | 2 +- plugin/daemon_example/daemon_example.cc | 2 +- plugin/fulltext/Makefile.am | 2 +- scripts/CMakeLists.txt | 2 +- scripts/comp_sql.c | 2 +- scripts/make_binary_distribution.sh | 2 +- scripts/mysql_fix_privilege_tables.sh | 2 +- scripts/mysql_install_db.pl.in | 2 +- scripts/mysqlbug.sh | 2 +- scripts/mysqld_multi.sh | 2 +- server-tools/CMakeLists.txt | 2 +- server-tools/instance-manager/CMakeLists.txt | 2 +- server-tools/instance-manager/IMService.cpp | 2 +- server-tools/instance-manager/IMService.h | 2 +- server-tools/instance-manager/Makefile.am | 2 +- server-tools/instance-manager/WindowsService.cpp | 2 +- server-tools/instance-manager/WindowsService.h | 2 +- server-tools/instance-manager/angel.cc | 2 +- server-tools/instance-manager/angel.h | 2 +- server-tools/instance-manager/buffer.h | 2 +- server-tools/instance-manager/command.cc | 2 +- server-tools/instance-manager/command.h | 2 +- server-tools/instance-manager/commands.h | 2 +- server-tools/instance-manager/guardian.cc | 2 +- server-tools/instance-manager/guardian.h | 2 +- server-tools/instance-manager/instance.h | 2 +- server-tools/instance-manager/instance_map.h | 2 +- server-tools/instance-manager/instance_options.h | 2 +- server-tools/instance-manager/listener.h | 2 +- server-tools/instance-manager/log.cc | 2 +- server-tools/instance-manager/manager.cc | 2 +- server-tools/instance-manager/manager.h | 2 +- server-tools/instance-manager/mysql_manager_error.h | 2 +- server-tools/instance-manager/mysqlmanager.cc | 2 +- server-tools/instance-manager/parse_output.h | 2 +- server-tools/instance-manager/portability.h | 2 +- server-tools/instance-manager/priv.cc | 2 +- server-tools/instance-manager/priv.h | 2 +- server-tools/instance-manager/protocol.h | 2 +- server-tools/instance-manager/thread_registry.cc | 2 +- server-tools/instance-manager/thread_registry.h | 2 +- sql-common/pack.c | 2 +- sql/Makefile.am | 2 +- sql/custom_conf.h | 2 +- sql/des_key_file.cc | 2 +- sql/discover.cc | 2 +- sql/event_data_objects.h | 2 +- sql/event_queue.cc | 2 +- sql/event_queue.h | 2 +- sql/event_scheduler.cc | 3 +-- sql/event_scheduler.h | 2 +- sql/events.h | 2 +- sql/field.cc | 2 +- sql/field.h | 2 +- sql/field_conv.cc | 2 +- sql/frm_crypt.cc | 2 +- sql/gstream.cc | 2 +- sql/gstream.h | 2 +- sql/ha_ndbcluster.h | 2 +- sql/ha_ndbcluster_binlog.cc | 2 +- sql/ha_ndbcluster_binlog.h | 2 +- sql/ha_ndbcluster_cond.cc | 2 +- sql/ha_ndbcluster_cond.h | 2 +- sql/ha_ndbcluster_tables.h | 2 +- sql/handler.cc | 2 +- sql/hash_filo.cc | 2 +- sql/hash_filo.h | 2 +- sql/hostname.cc | 2 +- sql/init.cc | 2 +- sql/item_cmpfunc.h | 2 +- sql/item_func.h | 2 +- sql/item_row.cc | 2 +- sql/item_strfunc.cc | 2 +- sql/item_subselect.cc | 2 +- sql/item_xmlfunc.cc | 2 +- sql/item_xmlfunc.h | 2 +- sql/lex_symbol.h | 2 +- sql/log.cc | 2 +- sql/log_event_old.h | 2 +- sql/mem_root_array.h | 2 +- sql/mf_iocache.cc | 2 +- sql/my_lock.c | 2 +- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 2 +- sql/mysqld_suffix.h | 2 +- sql/opt_range.cc | 2 +- sql/partition_element.h | 2 +- sql/password.c | 2 +- sql/procedure.cc | 2 +- sql/procedure.h | 2 +- sql/records.cc | 2 +- sql/repl_failsafe.h | 2 +- sql/rpl_filter.h | 2 +- sql/rpl_injector.h | 2 +- sql/rpl_record_old.h | 2 +- sql/rpl_rli.cc | 2 +- sql/rpl_rli.h | 2 +- sql/rpl_tblmap.h | 2 +- sql/rpl_utility.cc | 2 +- sql/rpl_utility.h | 2 +- sql/set_var.cc | 2 +- sql/share/charsets/Index.xml | 2 +- sql/share/charsets/armscii8.xml | 2 +- sql/share/charsets/ascii.xml | 2 +- sql/share/charsets/cp1250.xml | 2 +- sql/share/charsets/cp852.xml | 2 +- sql/share/charsets/hebrew.xml | 2 +- sql/share/charsets/latin1.xml | 2 +- sql/share/charsets/latin2.xml | 2 +- sql/share/charsets/latin5.xml | 2 +- sql/signal_handler.cc | 2 +- sql/slave.cc | 2 +- sql/sp_cache.h | 2 +- sql/sp_head.cc | 2 +- sql/sp_head.h | 2 +- sql/sp_rcontext.h | 2 +- sql/spatial.cc | 2 +- sql/spatial.h | 2 +- sql/sql_acl.cc | 2 +- sql/sql_analyse.h | 2 +- sql/sql_array.h | 2 +- sql/sql_base.cc | 2 +- sql/sql_bitmap.h | 2 +- sql/sql_cache.cc | 2 +- sql/sql_class.cc | 2 +- sql/sql_class.h | 2 +- sql/sql_client.cc | 2 +- sql/sql_cursor.h | 2 +- sql/sql_db.cc | 2 +- sql/sql_derived.cc | 2 +- sql/sql_do.cc | 2 +- sql/sql_error.h | 2 +- sql/sql_insert.cc | 2 +- sql/sql_lex.cc | 2 +- sql/sql_lex.h | 2 +- sql/sql_list.cc | 2 +- sql/sql_load.cc | 2 +- sql/sql_map.cc | 2 +- sql/sql_map.h | 2 +- sql/sql_partition.cc | 2 +- sql/sql_prepare.cc | 2 +- sql/sql_profile.h | 3 +-- sql/sql_repl.h | 2 +- sql/sql_servers.h | 2 +- sql/sql_show.h | 3 +-- sql/sql_sort.h | 2 +- sql/sql_string.cc | 2 +- sql/sql_trigger.cc | 2 +- sql/sql_udf.h | 2 +- sql/sql_view.cc | 2 +- sql/sql_yacc.yy | 2 +- sql/table.cc | 2 +- sql/table.h | 2 +- sql/tzfile.h | 2 +- sql/tztime.cc | 2 +- storage/archive/archive_test.c | 2 +- storage/archive/ha_archive.h | 2 +- storage/federated/ha_federated.cc | 2 +- storage/heap/_check.c | 2 +- storage/heap/_rectest.c | 2 +- storage/heap/heapdef.h | 2 +- storage/heap/hp_block.c | 2 +- storage/heap/hp_clear.c | 2 +- storage/heap/hp_close.c | 2 +- storage/heap/hp_delete.c | 2 +- storage/heap/hp_extra.c | 2 +- storage/heap/hp_open.c | 2 +- storage/heap/hp_panic.c | 2 +- storage/heap/hp_rename.c | 2 +- storage/heap/hp_rfirst.c | 2 +- storage/heap/hp_rkey.c | 2 +- storage/heap/hp_rlast.c | 2 +- storage/heap/hp_rnext.c | 2 +- storage/heap/hp_rprev.c | 2 +- storage/heap/hp_rrnd.c | 2 +- storage/heap/hp_rsame.c | 2 +- storage/heap/hp_scan.c | 2 +- storage/heap/hp_static.c | 2 +- storage/heap/hp_test1.c | 2 +- storage/heap/hp_update.c | 2 +- storage/myisam/ft_boolean_search.c | 2 +- storage/myisam/ft_eval.c | 2 +- storage/myisam/ft_eval.h | 2 +- storage/myisam/ft_nlq_search.c | 2 +- storage/myisam/ft_static.c | 2 +- storage/myisam/ft_stem.c | 2 +- storage/myisam/ft_test1.c | 2 +- storage/myisam/ft_test1.h | 2 +- storage/myisam/ft_update.c | 2 +- storage/myisam/ftbench/Ecompare.pl | 2 +- storage/myisam/ftbench/Ecreate.pl | 2 +- storage/myisam/ftbench/Ereport.pl | 2 +- storage/myisam/ftbench/ft-test-run.sh | 2 +- storage/myisam/mi_cache.c | 2 +- storage/myisam/mi_changed.c | 2 +- storage/myisam/mi_checksum.c | 2 +- storage/myisam/mi_info.c | 2 +- storage/myisam/mi_key.c | 2 +- storage/myisam/mi_keycache.c | 2 +- storage/myisam/mi_log.c | 2 +- storage/myisam/mi_panic.c | 2 +- storage/myisam/mi_rename.c | 2 +- storage/myisam/mi_rfirst.c | 2 +- storage/myisam/mi_rkey.c | 2 +- storage/myisam/mi_rlast.c | 2 +- storage/myisam/mi_rnext_same.c | 2 +- storage/myisam/mi_rprev.c | 2 +- storage/myisam/mi_rrnd.c | 2 +- storage/myisam/mi_rsame.c | 2 +- storage/myisam/mi_rsamepos.c | 2 +- storage/myisam/mi_scan.c | 2 +- storage/myisam/mi_statrec.c | 2 +- storage/myisam/mi_test3.c | 2 +- storage/myisam/mi_write.c | 2 +- storage/myisam/myisamchk.c | 2 +- storage/myisam/rt_index.h | 2 +- storage/myisam/rt_key.c | 2 +- storage/myisam/rt_key.h | 2 +- storage/myisam/rt_mbr.c | 2 +- storage/myisam/rt_mbr.h | 2 +- storage/myisam/rt_test.c | 2 +- storage/myisam/sp_defs.h | 2 +- storage/myisam/sp_key.c | 2 +- storage/myisammrg/Makefile.am | 2 +- storage/myisammrg/myrg_close.c | 2 +- storage/myisammrg/myrg_def.h | 2 +- storage/myisammrg/myrg_delete.c | 2 +- storage/myisammrg/myrg_extra.c | 2 +- storage/myisammrg/myrg_locking.c | 2 +- storage/myisammrg/myrg_panic.c | 2 +- storage/myisammrg/myrg_queue.c | 2 +- storage/myisammrg/myrg_range.c | 2 +- storage/myisammrg/myrg_rfirst.c | 2 +- storage/myisammrg/myrg_rlast.c | 2 +- storage/myisammrg/myrg_rnext.c | 2 +- storage/myisammrg/myrg_rnext_same.c | 2 +- storage/myisammrg/myrg_rprev.c | 2 +- storage/myisammrg/myrg_rrnd.c | 2 +- storage/myisammrg/myrg_rsame.c | 2 +- storage/myisammrg/myrg_static.c | 2 +- storage/myisammrg/myrg_update.c | 2 +- storage/myisammrg/myrg_write.c | 2 +- storage/ndb/config/make-win-dsw.sh | 2 +- storage/ndb/config/type_mgmapiclient.mk.am | 2 +- storage/ndb/config/type_ndbapiclient.mk.am | 2 +- storage/ndb/config/win-includes | 2 +- storage/ndb/config/win-libraries | 2 +- storage/ndb/config/win-name | 2 +- storage/ndb/config/win-sources | 2 +- storage/ndb/docs/Makefile.am | 2 +- storage/ndb/docs/doxygen/postdoxy.pl | 2 +- storage/ndb/docs/doxygen/predoxy.pl | 2 +- storage/ndb/include/Makefile.am | 2 +- storage/ndb/include/debugger/DebuggerNames.hpp | 2 +- storage/ndb/include/debugger/EventLogger.hpp | 2 +- storage/ndb/include/debugger/GrepError.hpp | 2 +- storage/ndb/include/debugger/SignalLoggerManager.hpp | 2 +- storage/ndb/include/editline/editline.h | 2 +- storage/ndb/include/kernel/AttributeDescriptor.hpp | 2 +- storage/ndb/include/kernel/AttributeHeader.hpp | 2 +- storage/ndb/include/kernel/AttributeList.hpp | 2 +- storage/ndb/include/kernel/BlockNumbers.h | 2 +- storage/ndb/include/kernel/GlobalSignalNumbers.h | 2 +- storage/ndb/include/kernel/GrepEvent.hpp | 2 +- storage/ndb/include/kernel/Interpreter.hpp | 2 +- storage/ndb/include/kernel/LogLevel.hpp | 2 +- storage/ndb/include/kernel/NodeBitmask.hpp | 2 +- storage/ndb/include/kernel/NodeInfo.hpp | 2 +- storage/ndb/include/kernel/NodeState.hpp | 2 +- storage/ndb/include/kernel/RefConvert.hpp | 2 +- storage/ndb/include/kernel/kernel_config_parameters.h | 2 +- storage/ndb/include/kernel/kernel_types.h | 2 +- storage/ndb/include/kernel/ndb_limits.h | 2 +- storage/ndb/include/kernel/signaldata/AbortAll.hpp | 2 +- storage/ndb/include/kernel/signaldata/AccFrag.hpp | 2 +- storage/ndb/include/kernel/signaldata/AccLock.hpp | 2 +- storage/ndb/include/kernel/signaldata/AccScan.hpp | 2 +- storage/ndb/include/kernel/signaldata/AccSizeAltReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/AllocNodeId.hpp | 2 +- storage/ndb/include/kernel/signaldata/AlterIndx.hpp | 2 +- storage/ndb/include/kernel/signaldata/AlterTab.hpp | 2 +- storage/ndb/include/kernel/signaldata/AlterTable.hpp | 2 +- storage/ndb/include/kernel/signaldata/AlterTrig.hpp | 2 +- storage/ndb/include/kernel/signaldata/ApiBroadcast.hpp | 2 +- storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp | 2 +- storage/ndb/include/kernel/signaldata/ApiVersion.hpp | 2 +- storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp | 2 +- storage/ndb/include/kernel/signaldata/AttrInfo.hpp | 2 +- storage/ndb/include/kernel/signaldata/BackupContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/BackupImpl.hpp | 2 +- storage/ndb/include/kernel/signaldata/BackupSignalData.hpp | 2 +- storage/ndb/include/kernel/signaldata/BlockCommitOrd.hpp | 2 +- storage/ndb/include/kernel/signaldata/BuildIndx.hpp | 2 +- storage/ndb/include/kernel/signaldata/CheckNodeGroups.hpp | 2 +- storage/ndb/include/kernel/signaldata/CloseComReqConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/CmInit.hpp | 2 +- storage/ndb/include/kernel/signaldata/CmRegSignalData.hpp | 2 +- storage/ndb/include/kernel/signaldata/CmvmiCfgConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/CntrMasterConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/CntrMasterReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/CntrStart.hpp | 2 +- storage/ndb/include/kernel/signaldata/ConfigParamId.hpp | 2 +- storage/ndb/include/kernel/signaldata/ContinueFragmented.hpp | 2 +- storage/ndb/include/kernel/signaldata/CopyActive.hpp | 2 +- storage/ndb/include/kernel/signaldata/CopyFrag.hpp | 2 +- storage/ndb/include/kernel/signaldata/CopyGCIReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateEvnt.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateFrag.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateFragmentation.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateIndx.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateObj.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateTab.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateTable.hpp | 2 +- storage/ndb/include/kernel/signaldata/CreateTrig.hpp | 2 +- storage/ndb/include/kernel/signaldata/DiAddTab.hpp | 2 +- storage/ndb/include/kernel/signaldata/DiGetNodes.hpp | 2 +- storage/ndb/include/kernel/signaldata/DictLock.hpp | 2 +- storage/ndb/include/kernel/signaldata/DictObjOp.hpp | 2 +- storage/ndb/include/kernel/signaldata/DictSchemaInfo.hpp | 2 +- storage/ndb/include/kernel/signaldata/DictSizeAltReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/DictStart.hpp | 2 +- storage/ndb/include/kernel/signaldata/DictTabInfo.hpp | 2 +- storage/ndb/include/kernel/signaldata/DihAddFrag.hpp | 2 +- storage/ndb/include/kernel/signaldata/DihContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/DihSizeAltReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/DihStartTab.hpp | 2 +- storage/ndb/include/kernel/signaldata/DihSwitchReplica.hpp | 2 +- storage/ndb/include/kernel/signaldata/DisconnectRep.hpp | 2 +- storage/ndb/include/kernel/signaldata/DropFilegroup.hpp | 2 +- storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp | 2 +- storage/ndb/include/kernel/signaldata/DropIndx.hpp | 2 +- storage/ndb/include/kernel/signaldata/DropObj.hpp | 2 +- storage/ndb/include/kernel/signaldata/DropTab.hpp | 2 +- storage/ndb/include/kernel/signaldata/DropTabFile.hpp | 2 +- storage/ndb/include/kernel/signaldata/DropTable.hpp | 2 +- storage/ndb/include/kernel/signaldata/DropTrig.hpp | 2 +- storage/ndb/include/kernel/signaldata/DumpStateOrd.hpp | 2 +- storage/ndb/include/kernel/signaldata/EmptyLcp.hpp | 2 +- storage/ndb/include/kernel/signaldata/EndTo.hpp | 2 +- storage/ndb/include/kernel/signaldata/EventReport.hpp | 2 +- storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/ExecFragReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/Extent.hpp | 2 +- storage/ndb/include/kernel/signaldata/FailRep.hpp | 2 +- storage/ndb/include/kernel/signaldata/FireTrigOrd.hpp | 2 +- storage/ndb/include/kernel/signaldata/FsAppendReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/FsCloseReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/FsConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/FsOpenReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/FsRef.hpp | 2 +- storage/ndb/include/kernel/signaldata/FsRemoveReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/GCPSave.hpp | 2 +- storage/ndb/include/kernel/signaldata/GetTabInfo.hpp | 2 +- storage/ndb/include/kernel/signaldata/GetTableId.hpp | 2 +- storage/ndb/include/kernel/signaldata/GrepImpl.hpp | 2 +- storage/ndb/include/kernel/signaldata/HotSpareRep.hpp | 2 +- storage/ndb/include/kernel/signaldata/IndxAttrInfo.hpp | 2 +- storage/ndb/include/kernel/signaldata/IndxKeyInfo.hpp | 2 +- .../ndb/include/kernel/signaldata/InvalidateNodeLCPConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/InvalidateNodeLCPReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/KeyInfo.hpp | 2 +- storage/ndb/include/kernel/signaldata/LCP.hpp | 2 +- storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/ListTables.hpp | 2 +- storage/ndb/include/kernel/signaldata/LqhFrag.hpp | 2 +- storage/ndb/include/kernel/signaldata/LqhKey.hpp | 2 +- storage/ndb/include/kernel/signaldata/LqhSizeAltReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/LqhTransConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/ManagementServer.hpp | 2 +- storage/ndb/include/kernel/signaldata/MasterGCP.hpp | 2 +- storage/ndb/include/kernel/signaldata/MasterLCP.hpp | 2 +- storage/ndb/include/kernel/signaldata/NFCompleteRep.hpp | 2 +- storage/ndb/include/kernel/signaldata/NdbSttor.hpp | 2 +- storage/ndb/include/kernel/signaldata/NdbfsContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/NextScan.hpp | 2 +- storage/ndb/include/kernel/signaldata/NodeFailRep.hpp | 2 +- storage/ndb/include/kernel/signaldata/NodeStateSignalData.hpp | 2 +- storage/ndb/include/kernel/signaldata/PackedSignal.hpp | 2 +- storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/PrepDropTab.hpp | 2 +- storage/ndb/include/kernel/signaldata/PrepFailReqRef.hpp | 2 +- storage/ndb/include/kernel/signaldata/ReadConfig.hpp | 2 +- storage/ndb/include/kernel/signaldata/ReadNodesConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/RelTabMem.hpp | 2 +- storage/ndb/include/kernel/signaldata/RepImpl.hpp | 2 +- storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/RestoreImpl.hpp | 2 +- storage/ndb/include/kernel/signaldata/ResumeReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/RouteOrd.hpp | 2 +- storage/ndb/include/kernel/signaldata/ScanFrag.hpp | 2 +- storage/ndb/include/kernel/signaldata/ScanTab.hpp | 2 +- storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp | 2 +- storage/ndb/include/kernel/signaldata/SetVarReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/SignalData.hpp | 2 +- storage/ndb/include/kernel/signaldata/SignalDataPrint.hpp | 2 +- storage/ndb/include/kernel/signaldata/SignalDroppedRep.hpp | 2 +- storage/ndb/include/kernel/signaldata/SrFragidConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/StartFragReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/StartInfo.hpp | 2 +- storage/ndb/include/kernel/signaldata/StartMe.hpp | 2 +- storage/ndb/include/kernel/signaldata/StartOrd.hpp | 2 +- storage/ndb/include/kernel/signaldata/StartPerm.hpp | 2 +- storage/ndb/include/kernel/signaldata/StartRec.hpp | 2 +- storage/ndb/include/kernel/signaldata/StartTo.hpp | 2 +- storage/ndb/include/kernel/signaldata/StopMe.hpp | 2 +- storage/ndb/include/kernel/signaldata/StopPerm.hpp | 2 +- storage/ndb/include/kernel/signaldata/StopReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/SumaImpl.hpp | 2 +- storage/ndb/include/kernel/signaldata/SystemError.hpp | 2 +- storage/ndb/include/kernel/signaldata/TamperOrd.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcCommit.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcHbRep.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcIndx.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcKeyConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcKeyFailConf.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcKeyRef.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcKeyReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcRollbackRep.hpp | 2 +- storage/ndb/include/kernel/signaldata/TcSizeAltReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/TestOrd.hpp | 2 +- storage/ndb/include/kernel/signaldata/TransIdAI.hpp | 2 +- storage/ndb/include/kernel/signaldata/TrigAttrInfo.hpp | 2 +- storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/TupCommit.hpp | 2 +- storage/ndb/include/kernel/signaldata/TupFrag.hpp | 2 +- storage/ndb/include/kernel/signaldata/TupKey.hpp | 2 +- storage/ndb/include/kernel/signaldata/TupSizeAltReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/TuxBound.hpp | 2 +- storage/ndb/include/kernel/signaldata/TuxContinueB.hpp | 2 +- storage/ndb/include/kernel/signaldata/TuxMaint.hpp | 2 +- storage/ndb/include/kernel/signaldata/TuxSizeAltReq.hpp | 2 +- storage/ndb/include/kernel/signaldata/UpdateTo.hpp | 2 +- storage/ndb/include/kernel/signaldata/UpgradeStartup.hpp | 2 +- storage/ndb/include/kernel/signaldata/UtilDelete.hpp | 2 +- storage/ndb/include/kernel/signaldata/UtilExecute.hpp | 2 +- storage/ndb/include/kernel/signaldata/UtilLock.hpp | 2 +- storage/ndb/include/kernel/signaldata/UtilPrepare.hpp | 2 +- storage/ndb/include/kernel/signaldata/UtilRelease.hpp | 2 +- storage/ndb/include/kernel/signaldata/UtilSequence.hpp | 2 +- storage/ndb/include/kernel/signaldata/WaitGCP.hpp | 2 +- storage/ndb/include/kernel/trigger_definitions.h | 2 +- storage/ndb/include/logger/ConsoleLogHandler.hpp | 2 +- storage/ndb/include/logger/FileLogHandler.hpp | 2 +- storage/ndb/include/logger/LogHandler.hpp | 2 +- storage/ndb/include/logger/Logger.hpp | 2 +- storage/ndb/include/logger/SysLogHandler.hpp | 2 +- storage/ndb/include/mgmapi/mgmapi.h | 2 +- storage/ndb/include/mgmapi/mgmapi_config_parameters.h | 2 +- storage/ndb/include/mgmapi/mgmapi_config_parameters_debug.h | 2 +- storage/ndb/include/mgmapi/mgmapi_debug.h | 2 +- storage/ndb/include/mgmapi/mgmapi_error.h | 2 +- storage/ndb/include/mgmapi/ndbd_exit_codes.h | 2 +- storage/ndb/include/mgmcommon/ConfigRetriever.hpp | 2 +- storage/ndb/include/mgmcommon/IPCConfig.hpp | 2 +- storage/ndb/include/mgmcommon/MgmtErrorReporter.hpp | 2 +- storage/ndb/include/ndb_constants.h | 2 +- storage/ndb/include/ndb_global.h.in | 2 +- storage/ndb/include/ndb_init.h | 2 +- storage/ndb/include/ndb_net.h | 2 +- storage/ndb/include/ndb_types.h.in | 2 +- storage/ndb/include/ndb_version.h.in | 2 +- storage/ndb/include/ndbapi/Ndb.hpp | 2 +- storage/ndb/include/ndbapi/NdbApi.hpp | 2 +- storage/ndb/include/ndbapi/NdbBlob.hpp | 2 +- storage/ndb/include/ndbapi/NdbDictionary.hpp | 2 +- storage/ndb/include/ndbapi/NdbError.hpp | 2 +- storage/ndb/include/ndbapi/NdbIndexOperation.hpp | 2 +- storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp | 2 +- storage/ndb/include/ndbapi/NdbIndexStat.hpp | 2 +- storage/ndb/include/ndbapi/NdbPool.hpp | 2 +- storage/ndb/include/ndbapi/NdbRecAttr.hpp | 2 +- storage/ndb/include/ndbapi/NdbReceiver.hpp | 2 +- storage/ndb/include/ndbapi/NdbScanFilter.hpp | 2 +- storage/ndb/include/ndbapi/NdbScanOperation.hpp | 2 +- storage/ndb/include/ndbapi/NdbTransaction.hpp | 2 +- storage/ndb/include/ndbapi/ndb_cluster_connection.hpp | 2 +- storage/ndb/include/ndbapi/ndb_opt_defaults.h | 2 +- storage/ndb/include/ndbapi/ndbapi_limits.h | 2 +- storage/ndb/include/ndbapi/ndberror.h | 2 +- storage/ndb/include/newtonapi/dba.h | 2 +- storage/ndb/include/newtonapi/defs/pcn_types.h | 2 +- storage/ndb/include/portlib/NdbCondition.h | 2 +- storage/ndb/include/portlib/NdbConfig.h | 2 +- storage/ndb/include/portlib/NdbDaemon.h | 2 +- storage/ndb/include/portlib/NdbEnv.h | 2 +- storage/ndb/include/portlib/NdbHost.h | 2 +- storage/ndb/include/portlib/NdbMain.h | 2 +- storage/ndb/include/portlib/NdbMem.h | 2 +- storage/ndb/include/portlib/NdbMutex.h | 2 +- storage/ndb/include/portlib/NdbSleep.h | 2 +- storage/ndb/include/portlib/NdbTCP.h | 2 +- storage/ndb/include/portlib/NdbThread.h | 2 +- storage/ndb/include/portlib/NdbTick.h | 2 +- storage/ndb/include/portlib/PortDefs.h | 2 +- storage/ndb/include/portlib/prefetch.h | 2 +- storage/ndb/include/transporter/TransporterCallback.hpp | 2 +- storage/ndb/include/transporter/TransporterDefinitions.hpp | 2 +- storage/ndb/include/transporter/TransporterRegistry.hpp | 2 +- storage/ndb/include/util/BaseString.hpp | 2 +- storage/ndb/include/util/Bitmask.hpp | 2 +- storage/ndb/include/util/File.hpp | 2 +- storage/ndb/include/util/InputStream.hpp | 2 +- storage/ndb/include/util/NdbAutoPtr.hpp | 2 +- storage/ndb/include/util/NdbOut.hpp | 2 +- storage/ndb/include/util/NdbSqlUtil.hpp | 2 +- storage/ndb/include/util/OutputStream.hpp | 2 +- storage/ndb/include/util/Parser.hpp | 2 +- storage/ndb/include/util/Properties.hpp | 2 +- storage/ndb/include/util/SimpleProperties.hpp | 2 +- storage/ndb/include/util/SocketAuthenticator.hpp | 2 +- storage/ndb/include/util/SocketClient.hpp | 2 +- storage/ndb/include/util/SocketServer.hpp | 2 +- storage/ndb/include/util/UtilBuffer.hpp | 2 +- storage/ndb/include/util/Vector.hpp | 2 +- storage/ndb/include/util/basestring_vsnprintf.h | 2 +- storage/ndb/include/util/md5_hash.hpp | 2 +- storage/ndb/include/util/ndb_opts.h | 2 +- storage/ndb/include/util/ndb_rand.h | 2 +- storage/ndb/include/util/random.h | 2 +- storage/ndb/include/util/socket_io.h | 2 +- storage/ndb/include/util/uucode.h | 2 +- storage/ndb/include/util/version.h | 2 +- storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp | 2 +- storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp | 2 +- storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp | 2 +- storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp | 2 +- storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp | 2 +- storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp | 2 +- storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp | 2 +- storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp | 2 +- storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp | 2 +- storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp | 2 +- storage/ndb/src/Makefile.am | 2 +- storage/ndb/src/common/Makefile.am | 2 +- storage/ndb/src/common/debugger/BlockNames.cpp | 2 +- storage/ndb/src/common/debugger/DebuggerNames.cpp | 2 +- storage/ndb/src/common/debugger/EventLogger.cpp | 2 +- storage/ndb/src/common/debugger/GrepError.cpp | 2 +- storage/ndb/src/common/debugger/Makefile.am | 2 +- storage/ndb/src/common/debugger/SignalLoggerManager.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/AccLock.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/AlterIndx.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/AlterTab.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/AlterTable.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/AlterTrig.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/BackupImpl.cpp | 2 +- .../ndb/src/common/debugger/signaldata/BackupSignalData.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/CloseComReqConf.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/CntrStart.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/ContinueB.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/CopyGCI.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/CreateEvnt.cpp | 2 +- .../ndb/src/common/debugger/signaldata/CreateFragmentation.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/CreateIndx.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/CreateTrig.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/DihContinueB.cpp | 2 +- .../ndb/src/common/debugger/signaldata/DihSwitchReplicaReq.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/DisconnectRep.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/DropIndx.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/DropTab.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/DropTrig.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/FailRep.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/FireTrigOrd.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/FsAppendReq.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/FsCloseReq.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/FsConf.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/FsOpenReq.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/FsRef.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/GCPSave.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/IndxAttrInfo.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/IndxKeyInfo.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/LCP.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/LqhFrag.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/LqhKey.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/LqhTrans.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/Makefile.am | 2 +- storage/ndb/src/common/debugger/signaldata/MasterLCP.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/NdbSttor.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/NdbfsContinueB.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/PrepDropTab.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/PrepFailReqRef.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/ReadNodesConf.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/ScanFrag.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/ScanTab.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp | 2 +- .../ndb/src/common/debugger/signaldata/SignalDroppedRep.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/SignalNames.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/StartRec.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/SumaImpl.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/SystemError.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TcIndx.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TcKeyConf.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TcKeyRef.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TcKeyReq.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TcRollbackRep.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TrigAttrInfo.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TupCommit.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TupKey.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/TuxMaint.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/UtilDelete.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/UtilExecute.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/UtilLock.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/UtilPrepare.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp | 2 +- storage/ndb/src/common/debugger/signaldata/print.awk | 2 +- storage/ndb/src/common/logger/ConsoleLogHandler.cpp | 2 +- storage/ndb/src/common/logger/FileLogHandler.cpp | 2 +- storage/ndb/src/common/logger/LogHandler.cpp | 2 +- storage/ndb/src/common/logger/LogHandlerList.cpp | 2 +- storage/ndb/src/common/logger/LogHandlerList.hpp | 2 +- storage/ndb/src/common/logger/Logger.cpp | 2 +- storage/ndb/src/common/logger/Makefile.am | 2 +- storage/ndb/src/common/logger/SysLogHandler.cpp | 2 +- .../ndb/src/common/logger/listtest/LogHandlerListUnitTest.cpp | 2 +- .../ndb/src/common/logger/listtest/LogHandlerListUnitTest.hpp | 2 +- storage/ndb/src/common/logger/loggertest/LoggerUnitTest.cpp | 2 +- storage/ndb/src/common/logger/loggertest/LoggerUnitTest.hpp | 2 +- storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp | 2 +- storage/ndb/src/common/mgmcommon/IPCConfig.cpp | 2 +- storage/ndb/src/common/mgmcommon/Makefile.am | 2 +- storage/ndb/src/common/mgmcommon/printConfig/printConfig.cpp | 2 +- storage/ndb/src/common/portlib/NdbCondition.c | 2 +- storage/ndb/src/common/portlib/NdbConfig.c | 2 +- storage/ndb/src/common/portlib/NdbDaemon.c | 2 +- storage/ndb/src/common/portlib/NdbEnv.c | 2 +- storage/ndb/src/common/portlib/NdbHost.c | 2 +- storage/ndb/src/common/portlib/NdbMem.c | 2 +- storage/ndb/src/common/portlib/NdbPortLibTest.cpp | 2 +- storage/ndb/src/common/portlib/NdbSleep.c | 2 +- storage/ndb/src/common/portlib/NdbTCP.cpp | 2 +- storage/ndb/src/common/portlib/NdbThread.c | 2 +- storage/ndb/src/common/portlib/NdbTick.c | 2 +- storage/ndb/src/common/portlib/memtest.c | 2 +- storage/ndb/src/common/portlib/mmstest.cpp | 2 +- storage/ndb/src/common/portlib/munmaptest.cpp | 2 +- storage/ndb/src/common/portlib/win32/NdbCondition.c | 2 +- storage/ndb/src/common/portlib/win32/NdbDaemon.c | 2 +- storage/ndb/src/common/portlib/win32/NdbEnv.c | 2 +- storage/ndb/src/common/portlib/win32/NdbHost.c | 2 +- storage/ndb/src/common/portlib/win32/NdbMem.c | 2 +- storage/ndb/src/common/portlib/win32/NdbMutex.c | 2 +- storage/ndb/src/common/portlib/win32/NdbSleep.c | 2 +- storage/ndb/src/common/portlib/win32/NdbTCP.c | 2 +- storage/ndb/src/common/portlib/win32/NdbThread.c | 2 +- storage/ndb/src/common/portlib/win32/NdbTick.c | 2 +- storage/ndb/src/common/transporter/Makefile.am | 2 +- storage/ndb/src/common/transporter/Packer.cpp | 2 +- storage/ndb/src/common/transporter/Packer.hpp | 2 +- storage/ndb/src/common/transporter/SCI_Transporter.cpp | 2 +- storage/ndb/src/common/transporter/SCI_Transporter.hpp | 2 +- storage/ndb/src/common/transporter/SHM_Buffer.hpp | 2 +- storage/ndb/src/common/transporter/SHM_Transporter.cpp | 2 +- storage/ndb/src/common/transporter/SHM_Transporter.hpp | 2 +- storage/ndb/src/common/transporter/SHM_Transporter.unix.cpp | 2 +- storage/ndb/src/common/transporter/SHM_Transporter.win32.cpp | 2 +- storage/ndb/src/common/transporter/SendBuffer.cpp | 2 +- storage/ndb/src/common/transporter/SendBuffer.hpp | 2 +- storage/ndb/src/common/transporter/TCP_Transporter.cpp | 2 +- storage/ndb/src/common/transporter/TCP_Transporter.hpp | 2 +- storage/ndb/src/common/transporter/Transporter.cpp | 2 +- storage/ndb/src/common/transporter/Transporter.hpp | 2 +- .../src/common/transporter/TransporterInternalDefinitions.hpp | 2 +- storage/ndb/src/common/transporter/TransporterRegistry.cpp | 2 +- .../src/common/transporter/basictest/basicTransporterTest.cpp | 2 +- storage/ndb/src/common/transporter/buddy.cpp | 2 +- storage/ndb/src/common/transporter/buddy.hpp | 2 +- storage/ndb/src/common/transporter/failoverSCI/failoverSCI.cpp | 2 +- .../src/common/transporter/perftest/perfTransporterTest.cpp | 2 +- .../ndb/src/common/transporter/priotest/prioSCI/prioSCI.cpp | 2 +- .../ndb/src/common/transporter/priotest/prioSHM/prioSHM.cpp | 2 +- .../ndb/src/common/transporter/priotest/prioTCP/prioTCP.cpp | 2 +- .../src/common/transporter/priotest/prioTransporterTest.cpp | 2 +- .../src/common/transporter/priotest/prioTransporterTest.hpp | 2 +- storage/ndb/src/common/util/BaseString.cpp | 2 +- storage/ndb/src/common/util/Bitmask.cpp | 2 +- storage/ndb/src/common/util/ConfigValues.cpp | 2 +- storage/ndb/src/common/util/File.cpp | 2 +- storage/ndb/src/common/util/InputStream.cpp | 2 +- storage/ndb/src/common/util/NdbOut.cpp | 2 +- storage/ndb/src/common/util/NdbSqlUtil.cpp | 2 +- storage/ndb/src/common/util/OutputStream.cpp | 2 +- storage/ndb/src/common/util/Parser.cpp | 2 +- storage/ndb/src/common/util/Properties.cpp | 2 +- storage/ndb/src/common/util/SimpleProperties.cpp | 2 +- storage/ndb/src/common/util/SocketAuthenticator.cpp | 2 +- storage/ndb/src/common/util/SocketClient.cpp | 2 +- storage/ndb/src/common/util/SocketServer.cpp | 2 +- storage/ndb/src/common/util/basestring_vsnprintf.c | 2 +- storage/ndb/src/common/util/filetest/FileUnitTest.cpp | 2 +- storage/ndb/src/common/util/filetest/FileUnitTest.hpp | 2 +- storage/ndb/src/common/util/md5_hash.cpp | 2 +- storage/ndb/src/common/util/ndb_init.c | 2 +- storage/ndb/src/common/util/ndb_rand.c | 2 +- storage/ndb/src/common/util/new.cpp | 2 +- storage/ndb/src/common/util/random.c | 2 +- storage/ndb/src/common/util/socket_io.cpp | 2 +- storage/ndb/src/common/util/strdup.c | 2 +- .../ndb/src/common/util/testConfigValues/testConfigValues.cpp | 2 +- storage/ndb/src/common/util/testProperties/testProperties.cpp | 2 +- storage/ndb/src/common/util/testSimpleProperties/sp_test.cpp | 2 +- storage/ndb/src/common/util/uucode.c | 2 +- storage/ndb/src/common/util/version.c | 2 +- storage/ndb/src/cw/Makefile.am | 2 +- storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp | 2 +- storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h | 2 +- storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc | 2 +- storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp | 2 +- storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp | 2 +- storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h | 2 +- storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp | 2 +- storage/ndb/src/cw/cpcc-win32/C++/TreeView.h | 2 +- storage/ndb/src/cw/cpcc-win32/C++/resource.h | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/Database.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/Process.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs | 2 +- .../src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs | 2 +- storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs | 2 +- .../ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs | 2 +- storage/ndb/src/cw/cpcd/APIService.cpp | 2 +- storage/ndb/src/cw/cpcd/APIService.hpp | 2 +- storage/ndb/src/cw/cpcd/CPCD.cpp | 2 +- storage/ndb/src/cw/cpcd/CPCD.hpp | 2 +- storage/ndb/src/cw/cpcd/Makefile.am | 2 +- storage/ndb/src/cw/cpcd/Monitor.cpp | 2 +- storage/ndb/src/cw/cpcd/Process.cpp | 2 +- storage/ndb/src/cw/cpcd/common.cpp | 2 +- storage/ndb/src/cw/cpcd/common.hpp | 2 +- storage/ndb/src/cw/cpcd/main.cpp | 2 +- storage/ndb/src/cw/test/socketclient/socketClientTest.cpp | 2 +- storage/ndb/src/cw/util/ClientInterface.cpp | 2 +- storage/ndb/src/cw/util/ClientInterface.hpp | 2 +- storage/ndb/src/cw/util/SocketRegistry.cpp | 2 +- storage/ndb/src/cw/util/SocketRegistry.hpp | 2 +- storage/ndb/src/cw/util/SocketService.cpp | 2 +- storage/ndb/src/cw/util/SocketService.hpp | 2 +- storage/ndb/src/kernel/SimBlockList.cpp | 2 +- storage/ndb/src/kernel/blocks/backup/Backup.cpp | 2 +- storage/ndb/src/kernel/blocks/backup/Backup.hpp | 2 +- storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp | 2 +- storage/ndb/src/kernel/blocks/backup/BackupInit.cpp | 2 +- storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp | 2 +- storage/ndb/src/kernel/blocks/backup/Makefile.am | 2 +- storage/ndb/src/kernel/blocks/backup/read.cpp | 2 +- storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 2 +- storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp | 2 +- storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp | 2 +- storage/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp | 2 +- storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp | 2 +- storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp | 2 +- storage/ndb/src/kernel/blocks/dbdict/Makefile.am | 2 +- storage/ndb/src/kernel/blocks/dbdict/Master_AddTable.sfl | 2 +- storage/ndb/src/kernel/blocks/dbdict/SchemaFile.hpp | 2 +- storage/ndb/src/kernel/blocks/dbdict/Slave_AddTable.sfl | 2 +- storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp | 2 +- storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp | 2 +- storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp | 2 +- storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 2 +- storage/ndb/src/kernel/blocks/dbdih/Makefile.am | 2 +- storage/ndb/src/kernel/blocks/dbdih/Sysfile.hpp | 2 +- storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp | 2 +- .../ndb/src/kernel/blocks/dbdih/printSysfile/printSysfile.cpp | 2 +- storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 2 +- storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 2 +- storage/ndb/src/kernel/blocks/dblqh/Makefile.am | 2 +- storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp | 2 +- storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.cpp | 2 +- storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.hpp | 2 +- storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp | 2 +- storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/AttributeOffset.hpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupAbort.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupBuffer.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupPagMan.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/Makefile.am | 2 +- storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp | 2 +- storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp | 2 +- storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp | 2 +- storage/ndb/src/kernel/blocks/dbutil/DbUtil.hpp | 2 +- storage/ndb/src/kernel/blocks/diskpage.cpp | 2 +- storage/ndb/src/kernel/blocks/diskpage.hpp | 2 +- storage/ndb/src/kernel/blocks/lgman.hpp | 2 +- storage/ndb/src/kernel/blocks/mutexes.hpp | 2 +- storage/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp | 2 +- storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrSysTable.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp | 2 +- .../src/kernel/blocks/ndbfs/AsyncFileTest/AsyncFileTest.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.hpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/Filename.hpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp | 2 +- .../blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/OpenFiles.hpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/Pool.hpp | 2 +- storage/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp | 2 +- storage/ndb/src/kernel/blocks/pgman.cpp | 2 +- storage/ndb/src/kernel/blocks/pgman.hpp | 2 +- storage/ndb/src/kernel/blocks/print_file.cpp | 2 +- storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp | 2 +- storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp | 2 +- storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp | 2 +- storage/ndb/src/kernel/blocks/qmgr/timer.hpp | 2 +- storage/ndb/src/kernel/blocks/record_types.hpp | 2 +- storage/ndb/src/kernel/blocks/restore.cpp | 2 +- storage/ndb/src/kernel/blocks/restore.hpp | 2 +- storage/ndb/src/kernel/blocks/suma/Suma.hpp | 2 +- storage/ndb/src/kernel/blocks/suma/SumaInit.cpp | 2 +- storage/ndb/src/kernel/blocks/trix/Trix.cpp | 2 +- storage/ndb/src/kernel/blocks/trix/Trix.hpp | 2 +- storage/ndb/src/kernel/blocks/tsman.cpp | 2 +- storage/ndb/src/kernel/blocks/tsman.hpp | 2 +- storage/ndb/src/kernel/error/ErrorHandlingMacros.hpp | 2 +- storage/ndb/src/kernel/error/ErrorReporter.cpp | 2 +- storage/ndb/src/kernel/error/ErrorReporter.hpp | 2 +- storage/ndb/src/kernel/error/Makefile.am | 2 +- storage/ndb/src/kernel/error/TimeModule.cpp | 2 +- storage/ndb/src/kernel/error/TimeModule.hpp | 2 +- storage/ndb/src/kernel/error/ndbd_exit_codes.c | 2 +- storage/ndb/src/kernel/main.cpp | 2 +- storage/ndb/src/kernel/vm/Array.hpp | 2 +- storage/ndb/src/kernel/vm/ArrayPool.hpp | 2 +- storage/ndb/src/kernel/vm/CArray.hpp | 2 +- storage/ndb/src/kernel/vm/Callback.hpp | 2 +- storage/ndb/src/kernel/vm/ClusterConfiguration.cpp | 2 +- storage/ndb/src/kernel/vm/ClusterConfiguration.hpp | 2 +- storage/ndb/src/kernel/vm/Configuration.cpp | 2 +- storage/ndb/src/kernel/vm/Configuration.hpp | 2 +- storage/ndb/src/kernel/vm/DLCFifoList.hpp | 2 +- storage/ndb/src/kernel/vm/DLCHashTable.hpp | 2 +- storage/ndb/src/kernel/vm/DLFifoList.hpp | 2 +- storage/ndb/src/kernel/vm/DLHashTable.hpp | 2 +- storage/ndb/src/kernel/vm/DLHashTable2.hpp | 2 +- storage/ndb/src/kernel/vm/DLList.hpp | 2 +- storage/ndb/src/kernel/vm/DataBuffer.hpp | 2 +- storage/ndb/src/kernel/vm/DynArr256.cpp | 2 +- storage/ndb/src/kernel/vm/DynArr256.hpp | 2 +- storage/ndb/src/kernel/vm/Emulator.cpp | 2 +- storage/ndb/src/kernel/vm/Emulator.hpp | 2 +- storage/ndb/src/kernel/vm/FastScheduler.cpp | 2 +- storage/ndb/src/kernel/vm/FastScheduler.hpp | 2 +- storage/ndb/src/kernel/vm/GlobalData.hpp | 2 +- storage/ndb/src/kernel/vm/KeyDescriptor.hpp | 2 +- storage/ndb/src/kernel/vm/KeyTable.hpp | 2 +- storage/ndb/src/kernel/vm/KeyTable2.hpp | 2 +- storage/ndb/src/kernel/vm/KeyTable2Ref.hpp | 2 +- storage/ndb/src/kernel/vm/LinearPool.hpp | 2 +- storage/ndb/src/kernel/vm/LongSignal.hpp | 2 +- storage/ndb/src/kernel/vm/Makefile.am | 2 +- storage/ndb/src/kernel/vm/Mutex.cpp | 2 +- storage/ndb/src/kernel/vm/Mutex.hpp | 2 +- storage/ndb/src/kernel/vm/NdbdSuperPool.cpp | 2 +- storage/ndb/src/kernel/vm/NdbdSuperPool.hpp | 2 +- storage/ndb/src/kernel/vm/Pool.cpp | 2 +- storage/ndb/src/kernel/vm/Pool.hpp | 2 +- storage/ndb/src/kernel/vm/Prio.hpp | 2 +- storage/ndb/src/kernel/vm/RWPool.cpp | 2 +- storage/ndb/src/kernel/vm/RWPool.hpp | 2 +- storage/ndb/src/kernel/vm/RequestTracker.hpp | 2 +- storage/ndb/src/kernel/vm/Rope.cpp | 2 +- storage/ndb/src/kernel/vm/Rope.hpp | 2 +- storage/ndb/src/kernel/vm/SLFifoList.hpp | 2 +- storage/ndb/src/kernel/vm/SLList.hpp | 2 +- storage/ndb/src/kernel/vm/SafeCounter.cpp | 2 +- storage/ndb/src/kernel/vm/SafeCounter.hpp | 2 +- storage/ndb/src/kernel/vm/SectionReader.cpp | 2 +- storage/ndb/src/kernel/vm/SectionReader.hpp | 2 +- storage/ndb/src/kernel/vm/SignalCounter.hpp | 2 +- storage/ndb/src/kernel/vm/SimBlockList.hpp | 2 +- storage/ndb/src/kernel/vm/SimplePropertiesSection.cpp | 2 +- storage/ndb/src/kernel/vm/SimulatedBlock.cpp | 2 +- storage/ndb/src/kernel/vm/SimulatedBlock.hpp | 2 +- storage/ndb/src/kernel/vm/SuperPool.cpp | 2 +- storage/ndb/src/kernel/vm/SuperPool.hpp | 2 +- storage/ndb/src/kernel/vm/ThreadConfig.cpp | 2 +- storage/ndb/src/kernel/vm/ThreadConfig.hpp | 2 +- storage/ndb/src/kernel/vm/TimeQueue.cpp | 2 +- storage/ndb/src/kernel/vm/TimeQueue.hpp | 2 +- storage/ndb/src/kernel/vm/TransporterCallback.cpp | 2 +- storage/ndb/src/kernel/vm/VMSignal.cpp | 2 +- storage/ndb/src/kernel/vm/VMSignal.hpp | 2 +- storage/ndb/src/kernel/vm/WOPool.cpp | 2 +- storage/ndb/src/kernel/vm/WOPool.hpp | 2 +- storage/ndb/src/kernel/vm/WaitQueue.hpp | 2 +- storage/ndb/src/kernel/vm/WatchDog.cpp | 2 +- storage/ndb/src/kernel/vm/WatchDog.hpp | 2 +- storage/ndb/src/kernel/vm/al_test/arrayListTest.cpp | 2 +- storage/ndb/src/kernel/vm/al_test/arrayPoolTest.cpp | 2 +- storage/ndb/src/kernel/vm/al_test/main.cpp | 2 +- storage/ndb/src/kernel/vm/bench_pool.cpp | 2 +- storage/ndb/src/kernel/vm/ndbd_malloc.cpp | 2 +- storage/ndb/src/kernel/vm/ndbd_malloc.hpp | 2 +- storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp | 2 +- storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp | 2 +- storage/ndb/src/kernel/vm/pc.hpp | 2 +- storage/ndb/src/kernel/vm/testCopy/rr.cpp | 2 +- storage/ndb/src/kernel/vm/testCopy/testCopy.cpp | 2 +- storage/ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp | 2 +- storage/ndb/src/kernel/vm/testLongSig/testLongSig.cpp | 2 +- storage/ndb/src/kernel/vm/testSimplePropertiesSection/test.cpp | 2 +- storage/ndb/src/kernel/vm/testSuperPool.cpp | 2 +- storage/ndb/src/mgmapi/LocalConfig.cpp | 2 +- storage/ndb/src/mgmapi/LocalConfig.hpp | 2 +- storage/ndb/src/mgmapi/Makefile.am | 2 +- storage/ndb/src/mgmapi/mgmapi.cpp | 2 +- storage/ndb/src/mgmapi/mgmapi_configuration.cpp | 2 +- storage/ndb/src/mgmapi/mgmapi_configuration.hpp | 2 +- storage/ndb/src/mgmapi/mgmapi_internal.h | 2 +- storage/ndb/src/mgmapi/ndb_logevent.cpp | 2 +- storage/ndb/src/mgmapi/ndb_logevent.hpp | 2 +- storage/ndb/src/mgmapi/test/keso.c | 2 +- storage/ndb/src/mgmapi/test/mgmSrvApi.cpp | 2 +- storage/ndb/src/mgmclient/CommandInterpreter.cpp | 2 +- storage/ndb/src/mgmclient/Makefile.am | 2 +- storage/ndb/src/mgmclient/main.cpp | 2 +- storage/ndb/src/mgmclient/ndb_mgmclient.h | 2 +- storage/ndb/src/mgmclient/ndb_mgmclient.hpp | 2 +- storage/ndb/src/mgmclient/test_cpcd/test_cpcd.cpp | 2 +- storage/ndb/src/mgmsrv/Config.cpp | 2 +- storage/ndb/src/mgmsrv/Config.hpp | 2 +- storage/ndb/src/mgmsrv/ConfigInfo.cpp | 2 +- storage/ndb/src/mgmsrv/ConfigInfo.hpp | 2 +- storage/ndb/src/mgmsrv/InitConfigFileParser.hpp | 2 +- storage/ndb/src/mgmsrv/MgmtSrvr.cpp | 2 +- storage/ndb/src/mgmsrv/MgmtSrvr.hpp | 2 +- storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp | 2 +- storage/ndb/src/mgmsrv/MgmtSrvrGeneralSignalHandling.cpp | 2 +- storage/ndb/src/mgmsrv/Services.cpp | 2 +- storage/ndb/src/mgmsrv/Services.hpp | 2 +- storage/ndb/src/mgmsrv/SignalQueue.cpp | 2 +- storage/ndb/src/mgmsrv/SignalQueue.hpp | 2 +- storage/ndb/src/mgmsrv/convertStrToInt.cpp | 2 +- storage/ndb/src/mgmsrv/convertStrToInt.hpp | 2 +- storage/ndb/src/mgmsrv/main.cpp | 2 +- storage/ndb/src/mgmsrv/mkconfig/mkconfig.cpp | 2 +- storage/ndb/src/ndbapi/API.hpp | 2 +- storage/ndb/src/ndbapi/ClusterMgr.cpp | 2 +- storage/ndb/src/ndbapi/ClusterMgr.hpp | 2 +- storage/ndb/src/ndbapi/DictCache.hpp | 2 +- storage/ndb/src/ndbapi/Makefile.am | 2 +- storage/ndb/src/ndbapi/Ndb.cpp | 2 +- storage/ndb/src/ndbapi/NdbApiSignal.cpp | 2 +- storage/ndb/src/ndbapi/NdbApiSignal.hpp | 2 +- storage/ndb/src/ndbapi/NdbBlob.cpp | 2 +- storage/ndb/src/ndbapi/NdbBlobImpl.hpp | 2 +- storage/ndb/src/ndbapi/NdbDictionary.cpp | 2 +- storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp | 2 +- storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp | 2 +- storage/ndb/src/ndbapi/NdbErrorOut.cpp | 2 +- storage/ndb/src/ndbapi/NdbImpl.hpp | 2 +- storage/ndb/src/ndbapi/NdbIndexOperation.cpp | 2 +- storage/ndb/src/ndbapi/NdbIndexStat.cpp | 2 +- storage/ndb/src/ndbapi/NdbLinHash.hpp | 2 +- storage/ndb/src/ndbapi/NdbOperation.cpp | 2 +- storage/ndb/src/ndbapi/NdbOperationDefine.cpp | 2 +- storage/ndb/src/ndbapi/NdbOperationExec.cpp | 2 +- storage/ndb/src/ndbapi/NdbOperationInt.cpp | 2 +- storage/ndb/src/ndbapi/NdbOperationScan.cpp | 2 +- storage/ndb/src/ndbapi/NdbOperationSearch.cpp | 2 +- storage/ndb/src/ndbapi/NdbPool.cpp | 2 +- storage/ndb/src/ndbapi/NdbPoolImpl.cpp | 2 +- storage/ndb/src/ndbapi/NdbPoolImpl.hpp | 2 +- storage/ndb/src/ndbapi/NdbRecAttr.cpp | 2 +- storage/ndb/src/ndbapi/NdbReceiver.cpp | 2 +- storage/ndb/src/ndbapi/NdbScanFilter.cpp | 2 +- storage/ndb/src/ndbapi/NdbScanOperation.cpp | 2 +- storage/ndb/src/ndbapi/NdbTransaction.cpp | 2 +- storage/ndb/src/ndbapi/NdbTransactionScan.cpp | 2 +- storage/ndb/src/ndbapi/NdbUtil.cpp | 2 +- storage/ndb/src/ndbapi/NdbUtil.hpp | 2 +- storage/ndb/src/ndbapi/NdbWaiter.hpp | 2 +- storage/ndb/src/ndbapi/Ndberr.cpp | 2 +- storage/ndb/src/ndbapi/Ndbif.cpp | 2 +- storage/ndb/src/ndbapi/Ndbinit.cpp | 2 +- storage/ndb/src/ndbapi/Ndblist.cpp | 2 +- storage/ndb/src/ndbapi/ObjectMap.cpp | 2 +- storage/ndb/src/ndbapi/ObjectMap.hpp | 2 +- storage/ndb/src/ndbapi/SignalSender.cpp | 2 +- storage/ndb/src/ndbapi/SignalSender.hpp | 2 +- storage/ndb/src/ndbapi/TransporterFacade.cpp | 2 +- storage/ndb/src/ndbapi/TransporterFacade.hpp | 2 +- storage/ndb/src/ndbapi/ndb_cluster_connection.cpp | 2 +- storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp | 2 +- storage/ndb/src/ndbapi/ndberror.c | 2 +- storage/ndb/src/ndbapi/signal-sender/SignalSender.cpp | 2 +- storage/ndb/src/ndbapi/signal-sender/SignalSender.hpp | 2 +- storage/ndb/test/Makefile.am | 2 +- storage/ndb/test/include/AtrtClient.hpp | 2 +- storage/ndb/test/include/CpcClient.hpp | 2 +- storage/ndb/test/include/DbUtil.hpp | 2 +- storage/ndb/test/include/HugoAsynchTransactions.hpp | 2 +- storage/ndb/test/include/HugoCalculator.hpp | 2 +- storage/ndb/test/include/HugoOperations.hpp | 2 +- storage/ndb/test/include/HugoTransactions.hpp | 2 +- storage/ndb/test/include/NDBT.hpp | 2 +- storage/ndb/test/include/NDBT_DataSet.hpp | 2 +- storage/ndb/test/include/NDBT_DataSetTransaction.hpp | 2 +- storage/ndb/test/include/NDBT_Error.hpp | 2 +- storage/ndb/test/include/NDBT_Output.hpp | 2 +- storage/ndb/test/include/NDBT_ResultRow.hpp | 2 +- storage/ndb/test/include/NDBT_ReturnCodes.h | 2 +- storage/ndb/test/include/NDBT_Stats.hpp | 2 +- storage/ndb/test/include/NDBT_Table.hpp | 2 +- storage/ndb/test/include/NDBT_Tables.hpp | 2 +- storage/ndb/test/include/NDBT_Test.hpp | 2 +- storage/ndb/test/include/NDBT_Thread.hpp | 2 +- storage/ndb/test/include/NdbBackup.hpp | 2 +- storage/ndb/test/include/NdbConfig.hpp | 2 +- storage/ndb/test/include/NdbGrep.hpp | 2 +- storage/ndb/test/include/NdbMixRestarter.hpp | 2 +- storage/ndb/test/include/NdbRestarter.hpp | 2 +- storage/ndb/test/include/NdbRestarts.hpp | 2 +- storage/ndb/test/include/NdbSchemaCon.hpp | 2 +- storage/ndb/test/include/NdbSchemaOp.hpp | 2 +- storage/ndb/test/include/NdbTest.hpp | 2 +- storage/ndb/test/include/NdbTimer.hpp | 2 +- storage/ndb/test/include/TestNdbEventOperation.hpp | 2 +- storage/ndb/test/include/UtilTransactions.hpp | 2 +- storage/ndb/test/include/getarg.h | 2 +- storage/ndb/test/ndbapi/InsertRecs.cpp | 2 +- storage/ndb/test/ndbapi/Makefile.am | 2 +- storage/ndb/test/ndbapi/ScanFilter.hpp | 2 +- storage/ndb/test/ndbapi/ScanFunctions.hpp | 2 +- storage/ndb/test/ndbapi/ScanInterpretTest.hpp | 2 +- storage/ndb/test/ndbapi/TraceNdbApi.cpp | 2 +- storage/ndb/test/ndbapi/VerifyNdbApi.cpp | 2 +- storage/ndb/test/ndbapi/acid.cpp | 2 +- storage/ndb/test/ndbapi/acid2.cpp | 2 +- storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp | 2 +- storage/ndb/test/ndbapi/adoInsertRecs.cpp | 2 +- storage/ndb/test/ndbapi/asyncGenerator.cpp | 2 +- storage/ndb/test/ndbapi/bank/Bank.cpp | 2 +- storage/ndb/test/ndbapi/bank/Bank.hpp | 2 +- storage/ndb/test/ndbapi/bank/BankLoad.cpp | 2 +- storage/ndb/test/ndbapi/bank/Makefile.am | 2 +- storage/ndb/test/ndbapi/bank/bankCreator.cpp | 2 +- storage/ndb/test/ndbapi/bank/bankMakeGL.cpp | 2 +- storage/ndb/test/ndbapi/bank/bankSumAccounts.cpp | 2 +- storage/ndb/test/ndbapi/bank/bankTimer.cpp | 2 +- storage/ndb/test/ndbapi/bank/bankTransactionMaker.cpp | 2 +- storage/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp | 2 +- storage/ndb/test/ndbapi/bank/testBank.cpp | 2 +- storage/ndb/test/ndbapi/bench/asyncGenerator.cpp | 2 +- storage/ndb/test/ndbapi/bench/dbGenerator.h | 2 +- storage/ndb/test/ndbapi/bench/dbPopulate.cpp | 2 +- storage/ndb/test/ndbapi/bench/dbPopulate.h | 2 +- storage/ndb/test/ndbapi/bench/macros.h | 2 +- storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp | 2 +- storage/ndb/test/ndbapi/bench/mainPopulate.cpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_async1.cpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_async2.cpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_error.hpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_schema.hpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_user_transaction.cpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_user_transaction2.cpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_user_transaction3.cpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_user_transaction4.cpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_user_transaction5.cpp | 2 +- storage/ndb/test/ndbapi/bench/ndb_user_transaction6.cpp | 2 +- storage/ndb/test/ndbapi/bench/testData.h | 2 +- storage/ndb/test/ndbapi/bench/testDefinitions.h | 2 +- storage/ndb/test/ndbapi/bench/userInterface.cpp | 2 +- storage/ndb/test/ndbapi/bench/userInterface.h | 2 +- storage/ndb/test/ndbapi/benchronja.cpp | 2 +- storage/ndb/test/ndbapi/bulk_copy.cpp | 2 +- storage/ndb/test/ndbapi/cdrserver.cpp | 2 +- storage/ndb/test/ndbapi/celloDb.cpp | 2 +- storage/ndb/test/ndbapi/create_all_tabs.cpp | 2 +- storage/ndb/test/ndbapi/create_tab.cpp | 2 +- storage/ndb/test/ndbapi/drop_all_tabs.cpp | 2 +- storage/ndb/test/ndbapi/flexAsynch.cpp | 2 +- storage/ndb/test/ndbapi/flexBench.cpp | 2 +- storage/ndb/test/ndbapi/flexHammer.cpp | 2 +- storage/ndb/test/ndbapi/flexScan.cpp | 2 +- storage/ndb/test/ndbapi/flexTT.cpp | 2 +- storage/ndb/test/ndbapi/flexTimedAsynch.cpp | 2 +- storage/ndb/test/ndbapi/flex_bench_mysql.cpp | 2 +- storage/ndb/test/ndbapi/index.cpp | 2 +- storage/ndb/test/ndbapi/index2.cpp | 2 +- storage/ndb/test/ndbapi/initronja.cpp | 2 +- storage/ndb/test/ndbapi/interpreterInTup.cpp | 2 +- storage/ndb/test/ndbapi/mainAsyncGenerator.cpp | 2 +- storage/ndb/test/ndbapi/msa.cpp | 2 +- storage/ndb/test/ndbapi/ndb_async1.cpp | 2 +- storage/ndb/test/ndbapi/ndb_async2.cpp | 2 +- storage/ndb/test/ndbapi/ndb_user_populate.cpp | 2 +- storage/ndb/test/ndbapi/ndb_user_transaction.cpp | 2 +- storage/ndb/test/ndbapi/ndb_user_transaction2.cpp | 2 +- storage/ndb/test/ndbapi/ndb_user_transaction3.cpp | 2 +- storage/ndb/test/ndbapi/ndb_user_transaction4.cpp | 2 +- storage/ndb/test/ndbapi/ndb_user_transaction5.cpp | 2 +- storage/ndb/test/ndbapi/ndb_user_transaction6.cpp | 2 +- storage/ndb/test/ndbapi/restarter.cpp | 2 +- storage/ndb/test/ndbapi/restarter2.cpp | 2 +- storage/ndb/test/ndbapi/restarts.cpp | 2 +- storage/ndb/test/ndbapi/size.cpp | 2 +- storage/ndb/test/ndbapi/testBackup.cpp | 2 +- storage/ndb/test/ndbapi/testBasic.cpp | 2 +- storage/ndb/test/ndbapi/testBasicAsynch.cpp | 2 +- storage/ndb/test/ndbapi/testBlobs.cpp | 2 +- storage/ndb/test/ndbapi/testDataBuffers.cpp | 2 +- storage/ndb/test/ndbapi/testDeadlock.cpp | 2 +- storage/ndb/test/ndbapi/testDict.cpp | 2 +- storage/ndb/test/ndbapi/testGrepVerify.cpp | 2 +- storage/ndb/test/ndbapi/testIndex.cpp | 2 +- storage/ndb/test/ndbapi/testIndexStat.cpp | 2 +- storage/ndb/test/ndbapi/testInterpreter.cpp | 2 +- storage/ndb/test/ndbapi/testMgm.cpp | 2 +- storage/ndb/test/ndbapi/testNDBT.cpp | 2 +- storage/ndb/test/ndbapi/testNdbApi.cpp | 2 +- storage/ndb/test/ndbapi/testNodeRestart.cpp | 2 +- storage/ndb/test/ndbapi/testOIBasic.cpp | 2 +- storage/ndb/test/ndbapi/testOperations.cpp | 2 +- storage/ndb/test/ndbapi/testOrderedIndex.cpp | 2 +- storage/ndb/test/ndbapi/testPartitioning.cpp | 2 +- storage/ndb/test/ndbapi/testReadPerf.cpp | 2 +- storage/ndb/test/ndbapi/testRestartGci.cpp | 2 +- storage/ndb/test/ndbapi/testSRBank.cpp | 2 +- storage/ndb/test/ndbapi/testScan.cpp | 2 +- storage/ndb/test/ndbapi/testScanInterpreter.cpp | 2 +- storage/ndb/test/ndbapi/testScanPerf.cpp | 2 +- storage/ndb/test/ndbapi/testSystemRestart.cpp | 2 +- storage/ndb/test/ndbapi/testTimeout.cpp | 2 +- storage/ndb/test/ndbapi/testTransactions.cpp | 2 +- storage/ndb/test/ndbapi/test_event.cpp | 2 +- storage/ndb/test/ndbapi/test_event_merge.cpp | 2 +- storage/ndb/test/ndbapi/userInterface.cpp | 2 +- storage/ndb/test/ndbnet/test.run | 2 +- storage/ndb/test/ndbnet/testError.run | 2 +- storage/ndb/test/ndbnet/testMNF.run | 2 +- storage/ndb/test/ndbnet/testNR.run | 2 +- storage/ndb/test/ndbnet/testNR1.run | 2 +- storage/ndb/test/ndbnet/testNR4.run | 2 +- storage/ndb/test/ndbnet/testSRhang.run | 2 +- storage/ndb/test/ndbnet/testTR295.run | 2 +- storage/ndb/test/newtonapi/basic_test/basic/basic.cpp | 2 +- storage/ndb/test/newtonapi/basic_test/bulk_read/br_test.cpp | 2 +- storage/ndb/test/newtonapi/basic_test/common.cpp | 2 +- storage/ndb/test/newtonapi/basic_test/common.hpp | 2 +- .../test/newtonapi/basic_test/ptr_binding/ptr_binding_test.cpp | 2 +- storage/ndb/test/newtonapi/basic_test/too_basic.cpp | 2 +- storage/ndb/test/newtonapi/perf_test/perf.cpp | 2 +- storage/ndb/test/odbc/SQL99_test/SQL99_test.cpp | 2 +- storage/ndb/test/odbc/SQL99_test/SQL99_test.h | 2 +- storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE.cpp | 2 +- storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE_HDBC.cpp | 2 +- storage/ndb/test/odbc/client/NDBT_SQLConnect.cpp | 2 +- storage/ndb/test/odbc/client/NDBT_SQLPrepare.cpp | 2 +- storage/ndb/test/odbc/client/SQLAllocEnvTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLAllocHandleTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLAllocHandleTest_bf.cpp | 2 +- storage/ndb/test/odbc/client/SQLBindColTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLBindParameterTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLCancelTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLCloseCursorTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLColAttributeTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLColAttributeTest1.cpp | 2 +- storage/ndb/test/odbc/client/SQLColAttributeTest2.cpp | 2 +- storage/ndb/test/odbc/client/SQLColAttributeTest3.cpp | 2 +- storage/ndb/test/odbc/client/SQLConnectTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLCopyDescTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLDescribeColTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLDisconnectTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLDriverConnectTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLEndTranTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLErrorTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLExecDirectTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLExecuteTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLFetchScrollTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLFetchTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLFreeHandleTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLFreeStmtTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetConnectAttrTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetCursorNameTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetDataTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetDescFieldTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetDescRecTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetDiagFieldTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetDiagRecSimpleTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetDiagRecTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetEnvAttrTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetFunctionsTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetInfoTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetStmtAttrTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLGetTypeInfoTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLMoreResultsTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLNumResultColsTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLParamDataTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLPrepareTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLPutDataTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLRowCountTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLSetConnectAttrTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLSetCursorNameTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLSetDescFieldTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLSetDescRecTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLSetEnvAttrTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLSetStmtAttrTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLTablesTest.cpp | 2 +- storage/ndb/test/odbc/client/SQLTransactTest.cpp | 2 +- storage/ndb/test/odbc/client/common.hpp | 2 +- storage/ndb/test/odbc/client/main.cpp | 2 +- storage/ndb/test/odbc/driver/testOdbcDriver.cpp | 2 +- storage/ndb/test/odbc/test_compiler/test_compiler.cpp | 2 +- storage/ndb/test/run-test/atrt-analyze-result.sh | 2 +- storage/ndb/test/run-test/atrt-clear-result.sh | 2 +- storage/ndb/test/run-test/atrt-gather-result.sh | 2 +- storage/ndb/test/run-test/atrt-setup.sh | 2 +- storage/ndb/test/run-test/atrt-testBackup | 2 +- storage/ndb/test/run-test/atrt.hpp | 2 +- storage/ndb/test/run-test/daily-devel-tests.txt | 2 +- storage/ndb/test/run-test/main.cpp | 2 +- storage/ndb/test/run-test/make-index.sh | 2 +- storage/ndb/test/src/CpcClient.cpp | 2 +- storage/ndb/test/src/DbUtil.cpp | 2 +- storage/ndb/test/src/HugoAsynchTransactions.cpp | 2 +- storage/ndb/test/src/HugoCalculator.cpp | 2 +- storage/ndb/test/src/HugoOperations.cpp | 2 +- storage/ndb/test/src/HugoTransactions.cpp | 2 +- storage/ndb/test/src/Makefile.am | 2 +- storage/ndb/test/src/NDBT_Error.cpp | 2 +- storage/ndb/test/src/NDBT_Output.cpp | 2 +- storage/ndb/test/src/NDBT_ResultRow.cpp | 2 +- storage/ndb/test/src/NDBT_ReturnCodes.cpp | 2 +- storage/ndb/test/src/NDBT_Table.cpp | 2 +- storage/ndb/test/src/NDBT_Tables.cpp | 2 +- storage/ndb/test/src/NDBT_Test.cpp | 2 +- storage/ndb/test/src/NDBT_Thread.cpp | 2 +- storage/ndb/test/src/NdbBackup.cpp | 2 +- storage/ndb/test/src/NdbConfig.cpp | 2 +- storage/ndb/test/src/NdbGrep.cpp | 2 +- storage/ndb/test/src/NdbMixRestarter.cpp | 2 +- storage/ndb/test/src/NdbRestarter.cpp | 2 +- storage/ndb/test/src/NdbRestarts.cpp | 2 +- storage/ndb/test/src/NdbSchemaCon.cpp | 2 +- storage/ndb/test/src/NdbSchemaOp.cpp | 2 +- storage/ndb/test/src/UtilTransactions.cpp | 2 +- storage/ndb/test/tools/Makefile.am | 2 +- storage/ndb/test/tools/copy_tab.cpp | 2 +- storage/ndb/test/tools/cpcc.cpp | 2 +- storage/ndb/test/tools/create_index.cpp | 2 +- storage/ndb/test/tools/hugoCalculator.cpp | 2 +- storage/ndb/test/tools/hugoFill.cpp | 2 +- storage/ndb/test/tools/hugoLoad.cpp | 2 +- storage/ndb/test/tools/hugoLockRecords.cpp | 2 +- storage/ndb/test/tools/hugoPkDelete.cpp | 2 +- storage/ndb/test/tools/hugoPkRead.cpp | 2 +- storage/ndb/test/tools/hugoPkReadRecord.cpp | 2 +- storage/ndb/test/tools/hugoPkUpdate.cpp | 2 +- storage/ndb/test/tools/hugoScanRead.cpp | 2 +- storage/ndb/test/tools/hugoScanUpdate.cpp | 2 +- storage/ndb/test/tools/listen.cpp | 2 +- storage/ndb/test/tools/rep_latency.cpp | 2 +- storage/ndb/test/tools/restart.cpp | 2 +- storage/ndb/test/tools/transproxy.cpp | 2 +- storage/ndb/test/tools/verify_index.cpp | 2 +- storage/ndb/tools/Makefile.am | 2 +- storage/ndb/tools/clean-links.sh | 2 +- storage/ndb/tools/delete_all.cpp | 2 +- storage/ndb/tools/desc.cpp | 2 +- storage/ndb/tools/drop_index.cpp | 2 +- storage/ndb/tools/drop_tab.cpp | 2 +- storage/ndb/tools/listTables.cpp | 2 +- storage/ndb/tools/make-errors.pl | 2 +- storage/ndb/tools/make-links.sh | 2 +- storage/ndb/tools/ndb_config.cpp | 2 +- storage/ndb/tools/ndb_error_reporter | 2 +- storage/ndb/tools/ndb_test_platform.cpp | 2 +- storage/ndb/tools/ndbsql.cpp | 2 +- storage/ndb/tools/restore/Restore.cpp | 2 +- storage/ndb/tools/restore/Restore.hpp | 2 +- storage/ndb/tools/restore/consumer.cpp | 2 +- storage/ndb/tools/restore/consumer.hpp | 2 +- storage/ndb/tools/restore/consumer_printer.cpp | 2 +- storage/ndb/tools/restore/consumer_printer.hpp | 2 +- storage/ndb/tools/restore/consumer_restore.hpp | 2 +- storage/ndb/tools/restore/ndb_nodegroup_map.h | 2 +- storage/ndb/tools/restore/restore_main.cpp | 2 +- storage/ndb/tools/rgrep | 2 +- storage/ndb/tools/select_all.cpp | 2 +- storage/ndb/tools/select_count.cpp | 2 +- storage/ndb/tools/waiter.cpp | 2 +- strings/bchange.c | 2 +- strings/bfill.c | 2 +- strings/bmove.c | 2 +- strings/bmove512.c | 2 +- strings/bmove_upp-sparc.s | 2 +- strings/bmove_upp.c | 2 +- strings/ctype-mb.c | 2 +- strings/ctype-simple.c | 3 +-- strings/ctype-uca.c | 3 +-- strings/ctype-utf8.c | 2 +- strings/ctype.c | 3 +-- strings/do_ctype.c | 2 +- strings/int2str.c | 2 +- strings/is_prefix.c | 2 +- strings/llstr.c | 2 +- strings/longlong2str-x86.s | 2 +- strings/longlong2str.c | 2 +- strings/longlong2str_asm.c | 2 +- strings/macros.asm | 2 +- strings/my_strtoll10-x86.s | 2 +- strings/my_strtoll10.c | 2 +- strings/ptr_cmp.asm | 2 +- strings/r_strinstr.c | 2 +- strings/str2int.c | 2 +- strings/str_alloc.c | 2 +- strings/strappend-sparc.s | 2 +- strings/strappend.c | 2 +- strings/strcend.c | 2 +- strings/strcont.c | 2 +- strings/strend-sparc.s | 2 +- strings/strend.c | 2 +- strings/strfill.c | 2 +- strings/strings-not-used.h | 2 +- strings/strings-x86.s | 2 +- strings/strings.asm | 2 +- strings/strinstr-sparc.s | 2 +- strings/strinstr.c | 2 +- strings/strmake-sparc.s | 2 +- strings/strmake.c | 2 +- strings/strmov-sparc.s | 2 +- strings/strmov.c | 2 +- strings/strnlen.c | 2 +- strings/strnmov-sparc.s | 2 +- strings/strnmov.c | 2 +- strings/strstr-sparc.s | 2 +- strings/strstr.c | 2 +- strings/strto.c | 2 +- strings/strtol.c | 2 +- strings/strtoll.c | 2 +- strings/strtoul.c | 2 +- strings/strtoull.c | 2 +- strings/strxmov-sparc.s | 2 +- strings/strxmov.asm | 2 +- strings/strxmov.c | 2 +- strings/strxnmov.c | 2 +- strings/t_ctype.h | 2 +- strings/udiv.c | 2 +- support-files/MacOSX/Makefile.am | 2 +- support-files/MySQL-shared-compat.spec.sh | 2 +- support-files/RHEL4-SElinux/Makefile.am | 2 +- support-files/mysql.spec.sh | 2 +- tests/CMakeLists.txt | 2 +- tests/Makefile.am | 3 +-- tests/connect_test.c | 2 +- tests/fork_big.pl | 2 +- tests/fork_big2.pl | 2 +- tests/insert_test.c | 2 +- tests/list_test.c | 2 +- tests/select_test.c | 2 +- tests/showdb_test.c | 2 +- tests/ssl_test.c | 2 +- tests/thread_test.c | 2 +- unittest/mytap/Makefile.am | 2 +- unittest/mytap/t/Makefile.am | 2 +- vio/CMakeLists.txt | 2 +- vio/test-ssl.c | 2 +- vio/test-sslclient.c | 2 +- vio/test-sslserver.c | 2 +- vio/viosocket.c | 2 +- vio/viossl.c | 2 +- vio/viosslfactories.c | 3 +-- vio/viotest-ssl.c | 2 +- win/build-nmake-x64.bat | 2 +- win/build-nmake.bat | 2 +- win/build-vs71.bat | 2 +- win/build-vs8.bat | 2 +- zlib/CMakeLists.txt | 2 +- zlib/Makefile.am | 2 +- 1668 files changed, 1668 insertions(+), 1697 deletions(-) diff --git a/BUILD/Makefile.am b/BUILD/Makefile.am index 72b586a72de..7b945af0f65 100644 --- a/BUILD/Makefile.am +++ b/BUILD/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2002, 2004-2005 MySQL AB +# Copyright (c) 2002, 2004-2008 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/BUILD/autorun.sh b/BUILD/autorun.sh index ef298b54eec..a97cec79c15 100755 --- a/BUILD/autorun.sh +++ b/BUILD/autorun.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005-2007 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/BUILD/compile-alpha-ccc b/BUILD/compile-alpha-ccc index 01bfaa9af68..02cf82db869 100755 --- a/BUILD/compile-alpha-ccc +++ b/BUILD/compile-alpha-ccc @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2000, 2005 MySQL AB +# Copyright (c) 2000, 2005, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-alpha-cxx b/BUILD/compile-alpha-cxx index ec35be1ba68..3e9873f183a 100755 --- a/BUILD/compile-alpha-cxx +++ b/BUILD/compile-alpha-cxx @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2000, 2005 MySQL AB +# Copyright (c) 2000, 2001, 2003, 2005-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-alpha-debug b/BUILD/compile-alpha-debug index 51895d3c230..3ff06c45267 100755 --- a/BUILD/compile-alpha-debug +++ b/BUILD/compile-alpha-debug @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2000, 2005 MySQL AB +# Copyright (c) 2000, 2001, 2005-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-amd64-debug-max b/BUILD/compile-amd64-debug-max index 273942df5f8..aa429229c02 100755 --- a/BUILD/compile-amd64-debug-max +++ b/BUILD/compile-amd64-debug-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-amd64-max b/BUILD/compile-amd64-max index c14f0d7104c..3fc970946db 100755 --- a/BUILD/compile-amd64-max +++ b/BUILD/compile-amd64-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-darwin-mwcc b/BUILD/compile-darwin-mwcc index 88747de77af..7d443cad4a1 100755 --- a/BUILD/compile-darwin-mwcc +++ b/BUILD/compile-darwin-mwcc @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-hpux11-parisc2-aCC b/BUILD/compile-hpux11-parisc2-aCC index 5d0df465bc9..492b5ea326e 100755 --- a/BUILD/compile-hpux11-parisc2-aCC +++ b/BUILD/compile-hpux11-parisc2-aCC @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004, 2005 MySQL AB +# Copyright (c) 2004, 2005, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-ia64-debug-max b/BUILD/compile-ia64-debug-max index 6686ae983c4..2c1fb170a43 100755 --- a/BUILD/compile-ia64-debug-max +++ b/BUILD/compile-ia64-debug-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2001, 2005 MySQL AB +# Copyright (c) 2001, 2005-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-irix-mips64-mipspro b/BUILD/compile-irix-mips64-mipspro index a8433c715ab..e72078ecb84 100755 --- a/BUILD/compile-irix-mips64-mipspro +++ b/BUILD/compile-irix-mips64-mipspro @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004, 2005 MySQL AB +# Copyright (c) 2004, 2005, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-pentium b/BUILD/compile-pentium index 0b8caa763ce..22d0ba97a74 100755 --- a/BUILD/compile-pentium +++ b/BUILD/compile-pentium @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2000, 2002 MySQL AB +# Copyright (c) 2000-2002, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-pentium-debug-max-no-embedded b/BUILD/compile-pentium-debug-max-no-embedded index 55aede7536f..346ed88c94b 100755 --- a/BUILD/compile-pentium-debug-max-no-embedded +++ b/BUILD/compile-pentium-debug-max-no-embedded @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2004, 2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-pentium-debug-openssl b/BUILD/compile-pentium-debug-openssl index 505cfe9b234..4d589a7fc4c 100755 --- a/BUILD/compile-pentium-debug-openssl +++ b/BUILD/compile-pentium-debug-openssl @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2001, 2003 MySQL AB +# Copyright (c) 2001, 2003, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-pentium-debug-yassl b/BUILD/compile-pentium-debug-yassl index 57ae409eafd..337b1e017d3 100755 --- a/BUILD/compile-pentium-debug-yassl +++ b/BUILD/compile-pentium-debug-yassl @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-pentium-max b/BUILD/compile-pentium-max index 7bd063cd24a..dbb884b53d4 100755 --- a/BUILD/compile-pentium-max +++ b/BUILD/compile-pentium-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2001, 2005 MySQL AB +# Copyright (c) 2001-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-pentium-pgcc b/BUILD/compile-pentium-pgcc index 383cd288bf1..aecd1413338 100755 --- a/BUILD/compile-pentium-pgcc +++ b/BUILD/compile-pentium-pgcc @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2000, 2005 MySQL AB +# Copyright (c) 2000, 2001, 2005, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-ppc-debug b/BUILD/compile-ppc-debug index 76b6bf65ce4..4d4e2410fa8 100755 --- a/BUILD/compile-ppc-debug +++ b/BUILD/compile-ppc-debug @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-ppc-debug-max b/BUILD/compile-ppc-debug-max index b2c7ec18b3e..6658b04ae30 100755 --- a/BUILD/compile-ppc-debug-max +++ b/BUILD/compile-ppc-debug-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2004, 2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-ppc-debug-max-no-ndb b/BUILD/compile-ppc-debug-max-no-ndb index e77c517b302..1a3c9302388 100755 --- a/BUILD/compile-ppc-debug-max-no-ndb +++ b/BUILD/compile-ppc-debug-max-no-ndb @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-ppc-max b/BUILD/compile-ppc-max index cd2ada87dd8..ccc59063efc 100755 --- a/BUILD/compile-ppc-max +++ b/BUILD/compile-ppc-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2004, 2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-solaris-sparc-debug b/BUILD/compile-solaris-sparc-debug index 8e4a4672f2e..1d86a09a7ea 100755 --- a/BUILD/compile-solaris-sparc-debug +++ b/BUILD/compile-solaris-sparc-debug @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2001, 2005 MySQL AB +# Copyright (c) 2001, 2002, 2005-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/BUILD/compile-solaris-sparc-purify b/BUILD/compile-solaris-sparc-purify index 1083835ba43..11345151987 100755 --- a/BUILD/compile-solaris-sparc-purify +++ b/BUILD/compile-solaris-sparc-purify @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2000, 2005 MySQL AB +# Copyright (c) 2000-2002, 2005-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/CMakeLists.txt b/CMakeLists.txt index 75927c40cae..1ef5e837c54 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/Docs/Makefile.am b/Docs/Makefile.am index 24f921a4877..de539caac6d 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2006 MySQL AB +# Copyright (c) 2000-2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/Makefile.am b/Makefile.am index f4179f5cb47..c699720e26a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/client/completion_hash.cc b/client/completion_hash.cc index cd0ea17dfaf..082d5e9bdc3 100644 --- a/client/completion_hash.cc +++ b/client/completion_hash.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/client/completion_hash.h b/client/completion_hash.h index 8e1b2d6e453..c2473190f30 100644 --- a/client/completion_hash.h +++ b/client/completion_hash.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public diff --git a/client/echo.c b/client/echo.c index e3d22edb3ae..81c5f9cd411 100644 --- a/client/echo.c +++ b/client/echo.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/client/get_password.c b/client/get_password.c index ea024f76fb6..1818067a6b7 100644 --- a/client/get_password.c +++ b/client/get_password.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/client/mysqldump.c b/client/mysqldump.c index 68d445f9a5b..b603c9e91af 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/client/sql_string.cc b/client/sql_string.cc index 010da7eb517..0b26f09328c 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/cmd-line-utils/Makefile.am b/cmd-line-utils/Makefile.am index 1a84ce7af38..74e69e5c61d 100644 --- a/cmd-line-utils/Makefile.am +++ b/cmd-line-utils/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2003, 2004 MySQL AB # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt index 8b27f79dcf4..8693f88ae7d 100755 --- a/dbug/CMakeLists.txt +++ b/dbug/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index cec0db6a4ae..396a0a3b771 100755 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/extra/Makefile.am b/extra/Makefile.am index 75422c4ee11..32c2e5ce54c 100644 --- a/extra/Makefile.am +++ b/extra/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2006 MySQL AB +# Copyright (c) 2000-2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/extra/charset2html.c b/extra/charset2html.c index 8dcfa0c8990..a2d575c5126 100644 --- a/extra/charset2html.c +++ b/extra/charset2html.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002-2004, 2007, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt index eda5c3d4652..69e4518e250 100644 --- a/extra/yassl/CMakeLists.txt +++ b/extra/yassl/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/Makefile.am b/extra/yassl/Makefile.am index 2280e02f537..7f7206ebf76 100644 --- a/extra/yassl/Makefile.am +++ b/extra/yassl/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2005, 2006 MySQL AB +# Copyright (c) 2005, 2006, 2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/examples/client/client.cpp b/extra/yassl/examples/client/client.cpp index d05c31d4d63..fc05b66aaf7 100644 --- a/extra/yassl/examples/client/client.cpp +++ b/extra/yassl/examples/client/client.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006 MySQL AB + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/examples/echoclient/echoclient.cpp b/extra/yassl/examples/echoclient/echoclient.cpp index c2b8ff66ac9..fabcfbec29e 100644 --- a/extra/yassl/examples/echoclient/echoclient.cpp +++ b/extra/yassl/examples/echoclient/echoclient.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006 MySQL AB + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/examples/echoserver/echoserver.cpp b/extra/yassl/examples/echoserver/echoserver.cpp index bd044e70e8b..82696568ace 100644 --- a/extra/yassl/examples/echoserver/echoserver.cpp +++ b/extra/yassl/examples/echoserver/echoserver.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006 MySQL AB + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/examples/server/server.cpp b/extra/yassl/examples/server/server.cpp index 3fac40e88c4..173ce8fb548 100644 --- a/extra/yassl/examples/server/server.cpp +++ b/extra/yassl/examples/server/server.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006 MySQL AB + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/buffer.hpp b/extra/yassl/include/buffer.hpp index 2d7817a7ca2..27f71199093 100644 --- a/extra/yassl/include/buffer.hpp +++ b/extra/yassl/include/buffer.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/cert_wrapper.hpp b/extra/yassl/include/cert_wrapper.hpp index d07e5b627b0..8be0f3b3e6a 100644 --- a/extra/yassl/include/cert_wrapper.hpp +++ b/extra/yassl/include/cert_wrapper.hpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/lock.hpp b/extra/yassl/include/lock.hpp index 487bedfcc70..5273f92f151 100644 --- a/extra/yassl/include/lock.hpp +++ b/extra/yassl/include/lock.hpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/openssl/prefix_ssl.h b/extra/yassl/include/openssl/prefix_ssl.h index 024cb0a9aff..22b3f4de34b 100644 --- a/extra/yassl/include/openssl/prefix_ssl.h +++ b/extra/yassl/include/openssl/prefix_ssl.h @@ -1,6 +1,5 @@ /* - Copyright (c) 2006, 2007 MySQL AB, 2008 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/socket_wrapper.hpp b/extra/yassl/include/socket_wrapper.hpp index 2372e64e56c..c9f1e3af09c 100644 --- a/extra/yassl/include/socket_wrapper.hpp +++ b/extra/yassl/include/socket_wrapper.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/yassl_error.hpp b/extra/yassl/include/yassl_error.hpp index 5ce70c3ca70..a4b29ae2e8c 100644 --- a/extra/yassl/include/yassl_error.hpp +++ b/extra/yassl/include/yassl_error.hpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2010 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/yassl_imp.hpp b/extra/yassl/include/yassl_imp.hpp index 04e85c16a04..a952da0d3d9 100644 --- a/extra/yassl/include/yassl_imp.hpp +++ b/extra/yassl/include/yassl_imp.hpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 686e958d7e1..6f3ea1c6ad3 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index 14b33eb9129..6a8c3f6c075 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp index f8174098249..6f356e9fd4f 100644 --- a/extra/yassl/src/buffer.cpp +++ b/extra/yassl/src/buffer.cpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp index 917cfa1a8fb..639f0996d7e 100644 --- a/extra/yassl/src/cert_wrapper.cpp +++ b/extra/yassl/src/cert_wrapper.cpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2008, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index ccd43c442c9..d8952d0daf0 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 4b1ed3d7fef..d0f6827e862 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2008 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/lock.cpp b/extra/yassl/src/lock.cpp index d603440757f..c74ea1c6b76 100644 --- a/extra/yassl/src/lock.cpp +++ b/extra/yassl/src/lock.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/make.bat b/extra/yassl/src/make.bat index cccd11dbd17..42f49ee4c0a 100755 --- a/extra/yassl/src/make.bat +++ b/extra/yassl/src/make.bat @@ -1,4 +1,4 @@ -REM Copyright (C) 2006, 2007 MySQL AB +REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp index d88df13c08e..7afd4d41d1d 100644 --- a/extra/yassl/src/socket_wrapper.cpp +++ b/extra/yassl/src/socket_wrapper.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 7c264e5a939..b0499a55e14 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2008-2010 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/template_instnt.cpp b/extra/yassl/src/template_instnt.cpp index fe3a251b865..638ddfb3e4e 100644 --- a/extra/yassl/src/template_instnt.cpp +++ b/extra/yassl/src/template_instnt.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/yassl.cpp b/extra/yassl/src/yassl.cpp index 99a1da5371b..b6b9a87e09a 100644 --- a/extra/yassl/src/yassl.cpp +++ b/extra/yassl/src/yassl.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index 2cefd27d428..62fec6b3b23 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/Makefile.am b/extra/yassl/taocrypt/Makefile.am index de59419a736..39a15a041e2 100644 --- a/extra/yassl/taocrypt/Makefile.am +++ b/extra/yassl/taocrypt/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2005, 2006 MySQL AB +# Copyright (c) 2005, 2006, 2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/benchmark/benchmark.cpp b/extra/yassl/taocrypt/benchmark/benchmark.cpp index 225a1a0fa46..1051b2a4a20 100644 --- a/extra/yassl/taocrypt/benchmark/benchmark.cpp +++ b/extra/yassl/taocrypt/benchmark/benchmark.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006, 2007 MySQL AB + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/benchmark/make.bat b/extra/yassl/taocrypt/benchmark/make.bat index 1457521bce9..e9156e0c8af 100755 --- a/extra/yassl/taocrypt/benchmark/make.bat +++ b/extra/yassl/taocrypt/benchmark/make.bat @@ -1,4 +1,4 @@ -REM Copyright (C) 2006, 2007 MySQL AB +REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/aes.hpp b/extra/yassl/taocrypt/include/aes.hpp index e2041fc9350..01763033156 100644 --- a/extra/yassl/taocrypt/include/aes.hpp +++ b/extra/yassl/taocrypt/include/aes.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index c20387d86c7..fee2f26fb73 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2010 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp index ae3df8a3009..d7a69211e02 100644 --- a/extra/yassl/taocrypt/include/block.hpp +++ b/extra/yassl/taocrypt/include/block.hpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/blowfish.hpp b/extra/yassl/taocrypt/include/blowfish.hpp index 3ad2aedc587..1f8d0589234 100644 --- a/extra/yassl/taocrypt/include/blowfish.hpp +++ b/extra/yassl/taocrypt/include/blowfish.hpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/des.hpp b/extra/yassl/taocrypt/include/des.hpp index 2bc41fc2628..d88e9ef2f46 100644 --- a/extra/yassl/taocrypt/include/des.hpp +++ b/extra/yassl/taocrypt/include/des.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/hash.hpp b/extra/yassl/taocrypt/include/hash.hpp index 4ebc82e073d..4d2f7dd35a1 100644 --- a/extra/yassl/taocrypt/include/hash.hpp +++ b/extra/yassl/taocrypt/include/hash.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/hc128.hpp b/extra/yassl/taocrypt/include/hc128.hpp index d1cf5f075f2..0449b28d8c7 100644 --- a/extra/yassl/taocrypt/include/hc128.hpp +++ b/extra/yassl/taocrypt/include/hc128.hpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp index 256573cf622..e1a2ed5f426 100644 --- a/extra/yassl/taocrypt/include/integer.hpp +++ b/extra/yassl/taocrypt/include/integer.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/kernelc.hpp b/extra/yassl/taocrypt/include/kernelc.hpp index 5bdf1cffa3f..0840b3f2740 100644 --- a/extra/yassl/taocrypt/include/kernelc.hpp +++ b/extra/yassl/taocrypt/include/kernelc.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp index b6925f916f8..1382d3690fb 100644 --- a/extra/yassl/taocrypt/include/misc.hpp +++ b/extra/yassl/taocrypt/include/misc.hpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp index 5fd36b80d3e..bfe8c6ec5d4 100644 --- a/extra/yassl/taocrypt/include/modes.hpp +++ b/extra/yassl/taocrypt/include/modes.hpp @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/pwdbased.hpp b/extra/yassl/taocrypt/include/pwdbased.hpp index d050fd8988b..9025cc1a50c 100644 --- a/extra/yassl/taocrypt/include/pwdbased.hpp +++ b/extra/yassl/taocrypt/include/pwdbased.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/rabbit.hpp b/extra/yassl/taocrypt/include/rabbit.hpp index 1e7276dd8ec..fb4e12c66bc 100644 --- a/extra/yassl/taocrypt/include/rabbit.hpp +++ b/extra/yassl/taocrypt/include/rabbit.hpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/rsa.hpp b/extra/yassl/taocrypt/include/rsa.hpp index 11a4ccfd039..ee3e378a69f 100644 --- a/extra/yassl/taocrypt/include/rsa.hpp +++ b/extra/yassl/taocrypt/include/rsa.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 568c0b3afd8..ef7ce092cde 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/include/types.hpp b/extra/yassl/taocrypt/include/types.hpp index 5d8bc9f0683..973e1d19893 100644 --- a/extra/yassl/taocrypt/include/types.hpp +++ b/extra/yassl/taocrypt/include/types.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/mySTL/stdexcept.hpp b/extra/yassl/taocrypt/mySTL/stdexcept.hpp index 15533eebc02..79ae6de3380 100644 --- a/extra/yassl/taocrypt/mySTL/stdexcept.hpp +++ b/extra/yassl/taocrypt/mySTL/stdexcept.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/mySTL/vector.hpp b/extra/yassl/taocrypt/mySTL/vector.hpp index 35b92610942..f3702b75125 100644 --- a/extra/yassl/taocrypt/mySTL/vector.hpp +++ b/extra/yassl/taocrypt/mySTL/vector.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/Makefile.am b/extra/yassl/taocrypt/src/Makefile.am index bdfa156d5e9..ede3821f872 100644 --- a/extra/yassl/taocrypt/src/Makefile.am +++ b/extra/yassl/taocrypt/src/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/aes.cpp b/extra/yassl/taocrypt/src/aes.cpp index 811b483b0c9..9b04e7b0dbc 100644 --- a/extra/yassl/taocrypt/src/aes.cpp +++ b/extra/yassl/taocrypt/src/aes.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/aestables.cpp b/extra/yassl/taocrypt/src/aestables.cpp index 05c2c3b8e62..60795a549e4 100644 --- a/extra/yassl/taocrypt/src/aestables.cpp +++ b/extra/yassl/taocrypt/src/aestables.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index 73423d47546..b4086522124 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/arc4.cpp b/extra/yassl/taocrypt/src/arc4.cpp index 4630adcb11a..a76a37904f9 100644 --- a/extra/yassl/taocrypt/src/arc4.cpp +++ b/extra/yassl/taocrypt/src/arc4.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/blowfish.cpp b/extra/yassl/taocrypt/src/blowfish.cpp index 64e8f0a84aa..cedae6af281 100644 --- a/extra/yassl/taocrypt/src/blowfish.cpp +++ b/extra/yassl/taocrypt/src/blowfish.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/coding.cpp b/extra/yassl/taocrypt/src/coding.cpp index ba485eea77e..bc4727cc5e3 100644 --- a/extra/yassl/taocrypt/src/coding.cpp +++ b/extra/yassl/taocrypt/src/coding.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/dsa.cpp b/extra/yassl/taocrypt/src/dsa.cpp index a4e9c9503e7..bf116d3e48d 100644 --- a/extra/yassl/taocrypt/src/dsa.cpp +++ b/extra/yassl/taocrypt/src/dsa.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/hash.cpp b/extra/yassl/taocrypt/src/hash.cpp index b36a486368c..c176e6a68d0 100644 --- a/extra/yassl/taocrypt/src/hash.cpp +++ b/extra/yassl/taocrypt/src/hash.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/hc128.cpp b/extra/yassl/taocrypt/src/hc128.cpp index aac92f0abb4..8934c318781 100644 --- a/extra/yassl/taocrypt/src/hc128.cpp +++ b/extra/yassl/taocrypt/src/hc128.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/make.bat b/extra/yassl/taocrypt/src/make.bat index ecd3023f5ab..a8c00f8ee0d 100755 --- a/extra/yassl/taocrypt/src/make.bat +++ b/extra/yassl/taocrypt/src/make.bat @@ -1,4 +1,4 @@ -REM Copyright (C) 2006, 2007 MySQL AB +REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/md4.cpp b/extra/yassl/taocrypt/src/md4.cpp index 54820f4c944..9364a1c23b1 100644 --- a/extra/yassl/taocrypt/src/md4.cpp +++ b/extra/yassl/taocrypt/src/md4.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/md5.cpp b/extra/yassl/taocrypt/src/md5.cpp index 4d0a8bd03be..ee0d64acc17 100644 --- a/extra/yassl/taocrypt/src/md5.cpp +++ b/extra/yassl/taocrypt/src/md5.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index 5ffa2a2a07a..b576d3d59d2 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/rabbit.cpp b/extra/yassl/taocrypt/src/rabbit.cpp index 0ea4146618a..071a25191f8 100644 --- a/extra/yassl/taocrypt/src/rabbit.cpp +++ b/extra/yassl/taocrypt/src/rabbit.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/random.cpp b/extra/yassl/taocrypt/src/random.cpp index aa9be7f1985..084871c5447 100644 --- a/extra/yassl/taocrypt/src/random.cpp +++ b/extra/yassl/taocrypt/src/random.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/ripemd.cpp b/extra/yassl/taocrypt/src/ripemd.cpp index e012db43de5..f77010ca94d 100644 --- a/extra/yassl/taocrypt/src/ripemd.cpp +++ b/extra/yassl/taocrypt/src/ripemd.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/rsa.cpp b/extra/yassl/taocrypt/src/rsa.cpp index 576146377a3..69c59402e48 100644 --- a/extra/yassl/taocrypt/src/rsa.cpp +++ b/extra/yassl/taocrypt/src/rsa.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/sha.cpp b/extra/yassl/taocrypt/src/sha.cpp index 1ae42d94e4c..f67a4f55067 100644 --- a/extra/yassl/taocrypt/src/sha.cpp +++ b/extra/yassl/taocrypt/src/sha.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/template_instnt.cpp b/extra/yassl/taocrypt/src/template_instnt.cpp index b472d18236f..de0137dda7c 100644 --- a/extra/yassl/taocrypt/src/template_instnt.cpp +++ b/extra/yassl/taocrypt/src/template_instnt.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/src/twofish.cpp b/extra/yassl/taocrypt/src/twofish.cpp index 4ff1304a4cd..235b712b7c5 100644 --- a/extra/yassl/taocrypt/src/twofish.cpp +++ b/extra/yassl/taocrypt/src/twofish.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/test/make.bat b/extra/yassl/taocrypt/test/make.bat index d6d62b984a8..51f266a1ee6 100755 --- a/extra/yassl/taocrypt/test/make.bat +++ b/extra/yassl/taocrypt/test/make.bat @@ -1,4 +1,4 @@ -REM Copyright (C) 2006, 2007 MySQL AB +REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/test/memory.cpp b/extra/yassl/taocrypt/test/memory.cpp index a9b21f94902..053d79688a2 100644 --- a/extra/yassl/taocrypt/test/memory.cpp +++ b/extra/yassl/taocrypt/test/memory.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/taocrypt/test/test.cpp b/extra/yassl/taocrypt/test/test.cpp index 4cd5dba8ac6..0643b79e51b 100644 --- a/extra/yassl/taocrypt/test/test.cpp +++ b/extra/yassl/taocrypt/test/test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006, 2007 MySQL AB + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/testsuite/make.bat b/extra/yassl/testsuite/make.bat index 941e499d7e6..e056f3fed53 100755 --- a/extra/yassl/testsuite/make.bat +++ b/extra/yassl/testsuite/make.bat @@ -1,4 +1,4 @@ -REM Copyright (C) 2006, 2007 MySQL AB +REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp index 1f10095b945..7f49565b1f0 100644 --- a/extra/yassl/testsuite/test.hpp +++ b/extra/yassl/testsuite/test.hpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/extra/yassl/testsuite/testsuite.cpp b/extra/yassl/testsuite/testsuite.cpp index fa8c997e7c2..7973a3704e1 100644 --- a/extra/yassl/testsuite/testsuite.cpp +++ b/extra/yassl/testsuite/testsuite.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006, 2007 MySQL AB + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/base64.h b/include/base64.h index 4ac0aa72ad8..52f1b6d2876 100644 --- a/include/base64.h +++ b/include/base64.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/errmsg.h b/include/errmsg.h index a6d8c770de8..c827dc1cc97 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/ft_global.h b/include/ft_global.h index 752371d6bc6..b9e80e56716 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/help_end.h b/include/help_end.h index 4426cb80bce..251b7806ad7 100644 --- a/include/help_end.h +++ b/include/help_end.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2005 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/help_start.h b/include/help_start.h index 3ae20eea7d7..4817edf9da9 100644 --- a/include/help_start.h +++ b/include/help_start.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2005 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/keycache.h b/include/keycache.h index 1307e869717..6d41fbd0b2b 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2003-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (c) 2003-2005, 2007 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/include/m_ctype.h b/include/m_ctype.h index b36fdbe6d68..a6146333ca4 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/m_string.h b/include/m_string.h index dc916792f60..08738c9e482 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_aes.h b/include/my_aes.h index 1bbdf5663ea..d60c45d2a9b 100644 --- a/include/my_aes.h +++ b/include/my_aes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_alloc.h b/include/my_alloc.h index 93b7438a1df..52595e9ab76 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_attribute.h b/include/my_attribute.h index 8309d85f20a..56e37abb833 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_base.h b/include/my_base.h index ffd68046029..7a58e3397b4 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -1,6 +1,5 @@ /* - Copyright (c) 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_compiler.h b/include/my_compiler.h index 5f898621159..3b37d4d7cf0 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -1,7 +1,7 @@ #ifndef MY_COMPILER_INCLUDED #define MY_COMPILER_INCLUDED -/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_dir.h b/include/my_dir.h index 06509a3af19..86dd5030090 100644 --- a/include/my_dir.h +++ b/include/my_dir.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_libwrap.h b/include/my_libwrap.h index 9a8579475fb..b71491d2776 100644 --- a/include/my_libwrap.h +++ b/include/my_libwrap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_list.h b/include/my_list.h index 775b56587b8..9d27ecad21f 100644 --- a/include/my_list.h +++ b/include/my_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_md5.h b/include/my_md5.h index 6458f27c5cc..709f211fa31 100644 --- a/include/my_md5.h +++ b/include/my_md5.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_net.h b/include/my_net.h index 3af79ea3db5..9986fbd9c35 100644 --- a/include/my_net.h +++ b/include/my_net.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2004, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_nosys.h b/include/my_nosys.h index df5639b81e2..ae824f2b4d3 100644 --- a/include/my_nosys.h +++ b/include/my_nosys.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_sys.h b/include/my_sys.h index 1973f07ac13..e6d99547dfc 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_tree.h b/include/my_tree.h index 24bbdd54019..f6015cadefc 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002, 2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_trie.h b/include/my_trie.h index 72dd485af04..a916024f5eb 100644 --- a/include/my_trie.h +++ b/include/my_trie.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_user.h b/include/my_user.h index 44eebf1551d..d1d09a43407 100644 --- a/include/my_user.h +++ b/include/my_user.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_vle.h b/include/my_vle.h index c09f82229c4..30b26d9776d 100644 --- a/include/my_vle.h +++ b/include/my_vle.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/include/my_xml.h b/include/my_xml.h index 6a453ee90be..1f7e5c554d2 100644 --- a/include/my_xml.h +++ b/include/my_xml.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/myisampack.h b/include/myisampack.h index 7d4871bd1cb..afbe83306d2 100644 --- a/include/myisampack.h +++ b/include/myisampack.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/mysql_time.h b/include/mysql_time.h index 0a3f17a81fb..0a3ddccbf3c 100644 --- a/include/mysql_time.h +++ b/include/mysql_time.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in index 04a43f2c968..2e1b3c6cef4 100644 --- a/include/mysql_version.h.in +++ b/include/mysql_version.h.in @@ -1,4 +1,4 @@ -/* Copyright Abandoned 1996, 1999, 2001 MySQL AB +/* Copyright (c) 1996, 1999-2004, 2007 MySQL AB This file is public domain and comes with NO WARRANTY of any kind */ /* Version numbers for protocol & mysqld */ diff --git a/include/queues.h b/include/queues.h index d01b73ba999..e5e211fb77b 100644 --- a/include/queues.h +++ b/include/queues.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/rijndael.h b/include/rijndael.h index 89963a85c99..75ee8fefdf3 100644 --- a/include/rijndael.h +++ b/include/rijndael.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/sslopt-case.h b/include/sslopt-case.h index adb9a28503b..d8faffe0249 100644 --- a/include/sslopt-case.h +++ b/include/sslopt-case.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/sslopt-vars.h b/include/sslopt-vars.h index 3369f870db2..dcb6a2f0513 100644 --- a/include/sslopt-vars.h +++ b/include/sslopt-vars.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/thr_alarm.h b/include/thr_alarm.h index fb906039269..8a5881af938 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2004, 2006-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/typelib.h b/include/typelib.h index 46106d1bdab..fb76fe6ca4a 100644 --- a/include/typelib.h +++ b/include/typelib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003, 2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/violite.h b/include/violite.h index 5facd0911b7..0e041922bd3 100644 --- a/include/violite.h +++ b/include/violite.h @@ -1,6 +1,5 @@ /* - Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/welcome_copyright_notice.h b/include/welcome_copyright_notice.h index 15d11bf3664..290e9b30eef 100644 --- a/include/welcome_copyright_notice.h +++ b/include/welcome_copyright_notice.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 2453547cac8..e4d620c1fa5 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -1,5 +1,4 @@ -# Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. -# Use is subject to license terms. +# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 GNU General Public License as diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index f87e625771f..4ed20289ddf 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2005 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libmysql/conf_to_src.c b/libmysql/conf_to_src.c index f39a2e1856f..5970e3b501a 100644 --- a/libmysql/conf_to_src.c +++ b/libmysql/conf_to_src.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libmysql/dll.c b/libmysql/dll.c index 8654c035c63..9336213998c 100644 --- a/libmysql/dll.c +++ b/libmysql/dll.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 163632127c3..a686796952f 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libmysql/get_password.c b/libmysql/get_password.c index 63d4e68541f..f4b07f2dabe 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libmysql/manager.c b/libmysql/manager.c index 335323cb31d..7617a4a40f2 100644 --- a/libmysql/manager.c +++ b/libmysql/manager.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2001-2004, 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index d4f0bea590b..56e593e222e 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2004 MySQL AB +# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 GNU General Public License as diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc index b4eddf39c1f..6c557a63eb9 100644 --- a/libmysqld/emb_qcache.cc +++ b/libmysqld/emb_qcache.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index d7f994d9b9f..f5a1f512b9a 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -1,5 +1,4 @@ -# Copyright (c) 2006-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. -# Use is subject to license terms. +# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index a0f1a64ffdc..22ab5d44433 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/mysql-test/include/default_my.cnf b/mysql-test/include/default_my.cnf index f4c9a617cd9..111c2704da2 100644 --- a/mysql-test/include/default_my.cnf +++ b/mysql-test/include/default_my.cnf @@ -1,4 +1,4 @@ -# Copyright (c) 2007 MySQL AB, 2009, 2010 Sun Microsystems, Inc. +# Copyright (c) 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index 8990bcbb5c0..7f7a14f38f6 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -1,4 +1,4 @@ -# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/mysql-test/lib/My/Find.pm b/mysql-test/lib/My/Find.pm index 2730f83a496..4fcbb756575 100644 --- a/mysql-test/lib/My/Find.pm +++ b/mysql-test/lib/My/Find.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt index 5150fcaafff..8a5338a20be 100644 --- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt +++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2008 MySQL AB +# Copyright (c) 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index 3abda6e7f67..e95a2c4a91e 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 522e516c6e7..dd5485e6799 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/mysql-test/lib/mtr_match.pm b/mysql-test/lib/mtr_match.pm index 6fc9832ac43..b5f512d77e0 100644 --- a/mysql-test/lib/mtr_match.pm +++ b/mysql-test/lib/mtr_match.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (C) 2004-2008 MySQL AB +# Copyright (c) 2004, 2006, 2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl index 3065892c968..12792b297ac 100755 --- a/mysql-test/lib/v1/mysql-test-run.pl +++ b/mysql-test/lib/v1/mysql-test-run.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl # -*- cperl -*- -# Copyright (c) 2008, 2009 Sun Microsystems, Inc. +# Copyright (c) 2008-2010 Sun Microsystems, Inc. # Use is subject to license terms. # # This program is free software; you can redistribute it and/or modify diff --git a/mysys/array.c b/mysys/array.c index db219eb2430..3f154778a3f 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2002, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (c) 2000, 2002, 2005, 2007 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/mysys/checksum.c b/mysys/checksum.c index 1c7c9358d53..b01f2002309 100644 --- a/mysys/checksum.c +++ b/mysys/checksum.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/default_modify.c b/mysys/default_modify.c index 88df0122da2..c9e3e11f23f 100644 --- a/mysys/default_modify.c +++ b/mysys/default_modify.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/errors.c b/mysys/errors.c index 1199df2f2be..a0997485ef2 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/list.c b/mysys/list.c index aaadd686365..74ab1968ce2 100644 --- a/mysys/list.c +++ b/mysys/list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/make-conf.c b/mysys/make-conf.c index 0dacde4dee0..9b4b4055601 100644 --- a/mysys/make-conf.c +++ b/mysys/make-conf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/md5.c b/mysys/md5.c index 2388cebedc4..71e6edf2410 100644 --- a/mysys/md5.c +++ b/mysys/md5.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_brkhant.c b/mysys/mf_brkhant.c index 3573b9973b2..90a68330d44 100644 --- a/mysys/mf_brkhant.c +++ b/mysys/mf_brkhant.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c index f0df0f3fa77..77ddfd83bb6 100644 --- a/mysys/mf_cache.c +++ b/mysys/mf_cache.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c index 1b428ded751..3d1e57e4e3b 100644 --- a/mysys/mf_dirname.c +++ b/mysys/mf_dirname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_fn_ext.c b/mysys/mf_fn_ext.c index da7fac3de73..06736087e71 100644 --- a/mysys/mf_fn_ext.c +++ b/mysys/mf_fn_ext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_format.c b/mysys/mf_format.c index b0c7075aa9a..b4125650d05 100644 --- a/mysys/mf_format.c +++ b/mysys/mf_format.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (c) 2000-2005, 2007 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index f517fcae70d..c5d18cc4c8c 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (c) 2000, 2004, 2005, 2007 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index dd56e332433..9221467b216 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -1,6 +1,5 @@ /* - Copyright (c) 2000-2004, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c index 6227a05ce06..c5ec34d8033 100644 --- a/mysys/mf_keycaches.c +++ b/mysys/mf_keycaches.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_path.c b/mysys/mf_path.c index 73e73cb7f76..b3ebcb2612a 100644 --- a/mysys/mf_path.c +++ b/mysys/mf_path.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_qsort.c b/mysys/mf_qsort.c index 4b3ecb603a6..f8ae55b9650 100644 --- a/mysys/mf_qsort.c +++ b/mysys/mf_qsort.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_radix.c b/mysys/mf_radix.c index 582ca76b8f8..969099654a9 100644 --- a/mysys/mf_radix.c +++ b/mysys/mf_radix.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_same.c b/mysys/mf_same.c index 6738dc8051e..368bf116ee9 100644 --- a/mysys/mf_same.c +++ b/mysys/mf_same.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c index 686ebbc1d14..d4e5a06e4d8 100644 --- a/mysys/mf_sort.c +++ b/mysys/mf_sort.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_soundex.c b/mysys/mf_soundex.c index fe30d8c81af..0a6c1fb9a4f 100644 --- a/mysys/mf_soundex.c +++ b/mysys/mf_soundex.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2004, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c index 40016210de4..1a17ca3c06c 100644 --- a/mysys/mf_tempfile.c +++ b/mysys/mf_tempfile.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_unixpath.c b/mysys/mf_unixpath.c index 75f8de14879..a36c6d8c181 100644 --- a/mysys/mf_unixpath.c +++ b/mysys/mf_unixpath.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_wcomp.c b/mysys/mf_wcomp.c index 4786537d1a5..70bc4c94b61 100644 --- a/mysys/mf_wcomp.c +++ b/mysys/mf_wcomp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mulalloc.c b/mysys/mulalloc.c index f4ca3d9f9ab..871e55fc73d 100644 --- a/mysys/mulalloc.c +++ b/mysys/mulalloc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_access.c b/mysys/my_access.c index 4734fbac8ba..e67bd7aedfa 100644 --- a/mysys/my_access.c +++ b/mysys/my_access.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_aes.c b/mysys/my_aes.c index 575d4702dee..42e02d003c1 100644 --- a/mysys/my_aes.c +++ b/mysys/my_aes.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_append.c b/mysys/my_append.c index d8789f95d95..c685536048c 100644 --- a/mysys/my_append.c +++ b/mysys/my_append.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_bit.c b/mysys/my_bit.c index 2881eb1ebd2..9d4a92b6b33 100644 --- a/mysys/my_bit.c +++ b/mysys/my_bit.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index b1dbb22c687..7026a6f9189 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_clock.c b/mysys/my_clock.c index adc755028d5..ab5e99315c5 100644 --- a/mysys/my_clock.c +++ b/mysys/my_clock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_compress.c b/mysys/my_compress.c index a3d9d56915e..45acb2db111 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_conio.c b/mysys/my_conio.c index 5dbd31193a9..3ed3dd8b1ee 100644 --- a/mysys/my_conio.c +++ b/mysys/my_conio.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_crc32.c b/mysys/my_crc32.c index 51c553da5ea..05e5501f141 100644 --- a/mysys/my_crc32.c +++ b/mysys/my_crc32.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_create.c b/mysys/my_create.c index 5c9a1e027d2..7b2e27f9fdf 100644 --- a/mysys/my_create.c +++ b/mysys/my_create.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_delete.c b/mysys/my_delete.c index 22425ed95fd..1ac761a1750 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_div.c b/mysys/my_div.c index d29d3668852..75dab5cfd3e 100644 --- a/mysys/my_div.c +++ b/mysys/my_div.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2004, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_dup.c b/mysys/my_dup.c index 55f5e0c0099..6603e1650d5 100644 --- a/mysys/my_dup.c +++ b/mysys/my_dup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_error.c b/mysys/my_error.c index 5167598bfae..fa8b2c1b5c9 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -1,6 +1,5 @@ /* - Copyright (c) 2000-2004, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c index 75c5ec6ff8b..f6016dc9d08 100644 --- a/mysys/my_fopen.c +++ b/mysys/my_fopen.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_getpagesize.c b/mysys/my_getpagesize.c index b0560cede35..a6ce2faf9e3 100644 --- a/mysys/my_getpagesize.c +++ b/mysys/my_getpagesize.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_handler_errors.h b/mysys/my_handler_errors.h index 1710ac81395..e507dcac3c9 100644 --- a/mysys/my_handler_errors.h +++ b/mysys/my_handler_errors.h @@ -1,5 +1,4 @@ -/* Copyright (c) 2008 MySQL AB - Use is subject to license terms. +/* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_init.c b/mysys/my_init.c index deb62603e9a..bf0cf9a486d 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index ecb61802842..7ac2c39a3bf 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2004, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (c) 2004, 2007 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/mysys/my_libwrap.c b/mysys/my_libwrap.c index e72334ba806..7a2ea491e86 100644 --- a/mysys/my_libwrap.c +++ b/mysys/my_libwrap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_lock.c b/mysys/my_lock.c index c0522ee849d..e31c0dd6a60 100644 --- a/mysys/my_lock.c +++ b/mysys/my_lock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2004, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_lockmem.c b/mysys/my_lockmem.c index b96331cd3cf..4cc239cc754 100644 --- a/mysys/my_lockmem.c +++ b/mysys/my_lockmem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_memmem.c b/mysys/my_memmem.c index c000f14bc66..7722f89bbd0 100644 --- a/mysys/my_memmem.c +++ b/mysys/my_memmem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_messnc.c b/mysys/my_messnc.c index e2431959b7a..e108d2f1999 100644 --- a/mysys/my_messnc.c +++ b/mysys/my_messnc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_mkdir.c b/mysys/my_mkdir.c index 676c6c1cd51..73c9e391127 100644 --- a/mysys/my_mkdir.c +++ b/mysys/my_mkdir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_mmap.c b/mysys/my_mmap.c index 023a06fd896..cde09c4a28e 100644 --- a/mysys/my_mmap.c +++ b/mysys/my_mmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_netware.c b/mysys/my_netware.c index 5b5c39c0ac0..708b6a2947b 100644 --- a/mysys/my_netware.c +++ b/mysys/my_netware.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_new.cc b/mysys/my_new.cc index edc393a5b55..14d6788bfe2 100644 --- a/mysys/my_new.cc +++ b/mysys/my_new.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2001, 2003-2006 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (c) 2000, 2001, 2003-2005 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/mysys/my_once.c b/mysys/my_once.c index b6f6656fce2..274c1bf56d8 100644 --- a/mysys/my_once.c +++ b/mysys/my_once.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_open.c b/mysys/my_open.c index 9060bb404e8..719ee8a89ac 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index aba3e47d754..a61a58038c1 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_quick.c b/mysys/my_quick.c index 0ba20a5bdee..262c8738512 100644 --- a/mysys/my_quick.c +++ b/mysys/my_quick.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_read.c b/mysys/my_read.c index 0c302d5b227..17106b15d2d 100644 --- a/mysys/my_read.c +++ b/mysys/my_read.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002, 2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c index a55282e03a0..198cc398477 100644 --- a/mysys/my_realloc.c +++ b/mysys/my_realloc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_rename.c b/mysys/my_rename.c index 39e6056a9e4..19b49ee88ae 100644 --- a/mysys/my_rename.c +++ b/mysys/my_rename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_sleep.c b/mysys/my_sleep.c index 87170e4af41..18559fb5b9b 100644 --- a/mysys/my_sleep.c +++ b/mysys/my_sleep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_static.h b/mysys/my_static.h index 90168b099a8..4d1a493bca1 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002-2004, 2007, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c index 7c3ddbb911c..15d5cee8c63 100644 --- a/mysys/my_symlink2.c +++ b/mysys/my_symlink2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_vle.c b/mysys/my_vle.c index 09f297eb553..0ab288eedec 100644 --- a/mysys/my_vle.c +++ b/mysys/my_vle.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/mysys/my_windac.c b/mysys/my_windac.c index f846853f7be..7d3c85225a0 100644 --- a/mysys/my_windac.c +++ b/mysys/my_windac.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c index 611307f5f34..0afbd6558ea 100644 --- a/mysys/my_winthread.c +++ b/mysys/my_winthread.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2001, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (c) 2000, 2001, 2005, 2007 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/mysys/my_write.c b/mysys/my_write.c index d0a59a605b6..a66795165a3 100644 --- a/mysys/my_write.c +++ b/mysys/my_write.c @@ -1,6 +1,5 @@ /* - Copyright (c) 2000, 2001, 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 6e0959ae08c..8637fcae626 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c index 24ab6a1ea9c..d6b2edcee5d 100644 --- a/mysys/ptr_cmp.c +++ b/mysys/ptr_cmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/queues.c b/mysys/queues.c index 9c85e493141..5f2f03175ef 100644 --- a/mysys/queues.c +++ b/mysys/queues.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2005 MySQL AB +/* Copyright (c) 2000-2003, 2005-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/rijndael.c b/mysys/rijndael.c index 2b12753c4e5..b668aff7c39 100644 --- a/mysys/rijndael.c +++ b/mysys/rijndael.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2004 MySQL AB +/* Copyright (c) 2002, 2004, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 8ef98f197b8..a18af229b08 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/test_charset.c b/mysys/test_charset.c index d867b49304e..93f93f26399 100644 --- a/mysys/test_charset.c +++ b/mysys/test_charset.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/test_dir.c b/mysys/test_dir.c index 54e6c99e21e..a1d2d53236b 100644 --- a/mysys/test_dir.c +++ b/mysys/test_dir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/test_fn.c b/mysys/test_fn.c index 249cc878390..d8037b71197 100644 --- a/mysys/test_fn.c +++ b/mysys/test_fn.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/test_xml.c b/mysys/test_xml.c index 0cb10e1c8d9..a1c71ffab35 100644 --- a/mysys/test_xml.c +++ b/mysys/test_xml.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/testhash.c b/mysys/testhash.c index 2add2ebd2d7..6b30eabc163 100644 --- a/mysys/testhash.c +++ b/mysys/testhash.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index e2fc54c487e..74bbf22aa86 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/thr_rwlock.c b/mysys/thr_rwlock.c index 0aa4d3fc3c4..a45d2276d5e 100644 --- a/mysys/thr_rwlock.c +++ b/mysys/thr_rwlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/tree.c b/mysys/tree.c index ef33f75b7c6..f2917d01fa1 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/trie.c b/mysys/trie.c index 5738b9b866b..3297f99ff55 100644 --- a/mysys/trie.c +++ b/mysys/trie.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/netware/mysql_fix_privilege_tables.pl b/netware/mysql_fix_privilege_tables.pl index e40b4158e1c..c0fe95ae196 100644 --- a/netware/mysql_fix_privilege_tables.pl +++ b/netware/mysql_fix_privilege_tables.pl @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Copyright (C) 2002 MySQL AB +# Copyright (c) 2002-2004 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/netware/mysql_secure_installation.pl b/netware/mysql_secure_installation.pl index 8550f0e6d6e..1c4d07ed4b0 100644 --- a/netware/mysql_secure_installation.pl +++ b/netware/mysql_secure_installation.pl @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Copyright (C) 2002 MySQL AB and Jeremy Cole +# Copyright (c) 2002, 2003 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc index af585bb4302..1b5b952399e 100644 --- a/plugin/daemon_example/daemon_example.cc +++ b/plugin/daemon_example/daemon_example.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/plugin/fulltext/Makefile.am b/plugin/fulltext/Makefile.am index 343416072dd..ed9c209e00d 100644 --- a/plugin/fulltext/Makefile.am +++ b/plugin/fulltext/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2005-2006 MySQL AB +# Copyright (c) 2005-2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index f0db25be79a..de566a81ad9 100755 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006-2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/scripts/comp_sql.c b/scripts/comp_sql.c index 88e88e632b6..88a3c08216a 100644 --- a/scripts/comp_sql.c +++ b/scripts/comp_sql.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 2ccd4f51b69..8c86c179bcd 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 3b179957932..24e745e42dd 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2000-2006 MySQL AB +# Copyright (c) 2000-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in index 12cd6a21ad1..b47a6045fc6 100644 --- a/scripts/mysql_install_db.pl.in +++ b/scripts/mysql_install_db.pl.in @@ -1,7 +1,7 @@ #!/usr/bin/perl # -*- cperl -*- # -# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/scripts/mysqlbug.sh b/scripts/mysqlbug.sh index 64804b5de19..4291f60bd36 100644 --- a/scripts/mysqlbug.sh +++ b/scripts/mysqlbug.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2000-2002, 2004 MySQL AB +# Copyright (c) 2000-2002, 2004, 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 5bf59ae27be..1aa4fdb09a3 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/server-tools/CMakeLists.txt b/server-tools/CMakeLists.txt index 3f02ba88f1d..7e0fb98a30a 100644 --- a/server-tools/CMakeLists.txt +++ b/server-tools/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/CMakeLists.txt b/server-tools/instance-manager/CMakeLists.txt index 2b9bce56ff7..8d659910820 100755 --- a/server-tools/instance-manager/CMakeLists.txt +++ b/server-tools/instance-manager/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/IMService.cpp b/server-tools/instance-manager/IMService.cpp index feccaadbecc..b8e4d4b0f12 100644 --- a/server-tools/instance-manager/IMService.cpp +++ b/server-tools/instance-manager/IMService.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/IMService.h b/server-tools/instance-manager/IMService.h index aceafb2fca6..7557e5fbeda 100644 --- a/server-tools/instance-manager/IMService.h +++ b/server-tools/instance-manager/IMService.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am index 19c4ac8de19..0f514cbf90f 100644 --- a/server-tools/instance-manager/Makefile.am +++ b/server-tools/instance-manager/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2003-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/WindowsService.cpp b/server-tools/instance-manager/WindowsService.cpp index 14795e2225a..09cb3d6f771 100644 --- a/server-tools/instance-manager/WindowsService.cpp +++ b/server-tools/instance-manager/WindowsService.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/WindowsService.h b/server-tools/instance-manager/WindowsService.h index 02a499e5f0c..c45bc5c2ead 100644 --- a/server-tools/instance-manager/WindowsService.h +++ b/server-tools/instance-manager/WindowsService.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/angel.cc b/server-tools/instance-manager/angel.cc index 64515c8498c..1aaa1f3d224 100644 --- a/server-tools/instance-manager/angel.cc +++ b/server-tools/instance-manager/angel.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2006 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/angel.h b/server-tools/instance-manager/angel.h index db21c250972..c8da39a70a3 100644 --- a/server-tools/instance-manager/angel.h +++ b/server-tools/instance-manager/angel.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2006 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/buffer.h b/server-tools/instance-manager/buffer.h index 3bd7a714437..2ac801bdabb 100644 --- a/server-tools/instance-manager/buffer.h +++ b/server-tools/instance-manager/buffer.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_BUFFER_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_BUFFER_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/command.cc b/server-tools/instance-manager/command.cc index ba84285ead2..118b2094c7f 100644 --- a/server-tools/instance-manager/command.cc +++ b/server-tools/instance-manager/command.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/command.h b/server-tools/instance-manager/command.h index 25d8c9849e8..146aaa8dd77 100644 --- a/server-tools/instance-manager/command.h +++ b/server-tools/instance-manager/command.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_COMMAND_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_COMMAND_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/commands.h b/server-tools/instance-manager/commands.h index 5c2b2f9bbb7..65ab3311437 100644 --- a/server-tools/instance-manager/commands.h +++ b/server-tools/instance-manager/commands.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_COMMANDS_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_COMMANDS_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc index b49b0ec0a00..d5511b3db47 100644 --- a/server-tools/instance-manager/guardian.cc +++ b/server-tools/instance-manager/guardian.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/guardian.h b/server-tools/instance-manager/guardian.h index d78058a6fc5..3a622bd9d9b 100644 --- a/server-tools/instance-manager/guardian.h +++ b/server-tools/instance-manager/guardian.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_GUARDIAN_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_GUARDIAN_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/instance.h b/server-tools/instance-manager/instance.h index aa9c923cba1..b3da78977c4 100644 --- a/server-tools/instance-manager/instance.h +++ b/server-tools/instance-manager/instance.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/instance_map.h b/server-tools/instance-manager/instance_map.h index af2f1868195..9cb7b9370ed 100644 --- a/server-tools/instance-manager/instance_map.h +++ b/server-tools/instance-manager/instance_map.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_MAP_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_MAP_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/instance_options.h b/server-tools/instance-manager/instance_options.h index b0503815036..e7113b43a71 100644 --- a/server-tools/instance-manager/instance_options.h +++ b/server-tools/instance-manager/instance_options.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_OPTIONS_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_OPTIONS_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/listener.h b/server-tools/instance-manager/listener.h index 964fb361fb5..8b70588a467 100644 --- a/server-tools/instance-manager/listener.h +++ b/server-tools/instance-manager/listener.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2006 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/log.cc b/server-tools/instance-manager/log.cc index 9f276523e49..9b049951fd7 100644 --- a/server-tools/instance-manager/log.cc +++ b/server-tools/instance-manager/log.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2006 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/manager.cc b/server-tools/instance-manager/manager.cc index 792461e41a9..a59126569fc 100644 --- a/server-tools/instance-manager/manager.cc +++ b/server-tools/instance-manager/manager.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2006 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/manager.h b/server-tools/instance-manager/manager.h index e6956884603..826318c44f4 100644 --- a/server-tools/instance-manager/manager.h +++ b/server-tools/instance-manager/manager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2006 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/mysql_manager_error.h b/server-tools/instance-manager/mysql_manager_error.h index e50e5d24f6d..39907bfe913 100644 --- a/server-tools/instance-manager/mysql_manager_error.h +++ b/server-tools/instance-manager/mysql_manager_error.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_MYSQL_MANAGER_ERROR_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_MYSQL_MANAGER_ERROR_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/mysqlmanager.cc b/server-tools/instance-manager/mysqlmanager.cc index 276d1ca3b49..fc3e7578624 100644 --- a/server-tools/instance-manager/mysqlmanager.cc +++ b/server-tools/instance-manager/mysqlmanager.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2006 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/parse_output.h b/server-tools/instance-manager/parse_output.h index 41618f643a3..65c2e5a7e32 100644 --- a/server-tools/instance-manager/parse_output.h +++ b/server-tools/instance-manager/parse_output.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H #define INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/portability.h b/server-tools/instance-manager/portability.h index 990e6140a9e..6a824d8a31a 100644 --- a/server-tools/instance-manager/portability.h +++ b/server-tools/instance-manager/portability.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2006 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/priv.cc b/server-tools/instance-manager/priv.cc index 74263934924..85088517033 100644 --- a/server-tools/instance-manager/priv.cc +++ b/server-tools/instance-manager/priv.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/priv.h b/server-tools/instance-manager/priv.h index 1c2124c0e77..d24e891ede7 100644 --- a/server-tools/instance-manager/priv.h +++ b/server-tools/instance-manager/priv.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/protocol.h b/server-tools/instance-manager/protocol.h index b06ae4dfdb2..e7bd72e3dc3 100644 --- a/server-tools/instance-manager/protocol.h +++ b/server-tools/instance-manager/protocol.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/thread_registry.cc b/server-tools/instance-manager/thread_registry.cc index 489caa0aaa8..39e21aed7ed 100644 --- a/server-tools/instance-manager/thread_registry.cc +++ b/server-tools/instance-manager/thread_registry.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/server-tools/instance-manager/thread_registry.h b/server-tools/instance-manager/thread_registry.h index d04c8442e44..cf83eff5c21 100644 --- a/server-tools/instance-manager/thread_registry.h +++ b/server-tools/instance-manager/thread_registry.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql-common/pack.c b/sql-common/pack.c index 7ff89471b45..ffaf6a4d67d 100644 --- a/sql-common/pack.c +++ b/sql-common/pack.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/Makefile.am b/sql/Makefile.am index 6c2e7079a51..149fc2ab673 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/sql/custom_conf.h b/sql/custom_conf.h index 137b7e9eef2..c3b3e2a9434 100644 --- a/sql/custom_conf.h +++ b/sql/custom_conf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/des_key_file.cc b/sql/des_key_file.cc index 317cb237360..e6fc2d8e20e 100644 --- a/sql/des_key_file.cc +++ b/sql/des_key_file.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2003, 2005 MySQL AB +/* Copyright (c) 2001-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/discover.cc b/sql/discover.cc index 56dc00cc5c4..e31ca281bee 100644 --- a/sql/discover.cc +++ b/sql/discover.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h index e32077b9c97..6464765a143 100644 --- a/sql/event_data_objects.h +++ b/sql/event_data_objects.h @@ -1,6 +1,6 @@ #ifndef _EVENT_DATA_OBJECTS_H_ #define _EVENT_DATA_OBJECTS_H_ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 04d4f858b43..d2bd1613eed 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/event_queue.h b/sql/event_queue.h index 2870ecb4d0b..6a098993e3d 100644 --- a/sql/event_queue.h +++ b/sql/event_queue.h @@ -1,6 +1,6 @@ #ifndef _EVENT_QUEUE_H_ #define _EVENT_QUEUE_H_ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index d217d8d76cd..65aa1c81aea 100755 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -1,6 +1,5 @@ /* - Copyright (c) 2006, 2007 MySQL AB, 2008-2010 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/event_scheduler.h b/sql/event_scheduler.h index 0be93a65d33..9cfb75e4590 100644 --- a/sql/event_scheduler.h +++ b/sql/event_scheduler.h @@ -1,6 +1,6 @@ #ifndef _EVENT_SCHEDULER_H_ #define _EVENT_SCHEDULER_H_ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/events.h b/sql/events.h index 2bc87517748..b5a1d8879d6 100644 --- a/sql/events.h +++ b/sql/events.h @@ -1,6 +1,6 @@ #ifndef _EVENT_H_ #define _EVENT_H_ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/field.cc b/sql/field.cc index 90029c12f0b..ea31e941cfe 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/field.h b/sql/field.h index cc709bc0c9c..01e97650c56 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/field_conv.cc b/sql/field_conv.cc index b97061be147..3c60bca74b9 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/frm_crypt.cc b/sql/frm_crypt.cc index 590205e83ab..702bdce2c82 100644 --- a/sql/frm_crypt.cc +++ b/sql/frm_crypt.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/gstream.cc b/sql/gstream.cc index 25bf599ff4e..9e556627da3 100644 --- a/sql/gstream.cc +++ b/sql/gstream.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (c) 2002, 2004, 2005, 2007 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/sql/gstream.h b/sql/gstream.h index 1ef90ad5bf0..6372c4ad670 100644 --- a/sql/gstream.h +++ b/sql/gstream.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000-2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index a17323d3fd6..93a9fba56a9 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 6d2a6f06c99..66530a64bd7 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/ha_ndbcluster_binlog.h b/sql/ha_ndbcluster_binlog.h index 1cad643e5ec..a05a65d9e7c 100644 --- a/sql/ha_ndbcluster_binlog.h +++ b/sql/ha_ndbcluster_binlog.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/ha_ndbcluster_cond.cc b/sql/ha_ndbcluster_cond.cc index bb35211944b..26e845ad85d 100644 --- a/sql/ha_ndbcluster_cond.cc +++ b/sql/ha_ndbcluster_cond.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2007, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/ha_ndbcluster_cond.h b/sql/ha_ndbcluster_cond.h index 4401a93c9e1..d494d46a4fe 100644 --- a/sql/ha_ndbcluster_cond.h +++ b/sql/ha_ndbcluster_cond.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2007 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/ha_ndbcluster_tables.h b/sql/ha_ndbcluster_tables.h index c6bc8f577f8..91cf9a2ebb8 100644 --- a/sql/ha_ndbcluster_tables.h +++ b/sql/ha_ndbcluster_tables.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/handler.cc b/sql/handler.cc index 4f5c613a6a4..d6b885e05d2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index 9303120e18a..18e3806486b 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2005 MySQL AB +/* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/hash_filo.h b/sql/hash_filo.h index ab13d338695..24b90e50142 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003, 2005 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/hostname.cc b/sql/hostname.cc index 38316a8ee19..ba211667bb1 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/init.cc b/sql/init.cc index afda36b6b9d..f9bd5bf6a27 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index b185bf02790..a7adc62b0f8 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_func.h b/sql/item_func.h index d769ceb0179..f63a952c0bf 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_row.cc b/sql/item_row.cc index 9bf9d78a3c2..1db71da1a21 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 27483ede032..25473815b9c 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 2c91d0573c1..d0a011accc4 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 4140fcfb11c..ef2cd8fa2c1 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h index dadbb5ccf42..02f5e698449 100644 --- a/sql/item_xmlfunc.h +++ b/sql/item_xmlfunc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/lex_symbol.h b/sql/lex_symbol.h index 000c0709071..34af52f1feb 100644 --- a/sql/lex_symbol.h +++ b/sql/lex_symbol.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB +/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/log.cc b/sql/log.cc index 93dd70b33c5..937b25284bd 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/log_event_old.h b/sql/log_event_old.h index 719802a80fb..0cc8d6189bf 100644 --- a/sql/log_event_old.h +++ b/sql/log_event_old.h @@ -1,4 +1,4 @@ -/* Copyright 2007 MySQL AB. All rights reserved. +/* Copyright (c) 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/mem_root_array.h b/sql/mem_root_array.h index 5ce4dcb584d..881b1f49bf2 100644 --- a/sql/mem_root_array.h +++ b/sql/mem_root_array.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc index 8c2d16c40b0..314794729c6 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000-2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/my_lock.c b/sql/my_lock.c index f66d7282f72..b8c3b9e1991 100644 --- a/sql/my_lock.c +++ b/sql/my_lock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 903fbcf019c..f0a5d806d10 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b7da50606dd..024ad659d89 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/mysqld_suffix.h b/sql/mysqld_suffix.h index 654d7cf88c1..c6324987bdc 100644 --- a/sql/mysqld_suffix.h +++ b/sql/mysqld_suffix.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000-2004, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ae6878c6756..0efa5c5a819 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/partition_element.h b/sql/partition_element.h index 905bc38165b..d43782a7098 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/password.c b/sql/password.c index e029ba51fc4..f6b8d19f22a 100644 --- a/sql/password.c +++ b/sql/password.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/procedure.cc b/sql/procedure.cc index c993ba976ac..a801528c115 100644 --- a/sql/procedure.cc +++ b/sql/procedure.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004-2005 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/procedure.h b/sql/procedure.h index ceb586766b1..fee38f6abf2 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000, 2002-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/records.cc b/sql/records.cc index da876f7554c..2484f091182 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h index 6ff78067aca..1a3e9c09fc9 100644 --- a/sql/repl_failsafe.h +++ b/sql/repl_failsafe.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2005 MySQL AB & Sasha +/* Copyright (c) 2001-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/rpl_filter.h b/sql/rpl_filter.h index ff7e4081bb1..4abe23d9207 100644 --- a/sql/rpl_filter.h +++ b/sql/rpl_filter.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h index 4ece092c5b8..88389c7f582 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/rpl_record_old.h b/sql/rpl_record_old.h index bdaedd56741..2a3a640e97c 100644 --- a/sql/rpl_record_old.h +++ b/sql/rpl_record_old.h @@ -1,4 +1,4 @@ -/* Copyright 2007 MySQL AB. All rights reserved. +/* Copyright (c) 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 904b5533f3b..85aab7ba4cb 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 959105b16e0..66be21d3db4 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/rpl_tblmap.h b/sql/rpl_tblmap.h index 3b5b10be580..b4f54450d7b 100644 --- a/sql/rpl_tblmap.h +++ b/sql/rpl_tblmap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 5f2b5cbf86b..d8c975fba90 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h index b2577643add..e5b37b9bd16 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/set_var.cc b/sql/set_var.cc index 269eea844aa..f4035ed0cde 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/Index.xml b/sql/share/charsets/Index.xml index 07e7e37b798..0c430cd2054 100644 --- a/sql/share/charsets/Index.xml +++ b/sql/share/charsets/Index.xml @@ -3,7 +3,7 @@ - Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/armscii8.xml b/sql/share/charsets/armscii8.xml index 714e57bb12e..78b3861a667 100644 --- a/sql/share/charsets/armscii8.xml +++ b/sql/share/charsets/armscii8.xml @@ -3,7 +3,7 @@ - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/ascii.xml b/sql/share/charsets/ascii.xml index f4fb79ac632..9ad240bde55 100644 --- a/sql/share/charsets/ascii.xml +++ b/sql/share/charsets/ascii.xml @@ -3,7 +3,7 @@ - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/cp1250.xml b/sql/share/charsets/cp1250.xml index bd0d7d3f3c0..ae51b92675a 100644 --- a/sql/share/charsets/cp1250.xml +++ b/sql/share/charsets/cp1250.xml @@ -3,7 +3,7 @@ - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/cp852.xml b/sql/share/charsets/cp852.xml index 25b622d2a4b..e1a4a069820 100644 --- a/sql/share/charsets/cp852.xml +++ b/sql/share/charsets/cp852.xml @@ -3,7 +3,7 @@ - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/hebrew.xml b/sql/share/charsets/hebrew.xml index 20d68487301..221dc7a8ae6 100644 --- a/sql/share/charsets/hebrew.xml +++ b/sql/share/charsets/hebrew.xml @@ -3,7 +3,7 @@ - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/latin1.xml b/sql/share/charsets/latin1.xml index 88ceff440d5..e989a0844b0 100644 --- a/sql/share/charsets/latin1.xml +++ b/sql/share/charsets/latin1.xml @@ -3,7 +3,7 @@ - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/latin2.xml b/sql/share/charsets/latin2.xml index 6b887b927a4..5ff73547bd0 100644 --- a/sql/share/charsets/latin2.xml +++ b/sql/share/charsets/latin2.xml @@ -3,7 +3,7 @@ - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/share/charsets/latin5.xml b/sql/share/charsets/latin5.xml index 9c23200a46d..ca2f0e0162f 100644 --- a/sql/share/charsets/latin5.xml +++ b/sql/share/charsets/latin5.xml @@ -3,7 +3,7 @@ - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index 121338c31d2..b11fd03e21c 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/slave.cc b/sql/slave.cc index 288077a6326..b2bcf37b761 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sp_cache.h b/sql/sp_cache.h index f4d44a1f29f..63fcf252d43 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002-2005, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 054fc5e223e..4268c9370db 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sp_head.h b/sql/sp_head.h index a026ac47221..d632e9a7a04 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -1,6 +1,6 @@ /* -*- C++ -*- */ /* - Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 368a017da21..eb7a4d676d2 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/spatial.cc b/sql/spatial.cc index 07f28855987..b1cfd0e5d87 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/spatial.h b/sql/spatial.h index 68a6c889615..80972421f83 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 80662832140..17000e40b97 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index 8807b40857e..87468f38492 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003, 2005 MySQL AB +/* Copyright (c) 2000-2003, 2005-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_array.h b/sql/sql_array.h index e1b22921519..0d5d2cdec2b 100644 --- a/sql/sql_array.h +++ b/sql/sql_array.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b191e9592ff..09010587d24 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index 97accefe8aa..b4b7e7025d9 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index cba7c876a4c..e6f97698703 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 0f6bd4c1954..80bd4eff457 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_class.h b/sql/sql_class.h index 5cdb005b517..4543f9ef7a2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_client.cc b/sql/sql_client.cc index 032a2e26e3a..e6678791a83 100644 --- a/sql/sql_client.cc +++ b/sql/sql_client.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_cursor.h b/sql/sql_cursor.h index 1f19cbfdbcf..480b55c28e0 100644 --- a/sql/sql_cursor.h +++ b/sql/sql_cursor.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_db.cc b/sql/sql_db.cc index fe3aed5c8f0..d3178fa0b99 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 01e2fd10be9..d8be84d0a67 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_do.cc b/sql/sql_do.cc index 8406a9eaf45..9ea265908a2 100644 --- a/sql/sql_do.cc +++ b/sql/sql_do.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_error.h b/sql/sql_error.h index f98264dce50..423e06fef52 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 7e94e7e7df3..a59e3fd14e9 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e171cf1c06d..78f0317b3fc 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 99cbd420607..0a054ced98a 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_list.cc b/sql/sql_list.cc index 49b649133d0..694daea3be0 100644 --- a/sql/sql_list.cc +++ b/sql/sql_list.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003, 2005 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_load.cc b/sql/sql_load.cc index b736fa59c22..fb495d05d60 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_map.cc b/sql/sql_map.cc index 55f9b08d3fe..54f9cecd384 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004-2005 MySQL AB +/* Copyright (c) 2000, 2001, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_map.h b/sql/sql_map.h index a1efba0da6f..fe602aa8771 100644 --- a/sql/sql_map.h +++ b/sql/sql_map.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2005 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 41f2b00a256..d8db68fc863 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2afd4085c51..ddfd5d3a755 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_profile.h b/sql/sql_profile.h index c59b342e502..fca17a60af6 100644 --- a/sql/sql_profile.h +++ b/sql/sql_profile.h @@ -1,6 +1,5 @@ /* - Copyright (c) 2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_repl.h b/sql/sql_repl.h index d5c9040f8dc..553f37e2f11 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB & Sasha +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_servers.h b/sql/sql_servers.h index 63c691893d1..08e9ac9852e 100644 --- a/sql/sql_servers.h +++ b/sql/sql_servers.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_show.h b/sql/sql_show.h index 3a6cd158cb4..b5d6c0af7d3 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -1,6 +1,5 @@ /* - Copyright (c) 2005-2008 MySQL AB, 2008 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_sort.h b/sql/sql_sort.h index 1e9322f7f5b..a60447da2f6 100644 --- a/sql/sql_sort.h +++ b/sql/sql_sort.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 10bd3511cd2..f692014011c 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 3ad956cb3fe..75112b00879 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_udf.h b/sql/sql_udf.h index 4b8b492698e..6a858dbb2d0 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003-2006 MySQL AB +/* Copyright (c) 2000, 2001, 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 41521395757..b45cee000bb 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7a6981f778a..64a7dd10058 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/table.cc b/sql/table.cc index 4577778285f..d221735e48e 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/table.h b/sql/table.h index 690abdff714..7dfb2ef084c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/tzfile.h b/sql/tzfile.h index 1ff82d62329..1c0f9195e1c 100644 --- a/sql/tzfile.h +++ b/sql/tzfile.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/tztime.cc b/sql/tztime.cc index 81a80686de2..6f340f26d0e 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/archive/archive_test.c b/storage/archive/archive_test.c index a5b2d1dfcc9..961590c61a1 100644 --- a/storage/archive/archive_test.c +++ b/storage/archive/archive_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index ab630ed22fd..66c60840502 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 7dd4f6b7149..980013029a9 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/_check.c b/storage/heap/_check.c index 08b6da62ae1..758e34e6c32 100644 --- a/storage/heap/_check.c +++ b/storage/heap/_check.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2002-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/_rectest.c b/storage/heap/_rectest.c index 068fedf719c..add2dc22eeb 100644 --- a/storage/heap/_rectest.c +++ b/storage/heap/_rectest.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h index 3fc94062303..744c52cc65a 100644 --- a/storage/heap/heapdef.h +++ b/storage/heap/heapdef.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_block.c b/storage/heap/hp_block.c index c622a9e52f8..cc9c67ceef3 100644 --- a/storage/heap/hp_block.c +++ b/storage/heap/hp_block.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_clear.c b/storage/heap/hp_clear.c index babfcbd6f41..2fffd121223 100644 --- a/storage/heap/hp_clear.c +++ b/storage/heap/hp_clear.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004, 2006 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_close.c b/storage/heap/hp_close.c index d571815980c..eb0aa27f4f8 100644 --- a/storage/heap/hp_close.c +++ b/storage/heap/hp_close.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_delete.c b/storage/heap/hp_delete.c index 3090b60d611..adad77f505d 100644 --- a/storage/heap/hp_delete.c +++ b/storage/heap/hp_delete.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004-2007 MySQL AB +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_extra.c b/storage/heap/hp_extra.c index 9ff6bfb860a..57cca428ccc 100644 --- a/storage/heap/hp_extra.c +++ b/storage/heap/hp_extra.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB +/* Copyright (c) 2000, 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_open.c b/storage/heap/hp_open.c index 4d5ec6e27ac..f128332228a 100644 --- a/storage/heap/hp_open.c +++ b/storage/heap/hp_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004, 2006 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_panic.c b/storage/heap/hp_panic.c index 9a2bd2c574e..7f539c2bcbf 100644 --- a/storage/heap/hp_panic.c +++ b/storage/heap/hp_panic.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_rename.c b/storage/heap/hp_rename.c index c2350450e2b..881edac33e1 100644 --- a/storage/heap/hp_rename.c +++ b/storage/heap/hp_rename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_rfirst.c b/storage/heap/hp_rfirst.c index d0d2ec9b506..fb75f31cf7c 100644 --- a/storage/heap/hp_rfirst.c +++ b/storage/heap/hp_rfirst.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_rkey.c b/storage/heap/hp_rkey.c index 6eeac6acd7b..74d71b8da47 100644 --- a/storage/heap/hp_rkey.c +++ b/storage/heap/hp_rkey.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004, 2006 MySQL AB +/* Copyright (c) 2000, 2002-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_rlast.c b/storage/heap/hp_rlast.c index 45ad7c21f49..9024f05242c 100644 --- a/storage/heap/hp_rlast.c +++ b/storage/heap/hp_rlast.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_rnext.c b/storage/heap/hp_rnext.c index 3d715f4e6d3..7ebcaac510d 100644 --- a/storage/heap/hp_rnext.c +++ b/storage/heap/hp_rnext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000, 2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_rprev.c b/storage/heap/hp_rprev.c index 63bfffffba9..a12804613c5 100644 --- a/storage/heap/hp_rprev.c +++ b/storage/heap/hp_rprev.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_rrnd.c b/storage/heap/hp_rrnd.c index 3ac23d293f2..8aa1a309593 100644 --- a/storage/heap/hp_rrnd.c +++ b/storage/heap/hp_rrnd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004, 2006 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_rsame.c b/storage/heap/hp_rsame.c index 1a3724672b6..06b49c4e568 100644 --- a/storage/heap/hp_rsame.c +++ b/storage/heap/hp_rsame.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_scan.c b/storage/heap/hp_scan.c index e8913e92c86..6b43300f8dc 100644 --- a/storage/heap/hp_scan.c +++ b/storage/heap/hp_scan.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_static.c b/storage/heap/hp_static.c index a501ba7e359..287f4194404 100644 --- a/storage/heap/hp_static.c +++ b/storage/heap/hp_static.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_test1.c b/storage/heap/hp_test1.c index b1b55098a78..dcb26e7ff8d 100644 --- a/storage/heap/hp_test1.c +++ b/storage/heap/hp_test1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003, 2006 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/heap/hp_update.c b/storage/heap/hp_update.c index 7f469af3c96..2dd0139be87 100644 --- a/storage/heap/hp_update.c +++ b/storage/heap/hp_update.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004-2005 MySQL AB +/* Copyright (c) 2000-2002, 2004-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 16cf2669c6d..2c6b81b2761 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_eval.c b/storage/myisam/ft_eval.c index de01510fdd7..537d6de8788 100644 --- a/storage/myisam/ft_eval.c +++ b/storage/myisam/ft_eval.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. diff --git a/storage/myisam/ft_eval.h b/storage/myisam/ft_eval.h index 9acc1a60d09..9f867dc5f27 100644 --- a/storage/myisam/ft_eval.h +++ b/storage/myisam/ft_eval.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & Sergei A. Golubchik +/* Copyright (c) 2000-2002, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index c74451828a4..5b8ed711393 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_static.c b/storage/myisam/ft_static.c index 1b6c7458fd7..99462d842fe 100644 --- a/storage/myisam/ft_static.c +++ b/storage/myisam/ft_static.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_stem.c b/storage/myisam/ft_stem.c index dfc132fcfa9..070bf1fe294 100644 --- a/storage/myisam/ft_stem.c +++ b/storage/myisam/ft_stem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_test1.c b/storage/myisam/ft_test1.c index b37935a0d7a..e9c59b241c3 100644 --- a/storage/myisam/ft_test1.c +++ b/storage/myisam/ft_test1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_test1.h b/storage/myisam/ft_test1.h index 4b466818460..803d34fd696 100644 --- a/storage/myisam/ft_test1.h +++ b/storage/myisam/ft_test1.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c index d1548e32870..fa3ad2b8fda 100644 --- a/storage/myisam/ft_update.c +++ b/storage/myisam/ft_update.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004, 2006 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ftbench/Ecompare.pl b/storage/myisam/ftbench/Ecompare.pl index 2c50ae9b9ce..b5c4950d4f7 100755 --- a/storage/myisam/ftbench/Ecompare.pl +++ b/storage/myisam/ftbench/Ecompare.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2003 MySQL AB +# Copyright (c) 2003, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ftbench/Ecreate.pl b/storage/myisam/ftbench/Ecreate.pl index 123ca729c31..4251c43388a 100755 --- a/storage/myisam/ftbench/Ecreate.pl +++ b/storage/myisam/ftbench/Ecreate.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2003 MySQL AB +# Copyright (c) 2003, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ftbench/Ereport.pl b/storage/myisam/ftbench/Ereport.pl index 2f63d7ea37a..f4d2dd5d271 100755 --- a/storage/myisam/ftbench/Ereport.pl +++ b/storage/myisam/ftbench/Ereport.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2003 MySQL AB +# Copyright (c) 2003, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ftbench/ft-test-run.sh b/storage/myisam/ftbench/ft-test-run.sh index 8726c263de9..1e822618eec 100755 --- a/storage/myisam/ftbench/ft-test-run.sh +++ b/storage/myisam/ftbench/ft-test-run.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2003 MySQL AB +# Copyright (c) 2003, 2005, 2006 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/myisam/mi_cache.c b/storage/myisam/mi_cache.c index d6dcc431a8d..d858f7f893a 100644 --- a/storage/myisam/mi_cache.c +++ b/storage/myisam/mi_cache.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_changed.c b/storage/myisam/mi_changed.c index 7422f995dd0..581412ffec7 100644 --- a/storage/myisam/mi_changed.c +++ b/storage/myisam/mi_changed.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_checksum.c b/storage/myisam/mi_checksum.c index 1aa56e571e3..38218c86116 100644 --- a/storage/myisam/mi_checksum.c +++ b/storage/myisam/mi_checksum.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003-2004 MySQL AB +/* Copyright (c) 2000, 2001, 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_info.c b/storage/myisam/mi_info.c index 91e7ca659e4..a2786d3ec42 100644 --- a/storage/myisam/mi_info.c +++ b/storage/myisam/mi_info.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003-2004 MySQL AB +/* Copyright (c) 2000, 2001, 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 3f445ebf44d..ff03027e8cd 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_keycache.c b/storage/myisam/mi_keycache.c index 5cf3fede1ae..c37e8b1e80f 100644 --- a/storage/myisam/mi_keycache.c +++ b/storage/myisam/mi_keycache.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_log.c b/storage/myisam/mi_log.c index 8b9ca038fec..674c08bae6e 100644 --- a/storage/myisam/mi_log.c +++ b/storage/myisam/mi_log.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB +/* Copyright (c) 2000, 2001, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_panic.c b/storage/myisam/mi_panic.c index 74c93761b61..378a2df50de 100644 --- a/storage/myisam/mi_panic.c +++ b/storage/myisam/mi_panic.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003 MySQL AB +/* Copyright (c) 2000, 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rename.c b/storage/myisam/mi_rename.c index 51669b0caa6..af9eb921558 100644 --- a/storage/myisam/mi_rename.c +++ b/storage/myisam/mi_rename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB +/* Copyright (c) 2000, 2001, 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rfirst.c b/storage/myisam/mi_rfirst.c index 5a8b27b3e85..b150c8c2375 100644 --- a/storage/myisam/mi_rfirst.c +++ b/storage/myisam/mi_rfirst.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index f1d35810d36..9d7a02bf6c7 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rlast.c b/storage/myisam/mi_rlast.c index 07be619617f..a0585c8d1f0 100644 --- a/storage/myisam/mi_rlast.c +++ b/storage/myisam/mi_rlast.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rnext_same.c b/storage/myisam/mi_rnext_same.c index 1892fe3e1e0..2c6a4fc0361 100644 --- a/storage/myisam/mi_rnext_same.c +++ b/storage/myisam/mi_rnext_same.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rprev.c b/storage/myisam/mi_rprev.c index d1407012590..8ff2aa5825e 100644 --- a/storage/myisam/mi_rprev.c +++ b/storage/myisam/mi_rprev.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB +/* Copyright (c) 2000, 2001, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rrnd.c b/storage/myisam/mi_rrnd.c index 211e5fa51cc..2d9ebe940b9 100644 --- a/storage/myisam/mi_rrnd.c +++ b/storage/myisam/mi_rrnd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rsame.c b/storage/myisam/mi_rsame.c index 8093498483f..2d1c0b17f95 100644 --- a/storage/myisam/mi_rsame.c +++ b/storage/myisam/mi_rsame.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2005 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_rsamepos.c b/storage/myisam/mi_rsamepos.c index 6a1e462b686..2053b742549 100644 --- a/storage/myisam/mi_rsamepos.c +++ b/storage/myisam/mi_rsamepos.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2005 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_scan.c b/storage/myisam/mi_scan.c index a225b399660..3dbd8f80ca5 100644 --- a/storage/myisam/mi_scan.c +++ b/storage/myisam/mi_scan.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_statrec.c b/storage/myisam/mi_statrec.c index e3771560c01..7b249dbbb19 100644 --- a/storage/myisam/mi_statrec.c +++ b/storage/myisam/mi_statrec.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004-2006 MySQL AB +/* Copyright (c) 2000-2002, 2004-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c index 5bdc33b8518..3d1e98cd06f 100644 --- a/storage/myisam/mi_test3.c +++ b/storage/myisam/mi_test3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 1bcf1b28ecf..ef2bd9de49e 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 8ab804cbaa2..282a02a08ee 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/rt_index.h b/storage/myisam/rt_index.h index 20193a1725d..29d90416390 100644 --- a/storage/myisam/rt_index.h +++ b/storage/myisam/rt_index.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2004 MySQL AB & Ramil Kalimullin +/* Copyright (c) 2002, 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/rt_key.c b/storage/myisam/rt_key.c index fe59af3c605..8eae8bb0c99 100644 --- a/storage/myisam/rt_key.c +++ b/storage/myisam/rt_key.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & Ramil Kalimullin +/* Copyright (c) 2000, 2002-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/rt_key.h b/storage/myisam/rt_key.h index 4b129aa18f8..2dc65c0f931 100644 --- a/storage/myisam/rt_key.h +++ b/storage/myisam/rt_key.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2004 MySQL AB & Ramil Kalimullin +/* Copyright (c) 2002, 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/rt_mbr.c b/storage/myisam/rt_mbr.c index deca23bbec7..5d8f17fdafa 100644 --- a/storage/myisam/rt_mbr.c +++ b/storage/myisam/rt_mbr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004, 2006 MySQL AB & Ramil Kalimullin +/* Copyright (c) 2002-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/rt_mbr.h b/storage/myisam/rt_mbr.h index d7ff9548e0d..9b766e9d423 100644 --- a/storage/myisam/rt_mbr.h +++ b/storage/myisam/rt_mbr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2004 MySQL AB & Ramil Kalimullin +/* Copyright (c) 2002, 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c index 7d15afd12ef..7433952c46d 100644 --- a/storage/myisam/rt_test.c +++ b/storage/myisam/rt_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004 MySQL AB +/* Copyright (c) 2002-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/sp_defs.h b/storage/myisam/sp_defs.h index 187ec62b2a3..1591f63f237 100644 --- a/storage/myisam/sp_defs.h +++ b/storage/myisam/sp_defs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2004 MySQL AB & Ramil Kalimullin +/* Copyright (c) 2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/sp_key.c b/storage/myisam/sp_key.c index 3748a38ff81..153a847d1dd 100644 --- a/storage/myisam/sp_key.c +++ b/storage/myisam/sp_key.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & Ramil Kalimullin +/* Copyright (c) 2000, 2002-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/Makefile.am b/storage/myisammrg/Makefile.am index 1ca51bc9d03..796e291d18b 100644 --- a/storage/myisammrg/Makefile.am +++ b/storage/myisammrg/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2002, 2005-2006 MySQL AB +# Copyright (c) 2000-2002, 2005, 2006, 2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_close.c b/storage/myisammrg/myrg_close.c index 97216ed47fe..553c6bf54e8 100644 --- a/storage/myisammrg/myrg_close.c +++ b/storage/myisammrg/myrg_close.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_def.h b/storage/myisammrg/myrg_def.h index 9c69da1424d..810fe0ecf9e 100644 --- a/storage/myisammrg/myrg_def.h +++ b/storage/myisammrg/myrg_def.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_delete.c b/storage/myisammrg/myrg_delete.c index 93d45198b36..28569f9b074 100644 --- a/storage/myisammrg/myrg_delete.c +++ b/storage/myisammrg/myrg_delete.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_extra.c b/storage/myisammrg/myrg_extra.c index 3d14f6a56e6..c5ec13005cd 100644 --- a/storage/myisammrg/myrg_extra.c +++ b/storage/myisammrg/myrg_extra.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_locking.c b/storage/myisammrg/myrg_locking.c index 4f1e3f844a1..baa3db474fc 100644 --- a/storage/myisammrg/myrg_locking.c +++ b/storage/myisammrg/myrg_locking.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_panic.c b/storage/myisammrg/myrg_panic.c index 0b1b7476873..9ee51631235 100644 --- a/storage/myisammrg/myrg_panic.c +++ b/storage/myisammrg/myrg_panic.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_queue.c b/storage/myisammrg/myrg_queue.c index d2579053784..4e1445534d6 100644 --- a/storage/myisammrg/myrg_queue.c +++ b/storage/myisammrg/myrg_queue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003, 2005 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_range.c b/storage/myisammrg/myrg_range.c index 26aa465e7d1..7908fa681d7 100644 --- a/storage/myisammrg/myrg_range.c +++ b/storage/myisammrg/myrg_range.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2004 MySQL AB +/* Copyright (c) 2002, 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_rfirst.c b/storage/myisammrg/myrg_rfirst.c index 9d7b0f9e83f..dd0488853fb 100644 --- a/storage/myisammrg/myrg_rfirst.c +++ b/storage/myisammrg/myrg_rfirst.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_rlast.c b/storage/myisammrg/myrg_rlast.c index 8086a2f8104..5f94cbb463c 100644 --- a/storage/myisammrg/myrg_rlast.c +++ b/storage/myisammrg/myrg_rlast.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_rnext.c b/storage/myisammrg/myrg_rnext.c index 82d5cbf38b1..3fb51d3bc40 100644 --- a/storage/myisammrg/myrg_rnext.c +++ b/storage/myisammrg/myrg_rnext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_rnext_same.c b/storage/myisammrg/myrg_rnext_same.c index ad7bbfb0f6e..89295adcf8e 100644 --- a/storage/myisammrg/myrg_rnext_same.c +++ b/storage/myisammrg/myrg_rnext_same.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2004 MySQL AB +/* Copyright (c) 2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_rprev.c b/storage/myisammrg/myrg_rprev.c index 66c94974940..32edd074289 100644 --- a/storage/myisammrg/myrg_rprev.c +++ b/storage/myisammrg/myrg_rprev.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_rrnd.c b/storage/myisammrg/myrg_rrnd.c index b598563680c..b2622c29519 100644 --- a/storage/myisammrg/myrg_rrnd.c +++ b/storage/myisammrg/myrg_rrnd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_rsame.c b/storage/myisammrg/myrg_rsame.c index 2f7523759dc..d7410446af5 100644 --- a/storage/myisammrg/myrg_rsame.c +++ b/storage/myisammrg/myrg_rsame.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_static.c b/storage/myisammrg/myrg_static.c index c20d2be4396..a18471a96f3 100644 --- a/storage/myisammrg/myrg_static.c +++ b/storage/myisammrg/myrg_static.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB +/* Copyright (c) 2000, 2001, 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_update.c b/storage/myisammrg/myrg_update.c index 5d883be8484..913d67bf90c 100644 --- a/storage/myisammrg/myrg_update.c +++ b/storage/myisammrg/myrg_update.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000-2002, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisammrg/myrg_write.c b/storage/myisammrg/myrg_write.c index 27534df2821..ae3db6712ad 100644 --- a/storage/myisammrg/myrg_write.c +++ b/storage/myisammrg/myrg_write.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2002, 2004 MySQL AB +/* Copyright (c) 2001, 2002, 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/config/make-win-dsw.sh b/storage/ndb/config/make-win-dsw.sh index 070a3665bc0..6c4eab7562d 100755 --- a/storage/ndb/config/make-win-dsw.sh +++ b/storage/ndb/config/make-win-dsw.sh @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/config/type_mgmapiclient.mk.am b/storage/ndb/config/type_mgmapiclient.mk.am index 662dc240cc6..cd4d9233bdd 100644 --- a/storage/ndb/config/type_mgmapiclient.mk.am +++ b/storage/ndb/config/type_mgmapiclient.mk.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/config/type_ndbapiclient.mk.am b/storage/ndb/config/type_ndbapiclient.mk.am index bb1da207638..89938ec91c2 100644 --- a/storage/ndb/config/type_ndbapiclient.mk.am +++ b/storage/ndb/config/type_ndbapiclient.mk.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/config/win-includes b/storage/ndb/config/win-includes index 0d6eec83ae7..81d0cc3ff88 100755 --- a/storage/ndb/config/win-includes +++ b/storage/ndb/config/win-includes @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/config/win-libraries b/storage/ndb/config/win-libraries index bc9275f9a7b..e09fcf6bdac 100755 --- a/storage/ndb/config/win-libraries +++ b/storage/ndb/config/win-libraries @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/config/win-name b/storage/ndb/config/win-name index 1ceb7019d3f..267afd9c0bd 100755 --- a/storage/ndb/config/win-name +++ b/storage/ndb/config/win-name @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/config/win-sources b/storage/ndb/config/win-sources index ccf0f6b7618..df249f89ae4 100755 --- a/storage/ndb/config/win-sources +++ b/storage/ndb/config/win-sources @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/docs/Makefile.am b/storage/ndb/docs/Makefile.am index 686341a2553..88e19c93eb4 100644 --- a/storage/ndb/docs/Makefile.am +++ b/storage/ndb/docs/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/docs/doxygen/postdoxy.pl b/storage/ndb/docs/doxygen/postdoxy.pl index a8eab31d47d..c37827c0da3 100755 --- a/storage/ndb/docs/doxygen/postdoxy.pl +++ b/storage/ndb/docs/doxygen/postdoxy.pl @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/docs/doxygen/predoxy.pl b/storage/ndb/docs/doxygen/predoxy.pl index 553052648af..bfa3ede39b7 100755 --- a/storage/ndb/docs/doxygen/predoxy.pl +++ b/storage/ndb/docs/doxygen/predoxy.pl @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2003-2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/Makefile.am b/storage/ndb/include/Makefile.am index 9e6ad016d75..37b6c9bf493 100644 --- a/storage/ndb/include/Makefile.am +++ b/storage/ndb/include/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/debugger/DebuggerNames.hpp b/storage/ndb/include/debugger/DebuggerNames.hpp index 86d76ae070c..95f86ceeee2 100644 --- a/storage/ndb/include/debugger/DebuggerNames.hpp +++ b/storage/ndb/include/debugger/DebuggerNames.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/debugger/EventLogger.hpp b/storage/ndb/include/debugger/EventLogger.hpp index 8ae96162a48..9c302360293 100644 --- a/storage/ndb/include/debugger/EventLogger.hpp +++ b/storage/ndb/include/debugger/EventLogger.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/debugger/GrepError.hpp b/storage/ndb/include/debugger/GrepError.hpp index 5a12a132f18..7fb1d1ce94e 100644 --- a/storage/ndb/include/debugger/GrepError.hpp +++ b/storage/ndb/include/debugger/GrepError.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/debugger/SignalLoggerManager.hpp b/storage/ndb/include/debugger/SignalLoggerManager.hpp index 578085ca1b8..05e90ee21de 100644 --- a/storage/ndb/include/debugger/SignalLoggerManager.hpp +++ b/storage/ndb/include/debugger/SignalLoggerManager.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/editline/editline.h b/storage/ndb/include/editline/editline.h index c0befc788e2..0e5173a4c60 100644 --- a/storage/ndb/include/editline/editline.h +++ b/storage/ndb/include/editline/editline.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/AttributeDescriptor.hpp b/storage/ndb/include/kernel/AttributeDescriptor.hpp index a49d0d65e44..db8bf882e77 100644 --- a/storage/ndb/include/kernel/AttributeDescriptor.hpp +++ b/storage/ndb/include/kernel/AttributeDescriptor.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/AttributeHeader.hpp b/storage/ndb/include/kernel/AttributeHeader.hpp index 52f93b6cd05..3db868f39cc 100644 --- a/storage/ndb/include/kernel/AttributeHeader.hpp +++ b/storage/ndb/include/kernel/AttributeHeader.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/AttributeList.hpp b/storage/ndb/include/kernel/AttributeList.hpp index b3f38735b2d..c9687499eb4 100644 --- a/storage/ndb/include/kernel/AttributeList.hpp +++ b/storage/ndb/include/kernel/AttributeList.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/BlockNumbers.h b/storage/ndb/include/kernel/BlockNumbers.h index 66e6a9a8c93..d6b7b777aa7 100644 --- a/storage/ndb/include/kernel/BlockNumbers.h +++ b/storage/ndb/include/kernel/BlockNumbers.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/GlobalSignalNumbers.h b/storage/ndb/include/kernel/GlobalSignalNumbers.h index 9653c20260f..ba7a2dc4517 100644 --- a/storage/ndb/include/kernel/GlobalSignalNumbers.h +++ b/storage/ndb/include/kernel/GlobalSignalNumbers.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/GrepEvent.hpp b/storage/ndb/include/kernel/GrepEvent.hpp index dd1034e6e91..b61e8ef337f 100644 --- a/storage/ndb/include/kernel/GrepEvent.hpp +++ b/storage/ndb/include/kernel/GrepEvent.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/Interpreter.hpp b/storage/ndb/include/kernel/Interpreter.hpp index 356d32599ac..dda92d17372 100644 --- a/storage/ndb/include/kernel/Interpreter.hpp +++ b/storage/ndb/include/kernel/Interpreter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/LogLevel.hpp b/storage/ndb/include/kernel/LogLevel.hpp index d58ac67083c..d36b505f0f2 100644 --- a/storage/ndb/include/kernel/LogLevel.hpp +++ b/storage/ndb/include/kernel/LogLevel.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/NodeBitmask.hpp b/storage/ndb/include/kernel/NodeBitmask.hpp index 7d48cd9f689..684ab0eabee 100644 --- a/storage/ndb/include/kernel/NodeBitmask.hpp +++ b/storage/ndb/include/kernel/NodeBitmask.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/NodeInfo.hpp b/storage/ndb/include/kernel/NodeInfo.hpp index e7fd8dcfccd..8c272e36946 100644 --- a/storage/ndb/include/kernel/NodeInfo.hpp +++ b/storage/ndb/include/kernel/NodeInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/NodeState.hpp b/storage/ndb/include/kernel/NodeState.hpp index 61fa25fb237..f692352a038 100644 --- a/storage/ndb/include/kernel/NodeState.hpp +++ b/storage/ndb/include/kernel/NodeState.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/RefConvert.hpp b/storage/ndb/include/kernel/RefConvert.hpp index c15681e1504..aab400eb3a0 100644 --- a/storage/ndb/include/kernel/RefConvert.hpp +++ b/storage/ndb/include/kernel/RefConvert.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/kernel_config_parameters.h b/storage/ndb/include/kernel/kernel_config_parameters.h index b715a1129d3..87ed2389416 100644 --- a/storage/ndb/include/kernel/kernel_config_parameters.h +++ b/storage/ndb/include/kernel/kernel_config_parameters.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/kernel_types.h b/storage/ndb/include/kernel/kernel_types.h index 0a607a50aff..f3493f598dc 100644 --- a/storage/ndb/include/kernel/kernel_types.h +++ b/storage/ndb/include/kernel/kernel_types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/ndb_limits.h b/storage/ndb/include/kernel/ndb_limits.h index 9a9521e82ef..0a38b6d7c26 100644 --- a/storage/ndb/include/kernel/ndb_limits.h +++ b/storage/ndb/include/kernel/ndb_limits.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AbortAll.hpp b/storage/ndb/include/kernel/signaldata/AbortAll.hpp index 2d7d3bd7c29..e0e7de7cd01 100644 --- a/storage/ndb/include/kernel/signaldata/AbortAll.hpp +++ b/storage/ndb/include/kernel/signaldata/AbortAll.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AccFrag.hpp b/storage/ndb/include/kernel/signaldata/AccFrag.hpp index c44e157485c..6491e0629fc 100644 --- a/storage/ndb/include/kernel/signaldata/AccFrag.hpp +++ b/storage/ndb/include/kernel/signaldata/AccFrag.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AccLock.hpp b/storage/ndb/include/kernel/signaldata/AccLock.hpp index bb7ed6dbe8b..8f36b582f0b 100644 --- a/storage/ndb/include/kernel/signaldata/AccLock.hpp +++ b/storage/ndb/include/kernel/signaldata/AccLock.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AccScan.hpp b/storage/ndb/include/kernel/signaldata/AccScan.hpp index a0aa38c8d8e..bc7a96140b2 100644 --- a/storage/ndb/include/kernel/signaldata/AccScan.hpp +++ b/storage/ndb/include/kernel/signaldata/AccScan.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AccSizeAltReq.hpp b/storage/ndb/include/kernel/signaldata/AccSizeAltReq.hpp index b3b239640ae..5c81e980574 100644 --- a/storage/ndb/include/kernel/signaldata/AccSizeAltReq.hpp +++ b/storage/ndb/include/kernel/signaldata/AccSizeAltReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AllocNodeId.hpp b/storage/ndb/include/kernel/signaldata/AllocNodeId.hpp index e37021ebbc8..351c7fa7aff 100644 --- a/storage/ndb/include/kernel/signaldata/AllocNodeId.hpp +++ b/storage/ndb/include/kernel/signaldata/AllocNodeId.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AlterIndx.hpp b/storage/ndb/include/kernel/signaldata/AlterIndx.hpp index bd9bf9a1293..9c9a2c07fe6 100644 --- a/storage/ndb/include/kernel/signaldata/AlterIndx.hpp +++ b/storage/ndb/include/kernel/signaldata/AlterIndx.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AlterTab.hpp b/storage/ndb/include/kernel/signaldata/AlterTab.hpp index d47d68cd2f8..ccafe8c8f58 100644 --- a/storage/ndb/include/kernel/signaldata/AlterTab.hpp +++ b/storage/ndb/include/kernel/signaldata/AlterTab.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AlterTable.hpp b/storage/ndb/include/kernel/signaldata/AlterTable.hpp index 3d348f8582a..4e292c61920 100644 --- a/storage/ndb/include/kernel/signaldata/AlterTable.hpp +++ b/storage/ndb/include/kernel/signaldata/AlterTable.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AlterTrig.hpp b/storage/ndb/include/kernel/signaldata/AlterTrig.hpp index 5ecda1c470c..b2adba22595 100644 --- a/storage/ndb/include/kernel/signaldata/AlterTrig.hpp +++ b/storage/ndb/include/kernel/signaldata/AlterTrig.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ApiBroadcast.hpp b/storage/ndb/include/kernel/signaldata/ApiBroadcast.hpp index 8d71d335103..ea24fdf8b74 100644 --- a/storage/ndb/include/kernel/signaldata/ApiBroadcast.hpp +++ b/storage/ndb/include/kernel/signaldata/ApiBroadcast.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp b/storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp index 119b2cdfc61..ccb01673f8e 100644 --- a/storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp +++ b/storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ApiVersion.hpp b/storage/ndb/include/kernel/signaldata/ApiVersion.hpp index c895d881f61..a9d93e4f0ab 100644 --- a/storage/ndb/include/kernel/signaldata/ApiVersion.hpp +++ b/storage/ndb/include/kernel/signaldata/ApiVersion.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp b/storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp index ed7e3929414..0f14109f4d5 100644 --- a/storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp +++ b/storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/AttrInfo.hpp b/storage/ndb/include/kernel/signaldata/AttrInfo.hpp index eafa79f0258..50128e4659f 100644 --- a/storage/ndb/include/kernel/signaldata/AttrInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/AttrInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp b/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp index d96173d6807..178732e3416 100644 --- a/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/BackupImpl.hpp b/storage/ndb/include/kernel/signaldata/BackupImpl.hpp index 5286c975f13..f4197572be0 100644 --- a/storage/ndb/include/kernel/signaldata/BackupImpl.hpp +++ b/storage/ndb/include/kernel/signaldata/BackupImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp b/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp index 21e24fcf5bc..ffcc2482c0a 100644 --- a/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp +++ b/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/BlockCommitOrd.hpp b/storage/ndb/include/kernel/signaldata/BlockCommitOrd.hpp index 924045926f9..d6ffc721a0e 100644 --- a/storage/ndb/include/kernel/signaldata/BlockCommitOrd.hpp +++ b/storage/ndb/include/kernel/signaldata/BlockCommitOrd.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/BuildIndx.hpp b/storage/ndb/include/kernel/signaldata/BuildIndx.hpp index d52dee648b8..591991746cf 100644 --- a/storage/ndb/include/kernel/signaldata/BuildIndx.hpp +++ b/storage/ndb/include/kernel/signaldata/BuildIndx.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CheckNodeGroups.hpp b/storage/ndb/include/kernel/signaldata/CheckNodeGroups.hpp index 6fc04a31709..a1b57da12ba 100644 --- a/storage/ndb/include/kernel/signaldata/CheckNodeGroups.hpp +++ b/storage/ndb/include/kernel/signaldata/CheckNodeGroups.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CloseComReqConf.hpp b/storage/ndb/include/kernel/signaldata/CloseComReqConf.hpp index fbc92acfb2f..fa3ecf7e3cd 100644 --- a/storage/ndb/include/kernel/signaldata/CloseComReqConf.hpp +++ b/storage/ndb/include/kernel/signaldata/CloseComReqConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CmInit.hpp b/storage/ndb/include/kernel/signaldata/CmInit.hpp index a61c58abb51..950b5fd011e 100644 --- a/storage/ndb/include/kernel/signaldata/CmInit.hpp +++ b/storage/ndb/include/kernel/signaldata/CmInit.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CmRegSignalData.hpp b/storage/ndb/include/kernel/signaldata/CmRegSignalData.hpp index e2e35cc9f93..c59530608a4 100644 --- a/storage/ndb/include/kernel/signaldata/CmRegSignalData.hpp +++ b/storage/ndb/include/kernel/signaldata/CmRegSignalData.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CmvmiCfgConf.hpp b/storage/ndb/include/kernel/signaldata/CmvmiCfgConf.hpp index dc2eaee786b..4a07c314832 100644 --- a/storage/ndb/include/kernel/signaldata/CmvmiCfgConf.hpp +++ b/storage/ndb/include/kernel/signaldata/CmvmiCfgConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CntrMasterConf.hpp b/storage/ndb/include/kernel/signaldata/CntrMasterConf.hpp index f2948a8835e..f5c8db36325 100644 --- a/storage/ndb/include/kernel/signaldata/CntrMasterConf.hpp +++ b/storage/ndb/include/kernel/signaldata/CntrMasterConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CntrMasterReq.hpp b/storage/ndb/include/kernel/signaldata/CntrMasterReq.hpp index 50ff9b95e6c..12c4e6dca50 100644 --- a/storage/ndb/include/kernel/signaldata/CntrMasterReq.hpp +++ b/storage/ndb/include/kernel/signaldata/CntrMasterReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CntrStart.hpp b/storage/ndb/include/kernel/signaldata/CntrStart.hpp index 9fc25a3fc4b..d0fb272f32b 100644 --- a/storage/ndb/include/kernel/signaldata/CntrStart.hpp +++ b/storage/ndb/include/kernel/signaldata/CntrStart.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ConfigParamId.hpp b/storage/ndb/include/kernel/signaldata/ConfigParamId.hpp index 90d604fd024..3afecb8fec0 100644 --- a/storage/ndb/include/kernel/signaldata/ConfigParamId.hpp +++ b/storage/ndb/include/kernel/signaldata/ConfigParamId.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ContinueFragmented.hpp b/storage/ndb/include/kernel/signaldata/ContinueFragmented.hpp index 31f47392a8b..e7e5eb2442b 100644 --- a/storage/ndb/include/kernel/signaldata/ContinueFragmented.hpp +++ b/storage/ndb/include/kernel/signaldata/ContinueFragmented.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CopyActive.hpp b/storage/ndb/include/kernel/signaldata/CopyActive.hpp index 2107d63ca5d..6a0594be94b 100644 --- a/storage/ndb/include/kernel/signaldata/CopyActive.hpp +++ b/storage/ndb/include/kernel/signaldata/CopyActive.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CopyFrag.hpp b/storage/ndb/include/kernel/signaldata/CopyFrag.hpp index d985358dce4..da9b3980f47 100644 --- a/storage/ndb/include/kernel/signaldata/CopyFrag.hpp +++ b/storage/ndb/include/kernel/signaldata/CopyFrag.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CopyGCIReq.hpp b/storage/ndb/include/kernel/signaldata/CopyGCIReq.hpp index c669e5cabee..917d8fdf39d 100644 --- a/storage/ndb/include/kernel/signaldata/CopyGCIReq.hpp +++ b/storage/ndb/include/kernel/signaldata/CopyGCIReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateEvnt.hpp b/storage/ndb/include/kernel/signaldata/CreateEvnt.hpp index ac191536b18..0fcb84d182e 100644 --- a/storage/ndb/include/kernel/signaldata/CreateEvnt.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateEvnt.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp b/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp index fa92af1de8c..58382e2bc37 100644 --- a/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp b/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp index bbd3e818681..d1b5cf73370 100644 --- a/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateFrag.hpp b/storage/ndb/include/kernel/signaldata/CreateFrag.hpp index dad2aa542ca..735081a5428 100644 --- a/storage/ndb/include/kernel/signaldata/CreateFrag.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateFrag.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateFragmentation.hpp b/storage/ndb/include/kernel/signaldata/CreateFragmentation.hpp index 9a4adcd1a13..c39dd25844c 100644 --- a/storage/ndb/include/kernel/signaldata/CreateFragmentation.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateFragmentation.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateIndx.hpp b/storage/ndb/include/kernel/signaldata/CreateIndx.hpp index 74f1237c383..ae94865ea7d 100644 --- a/storage/ndb/include/kernel/signaldata/CreateIndx.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateIndx.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateObj.hpp b/storage/ndb/include/kernel/signaldata/CreateObj.hpp index 59c014647b6..c707bfab007 100644 --- a/storage/ndb/include/kernel/signaldata/CreateObj.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateObj.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateTab.hpp b/storage/ndb/include/kernel/signaldata/CreateTab.hpp index 51eed93bde9..6b158125fb5 100644 --- a/storage/ndb/include/kernel/signaldata/CreateTab.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateTab.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateTable.hpp b/storage/ndb/include/kernel/signaldata/CreateTable.hpp index 6ee304fcad8..27fc3761b59 100644 --- a/storage/ndb/include/kernel/signaldata/CreateTable.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateTable.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/CreateTrig.hpp b/storage/ndb/include/kernel/signaldata/CreateTrig.hpp index c02dac4228b..61050bc3c1a 100644 --- a/storage/ndb/include/kernel/signaldata/CreateTrig.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateTrig.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DiAddTab.hpp b/storage/ndb/include/kernel/signaldata/DiAddTab.hpp index 787eb5eb6db..d3d404b853e 100644 --- a/storage/ndb/include/kernel/signaldata/DiAddTab.hpp +++ b/storage/ndb/include/kernel/signaldata/DiAddTab.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DiGetNodes.hpp b/storage/ndb/include/kernel/signaldata/DiGetNodes.hpp index 5e22c64143e..aba3d417988 100644 --- a/storage/ndb/include/kernel/signaldata/DiGetNodes.hpp +++ b/storage/ndb/include/kernel/signaldata/DiGetNodes.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DictLock.hpp b/storage/ndb/include/kernel/signaldata/DictLock.hpp index 9cf6199ae5c..0337ff61abb 100644 --- a/storage/ndb/include/kernel/signaldata/DictLock.hpp +++ b/storage/ndb/include/kernel/signaldata/DictLock.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DictObjOp.hpp b/storage/ndb/include/kernel/signaldata/DictObjOp.hpp index c153731139c..2058ded4591 100644 --- a/storage/ndb/include/kernel/signaldata/DictObjOp.hpp +++ b/storage/ndb/include/kernel/signaldata/DictObjOp.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DictSchemaInfo.hpp b/storage/ndb/include/kernel/signaldata/DictSchemaInfo.hpp index 88919769b37..5e8a344b26e 100644 --- a/storage/ndb/include/kernel/signaldata/DictSchemaInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/DictSchemaInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DictSizeAltReq.hpp b/storage/ndb/include/kernel/signaldata/DictSizeAltReq.hpp index a5b2584a374..133f6df8ec4 100644 --- a/storage/ndb/include/kernel/signaldata/DictSizeAltReq.hpp +++ b/storage/ndb/include/kernel/signaldata/DictSizeAltReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DictStart.hpp b/storage/ndb/include/kernel/signaldata/DictStart.hpp index ec317149095..4e8b2c129de 100644 --- a/storage/ndb/include/kernel/signaldata/DictStart.hpp +++ b/storage/ndb/include/kernel/signaldata/DictStart.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp b/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp index 3923d8e6fbf..6fef079a1a0 100644 --- a/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DihAddFrag.hpp b/storage/ndb/include/kernel/signaldata/DihAddFrag.hpp index 123b81c9480..5c7215a463e 100644 --- a/storage/ndb/include/kernel/signaldata/DihAddFrag.hpp +++ b/storage/ndb/include/kernel/signaldata/DihAddFrag.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DihContinueB.hpp b/storage/ndb/include/kernel/signaldata/DihContinueB.hpp index 4bec9af4856..71319483fff 100644 --- a/storage/ndb/include/kernel/signaldata/DihContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/DihContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DihSizeAltReq.hpp b/storage/ndb/include/kernel/signaldata/DihSizeAltReq.hpp index 9e901d5bf49..653e20bec55 100644 --- a/storage/ndb/include/kernel/signaldata/DihSizeAltReq.hpp +++ b/storage/ndb/include/kernel/signaldata/DihSizeAltReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DihStartTab.hpp b/storage/ndb/include/kernel/signaldata/DihStartTab.hpp index 434712dbf47..b8bad19aa57 100644 --- a/storage/ndb/include/kernel/signaldata/DihStartTab.hpp +++ b/storage/ndb/include/kernel/signaldata/DihStartTab.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DihSwitchReplica.hpp b/storage/ndb/include/kernel/signaldata/DihSwitchReplica.hpp index cbeeb60af92..4c43f1c76b2 100644 --- a/storage/ndb/include/kernel/signaldata/DihSwitchReplica.hpp +++ b/storage/ndb/include/kernel/signaldata/DihSwitchReplica.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DisconnectRep.hpp b/storage/ndb/include/kernel/signaldata/DisconnectRep.hpp index 26515fc0ef8..6faf2d45bfc 100644 --- a/storage/ndb/include/kernel/signaldata/DisconnectRep.hpp +++ b/storage/ndb/include/kernel/signaldata/DisconnectRep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp b/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp index a243380246e..f664cd04ec8 100644 --- a/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp +++ b/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp b/storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp index da1d953c1ca..ceaf14d2365 100644 --- a/storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp +++ b/storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DropIndx.hpp b/storage/ndb/include/kernel/signaldata/DropIndx.hpp index 6e3b183995f..b2862f6af78 100644 --- a/storage/ndb/include/kernel/signaldata/DropIndx.hpp +++ b/storage/ndb/include/kernel/signaldata/DropIndx.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DropObj.hpp b/storage/ndb/include/kernel/signaldata/DropObj.hpp index 278c9063c37..c9138dbccbd 100644 --- a/storage/ndb/include/kernel/signaldata/DropObj.hpp +++ b/storage/ndb/include/kernel/signaldata/DropObj.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DropTab.hpp b/storage/ndb/include/kernel/signaldata/DropTab.hpp index fd865bd3da2..3ffa5f80d03 100644 --- a/storage/ndb/include/kernel/signaldata/DropTab.hpp +++ b/storage/ndb/include/kernel/signaldata/DropTab.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DropTabFile.hpp b/storage/ndb/include/kernel/signaldata/DropTabFile.hpp index d9e6b96b5a9..464ee91c4ae 100644 --- a/storage/ndb/include/kernel/signaldata/DropTabFile.hpp +++ b/storage/ndb/include/kernel/signaldata/DropTabFile.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DropTable.hpp b/storage/ndb/include/kernel/signaldata/DropTable.hpp index c0a4596e1dc..7e3d5bb6e50 100644 --- a/storage/ndb/include/kernel/signaldata/DropTable.hpp +++ b/storage/ndb/include/kernel/signaldata/DropTable.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DropTrig.hpp b/storage/ndb/include/kernel/signaldata/DropTrig.hpp index 27e1a67801d..7eaefb8582a 100644 --- a/storage/ndb/include/kernel/signaldata/DropTrig.hpp +++ b/storage/ndb/include/kernel/signaldata/DropTrig.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/DumpStateOrd.hpp b/storage/ndb/include/kernel/signaldata/DumpStateOrd.hpp index 46c5ef3751b..0d945c0bce5 100644 --- a/storage/ndb/include/kernel/signaldata/DumpStateOrd.hpp +++ b/storage/ndb/include/kernel/signaldata/DumpStateOrd.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/EmptyLcp.hpp b/storage/ndb/include/kernel/signaldata/EmptyLcp.hpp index 60fccd742b6..b4ec8f2c336 100644 --- a/storage/ndb/include/kernel/signaldata/EmptyLcp.hpp +++ b/storage/ndb/include/kernel/signaldata/EmptyLcp.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/EndTo.hpp b/storage/ndb/include/kernel/signaldata/EndTo.hpp index 0885edff45b..a984e690692 100644 --- a/storage/ndb/include/kernel/signaldata/EndTo.hpp +++ b/storage/ndb/include/kernel/signaldata/EndTo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/EventReport.hpp b/storage/ndb/include/kernel/signaldata/EventReport.hpp index e7b1fa3d79a..91344ed7537 100644 --- a/storage/ndb/include/kernel/signaldata/EventReport.hpp +++ b/storage/ndb/include/kernel/signaldata/EventReport.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp b/storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp index d72b6dec3e5..f466c36f09f 100644 --- a/storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp +++ b/storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ExecFragReq.hpp b/storage/ndb/include/kernel/signaldata/ExecFragReq.hpp index 47155638b81..3f2dae50009 100644 --- a/storage/ndb/include/kernel/signaldata/ExecFragReq.hpp +++ b/storage/ndb/include/kernel/signaldata/ExecFragReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/Extent.hpp b/storage/ndb/include/kernel/signaldata/Extent.hpp index 283ea7ba85a..8445d34ee7d 100644 --- a/storage/ndb/include/kernel/signaldata/Extent.hpp +++ b/storage/ndb/include/kernel/signaldata/Extent.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FailRep.hpp b/storage/ndb/include/kernel/signaldata/FailRep.hpp index 798ff3f5e47..3a1439b9447 100644 --- a/storage/ndb/include/kernel/signaldata/FailRep.hpp +++ b/storage/ndb/include/kernel/signaldata/FailRep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FireTrigOrd.hpp b/storage/ndb/include/kernel/signaldata/FireTrigOrd.hpp index d33f8be3650..99e39cef0fd 100644 --- a/storage/ndb/include/kernel/signaldata/FireTrigOrd.hpp +++ b/storage/ndb/include/kernel/signaldata/FireTrigOrd.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FsAppendReq.hpp b/storage/ndb/include/kernel/signaldata/FsAppendReq.hpp index dafd597dbe6..d5a0a4a654e 100644 --- a/storage/ndb/include/kernel/signaldata/FsAppendReq.hpp +++ b/storage/ndb/include/kernel/signaldata/FsAppendReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FsCloseReq.hpp b/storage/ndb/include/kernel/signaldata/FsCloseReq.hpp index 41d12c71dd7..e248c36420e 100644 --- a/storage/ndb/include/kernel/signaldata/FsCloseReq.hpp +++ b/storage/ndb/include/kernel/signaldata/FsCloseReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FsConf.hpp b/storage/ndb/include/kernel/signaldata/FsConf.hpp index 87d56e9a364..185c81be9c7 100644 --- a/storage/ndb/include/kernel/signaldata/FsConf.hpp +++ b/storage/ndb/include/kernel/signaldata/FsConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp b/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp index 8126267f946..ad35c5bac6d 100644 --- a/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp +++ b/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp b/storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp index cf3112ec523..7dd28f0a33b 100644 --- a/storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp +++ b/storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FsRef.hpp b/storage/ndb/include/kernel/signaldata/FsRef.hpp index ab5a269f496..46405ca6040 100644 --- a/storage/ndb/include/kernel/signaldata/FsRef.hpp +++ b/storage/ndb/include/kernel/signaldata/FsRef.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/FsRemoveReq.hpp b/storage/ndb/include/kernel/signaldata/FsRemoveReq.hpp index 24971a489e6..436f3cecefe 100644 --- a/storage/ndb/include/kernel/signaldata/FsRemoveReq.hpp +++ b/storage/ndb/include/kernel/signaldata/FsRemoveReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/GCPSave.hpp b/storage/ndb/include/kernel/signaldata/GCPSave.hpp index 61a0414c093..33494b3a02b 100644 --- a/storage/ndb/include/kernel/signaldata/GCPSave.hpp +++ b/storage/ndb/include/kernel/signaldata/GCPSave.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/GetTabInfo.hpp b/storage/ndb/include/kernel/signaldata/GetTabInfo.hpp index 0a5e38fa91a..299224a822d 100644 --- a/storage/ndb/include/kernel/signaldata/GetTabInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/GetTabInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/GetTableId.hpp b/storage/ndb/include/kernel/signaldata/GetTableId.hpp index 8c785a911ab..e724600ddde 100644 --- a/storage/ndb/include/kernel/signaldata/GetTableId.hpp +++ b/storage/ndb/include/kernel/signaldata/GetTableId.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/GrepImpl.hpp b/storage/ndb/include/kernel/signaldata/GrepImpl.hpp index 335c78f58eb..d8d96640faf 100644 --- a/storage/ndb/include/kernel/signaldata/GrepImpl.hpp +++ b/storage/ndb/include/kernel/signaldata/GrepImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/HotSpareRep.hpp b/storage/ndb/include/kernel/signaldata/HotSpareRep.hpp index c3e2922f1d7..95cfb10b1ba 100644 --- a/storage/ndb/include/kernel/signaldata/HotSpareRep.hpp +++ b/storage/ndb/include/kernel/signaldata/HotSpareRep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/IndxAttrInfo.hpp b/storage/ndb/include/kernel/signaldata/IndxAttrInfo.hpp index f42e9ff8657..63d9bd53f32 100755 --- a/storage/ndb/include/kernel/signaldata/IndxAttrInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/IndxAttrInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/IndxKeyInfo.hpp b/storage/ndb/include/kernel/signaldata/IndxKeyInfo.hpp index 82ba9ae6c3f..9cbe51ce6f9 100755 --- a/storage/ndb/include/kernel/signaldata/IndxKeyInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/IndxKeyInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/InvalidateNodeLCPConf.hpp b/storage/ndb/include/kernel/signaldata/InvalidateNodeLCPConf.hpp index 49293a5d18b..bd9108f781a 100644 --- a/storage/ndb/include/kernel/signaldata/InvalidateNodeLCPConf.hpp +++ b/storage/ndb/include/kernel/signaldata/InvalidateNodeLCPConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/InvalidateNodeLCPReq.hpp b/storage/ndb/include/kernel/signaldata/InvalidateNodeLCPReq.hpp index 57f9870d019..61d665e81aa 100644 --- a/storage/ndb/include/kernel/signaldata/InvalidateNodeLCPReq.hpp +++ b/storage/ndb/include/kernel/signaldata/InvalidateNodeLCPReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/KeyInfo.hpp b/storage/ndb/include/kernel/signaldata/KeyInfo.hpp index 48bb028d726..d838c87c306 100644 --- a/storage/ndb/include/kernel/signaldata/KeyInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/KeyInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/LCP.hpp b/storage/ndb/include/kernel/signaldata/LCP.hpp index 844b5de0afd..9feef8cc6dc 100644 --- a/storage/ndb/include/kernel/signaldata/LCP.hpp +++ b/storage/ndb/include/kernel/signaldata/LCP.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp b/storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp index b1d0f392817..c0c18677312 100644 --- a/storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ListTables.hpp b/storage/ndb/include/kernel/signaldata/ListTables.hpp index 75cad41d03a..d42dcdb3136 100644 --- a/storage/ndb/include/kernel/signaldata/ListTables.hpp +++ b/storage/ndb/include/kernel/signaldata/ListTables.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/LqhFrag.hpp b/storage/ndb/include/kernel/signaldata/LqhFrag.hpp index d4f4877cc5b..fdf7b02bb05 100644 --- a/storage/ndb/include/kernel/signaldata/LqhFrag.hpp +++ b/storage/ndb/include/kernel/signaldata/LqhFrag.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/LqhKey.hpp b/storage/ndb/include/kernel/signaldata/LqhKey.hpp index c85a4d4a796..8f9afac6b26 100644 --- a/storage/ndb/include/kernel/signaldata/LqhKey.hpp +++ b/storage/ndb/include/kernel/signaldata/LqhKey.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/LqhSizeAltReq.hpp b/storage/ndb/include/kernel/signaldata/LqhSizeAltReq.hpp index 109f7343678..3443b91b394 100644 --- a/storage/ndb/include/kernel/signaldata/LqhSizeAltReq.hpp +++ b/storage/ndb/include/kernel/signaldata/LqhSizeAltReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/LqhTransConf.hpp b/storage/ndb/include/kernel/signaldata/LqhTransConf.hpp index 4a72d344ad6..ae0a32e1ace 100644 --- a/storage/ndb/include/kernel/signaldata/LqhTransConf.hpp +++ b/storage/ndb/include/kernel/signaldata/LqhTransConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ManagementServer.hpp b/storage/ndb/include/kernel/signaldata/ManagementServer.hpp index c97a252d638..970acd4d181 100644 --- a/storage/ndb/include/kernel/signaldata/ManagementServer.hpp +++ b/storage/ndb/include/kernel/signaldata/ManagementServer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/MasterGCP.hpp b/storage/ndb/include/kernel/signaldata/MasterGCP.hpp index 683a1ac869f..661f299e661 100644 --- a/storage/ndb/include/kernel/signaldata/MasterGCP.hpp +++ b/storage/ndb/include/kernel/signaldata/MasterGCP.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/MasterLCP.hpp b/storage/ndb/include/kernel/signaldata/MasterLCP.hpp index b9fbff2313d..bb7f254f8b6 100644 --- a/storage/ndb/include/kernel/signaldata/MasterLCP.hpp +++ b/storage/ndb/include/kernel/signaldata/MasterLCP.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/NFCompleteRep.hpp b/storage/ndb/include/kernel/signaldata/NFCompleteRep.hpp index 18b201021b5..974e37c0f8c 100644 --- a/storage/ndb/include/kernel/signaldata/NFCompleteRep.hpp +++ b/storage/ndb/include/kernel/signaldata/NFCompleteRep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/NdbSttor.hpp b/storage/ndb/include/kernel/signaldata/NdbSttor.hpp index e5e5dfb829c..564d37853eb 100644 --- a/storage/ndb/include/kernel/signaldata/NdbSttor.hpp +++ b/storage/ndb/include/kernel/signaldata/NdbSttor.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/NdbfsContinueB.hpp b/storage/ndb/include/kernel/signaldata/NdbfsContinueB.hpp index 22e6e8e3e0b..505e3eff636 100644 --- a/storage/ndb/include/kernel/signaldata/NdbfsContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/NdbfsContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/NextScan.hpp b/storage/ndb/include/kernel/signaldata/NextScan.hpp index 3cc227785b4..3c61ba4669b 100644 --- a/storage/ndb/include/kernel/signaldata/NextScan.hpp +++ b/storage/ndb/include/kernel/signaldata/NextScan.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/NodeFailRep.hpp b/storage/ndb/include/kernel/signaldata/NodeFailRep.hpp index a7c55e8fff1..40be5efb35e 100644 --- a/storage/ndb/include/kernel/signaldata/NodeFailRep.hpp +++ b/storage/ndb/include/kernel/signaldata/NodeFailRep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/NodeStateSignalData.hpp b/storage/ndb/include/kernel/signaldata/NodeStateSignalData.hpp index 0c15f3f968b..e3502fe5439 100644 --- a/storage/ndb/include/kernel/signaldata/NodeStateSignalData.hpp +++ b/storage/ndb/include/kernel/signaldata/NodeStateSignalData.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/PackedSignal.hpp b/storage/ndb/include/kernel/signaldata/PackedSignal.hpp index 50f9517b1c8..338b23f75de 100644 --- a/storage/ndb/include/kernel/signaldata/PackedSignal.hpp +++ b/storage/ndb/include/kernel/signaldata/PackedSignal.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp b/storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp index 2cb89360a75..f0255e25d1d 100644 --- a/storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/PrepDropTab.hpp b/storage/ndb/include/kernel/signaldata/PrepDropTab.hpp index 9fed2f287d2..cc93bd7d744 100644 --- a/storage/ndb/include/kernel/signaldata/PrepDropTab.hpp +++ b/storage/ndb/include/kernel/signaldata/PrepDropTab.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/PrepFailReqRef.hpp b/storage/ndb/include/kernel/signaldata/PrepFailReqRef.hpp index e7b83f6b316..ea22efef21a 100644 --- a/storage/ndb/include/kernel/signaldata/PrepFailReqRef.hpp +++ b/storage/ndb/include/kernel/signaldata/PrepFailReqRef.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ReadConfig.hpp b/storage/ndb/include/kernel/signaldata/ReadConfig.hpp index 68a32ec4e68..afbb8ae1fdf 100644 --- a/storage/ndb/include/kernel/signaldata/ReadConfig.hpp +++ b/storage/ndb/include/kernel/signaldata/ReadConfig.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ReadNodesConf.hpp b/storage/ndb/include/kernel/signaldata/ReadNodesConf.hpp index f42c9249418..abad5403702 100644 --- a/storage/ndb/include/kernel/signaldata/ReadNodesConf.hpp +++ b/storage/ndb/include/kernel/signaldata/ReadNodesConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/RelTabMem.hpp b/storage/ndb/include/kernel/signaldata/RelTabMem.hpp index 372ef58d283..5b02e167842 100644 --- a/storage/ndb/include/kernel/signaldata/RelTabMem.hpp +++ b/storage/ndb/include/kernel/signaldata/RelTabMem.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/RepImpl.hpp b/storage/ndb/include/kernel/signaldata/RepImpl.hpp index a82ae979d4d..4380efd9246 100644 --- a/storage/ndb/include/kernel/signaldata/RepImpl.hpp +++ b/storage/ndb/include/kernel/signaldata/RepImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp b/storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp index 60e133f7c2b..fc7640565d2 100644 --- a/storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/RestoreImpl.hpp b/storage/ndb/include/kernel/signaldata/RestoreImpl.hpp index 60acebdd809..72a967f0f11 100644 --- a/storage/ndb/include/kernel/signaldata/RestoreImpl.hpp +++ b/storage/ndb/include/kernel/signaldata/RestoreImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ResumeReq.hpp b/storage/ndb/include/kernel/signaldata/ResumeReq.hpp index 5ef57a9b700..21b7d18b51a 100644 --- a/storage/ndb/include/kernel/signaldata/ResumeReq.hpp +++ b/storage/ndb/include/kernel/signaldata/ResumeReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/RouteOrd.hpp b/storage/ndb/include/kernel/signaldata/RouteOrd.hpp index 01ed8fd98f2..f00cf068852 100644 --- a/storage/ndb/include/kernel/signaldata/RouteOrd.hpp +++ b/storage/ndb/include/kernel/signaldata/RouteOrd.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ScanFrag.hpp b/storage/ndb/include/kernel/signaldata/ScanFrag.hpp index c06ad20b6a2..a6e4f150525 100644 --- a/storage/ndb/include/kernel/signaldata/ScanFrag.hpp +++ b/storage/ndb/include/kernel/signaldata/ScanFrag.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/ScanTab.hpp b/storage/ndb/include/kernel/signaldata/ScanTab.hpp index 3d2071ca019..5fac09faedd 100644 --- a/storage/ndb/include/kernel/signaldata/ScanTab.hpp +++ b/storage/ndb/include/kernel/signaldata/ScanTab.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp b/storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp index 942baf2a9ad..2483aed6c0c 100644 --- a/storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp +++ b/storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/SetVarReq.hpp b/storage/ndb/include/kernel/signaldata/SetVarReq.hpp index a4bf54d2a2a..36c27000681 100644 --- a/storage/ndb/include/kernel/signaldata/SetVarReq.hpp +++ b/storage/ndb/include/kernel/signaldata/SetVarReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/SignalData.hpp b/storage/ndb/include/kernel/signaldata/SignalData.hpp index 812a0dda6f8..ad9d3267a57 100644 --- a/storage/ndb/include/kernel/signaldata/SignalData.hpp +++ b/storage/ndb/include/kernel/signaldata/SignalData.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/SignalDataPrint.hpp b/storage/ndb/include/kernel/signaldata/SignalDataPrint.hpp index 1d0b3a17bfd..7fd18f43b37 100644 --- a/storage/ndb/include/kernel/signaldata/SignalDataPrint.hpp +++ b/storage/ndb/include/kernel/signaldata/SignalDataPrint.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/SignalDroppedRep.hpp b/storage/ndb/include/kernel/signaldata/SignalDroppedRep.hpp index fd6d5afabce..dcedbb18d73 100644 --- a/storage/ndb/include/kernel/signaldata/SignalDroppedRep.hpp +++ b/storage/ndb/include/kernel/signaldata/SignalDroppedRep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/SrFragidConf.hpp b/storage/ndb/include/kernel/signaldata/SrFragidConf.hpp index e534378779e..58fb7403165 100644 --- a/storage/ndb/include/kernel/signaldata/SrFragidConf.hpp +++ b/storage/ndb/include/kernel/signaldata/SrFragidConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StartFragReq.hpp b/storage/ndb/include/kernel/signaldata/StartFragReq.hpp index 46a3251e812..09478152ae6 100644 --- a/storage/ndb/include/kernel/signaldata/StartFragReq.hpp +++ b/storage/ndb/include/kernel/signaldata/StartFragReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StartInfo.hpp b/storage/ndb/include/kernel/signaldata/StartInfo.hpp index 733082cae1e..17cc6a92a11 100644 --- a/storage/ndb/include/kernel/signaldata/StartInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/StartInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StartMe.hpp b/storage/ndb/include/kernel/signaldata/StartMe.hpp index 56b20efe951..ae5d21d7766 100644 --- a/storage/ndb/include/kernel/signaldata/StartMe.hpp +++ b/storage/ndb/include/kernel/signaldata/StartMe.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StartOrd.hpp b/storage/ndb/include/kernel/signaldata/StartOrd.hpp index 03092719629..0d9e4d8ab4e 100644 --- a/storage/ndb/include/kernel/signaldata/StartOrd.hpp +++ b/storage/ndb/include/kernel/signaldata/StartOrd.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StartPerm.hpp b/storage/ndb/include/kernel/signaldata/StartPerm.hpp index 16229f6552f..739d0540cfd 100644 --- a/storage/ndb/include/kernel/signaldata/StartPerm.hpp +++ b/storage/ndb/include/kernel/signaldata/StartPerm.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StartRec.hpp b/storage/ndb/include/kernel/signaldata/StartRec.hpp index 24367c541ab..9a848bd23e7 100644 --- a/storage/ndb/include/kernel/signaldata/StartRec.hpp +++ b/storage/ndb/include/kernel/signaldata/StartRec.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StartTo.hpp b/storage/ndb/include/kernel/signaldata/StartTo.hpp index f8ac256e98f..39a05f6e710 100644 --- a/storage/ndb/include/kernel/signaldata/StartTo.hpp +++ b/storage/ndb/include/kernel/signaldata/StartTo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StopMe.hpp b/storage/ndb/include/kernel/signaldata/StopMe.hpp index 98531bffa00..bc1a47fa4d7 100644 --- a/storage/ndb/include/kernel/signaldata/StopMe.hpp +++ b/storage/ndb/include/kernel/signaldata/StopMe.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StopPerm.hpp b/storage/ndb/include/kernel/signaldata/StopPerm.hpp index 145a120646a..faeb617b01a 100644 --- a/storage/ndb/include/kernel/signaldata/StopPerm.hpp +++ b/storage/ndb/include/kernel/signaldata/StopPerm.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/StopReq.hpp b/storage/ndb/include/kernel/signaldata/StopReq.hpp index a065f528735..c0bbd1dd589 100644 --- a/storage/ndb/include/kernel/signaldata/StopReq.hpp +++ b/storage/ndb/include/kernel/signaldata/StopReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/SumaImpl.hpp b/storage/ndb/include/kernel/signaldata/SumaImpl.hpp index 94775a5f3f4..6aa9ced23f7 100644 --- a/storage/ndb/include/kernel/signaldata/SumaImpl.hpp +++ b/storage/ndb/include/kernel/signaldata/SumaImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/SystemError.hpp b/storage/ndb/include/kernel/signaldata/SystemError.hpp index ac4ea154198..dd9f1e6acb8 100644 --- a/storage/ndb/include/kernel/signaldata/SystemError.hpp +++ b/storage/ndb/include/kernel/signaldata/SystemError.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TamperOrd.hpp b/storage/ndb/include/kernel/signaldata/TamperOrd.hpp index 34831704166..92fb4453641 100644 --- a/storage/ndb/include/kernel/signaldata/TamperOrd.hpp +++ b/storage/ndb/include/kernel/signaldata/TamperOrd.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcCommit.hpp b/storage/ndb/include/kernel/signaldata/TcCommit.hpp index f0234e22ccf..1604c4827e3 100644 --- a/storage/ndb/include/kernel/signaldata/TcCommit.hpp +++ b/storage/ndb/include/kernel/signaldata/TcCommit.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcContinueB.hpp b/storage/ndb/include/kernel/signaldata/TcContinueB.hpp index b21b4bb4e46..ad18cb00337 100644 --- a/storage/ndb/include/kernel/signaldata/TcContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/TcContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcHbRep.hpp b/storage/ndb/include/kernel/signaldata/TcHbRep.hpp index da3b8d583d3..3d796dd37c5 100644 --- a/storage/ndb/include/kernel/signaldata/TcHbRep.hpp +++ b/storage/ndb/include/kernel/signaldata/TcHbRep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcIndx.hpp b/storage/ndb/include/kernel/signaldata/TcIndx.hpp index 4dc54e9b188..dd072af24a8 100644 --- a/storage/ndb/include/kernel/signaldata/TcIndx.hpp +++ b/storage/ndb/include/kernel/signaldata/TcIndx.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcKeyConf.hpp b/storage/ndb/include/kernel/signaldata/TcKeyConf.hpp index fd8932c3c87..c80421d6a98 100644 --- a/storage/ndb/include/kernel/signaldata/TcKeyConf.hpp +++ b/storage/ndb/include/kernel/signaldata/TcKeyConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcKeyFailConf.hpp b/storage/ndb/include/kernel/signaldata/TcKeyFailConf.hpp index 076f4f22a51..a8684695ce7 100644 --- a/storage/ndb/include/kernel/signaldata/TcKeyFailConf.hpp +++ b/storage/ndb/include/kernel/signaldata/TcKeyFailConf.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcKeyRef.hpp b/storage/ndb/include/kernel/signaldata/TcKeyRef.hpp index 56f6cdae29d..49b32343388 100644 --- a/storage/ndb/include/kernel/signaldata/TcKeyRef.hpp +++ b/storage/ndb/include/kernel/signaldata/TcKeyRef.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcKeyReq.hpp b/storage/ndb/include/kernel/signaldata/TcKeyReq.hpp index ee65b4baebf..6c912231159 100644 --- a/storage/ndb/include/kernel/signaldata/TcKeyReq.hpp +++ b/storage/ndb/include/kernel/signaldata/TcKeyReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcRollbackRep.hpp b/storage/ndb/include/kernel/signaldata/TcRollbackRep.hpp index 609756605d5..20c80d64db1 100644 --- a/storage/ndb/include/kernel/signaldata/TcRollbackRep.hpp +++ b/storage/ndb/include/kernel/signaldata/TcRollbackRep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TcSizeAltReq.hpp b/storage/ndb/include/kernel/signaldata/TcSizeAltReq.hpp index 12bf9b3c72d..b8aa182f601 100644 --- a/storage/ndb/include/kernel/signaldata/TcSizeAltReq.hpp +++ b/storage/ndb/include/kernel/signaldata/TcSizeAltReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TestOrd.hpp b/storage/ndb/include/kernel/signaldata/TestOrd.hpp index 44368a213fe..55f7a35c51f 100644 --- a/storage/ndb/include/kernel/signaldata/TestOrd.hpp +++ b/storage/ndb/include/kernel/signaldata/TestOrd.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TransIdAI.hpp b/storage/ndb/include/kernel/signaldata/TransIdAI.hpp index a2af9ed89cc..d26d7cd5d3e 100755 --- a/storage/ndb/include/kernel/signaldata/TransIdAI.hpp +++ b/storage/ndb/include/kernel/signaldata/TransIdAI.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TrigAttrInfo.hpp b/storage/ndb/include/kernel/signaldata/TrigAttrInfo.hpp index 79371258b3d..0d3a84a080c 100644 --- a/storage/ndb/include/kernel/signaldata/TrigAttrInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/TrigAttrInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp b/storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp index edfcf4ac5d1..635a4da848c 100644 --- a/storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TupCommit.hpp b/storage/ndb/include/kernel/signaldata/TupCommit.hpp index 11d0dbbb8d3..f99d7a1f946 100644 --- a/storage/ndb/include/kernel/signaldata/TupCommit.hpp +++ b/storage/ndb/include/kernel/signaldata/TupCommit.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TupFrag.hpp b/storage/ndb/include/kernel/signaldata/TupFrag.hpp index 106518dd47b..4d47cd3b50a 100644 --- a/storage/ndb/include/kernel/signaldata/TupFrag.hpp +++ b/storage/ndb/include/kernel/signaldata/TupFrag.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TupKey.hpp b/storage/ndb/include/kernel/signaldata/TupKey.hpp index e77dbd471e7..ea277c37eb5 100644 --- a/storage/ndb/include/kernel/signaldata/TupKey.hpp +++ b/storage/ndb/include/kernel/signaldata/TupKey.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TupSizeAltReq.hpp b/storage/ndb/include/kernel/signaldata/TupSizeAltReq.hpp index 1fb4eae8f51..106f62cd8ee 100644 --- a/storage/ndb/include/kernel/signaldata/TupSizeAltReq.hpp +++ b/storage/ndb/include/kernel/signaldata/TupSizeAltReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TuxBound.hpp b/storage/ndb/include/kernel/signaldata/TuxBound.hpp index c0f8fd82038..18f60de2402 100644 --- a/storage/ndb/include/kernel/signaldata/TuxBound.hpp +++ b/storage/ndb/include/kernel/signaldata/TuxBound.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TuxContinueB.hpp b/storage/ndb/include/kernel/signaldata/TuxContinueB.hpp index 87ac4d89211..ba76eb503ca 100644 --- a/storage/ndb/include/kernel/signaldata/TuxContinueB.hpp +++ b/storage/ndb/include/kernel/signaldata/TuxContinueB.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TuxMaint.hpp b/storage/ndb/include/kernel/signaldata/TuxMaint.hpp index 37237383e76..30b2f767bd3 100644 --- a/storage/ndb/include/kernel/signaldata/TuxMaint.hpp +++ b/storage/ndb/include/kernel/signaldata/TuxMaint.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/TuxSizeAltReq.hpp b/storage/ndb/include/kernel/signaldata/TuxSizeAltReq.hpp index bf2314d7159..4ebe849370f 100644 --- a/storage/ndb/include/kernel/signaldata/TuxSizeAltReq.hpp +++ b/storage/ndb/include/kernel/signaldata/TuxSizeAltReq.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/UpdateTo.hpp b/storage/ndb/include/kernel/signaldata/UpdateTo.hpp index e46fe1c1556..bca1d36b737 100644 --- a/storage/ndb/include/kernel/signaldata/UpdateTo.hpp +++ b/storage/ndb/include/kernel/signaldata/UpdateTo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/UpgradeStartup.hpp b/storage/ndb/include/kernel/signaldata/UpgradeStartup.hpp index 80f6a161e05..dbe63f7ba11 100644 --- a/storage/ndb/include/kernel/signaldata/UpgradeStartup.hpp +++ b/storage/ndb/include/kernel/signaldata/UpgradeStartup.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/UtilDelete.hpp b/storage/ndb/include/kernel/signaldata/UtilDelete.hpp index fb5c0ece0fd..41d009785df 100644 --- a/storage/ndb/include/kernel/signaldata/UtilDelete.hpp +++ b/storage/ndb/include/kernel/signaldata/UtilDelete.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/UtilExecute.hpp b/storage/ndb/include/kernel/signaldata/UtilExecute.hpp index 24a3d5874d2..672d821c974 100644 --- a/storage/ndb/include/kernel/signaldata/UtilExecute.hpp +++ b/storage/ndb/include/kernel/signaldata/UtilExecute.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/UtilLock.hpp b/storage/ndb/include/kernel/signaldata/UtilLock.hpp index 75a697714f0..842dde169a0 100644 --- a/storage/ndb/include/kernel/signaldata/UtilLock.hpp +++ b/storage/ndb/include/kernel/signaldata/UtilLock.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/UtilPrepare.hpp b/storage/ndb/include/kernel/signaldata/UtilPrepare.hpp index 4de9e61f699..08bc10b5ed9 100644 --- a/storage/ndb/include/kernel/signaldata/UtilPrepare.hpp +++ b/storage/ndb/include/kernel/signaldata/UtilPrepare.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/UtilRelease.hpp b/storage/ndb/include/kernel/signaldata/UtilRelease.hpp index 97623670399..692130e9ade 100644 --- a/storage/ndb/include/kernel/signaldata/UtilRelease.hpp +++ b/storage/ndb/include/kernel/signaldata/UtilRelease.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/UtilSequence.hpp b/storage/ndb/include/kernel/signaldata/UtilSequence.hpp index b24a6f83b7d..e62b4284f59 100644 --- a/storage/ndb/include/kernel/signaldata/UtilSequence.hpp +++ b/storage/ndb/include/kernel/signaldata/UtilSequence.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/signaldata/WaitGCP.hpp b/storage/ndb/include/kernel/signaldata/WaitGCP.hpp index 7e62debdf18..e9590019d5b 100644 --- a/storage/ndb/include/kernel/signaldata/WaitGCP.hpp +++ b/storage/ndb/include/kernel/signaldata/WaitGCP.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/kernel/trigger_definitions.h b/storage/ndb/include/kernel/trigger_definitions.h index b9644e040fa..34c45a2a89f 100644 --- a/storage/ndb/include/kernel/trigger_definitions.h +++ b/storage/ndb/include/kernel/trigger_definitions.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/logger/ConsoleLogHandler.hpp b/storage/ndb/include/logger/ConsoleLogHandler.hpp index cfcb598fb5e..f0a77020f68 100644 --- a/storage/ndb/include/logger/ConsoleLogHandler.hpp +++ b/storage/ndb/include/logger/ConsoleLogHandler.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/logger/FileLogHandler.hpp b/storage/ndb/include/logger/FileLogHandler.hpp index 36a35399ac8..79ca35a4767 100644 --- a/storage/ndb/include/logger/FileLogHandler.hpp +++ b/storage/ndb/include/logger/FileLogHandler.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/logger/LogHandler.hpp b/storage/ndb/include/logger/LogHandler.hpp index 98809280d0c..2dd3f25edf8 100644 --- a/storage/ndb/include/logger/LogHandler.hpp +++ b/storage/ndb/include/logger/LogHandler.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/logger/Logger.hpp b/storage/ndb/include/logger/Logger.hpp index 01bda35b050..775921e94c5 100644 --- a/storage/ndb/include/logger/Logger.hpp +++ b/storage/ndb/include/logger/Logger.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/logger/SysLogHandler.hpp b/storage/ndb/include/logger/SysLogHandler.hpp index e2d4af54e7a..6945befd314 100644 --- a/storage/ndb/include/logger/SysLogHandler.hpp +++ b/storage/ndb/include/logger/SysLogHandler.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h index 0853f5a4422..0ccca42cc56 100644 --- a/storage/ndb/include/mgmapi/mgmapi.h +++ b/storage/ndb/include/mgmapi/mgmapi.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h index ac2cbf060fd..8a354917fc9 100644 --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters_debug.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters_debug.h index 20e10fb52db..d1cb5a201ae 100644 --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters_debug.h +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters_debug.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmapi/mgmapi_debug.h b/storage/ndb/include/mgmapi/mgmapi_debug.h index ceb1e6f4eb5..206176da7be 100644 --- a/storage/ndb/include/mgmapi/mgmapi_debug.h +++ b/storage/ndb/include/mgmapi/mgmapi_debug.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmapi/mgmapi_error.h b/storage/ndb/include/mgmapi/mgmapi_error.h index 2d0aa1ded0f..97d180b0f3a 100644 --- a/storage/ndb/include/mgmapi/mgmapi_error.h +++ b/storage/ndb/include/mgmapi/mgmapi_error.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmapi/ndbd_exit_codes.h b/storage/ndb/include/mgmapi/ndbd_exit_codes.h index 30578bdf722..bad923763a9 100644 --- a/storage/ndb/include/mgmapi/ndbd_exit_codes.h +++ b/storage/ndb/include/mgmapi/ndbd_exit_codes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmcommon/ConfigRetriever.hpp b/storage/ndb/include/mgmcommon/ConfigRetriever.hpp index 27a189c1563..e5ff63f4bd0 100644 --- a/storage/ndb/include/mgmcommon/ConfigRetriever.hpp +++ b/storage/ndb/include/mgmcommon/ConfigRetriever.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmcommon/IPCConfig.hpp b/storage/ndb/include/mgmcommon/IPCConfig.hpp index 8e8b99eda73..495ae4d725d 100644 --- a/storage/ndb/include/mgmcommon/IPCConfig.hpp +++ b/storage/ndb/include/mgmcommon/IPCConfig.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/mgmcommon/MgmtErrorReporter.hpp b/storage/ndb/include/mgmcommon/MgmtErrorReporter.hpp index 2b5f2c9a6fd..159e77d3d9e 100644 --- a/storage/ndb/include/mgmcommon/MgmtErrorReporter.hpp +++ b/storage/ndb/include/mgmcommon/MgmtErrorReporter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndb_constants.h b/storage/ndb/include/ndb_constants.h index e2f8e17e913..90288bcc5ad 100644 --- a/storage/ndb/include/ndb_constants.h +++ b/storage/ndb/include/ndb_constants.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndb_global.h.in b/storage/ndb/include/ndb_global.h.in index 2fc594b3f5a..dc9bdeedff9 100644 --- a/storage/ndb/include/ndb_global.h.in +++ b/storage/ndb/include/ndb_global.h.in @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndb_init.h b/storage/ndb/include/ndb_init.h index 02db89adac4..3113123f019 100644 --- a/storage/ndb/include/ndb_init.h +++ b/storage/ndb/include/ndb_init.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndb_net.h b/storage/ndb/include/ndb_net.h index 3bb63f7e432..67423febde3 100644 --- a/storage/ndb/include/ndb_net.h +++ b/storage/ndb/include/ndb_net.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndb_types.h.in b/storage/ndb/include/ndb_types.h.in index 02db659e961..cf116825b65 100644 --- a/storage/ndb/include/ndb_types.h.in +++ b/storage/ndb/include/ndb_types.h.in @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndb_version.h.in b/storage/ndb/include/ndb_version.h.in index 97072315521..3282257a863 100644 --- a/storage/ndb/include/ndb_version.h.in +++ b/storage/ndb/include/ndb_version.h.in @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/Ndb.hpp b/storage/ndb/include/ndbapi/Ndb.hpp index f31638db283..1bbc002c79c 100644 --- a/storage/ndb/include/ndbapi/Ndb.hpp +++ b/storage/ndb/include/ndbapi/Ndb.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbApi.hpp b/storage/ndb/include/ndbapi/NdbApi.hpp index ef2f5871fbf..bc5a5f760b7 100644 --- a/storage/ndb/include/ndbapi/NdbApi.hpp +++ b/storage/ndb/include/ndbapi/NdbApi.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbBlob.hpp b/storage/ndb/include/ndbapi/NdbBlob.hpp index 9d4daf7498b..f20c08eb697 100644 --- a/storage/ndb/include/ndbapi/NdbBlob.hpp +++ b/storage/ndb/include/ndbapi/NdbBlob.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbDictionary.hpp b/storage/ndb/include/ndbapi/NdbDictionary.hpp index 0e782ba9214..2e64658b6a4 100644 --- a/storage/ndb/include/ndbapi/NdbDictionary.hpp +++ b/storage/ndb/include/ndbapi/NdbDictionary.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbError.hpp b/storage/ndb/include/ndbapi/NdbError.hpp index aa27caf78f9..273cb3aef77 100644 --- a/storage/ndb/include/ndbapi/NdbError.hpp +++ b/storage/ndb/include/ndbapi/NdbError.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbIndexOperation.hpp b/storage/ndb/include/ndbapi/NdbIndexOperation.hpp index 49e55f54f1a..49de7704ffa 100644 --- a/storage/ndb/include/ndbapi/NdbIndexOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbIndexOperation.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp b/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp index 38f353010a9..cd58b7c10c5 100644 --- a/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbIndexStat.hpp b/storage/ndb/include/ndbapi/NdbIndexStat.hpp index 9818ace9bde..c300d401f3a 100644 --- a/storage/ndb/include/ndbapi/NdbIndexStat.hpp +++ b/storage/ndb/include/ndbapi/NdbIndexStat.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbPool.hpp b/storage/ndb/include/ndbapi/NdbPool.hpp index 44b6d7488f0..d7c49f7e868 100644 --- a/storage/ndb/include/ndbapi/NdbPool.hpp +++ b/storage/ndb/include/ndbapi/NdbPool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbRecAttr.hpp b/storage/ndb/include/ndbapi/NdbRecAttr.hpp index 121339e470b..d47e0ead87d 100644 --- a/storage/ndb/include/ndbapi/NdbRecAttr.hpp +++ b/storage/ndb/include/ndbapi/NdbRecAttr.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbReceiver.hpp b/storage/ndb/include/ndbapi/NdbReceiver.hpp index b8abd281496..20ec5d0690e 100644 --- a/storage/ndb/include/ndbapi/NdbReceiver.hpp +++ b/storage/ndb/include/ndbapi/NdbReceiver.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbScanFilter.hpp b/storage/ndb/include/ndbapi/NdbScanFilter.hpp index 4527012a6c4..9274160ded5 100644 --- a/storage/ndb/include/ndbapi/NdbScanFilter.hpp +++ b/storage/ndb/include/ndbapi/NdbScanFilter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbScanOperation.hpp b/storage/ndb/include/ndbapi/NdbScanOperation.hpp index bc24b782add..d1e0670fc1f 100644 --- a/storage/ndb/include/ndbapi/NdbScanOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbScanOperation.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/NdbTransaction.hpp b/storage/ndb/include/ndbapi/NdbTransaction.hpp index 6a057655398..d878bc75f65 100644 --- a/storage/ndb/include/ndbapi/NdbTransaction.hpp +++ b/storage/ndb/include/ndbapi/NdbTransaction.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp b/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp index 80bfe7461f8..72d8c7899c3 100644 --- a/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp +++ b/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/ndb_opt_defaults.h b/storage/ndb/include/ndbapi/ndb_opt_defaults.h index f29e2cb40d5..5ce8611bbe2 100644 --- a/storage/ndb/include/ndbapi/ndb_opt_defaults.h +++ b/storage/ndb/include/ndbapi/ndb_opt_defaults.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/ndbapi_limits.h b/storage/ndb/include/ndbapi/ndbapi_limits.h index 98551866edc..02d204673d6 100644 --- a/storage/ndb/include/ndbapi/ndbapi_limits.h +++ b/storage/ndb/include/ndbapi/ndbapi_limits.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/ndbapi/ndberror.h b/storage/ndb/include/ndbapi/ndberror.h index 8d7701f035a..0b963a02267 100644 --- a/storage/ndb/include/ndbapi/ndberror.h +++ b/storage/ndb/include/ndbapi/ndberror.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/newtonapi/dba.h b/storage/ndb/include/newtonapi/dba.h index b0231378a2b..ddae237f5c8 100644 --- a/storage/ndb/include/newtonapi/dba.h +++ b/storage/ndb/include/newtonapi/dba.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/newtonapi/defs/pcn_types.h b/storage/ndb/include/newtonapi/defs/pcn_types.h index 9e8b2285023..9f026e9c40e 100644 --- a/storage/ndb/include/newtonapi/defs/pcn_types.h +++ b/storage/ndb/include/newtonapi/defs/pcn_types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbCondition.h b/storage/ndb/include/portlib/NdbCondition.h index dbc35b0b4ab..e3128628e2e 100644 --- a/storage/ndb/include/portlib/NdbCondition.h +++ b/storage/ndb/include/portlib/NdbCondition.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbConfig.h b/storage/ndb/include/portlib/NdbConfig.h index 2b6c931da72..2a7fc582393 100644 --- a/storage/ndb/include/portlib/NdbConfig.h +++ b/storage/ndb/include/portlib/NdbConfig.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbDaemon.h b/storage/ndb/include/portlib/NdbDaemon.h index b6e39321e38..11fbdfa9cf6 100644 --- a/storage/ndb/include/portlib/NdbDaemon.h +++ b/storage/ndb/include/portlib/NdbDaemon.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbEnv.h b/storage/ndb/include/portlib/NdbEnv.h index c6590264e23..69630cae1a0 100644 --- a/storage/ndb/include/portlib/NdbEnv.h +++ b/storage/ndb/include/portlib/NdbEnv.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbHost.h b/storage/ndb/include/portlib/NdbHost.h index 5464a024a62..bff7a95c1a5 100644 --- a/storage/ndb/include/portlib/NdbHost.h +++ b/storage/ndb/include/portlib/NdbHost.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbMain.h b/storage/ndb/include/portlib/NdbMain.h index d49411ec8c9..e318ecaece4 100644 --- a/storage/ndb/include/portlib/NdbMain.h +++ b/storage/ndb/include/portlib/NdbMain.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbMem.h b/storage/ndb/include/portlib/NdbMem.h index d271c976862..e5f66964bde 100644 --- a/storage/ndb/include/portlib/NdbMem.h +++ b/storage/ndb/include/portlib/NdbMem.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbMutex.h b/storage/ndb/include/portlib/NdbMutex.h index 0f04511ca37..8cfcdd4063e 100644 --- a/storage/ndb/include/portlib/NdbMutex.h +++ b/storage/ndb/include/portlib/NdbMutex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbSleep.h b/storage/ndb/include/portlib/NdbSleep.h index a17f3e6a8b0..803522dd5a8 100644 --- a/storage/ndb/include/portlib/NdbSleep.h +++ b/storage/ndb/include/portlib/NdbSleep.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbTCP.h b/storage/ndb/include/portlib/NdbTCP.h index b2f0b12efb4..76a9fd80366 100644 --- a/storage/ndb/include/portlib/NdbTCP.h +++ b/storage/ndb/include/portlib/NdbTCP.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbThread.h b/storage/ndb/include/portlib/NdbThread.h index 373e2218c6c..759f07fa8a0 100644 --- a/storage/ndb/include/portlib/NdbThread.h +++ b/storage/ndb/include/portlib/NdbThread.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/NdbTick.h b/storage/ndb/include/portlib/NdbTick.h index 70c36fdfd1e..07774b7783c 100644 --- a/storage/ndb/include/portlib/NdbTick.h +++ b/storage/ndb/include/portlib/NdbTick.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/PortDefs.h b/storage/ndb/include/portlib/PortDefs.h index 87b87b497a2..72c8695a6d5 100644 --- a/storage/ndb/include/portlib/PortDefs.h +++ b/storage/ndb/include/portlib/PortDefs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/portlib/prefetch.h b/storage/ndb/include/portlib/prefetch.h index f098c2ba6c0..217f4befcd4 100644 --- a/storage/ndb/include/portlib/prefetch.h +++ b/storage/ndb/include/portlib/prefetch.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/transporter/TransporterCallback.hpp b/storage/ndb/include/transporter/TransporterCallback.hpp index 076d0de44c0..2c09674410c 100644 --- a/storage/ndb/include/transporter/TransporterCallback.hpp +++ b/storage/ndb/include/transporter/TransporterCallback.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/transporter/TransporterDefinitions.hpp b/storage/ndb/include/transporter/TransporterDefinitions.hpp index 003824d01e8..87011d3a3e9 100644 --- a/storage/ndb/include/transporter/TransporterDefinitions.hpp +++ b/storage/ndb/include/transporter/TransporterDefinitions.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/transporter/TransporterRegistry.hpp b/storage/ndb/include/transporter/TransporterRegistry.hpp index 4a639d05b95..1020e935c2d 100644 --- a/storage/ndb/include/transporter/TransporterRegistry.hpp +++ b/storage/ndb/include/transporter/TransporterRegistry.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/BaseString.hpp b/storage/ndb/include/util/BaseString.hpp index 0c41f254edc..14cfdb2fa88 100644 --- a/storage/ndb/include/util/BaseString.hpp +++ b/storage/ndb/include/util/BaseString.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/Bitmask.hpp b/storage/ndb/include/util/Bitmask.hpp index d1663b7c76d..09ff69cc43e 100644 --- a/storage/ndb/include/util/Bitmask.hpp +++ b/storage/ndb/include/util/Bitmask.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/File.hpp b/storage/ndb/include/util/File.hpp index b9d348683ec..2de15794ec7 100644 --- a/storage/ndb/include/util/File.hpp +++ b/storage/ndb/include/util/File.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/InputStream.hpp b/storage/ndb/include/util/InputStream.hpp index 3e696eac732..0e09ab3869b 100644 --- a/storage/ndb/include/util/InputStream.hpp +++ b/storage/ndb/include/util/InputStream.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/NdbAutoPtr.hpp b/storage/ndb/include/util/NdbAutoPtr.hpp index 5210fbc6dde..e4d04478224 100644 --- a/storage/ndb/include/util/NdbAutoPtr.hpp +++ b/storage/ndb/include/util/NdbAutoPtr.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/NdbOut.hpp b/storage/ndb/include/util/NdbOut.hpp index 6afb3af87e3..dd6082d146a 100644 --- a/storage/ndb/include/util/NdbOut.hpp +++ b/storage/ndb/include/util/NdbOut.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/NdbSqlUtil.hpp b/storage/ndb/include/util/NdbSqlUtil.hpp index 8d063f1908b..571f381ff03 100644 --- a/storage/ndb/include/util/NdbSqlUtil.hpp +++ b/storage/ndb/include/util/NdbSqlUtil.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/OutputStream.hpp b/storage/ndb/include/util/OutputStream.hpp index 05fc69a46c3..07d09ee5d29 100644 --- a/storage/ndb/include/util/OutputStream.hpp +++ b/storage/ndb/include/util/OutputStream.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/Parser.hpp b/storage/ndb/include/util/Parser.hpp index 5be18bbcc90..43121d5bca9 100644 --- a/storage/ndb/include/util/Parser.hpp +++ b/storage/ndb/include/util/Parser.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/Properties.hpp b/storage/ndb/include/util/Properties.hpp index 3533d710662..d14795c94f9 100644 --- a/storage/ndb/include/util/Properties.hpp +++ b/storage/ndb/include/util/Properties.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/SimpleProperties.hpp b/storage/ndb/include/util/SimpleProperties.hpp index 18acf689415..4b8be6ae449 100644 --- a/storage/ndb/include/util/SimpleProperties.hpp +++ b/storage/ndb/include/util/SimpleProperties.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/SocketAuthenticator.hpp b/storage/ndb/include/util/SocketAuthenticator.hpp index e76af30dc35..24f0f11eb05 100644 --- a/storage/ndb/include/util/SocketAuthenticator.hpp +++ b/storage/ndb/include/util/SocketAuthenticator.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/SocketClient.hpp b/storage/ndb/include/util/SocketClient.hpp index bb8d9b9ac41..429cf310e69 100644 --- a/storage/ndb/include/util/SocketClient.hpp +++ b/storage/ndb/include/util/SocketClient.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/SocketServer.hpp b/storage/ndb/include/util/SocketServer.hpp index 8b49dc6db4e..73892d962aa 100644 --- a/storage/ndb/include/util/SocketServer.hpp +++ b/storage/ndb/include/util/SocketServer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/UtilBuffer.hpp b/storage/ndb/include/util/UtilBuffer.hpp index acc8f7133f0..a0f4e0dfd38 100644 --- a/storage/ndb/include/util/UtilBuffer.hpp +++ b/storage/ndb/include/util/UtilBuffer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/Vector.hpp b/storage/ndb/include/util/Vector.hpp index 7ae4228985d..1950b37f30e 100644 --- a/storage/ndb/include/util/Vector.hpp +++ b/storage/ndb/include/util/Vector.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/basestring_vsnprintf.h b/storage/ndb/include/util/basestring_vsnprintf.h index ade90b3f678..ed700e47520 100644 --- a/storage/ndb/include/util/basestring_vsnprintf.h +++ b/storage/ndb/include/util/basestring_vsnprintf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/md5_hash.hpp b/storage/ndb/include/util/md5_hash.hpp index 932d71ee22e..c6ff2230f89 100644 --- a/storage/ndb/include/util/md5_hash.hpp +++ b/storage/ndb/include/util/md5_hash.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/ndb_opts.h b/storage/ndb/include/util/ndb_opts.h index f18bb9646cc..470579c115a 100644 --- a/storage/ndb/include/util/ndb_opts.h +++ b/storage/ndb/include/util/ndb_opts.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/ndb_rand.h b/storage/ndb/include/util/ndb_rand.h index 1521ca9c4ff..815ac904ec8 100644 --- a/storage/ndb/include/util/ndb_rand.h +++ b/storage/ndb/include/util/ndb_rand.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/random.h b/storage/ndb/include/util/random.h index b448e9c2b01..5e74c4d0710 100644 --- a/storage/ndb/include/util/random.h +++ b/storage/ndb/include/util/random.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/socket_io.h b/storage/ndb/include/util/socket_io.h index f76b6790b19..23eb0aaae35 100644 --- a/storage/ndb/include/util/socket_io.h +++ b/storage/ndb/include/util/socket_io.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/uucode.h b/storage/ndb/include/util/uucode.h index 3c10888a395..3210bbf0dcb 100644 --- a/storage/ndb/include/util/uucode.h +++ b/storage/ndb/include/util/uucode.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/include/util/version.h b/storage/ndb/include/util/version.h index 9ea18ecd9d9..6056b0f37e3 100644 --- a/storage/ndb/include/util/version.h +++ b/storage/ndb/include/util/version.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp b/storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp index fbe5397c5cf..b58891e97d8 100644 --- a/storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp +++ b/storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp b/storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp index 5a2241fc05f..37bf23749a9 100644 --- a/storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp +++ b/storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp b/storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp index 864b2baa2ed..9f6d43cddb9 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp +++ b/storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp @@ -1,6 +1,6 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp b/storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp index 1f19f36d674..60c531547d4 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp +++ b/storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp b/storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp index b1aef8d3588..93add04956a 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp +++ b/storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp b/storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp index f8df5bf0f48..382dd2dd1d0 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp +++ b/storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp b/storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp index be62d19dbc4..b189c2105b1 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp +++ b/storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp @@ -1,5 +1,5 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp b/storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp index 4e82fc3e42b..d4b7510f0f9 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp +++ b/storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp b/storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp index 5943894a3ee..a936779bec7 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp +++ b/storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp b/storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp index 440face79ae..991de0308aa 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp +++ b/storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/Makefile.am b/storage/ndb/src/Makefile.am index 627347daf02..572571e776b 100644 --- a/storage/ndb/src/Makefile.am +++ b/storage/ndb/src/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/Makefile.am b/storage/ndb/src/common/Makefile.am index 9d601c7a18a..738732f9a28 100644 --- a/storage/ndb/src/common/Makefile.am +++ b/storage/ndb/src/common/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/BlockNames.cpp b/storage/ndb/src/common/debugger/BlockNames.cpp index 86acbc47198..360edddab16 100644 --- a/storage/ndb/src/common/debugger/BlockNames.cpp +++ b/storage/ndb/src/common/debugger/BlockNames.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/DebuggerNames.cpp b/storage/ndb/src/common/debugger/DebuggerNames.cpp index ba32ac6e6b8..f10cca02499 100644 --- a/storage/ndb/src/common/debugger/DebuggerNames.cpp +++ b/storage/ndb/src/common/debugger/DebuggerNames.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/EventLogger.cpp b/storage/ndb/src/common/debugger/EventLogger.cpp index 068b0c6ac18..fec9d2a2d73 100644 --- a/storage/ndb/src/common/debugger/EventLogger.cpp +++ b/storage/ndb/src/common/debugger/EventLogger.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/GrepError.cpp b/storage/ndb/src/common/debugger/GrepError.cpp index 091c7da0978..aee8e444a92 100644 --- a/storage/ndb/src/common/debugger/GrepError.cpp +++ b/storage/ndb/src/common/debugger/GrepError.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/Makefile.am b/storage/ndb/src/common/debugger/Makefile.am index 56910ee8ea4..0a09afa247e 100644 --- a/storage/ndb/src/common/debugger/Makefile.am +++ b/storage/ndb/src/common/debugger/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/SignalLoggerManager.cpp b/storage/ndb/src/common/debugger/SignalLoggerManager.cpp index 48cacb6bc1a..271c39cf864 100644 --- a/storage/ndb/src/common/debugger/SignalLoggerManager.cpp +++ b/storage/ndb/src/common/debugger/SignalLoggerManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/AccLock.cpp b/storage/ndb/src/common/debugger/signaldata/AccLock.cpp index 0b37e1bd0d7..c5511094bb1 100644 --- a/storage/ndb/src/common/debugger/signaldata/AccLock.cpp +++ b/storage/ndb/src/common/debugger/signaldata/AccLock.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/AlterIndx.cpp b/storage/ndb/src/common/debugger/signaldata/AlterIndx.cpp index 1ac5b7fb3e8..8e7cedc4fc9 100644 --- a/storage/ndb/src/common/debugger/signaldata/AlterIndx.cpp +++ b/storage/ndb/src/common/debugger/signaldata/AlterIndx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/AlterTab.cpp b/storage/ndb/src/common/debugger/signaldata/AlterTab.cpp index f9b6df1f4c0..03d6b3cf973 100644 --- a/storage/ndb/src/common/debugger/signaldata/AlterTab.cpp +++ b/storage/ndb/src/common/debugger/signaldata/AlterTab.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/AlterTable.cpp b/storage/ndb/src/common/debugger/signaldata/AlterTable.cpp index 8e23bd72db3..a390dc5d7b9 100644 --- a/storage/ndb/src/common/debugger/signaldata/AlterTable.cpp +++ b/storage/ndb/src/common/debugger/signaldata/AlterTable.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/AlterTrig.cpp b/storage/ndb/src/common/debugger/signaldata/AlterTrig.cpp index cdd7ee2fbf2..50463f0a991 100644 --- a/storage/ndb/src/common/debugger/signaldata/AlterTrig.cpp +++ b/storage/ndb/src/common/debugger/signaldata/AlterTrig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/BackupImpl.cpp b/storage/ndb/src/common/debugger/signaldata/BackupImpl.cpp index 4bbac738826..05730c3d576 100644 --- a/storage/ndb/src/common/debugger/signaldata/BackupImpl.cpp +++ b/storage/ndb/src/common/debugger/signaldata/BackupImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/BackupSignalData.cpp b/storage/ndb/src/common/debugger/signaldata/BackupSignalData.cpp index d196233071d..14cc4fbe9f0 100644 --- a/storage/ndb/src/common/debugger/signaldata/BackupSignalData.cpp +++ b/storage/ndb/src/common/debugger/signaldata/BackupSignalData.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/CloseComReqConf.cpp b/storage/ndb/src/common/debugger/signaldata/CloseComReqConf.cpp index 76284517ac7..f5a2c16789d 100644 --- a/storage/ndb/src/common/debugger/signaldata/CloseComReqConf.cpp +++ b/storage/ndb/src/common/debugger/signaldata/CloseComReqConf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/CntrStart.cpp b/storage/ndb/src/common/debugger/signaldata/CntrStart.cpp index 813bcef96d6..e25de741691 100644 --- a/storage/ndb/src/common/debugger/signaldata/CntrStart.cpp +++ b/storage/ndb/src/common/debugger/signaldata/CntrStart.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/ContinueB.cpp b/storage/ndb/src/common/debugger/signaldata/ContinueB.cpp index cd94abd6f2c..e192071a9b9 100644 --- a/storage/ndb/src/common/debugger/signaldata/ContinueB.cpp +++ b/storage/ndb/src/common/debugger/signaldata/ContinueB.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/CopyGCI.cpp b/storage/ndb/src/common/debugger/signaldata/CopyGCI.cpp index 6ea5f422fda..61b0de57be5 100644 --- a/storage/ndb/src/common/debugger/signaldata/CopyGCI.cpp +++ b/storage/ndb/src/common/debugger/signaldata/CopyGCI.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/CreateEvnt.cpp b/storage/ndb/src/common/debugger/signaldata/CreateEvnt.cpp index d957b5039ca..395791145e3 100644 --- a/storage/ndb/src/common/debugger/signaldata/CreateEvnt.cpp +++ b/storage/ndb/src/common/debugger/signaldata/CreateEvnt.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/CreateFragmentation.cpp b/storage/ndb/src/common/debugger/signaldata/CreateFragmentation.cpp index ef4c277dc69..037ed5fb159 100644 --- a/storage/ndb/src/common/debugger/signaldata/CreateFragmentation.cpp +++ b/storage/ndb/src/common/debugger/signaldata/CreateFragmentation.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/CreateIndx.cpp b/storage/ndb/src/common/debugger/signaldata/CreateIndx.cpp index a72d51aa4e2..6c22cd03640 100644 --- a/storage/ndb/src/common/debugger/signaldata/CreateIndx.cpp +++ b/storage/ndb/src/common/debugger/signaldata/CreateIndx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/CreateTrig.cpp b/storage/ndb/src/common/debugger/signaldata/CreateTrig.cpp index 14a980ed5f7..c26bfe45f73 100644 --- a/storage/ndb/src/common/debugger/signaldata/CreateTrig.cpp +++ b/storage/ndb/src/common/debugger/signaldata/CreateTrig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp b/storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp index dae5527dc5e..a2087ec3813 100644 --- a/storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp +++ b/storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/DihContinueB.cpp b/storage/ndb/src/common/debugger/signaldata/DihContinueB.cpp index 30b15fe7de1..9985b53d871 100644 --- a/storage/ndb/src/common/debugger/signaldata/DihContinueB.cpp +++ b/storage/ndb/src/common/debugger/signaldata/DihContinueB.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/DihSwitchReplicaReq.cpp b/storage/ndb/src/common/debugger/signaldata/DihSwitchReplicaReq.cpp index ce8c05b61e0..e0dade885a3 100644 --- a/storage/ndb/src/common/debugger/signaldata/DihSwitchReplicaReq.cpp +++ b/storage/ndb/src/common/debugger/signaldata/DihSwitchReplicaReq.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/DisconnectRep.cpp b/storage/ndb/src/common/debugger/signaldata/DisconnectRep.cpp index 10efb20f393..34e6fe14d50 100644 --- a/storage/ndb/src/common/debugger/signaldata/DisconnectRep.cpp +++ b/storage/ndb/src/common/debugger/signaldata/DisconnectRep.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/DropIndx.cpp b/storage/ndb/src/common/debugger/signaldata/DropIndx.cpp index 39d0333399e..7ff132ba35c 100644 --- a/storage/ndb/src/common/debugger/signaldata/DropIndx.cpp +++ b/storage/ndb/src/common/debugger/signaldata/DropIndx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/DropTab.cpp b/storage/ndb/src/common/debugger/signaldata/DropTab.cpp index 2715239119d..cce4aaaf80a 100644 --- a/storage/ndb/src/common/debugger/signaldata/DropTab.cpp +++ b/storage/ndb/src/common/debugger/signaldata/DropTab.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/DropTrig.cpp b/storage/ndb/src/common/debugger/signaldata/DropTrig.cpp index 6e4caae01ab..cd5f23149fc 100644 --- a/storage/ndb/src/common/debugger/signaldata/DropTrig.cpp +++ b/storage/ndb/src/common/debugger/signaldata/DropTrig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/FailRep.cpp b/storage/ndb/src/common/debugger/signaldata/FailRep.cpp index fa2a431e7c5..b735cfea7e9 100644 --- a/storage/ndb/src/common/debugger/signaldata/FailRep.cpp +++ b/storage/ndb/src/common/debugger/signaldata/FailRep.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/FireTrigOrd.cpp b/storage/ndb/src/common/debugger/signaldata/FireTrigOrd.cpp index b1bf52542b7..a4382b76026 100644 --- a/storage/ndb/src/common/debugger/signaldata/FireTrigOrd.cpp +++ b/storage/ndb/src/common/debugger/signaldata/FireTrigOrd.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/FsAppendReq.cpp b/storage/ndb/src/common/debugger/signaldata/FsAppendReq.cpp index a574a83b7ab..ee97b222048 100644 --- a/storage/ndb/src/common/debugger/signaldata/FsAppendReq.cpp +++ b/storage/ndb/src/common/debugger/signaldata/FsAppendReq.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/FsCloseReq.cpp b/storage/ndb/src/common/debugger/signaldata/FsCloseReq.cpp index 72c2a474e75..65d12f0aa74 100644 --- a/storage/ndb/src/common/debugger/signaldata/FsCloseReq.cpp +++ b/storage/ndb/src/common/debugger/signaldata/FsCloseReq.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/FsConf.cpp b/storage/ndb/src/common/debugger/signaldata/FsConf.cpp index ed9124fcfeb..6cdf512b186 100644 --- a/storage/ndb/src/common/debugger/signaldata/FsConf.cpp +++ b/storage/ndb/src/common/debugger/signaldata/FsConf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/FsOpenReq.cpp b/storage/ndb/src/common/debugger/signaldata/FsOpenReq.cpp index 0029be79fdd..c80e7b4a535 100644 --- a/storage/ndb/src/common/debugger/signaldata/FsOpenReq.cpp +++ b/storage/ndb/src/common/debugger/signaldata/FsOpenReq.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp b/storage/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp index e1331d2353f..66a2abe2484 100644 --- a/storage/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp +++ b/storage/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/FsRef.cpp b/storage/ndb/src/common/debugger/signaldata/FsRef.cpp index 3d9eccc9407..8b54d260bf1 100644 --- a/storage/ndb/src/common/debugger/signaldata/FsRef.cpp +++ b/storage/ndb/src/common/debugger/signaldata/FsRef.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/GCPSave.cpp b/storage/ndb/src/common/debugger/signaldata/GCPSave.cpp index b1dbb5887dd..b4086e692ba 100644 --- a/storage/ndb/src/common/debugger/signaldata/GCPSave.cpp +++ b/storage/ndb/src/common/debugger/signaldata/GCPSave.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/IndxAttrInfo.cpp b/storage/ndb/src/common/debugger/signaldata/IndxAttrInfo.cpp index a4bc3f04c04..734dd764723 100755 --- a/storage/ndb/src/common/debugger/signaldata/IndxAttrInfo.cpp +++ b/storage/ndb/src/common/debugger/signaldata/IndxAttrInfo.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/IndxKeyInfo.cpp b/storage/ndb/src/common/debugger/signaldata/IndxKeyInfo.cpp index 78e3a98f6ce..b03de35bac7 100755 --- a/storage/ndb/src/common/debugger/signaldata/IndxKeyInfo.cpp +++ b/storage/ndb/src/common/debugger/signaldata/IndxKeyInfo.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/LCP.cpp b/storage/ndb/src/common/debugger/signaldata/LCP.cpp index 946c43c8d7e..ad292da1254 100644 --- a/storage/ndb/src/common/debugger/signaldata/LCP.cpp +++ b/storage/ndb/src/common/debugger/signaldata/LCP.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/LqhFrag.cpp b/storage/ndb/src/common/debugger/signaldata/LqhFrag.cpp index 0d7a2cf1e4d..d1dcd3eba86 100644 --- a/storage/ndb/src/common/debugger/signaldata/LqhFrag.cpp +++ b/storage/ndb/src/common/debugger/signaldata/LqhFrag.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/LqhKey.cpp b/storage/ndb/src/common/debugger/signaldata/LqhKey.cpp index ca17c81ec17..d3f09b3a938 100644 --- a/storage/ndb/src/common/debugger/signaldata/LqhKey.cpp +++ b/storage/ndb/src/common/debugger/signaldata/LqhKey.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/LqhTrans.cpp b/storage/ndb/src/common/debugger/signaldata/LqhTrans.cpp index f413ccc6311..457b0cf8037 100644 --- a/storage/ndb/src/common/debugger/signaldata/LqhTrans.cpp +++ b/storage/ndb/src/common/debugger/signaldata/LqhTrans.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/Makefile.am b/storage/ndb/src/common/debugger/signaldata/Makefile.am index 280cd6a5a39..839ce81ac77 100644 --- a/storage/ndb/src/common/debugger/signaldata/Makefile.am +++ b/storage/ndb/src/common/debugger/signaldata/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/MasterLCP.cpp b/storage/ndb/src/common/debugger/signaldata/MasterLCP.cpp index 620695a91a4..92539e3c025 100644 --- a/storage/ndb/src/common/debugger/signaldata/MasterLCP.cpp +++ b/storage/ndb/src/common/debugger/signaldata/MasterLCP.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp b/storage/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp index 800dc074aa7..88520894382 100644 --- a/storage/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp +++ b/storage/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/NdbSttor.cpp b/storage/ndb/src/common/debugger/signaldata/NdbSttor.cpp index 3a67e2e7806..8ec521b684a 100644 --- a/storage/ndb/src/common/debugger/signaldata/NdbSttor.cpp +++ b/storage/ndb/src/common/debugger/signaldata/NdbSttor.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/NdbfsContinueB.cpp b/storage/ndb/src/common/debugger/signaldata/NdbfsContinueB.cpp index cd592533638..e96c7d54815 100644 --- a/storage/ndb/src/common/debugger/signaldata/NdbfsContinueB.cpp +++ b/storage/ndb/src/common/debugger/signaldata/NdbfsContinueB.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp b/storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp index a5f585c23f0..92c7047a4d3 100644 --- a/storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp +++ b/storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/PrepDropTab.cpp b/storage/ndb/src/common/debugger/signaldata/PrepDropTab.cpp index 112b92f3fcc..bcb89a6511e 100644 --- a/storage/ndb/src/common/debugger/signaldata/PrepDropTab.cpp +++ b/storage/ndb/src/common/debugger/signaldata/PrepDropTab.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/PrepFailReqRef.cpp b/storage/ndb/src/common/debugger/signaldata/PrepFailReqRef.cpp index cea7c65485d..b693af31234 100644 --- a/storage/ndb/src/common/debugger/signaldata/PrepFailReqRef.cpp +++ b/storage/ndb/src/common/debugger/signaldata/PrepFailReqRef.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/ReadNodesConf.cpp b/storage/ndb/src/common/debugger/signaldata/ReadNodesConf.cpp index d8f8344ea95..5c1fdb4ffd3 100644 --- a/storage/ndb/src/common/debugger/signaldata/ReadNodesConf.cpp +++ b/storage/ndb/src/common/debugger/signaldata/ReadNodesConf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/ScanFrag.cpp b/storage/ndb/src/common/debugger/signaldata/ScanFrag.cpp index de05426d40b..9bdfe1ad40a 100644 --- a/storage/ndb/src/common/debugger/signaldata/ScanFrag.cpp +++ b/storage/ndb/src/common/debugger/signaldata/ScanFrag.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/ScanTab.cpp b/storage/ndb/src/common/debugger/signaldata/ScanTab.cpp index 4f6b69ebfba..eec46313b2f 100644 --- a/storage/ndb/src/common/debugger/signaldata/ScanTab.cpp +++ b/storage/ndb/src/common/debugger/signaldata/ScanTab.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp b/storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp index 00ccf2b9bab..e5804316bef 100644 --- a/storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp +++ b/storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/SignalDroppedRep.cpp b/storage/ndb/src/common/debugger/signaldata/SignalDroppedRep.cpp index e812efc85a6..2f060f671f6 100644 --- a/storage/ndb/src/common/debugger/signaldata/SignalDroppedRep.cpp +++ b/storage/ndb/src/common/debugger/signaldata/SignalDroppedRep.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/SignalNames.cpp b/storage/ndb/src/common/debugger/signaldata/SignalNames.cpp index b4221cbec8e..bfa8f49f169 100644 --- a/storage/ndb/src/common/debugger/signaldata/SignalNames.cpp +++ b/storage/ndb/src/common/debugger/signaldata/SignalNames.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/StartRec.cpp b/storage/ndb/src/common/debugger/signaldata/StartRec.cpp index 69054528d95..dcbfa6ca084 100644 --- a/storage/ndb/src/common/debugger/signaldata/StartRec.cpp +++ b/storage/ndb/src/common/debugger/signaldata/StartRec.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/SumaImpl.cpp b/storage/ndb/src/common/debugger/signaldata/SumaImpl.cpp index 19a40589a96..6bd1b73cb14 100644 --- a/storage/ndb/src/common/debugger/signaldata/SumaImpl.cpp +++ b/storage/ndb/src/common/debugger/signaldata/SumaImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/SystemError.cpp b/storage/ndb/src/common/debugger/signaldata/SystemError.cpp index c1acde0b6ad..5cbde43e072 100644 --- a/storage/ndb/src/common/debugger/signaldata/SystemError.cpp +++ b/storage/ndb/src/common/debugger/signaldata/SystemError.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TcIndx.cpp b/storage/ndb/src/common/debugger/signaldata/TcIndx.cpp index 8efbf106534..3fe205cdc03 100644 --- a/storage/ndb/src/common/debugger/signaldata/TcIndx.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TcIndx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TcKeyConf.cpp b/storage/ndb/src/common/debugger/signaldata/TcKeyConf.cpp index 377863f9446..381528bf627 100644 --- a/storage/ndb/src/common/debugger/signaldata/TcKeyConf.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TcKeyConf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TcKeyRef.cpp b/storage/ndb/src/common/debugger/signaldata/TcKeyRef.cpp index eb512de52e6..1e981fca561 100644 --- a/storage/ndb/src/common/debugger/signaldata/TcKeyRef.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TcKeyRef.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TcKeyReq.cpp b/storage/ndb/src/common/debugger/signaldata/TcKeyReq.cpp index 2b7a66abd6b..169812e59e9 100644 --- a/storage/ndb/src/common/debugger/signaldata/TcKeyReq.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TcKeyReq.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TcRollbackRep.cpp b/storage/ndb/src/common/debugger/signaldata/TcRollbackRep.cpp index 92191619982..f1c45d5faae 100644 --- a/storage/ndb/src/common/debugger/signaldata/TcRollbackRep.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TcRollbackRep.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TrigAttrInfo.cpp b/storage/ndb/src/common/debugger/signaldata/TrigAttrInfo.cpp index 14329c66c2a..47ecd21db4d 100644 --- a/storage/ndb/src/common/debugger/signaldata/TrigAttrInfo.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TrigAttrInfo.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TupCommit.cpp b/storage/ndb/src/common/debugger/signaldata/TupCommit.cpp index a796d87bd91..d3238c3c9a5 100644 --- a/storage/ndb/src/common/debugger/signaldata/TupCommit.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TupCommit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TupKey.cpp b/storage/ndb/src/common/debugger/signaldata/TupKey.cpp index 03811bfd7c9..7055dff9fa1 100644 --- a/storage/ndb/src/common/debugger/signaldata/TupKey.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TupKey.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/TuxMaint.cpp b/storage/ndb/src/common/debugger/signaldata/TuxMaint.cpp index f7a41a84992..141befa279a 100644 --- a/storage/ndb/src/common/debugger/signaldata/TuxMaint.cpp +++ b/storage/ndb/src/common/debugger/signaldata/TuxMaint.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/UtilDelete.cpp b/storage/ndb/src/common/debugger/signaldata/UtilDelete.cpp index 38f5b8a7c06..3d1ac8cb92e 100644 --- a/storage/ndb/src/common/debugger/signaldata/UtilDelete.cpp +++ b/storage/ndb/src/common/debugger/signaldata/UtilDelete.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/UtilExecute.cpp b/storage/ndb/src/common/debugger/signaldata/UtilExecute.cpp index a0cfcbdb356..8dfbd77396d 100644 --- a/storage/ndb/src/common/debugger/signaldata/UtilExecute.cpp +++ b/storage/ndb/src/common/debugger/signaldata/UtilExecute.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/UtilLock.cpp b/storage/ndb/src/common/debugger/signaldata/UtilLock.cpp index 3004f9d0975..094224de134 100644 --- a/storage/ndb/src/common/debugger/signaldata/UtilLock.cpp +++ b/storage/ndb/src/common/debugger/signaldata/UtilLock.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/UtilPrepare.cpp b/storage/ndb/src/common/debugger/signaldata/UtilPrepare.cpp index 36591d18a54..927b4089245 100644 --- a/storage/ndb/src/common/debugger/signaldata/UtilPrepare.cpp +++ b/storage/ndb/src/common/debugger/signaldata/UtilPrepare.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp b/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp index 164987a9720..0b7f81ed812 100644 --- a/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp +++ b/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/debugger/signaldata/print.awk b/storage/ndb/src/common/debugger/signaldata/print.awk index 3c289e59f63..199cb16bd6e 100644 --- a/storage/ndb/src/common/debugger/signaldata/print.awk +++ b/storage/ndb/src/common/debugger/signaldata/print.awk @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/ConsoleLogHandler.cpp b/storage/ndb/src/common/logger/ConsoleLogHandler.cpp index d0cafcb3590..eea8b2855d9 100644 --- a/storage/ndb/src/common/logger/ConsoleLogHandler.cpp +++ b/storage/ndb/src/common/logger/ConsoleLogHandler.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/FileLogHandler.cpp b/storage/ndb/src/common/logger/FileLogHandler.cpp index a4f610777eb..a30a1a97b28 100644 --- a/storage/ndb/src/common/logger/FileLogHandler.cpp +++ b/storage/ndb/src/common/logger/FileLogHandler.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/LogHandler.cpp b/storage/ndb/src/common/logger/LogHandler.cpp index b746bcc3cd7..b8eaeddac98 100644 --- a/storage/ndb/src/common/logger/LogHandler.cpp +++ b/storage/ndb/src/common/logger/LogHandler.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/LogHandlerList.cpp b/storage/ndb/src/common/logger/LogHandlerList.cpp index 376e96c3c8c..f4e71ff4325 100644 --- a/storage/ndb/src/common/logger/LogHandlerList.cpp +++ b/storage/ndb/src/common/logger/LogHandlerList.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/LogHandlerList.hpp b/storage/ndb/src/common/logger/LogHandlerList.hpp index ad87c0294cf..f6f372df4cc 100644 --- a/storage/ndb/src/common/logger/LogHandlerList.hpp +++ b/storage/ndb/src/common/logger/LogHandlerList.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/Logger.cpp b/storage/ndb/src/common/logger/Logger.cpp index 3df3a778fc0..f35a1f6b087 100644 --- a/storage/ndb/src/common/logger/Logger.cpp +++ b/storage/ndb/src/common/logger/Logger.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/Makefile.am b/storage/ndb/src/common/logger/Makefile.am index 77615212e0d..4ce8f21a95a 100644 --- a/storage/ndb/src/common/logger/Makefile.am +++ b/storage/ndb/src/common/logger/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/SysLogHandler.cpp b/storage/ndb/src/common/logger/SysLogHandler.cpp index 3178ef6e1c7..f7265f9414b 100644 --- a/storage/ndb/src/common/logger/SysLogHandler.cpp +++ b/storage/ndb/src/common/logger/SysLogHandler.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.cpp b/storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.cpp index e478573a094..b1f10db0338 100644 --- a/storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.cpp +++ b/storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.hpp b/storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.hpp index ae7846af19e..5aa36cefe16 100644 --- a/storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.hpp +++ b/storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/loggertest/LoggerUnitTest.cpp b/storage/ndb/src/common/logger/loggertest/LoggerUnitTest.cpp index adc3c219622..ef8be1e60b7 100644 --- a/storage/ndb/src/common/logger/loggertest/LoggerUnitTest.cpp +++ b/storage/ndb/src/common/logger/loggertest/LoggerUnitTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/logger/loggertest/LoggerUnitTest.hpp b/storage/ndb/src/common/logger/loggertest/LoggerUnitTest.hpp index e7d25292aab..0a25723d038 100644 --- a/storage/ndb/src/common/logger/loggertest/LoggerUnitTest.hpp +++ b/storage/ndb/src/common/logger/loggertest/LoggerUnitTest.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp index 35b1a91e9da..6ce0e4de376 100644 --- a/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/mgmcommon/IPCConfig.cpp b/storage/ndb/src/common/mgmcommon/IPCConfig.cpp index 81d1d923ee9..8081ecf7ea4 100644 --- a/storage/ndb/src/common/mgmcommon/IPCConfig.cpp +++ b/storage/ndb/src/common/mgmcommon/IPCConfig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/mgmcommon/Makefile.am b/storage/ndb/src/common/mgmcommon/Makefile.am index ad56e8c1459..8b83628fe64 100644 --- a/storage/ndb/src/common/mgmcommon/Makefile.am +++ b/storage/ndb/src/common/mgmcommon/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/mgmcommon/printConfig/printConfig.cpp b/storage/ndb/src/common/mgmcommon/printConfig/printConfig.cpp index 348075a6cd2..76bcc0fe64c 100644 --- a/storage/ndb/src/common/mgmcommon/printConfig/printConfig.cpp +++ b/storage/ndb/src/common/mgmcommon/printConfig/printConfig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbCondition.c b/storage/ndb/src/common/portlib/NdbCondition.c index da1d67e660e..29e8a471f18 100644 --- a/storage/ndb/src/common/portlib/NdbCondition.c +++ b/storage/ndb/src/common/portlib/NdbCondition.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbConfig.c b/storage/ndb/src/common/portlib/NdbConfig.c index 193b3429a3d..7d7f24abf90 100644 --- a/storage/ndb/src/common/portlib/NdbConfig.c +++ b/storage/ndb/src/common/portlib/NdbConfig.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbDaemon.c b/storage/ndb/src/common/portlib/NdbDaemon.c index d440b68290e..fc76222e2c7 100644 --- a/storage/ndb/src/common/portlib/NdbDaemon.c +++ b/storage/ndb/src/common/portlib/NdbDaemon.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbEnv.c b/storage/ndb/src/common/portlib/NdbEnv.c index faa9a20a516..ed73986d23d 100644 --- a/storage/ndb/src/common/portlib/NdbEnv.c +++ b/storage/ndb/src/common/portlib/NdbEnv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbHost.c b/storage/ndb/src/common/portlib/NdbHost.c index 26563a65d9c..b082fe4551f 100644 --- a/storage/ndb/src/common/portlib/NdbHost.c +++ b/storage/ndb/src/common/portlib/NdbHost.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbMem.c b/storage/ndb/src/common/portlib/NdbMem.c index 7c95e02cd0c..80d847a9877 100644 --- a/storage/ndb/src/common/portlib/NdbMem.c +++ b/storage/ndb/src/common/portlib/NdbMem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbPortLibTest.cpp b/storage/ndb/src/common/portlib/NdbPortLibTest.cpp index 2cc19f70218..1658045d468 100644 --- a/storage/ndb/src/common/portlib/NdbPortLibTest.cpp +++ b/storage/ndb/src/common/portlib/NdbPortLibTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbSleep.c b/storage/ndb/src/common/portlib/NdbSleep.c index b3251939938..f8dc7828c57 100644 --- a/storage/ndb/src/common/portlib/NdbSleep.c +++ b/storage/ndb/src/common/portlib/NdbSleep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbTCP.cpp b/storage/ndb/src/common/portlib/NdbTCP.cpp index 72892b93e62..18b0f37c12a 100644 --- a/storage/ndb/src/common/portlib/NdbTCP.cpp +++ b/storage/ndb/src/common/portlib/NdbTCP.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbThread.c b/storage/ndb/src/common/portlib/NdbThread.c index d8c010b6a06..aa5790abaac 100644 --- a/storage/ndb/src/common/portlib/NdbThread.c +++ b/storage/ndb/src/common/portlib/NdbThread.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/NdbTick.c b/storage/ndb/src/common/portlib/NdbTick.c index 7e54984794f..34cc95a3f3c 100644 --- a/storage/ndb/src/common/portlib/NdbTick.c +++ b/storage/ndb/src/common/portlib/NdbTick.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/memtest.c b/storage/ndb/src/common/portlib/memtest.c index b9ad2cee315..2bcfa53d07d 100644 --- a/storage/ndb/src/common/portlib/memtest.c +++ b/storage/ndb/src/common/portlib/memtest.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/mmstest.cpp b/storage/ndb/src/common/portlib/mmstest.cpp index 3ffb2e1a5aa..cc61186a4ac 100644 --- a/storage/ndb/src/common/portlib/mmstest.cpp +++ b/storage/ndb/src/common/portlib/mmstest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/munmaptest.cpp b/storage/ndb/src/common/portlib/munmaptest.cpp index 57f1756f1ee..a4a48b280f6 100644 --- a/storage/ndb/src/common/portlib/munmaptest.cpp +++ b/storage/ndb/src/common/portlib/munmaptest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbCondition.c b/storage/ndb/src/common/portlib/win32/NdbCondition.c index 1a68572297c..f90c44ba23b 100644 --- a/storage/ndb/src/common/portlib/win32/NdbCondition.c +++ b/storage/ndb/src/common/portlib/win32/NdbCondition.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbDaemon.c b/storage/ndb/src/common/portlib/win32/NdbDaemon.c index 6cfffbd8600..f83775162e6 100644 --- a/storage/ndb/src/common/portlib/win32/NdbDaemon.c +++ b/storage/ndb/src/common/portlib/win32/NdbDaemon.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbEnv.c b/storage/ndb/src/common/portlib/win32/NdbEnv.c index dedd9c9c1fe..06898a5286e 100644 --- a/storage/ndb/src/common/portlib/win32/NdbEnv.c +++ b/storage/ndb/src/common/portlib/win32/NdbEnv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbHost.c b/storage/ndb/src/common/portlib/win32/NdbHost.c index 34977942eb6..b063b350af8 100644 --- a/storage/ndb/src/common/portlib/win32/NdbHost.c +++ b/storage/ndb/src/common/portlib/win32/NdbHost.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbMem.c b/storage/ndb/src/common/portlib/win32/NdbMem.c index 39c84f4717a..97bce82d4e1 100644 --- a/storage/ndb/src/common/portlib/win32/NdbMem.c +++ b/storage/ndb/src/common/portlib/win32/NdbMem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbMutex.c b/storage/ndb/src/common/portlib/win32/NdbMutex.c index af04531543e..d88f69a2c58 100644 --- a/storage/ndb/src/common/portlib/win32/NdbMutex.c +++ b/storage/ndb/src/common/portlib/win32/NdbMutex.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbSleep.c b/storage/ndb/src/common/portlib/win32/NdbSleep.c index 9c3df0ec0ca..17aa44a4108 100644 --- a/storage/ndb/src/common/portlib/win32/NdbSleep.c +++ b/storage/ndb/src/common/portlib/win32/NdbSleep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbTCP.c b/storage/ndb/src/common/portlib/win32/NdbTCP.c index e1d9bf91009..07aa2ba5ad6 100644 --- a/storage/ndb/src/common/portlib/win32/NdbTCP.c +++ b/storage/ndb/src/common/portlib/win32/NdbTCP.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbThread.c b/storage/ndb/src/common/portlib/win32/NdbThread.c index 3cd57b40422..f063555954c 100644 --- a/storage/ndb/src/common/portlib/win32/NdbThread.c +++ b/storage/ndb/src/common/portlib/win32/NdbThread.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/portlib/win32/NdbTick.c b/storage/ndb/src/common/portlib/win32/NdbTick.c index 3e9c6f47349..db6bef6e949 100644 --- a/storage/ndb/src/common/portlib/win32/NdbTick.c +++ b/storage/ndb/src/common/portlib/win32/NdbTick.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/Makefile.am b/storage/ndb/src/common/transporter/Makefile.am index 83ac3b6121d..e875d0ed29b 100644 --- a/storage/ndb/src/common/transporter/Makefile.am +++ b/storage/ndb/src/common/transporter/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/Packer.cpp b/storage/ndb/src/common/transporter/Packer.cpp index df7ff078e63..e917fa3e898 100644 --- a/storage/ndb/src/common/transporter/Packer.cpp +++ b/storage/ndb/src/common/transporter/Packer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/Packer.hpp b/storage/ndb/src/common/transporter/Packer.hpp index 8a1feb87ed7..f06fb7dda62 100644 --- a/storage/ndb/src/common/transporter/Packer.hpp +++ b/storage/ndb/src/common/transporter/Packer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SCI_Transporter.cpp b/storage/ndb/src/common/transporter/SCI_Transporter.cpp index 0720fe84973..a9f3a4ea129 100644 --- a/storage/ndb/src/common/transporter/SCI_Transporter.cpp +++ b/storage/ndb/src/common/transporter/SCI_Transporter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SCI_Transporter.hpp b/storage/ndb/src/common/transporter/SCI_Transporter.hpp index f774186f238..d8f4c85b7ed 100644 --- a/storage/ndb/src/common/transporter/SCI_Transporter.hpp +++ b/storage/ndb/src/common/transporter/SCI_Transporter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SHM_Buffer.hpp b/storage/ndb/src/common/transporter/SHM_Buffer.hpp index aecadf23943..de6d522b856 100644 --- a/storage/ndb/src/common/transporter/SHM_Buffer.hpp +++ b/storage/ndb/src/common/transporter/SHM_Buffer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SHM_Transporter.cpp b/storage/ndb/src/common/transporter/SHM_Transporter.cpp index 3ce21940254..48127541af6 100644 --- a/storage/ndb/src/common/transporter/SHM_Transporter.cpp +++ b/storage/ndb/src/common/transporter/SHM_Transporter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SHM_Transporter.hpp b/storage/ndb/src/common/transporter/SHM_Transporter.hpp index bdb31298b8b..430a4975fea 100644 --- a/storage/ndb/src/common/transporter/SHM_Transporter.hpp +++ b/storage/ndb/src/common/transporter/SHM_Transporter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SHM_Transporter.unix.cpp b/storage/ndb/src/common/transporter/SHM_Transporter.unix.cpp index 5cab98aa075..2bb5c1d15ac 100644 --- a/storage/ndb/src/common/transporter/SHM_Transporter.unix.cpp +++ b/storage/ndb/src/common/transporter/SHM_Transporter.unix.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SHM_Transporter.win32.cpp b/storage/ndb/src/common/transporter/SHM_Transporter.win32.cpp index 5a753179b59..2a26c32f558 100644 --- a/storage/ndb/src/common/transporter/SHM_Transporter.win32.cpp +++ b/storage/ndb/src/common/transporter/SHM_Transporter.win32.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SendBuffer.cpp b/storage/ndb/src/common/transporter/SendBuffer.cpp index c0cf81ba823..36a08a0f151 100644 --- a/storage/ndb/src/common/transporter/SendBuffer.cpp +++ b/storage/ndb/src/common/transporter/SendBuffer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/SendBuffer.hpp b/storage/ndb/src/common/transporter/SendBuffer.hpp index 73dda433493..328514fae8a 100644 --- a/storage/ndb/src/common/transporter/SendBuffer.hpp +++ b/storage/ndb/src/common/transporter/SendBuffer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/TCP_Transporter.cpp b/storage/ndb/src/common/transporter/TCP_Transporter.cpp index 8b386483bff..68b2eb8d138 100644 --- a/storage/ndb/src/common/transporter/TCP_Transporter.cpp +++ b/storage/ndb/src/common/transporter/TCP_Transporter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/TCP_Transporter.hpp b/storage/ndb/src/common/transporter/TCP_Transporter.hpp index ed1a154c944..868e0d0df8a 100644 --- a/storage/ndb/src/common/transporter/TCP_Transporter.hpp +++ b/storage/ndb/src/common/transporter/TCP_Transporter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/Transporter.cpp b/storage/ndb/src/common/transporter/Transporter.cpp index 269a5fba4e9..9f616d8dea0 100644 --- a/storage/ndb/src/common/transporter/Transporter.cpp +++ b/storage/ndb/src/common/transporter/Transporter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/Transporter.hpp b/storage/ndb/src/common/transporter/Transporter.hpp index 1a979207b0c..6526bc8ad47 100644 --- a/storage/ndb/src/common/transporter/Transporter.hpp +++ b/storage/ndb/src/common/transporter/Transporter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/TransporterInternalDefinitions.hpp b/storage/ndb/src/common/transporter/TransporterInternalDefinitions.hpp index 0576b188227..b19c28250ec 100644 --- a/storage/ndb/src/common/transporter/TransporterInternalDefinitions.hpp +++ b/storage/ndb/src/common/transporter/TransporterInternalDefinitions.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/TransporterRegistry.cpp b/storage/ndb/src/common/transporter/TransporterRegistry.cpp index 848738b2983..6e525fcfb4f 100644 --- a/storage/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/storage/ndb/src/common/transporter/TransporterRegistry.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/basictest/basicTransporterTest.cpp b/storage/ndb/src/common/transporter/basictest/basicTransporterTest.cpp index 58693de7f48..5c780a017b2 100644 --- a/storage/ndb/src/common/transporter/basictest/basicTransporterTest.cpp +++ b/storage/ndb/src/common/transporter/basictest/basicTransporterTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/buddy.cpp b/storage/ndb/src/common/transporter/buddy.cpp index 3c33f5c8f55..aaad982dcab 100644 --- a/storage/ndb/src/common/transporter/buddy.cpp +++ b/storage/ndb/src/common/transporter/buddy.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/buddy.hpp b/storage/ndb/src/common/transporter/buddy.hpp index 7bb7d626c6d..89093d7ec88 100644 --- a/storage/ndb/src/common/transporter/buddy.hpp +++ b/storage/ndb/src/common/transporter/buddy.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/failoverSCI/failoverSCI.cpp b/storage/ndb/src/common/transporter/failoverSCI/failoverSCI.cpp index b4eca4e6ddd..c5250c5e4e9 100644 --- a/storage/ndb/src/common/transporter/failoverSCI/failoverSCI.cpp +++ b/storage/ndb/src/common/transporter/failoverSCI/failoverSCI.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/perftest/perfTransporterTest.cpp b/storage/ndb/src/common/transporter/perftest/perfTransporterTest.cpp index bc4606e827c..15c4c7e3750 100644 --- a/storage/ndb/src/common/transporter/perftest/perfTransporterTest.cpp +++ b/storage/ndb/src/common/transporter/perftest/perfTransporterTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/priotest/prioSCI/prioSCI.cpp b/storage/ndb/src/common/transporter/priotest/prioSCI/prioSCI.cpp index ae0773eace4..0a314c8b2e4 100644 --- a/storage/ndb/src/common/transporter/priotest/prioSCI/prioSCI.cpp +++ b/storage/ndb/src/common/transporter/priotest/prioSCI/prioSCI.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/priotest/prioSHM/prioSHM.cpp b/storage/ndb/src/common/transporter/priotest/prioSHM/prioSHM.cpp index ecbd53067d3..38216ab2827 100644 --- a/storage/ndb/src/common/transporter/priotest/prioSHM/prioSHM.cpp +++ b/storage/ndb/src/common/transporter/priotest/prioSHM/prioSHM.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/priotest/prioTCP/prioTCP.cpp b/storage/ndb/src/common/transporter/priotest/prioTCP/prioTCP.cpp index ffbad231474..d6a34a6a9c7 100644 --- a/storage/ndb/src/common/transporter/priotest/prioTCP/prioTCP.cpp +++ b/storage/ndb/src/common/transporter/priotest/prioTCP/prioTCP.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/priotest/prioTransporterTest.cpp b/storage/ndb/src/common/transporter/priotest/prioTransporterTest.cpp index c9d149187a1..0c93543aa3c 100644 --- a/storage/ndb/src/common/transporter/priotest/prioTransporterTest.cpp +++ b/storage/ndb/src/common/transporter/priotest/prioTransporterTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/transporter/priotest/prioTransporterTest.hpp b/storage/ndb/src/common/transporter/priotest/prioTransporterTest.hpp index 8e1f04f4301..cbe0919a1d8 100644 --- a/storage/ndb/src/common/transporter/priotest/prioTransporterTest.hpp +++ b/storage/ndb/src/common/transporter/priotest/prioTransporterTest.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/BaseString.cpp b/storage/ndb/src/common/util/BaseString.cpp index 7e5adf0e9ef..a805ef280c3 100644 --- a/storage/ndb/src/common/util/BaseString.cpp +++ b/storage/ndb/src/common/util/BaseString.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/Bitmask.cpp b/storage/ndb/src/common/util/Bitmask.cpp index 22919fe585a..93902a6a16b 100644 --- a/storage/ndb/src/common/util/Bitmask.cpp +++ b/storage/ndb/src/common/util/Bitmask.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2005 MySQL AB +/* Copyright (c) 2004-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/ConfigValues.cpp b/storage/ndb/src/common/util/ConfigValues.cpp index 9309fe3fbd6..3ed8acfa561 100644 --- a/storage/ndb/src/common/util/ConfigValues.cpp +++ b/storage/ndb/src/common/util/ConfigValues.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2006 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/File.cpp b/storage/ndb/src/common/util/File.cpp index 53e129e56a6..057aac02166 100644 --- a/storage/ndb/src/common/util/File.cpp +++ b/storage/ndb/src/common/util/File.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/InputStream.cpp b/storage/ndb/src/common/util/InputStream.cpp index 2337344d91a..3c4de7696d5 100644 --- a/storage/ndb/src/common/util/InputStream.cpp +++ b/storage/ndb/src/common/util/InputStream.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/NdbOut.cpp b/storage/ndb/src/common/util/NdbOut.cpp index 61de2be7572..27bd90a466d 100644 --- a/storage/ndb/src/common/util/NdbOut.cpp +++ b/storage/ndb/src/common/util/NdbOut.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/NdbSqlUtil.cpp b/storage/ndb/src/common/util/NdbSqlUtil.cpp index 0f62d66c149..c89c06063a6 100644 --- a/storage/ndb/src/common/util/NdbSqlUtil.cpp +++ b/storage/ndb/src/common/util/NdbSqlUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/OutputStream.cpp b/storage/ndb/src/common/util/OutputStream.cpp index cd619380e5a..eb3a495c2ed 100644 --- a/storage/ndb/src/common/util/OutputStream.cpp +++ b/storage/ndb/src/common/util/OutputStream.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/Parser.cpp b/storage/ndb/src/common/util/Parser.cpp index 2c61a07ad52..962532bf4cd 100644 --- a/storage/ndb/src/common/util/Parser.cpp +++ b/storage/ndb/src/common/util/Parser.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/Properties.cpp b/storage/ndb/src/common/util/Properties.cpp index 11a1d8690ae..d48f993c413 100644 --- a/storage/ndb/src/common/util/Properties.cpp +++ b/storage/ndb/src/common/util/Properties.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/SimpleProperties.cpp b/storage/ndb/src/common/util/SimpleProperties.cpp index 813b38dffd7..aad829e73da 100644 --- a/storage/ndb/src/common/util/SimpleProperties.cpp +++ b/storage/ndb/src/common/util/SimpleProperties.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/SocketAuthenticator.cpp b/storage/ndb/src/common/util/SocketAuthenticator.cpp index 2f939da6387..4cef9028053 100644 --- a/storage/ndb/src/common/util/SocketAuthenticator.cpp +++ b/storage/ndb/src/common/util/SocketAuthenticator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/SocketClient.cpp b/storage/ndb/src/common/util/SocketClient.cpp index 3d1fd07d581..52f3963f448 100644 --- a/storage/ndb/src/common/util/SocketClient.cpp +++ b/storage/ndb/src/common/util/SocketClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/SocketServer.cpp b/storage/ndb/src/common/util/SocketServer.cpp index 47bf562f7d1..c9870cc87d9 100644 --- a/storage/ndb/src/common/util/SocketServer.cpp +++ b/storage/ndb/src/common/util/SocketServer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/basestring_vsnprintf.c b/storage/ndb/src/common/util/basestring_vsnprintf.c index 07762a4e503..48a63896fe7 100644 --- a/storage/ndb/src/common/util/basestring_vsnprintf.c +++ b/storage/ndb/src/common/util/basestring_vsnprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/filetest/FileUnitTest.cpp b/storage/ndb/src/common/util/filetest/FileUnitTest.cpp index 35b86623351..55fc8304f0a 100644 --- a/storage/ndb/src/common/util/filetest/FileUnitTest.cpp +++ b/storage/ndb/src/common/util/filetest/FileUnitTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/filetest/FileUnitTest.hpp b/storage/ndb/src/common/util/filetest/FileUnitTest.hpp index 231c5919244..c9d10ec9820 100644 --- a/storage/ndb/src/common/util/filetest/FileUnitTest.hpp +++ b/storage/ndb/src/common/util/filetest/FileUnitTest.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/md5_hash.cpp b/storage/ndb/src/common/util/md5_hash.cpp index 4b5c5623886..353f5d0e139 100644 --- a/storage/ndb/src/common/util/md5_hash.cpp +++ b/storage/ndb/src/common/util/md5_hash.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/ndb_init.c b/storage/ndb/src/common/util/ndb_init.c index 6c69dfbf8b6..06fcf6209f8 100644 --- a/storage/ndb/src/common/util/ndb_init.c +++ b/storage/ndb/src/common/util/ndb_init.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/ndb_rand.c b/storage/ndb/src/common/util/ndb_rand.c index 4fcc483cd49..f7574ed4de8 100644 --- a/storage/ndb/src/common/util/ndb_rand.c +++ b/storage/ndb/src/common/util/ndb_rand.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/new.cpp b/storage/ndb/src/common/util/new.cpp index bc9db0d749f..3aaca0b7af3 100644 --- a/storage/ndb/src/common/util/new.cpp +++ b/storage/ndb/src/common/util/new.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2005 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/random.c b/storage/ndb/src/common/util/random.c index 20ef537d89a..4480e20fa93 100644 --- a/storage/ndb/src/common/util/random.c +++ b/storage/ndb/src/common/util/random.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/socket_io.cpp b/storage/ndb/src/common/util/socket_io.cpp index dfdcd19412f..ab0c8bde836 100644 --- a/storage/ndb/src/common/util/socket_io.cpp +++ b/storage/ndb/src/common/util/socket_io.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/strdup.c b/storage/ndb/src/common/util/strdup.c index d26b94fdb25..206a3a7866c 100644 --- a/storage/ndb/src/common/util/strdup.c +++ b/storage/ndb/src/common/util/strdup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/testConfigValues/testConfigValues.cpp b/storage/ndb/src/common/util/testConfigValues/testConfigValues.cpp index b887808c62e..3777bd1d27f 100644 --- a/storage/ndb/src/common/util/testConfigValues/testConfigValues.cpp +++ b/storage/ndb/src/common/util/testConfigValues/testConfigValues.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/testProperties/testProperties.cpp b/storage/ndb/src/common/util/testProperties/testProperties.cpp index c4120e92400..ae3022ce7fe 100644 --- a/storage/ndb/src/common/util/testProperties/testProperties.cpp +++ b/storage/ndb/src/common/util/testProperties/testProperties.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/testSimpleProperties/sp_test.cpp b/storage/ndb/src/common/util/testSimpleProperties/sp_test.cpp index ebc445a77ad..93e4472c41b 100644 --- a/storage/ndb/src/common/util/testSimpleProperties/sp_test.cpp +++ b/storage/ndb/src/common/util/testSimpleProperties/sp_test.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/uucode.c b/storage/ndb/src/common/util/uucode.c index ad2db2fcbbe..d0d22893544 100644 --- a/storage/ndb/src/common/util/uucode.c +++ b/storage/ndb/src/common/util/uucode.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/common/util/version.c b/storage/ndb/src/common/util/version.c index 56a92489131..ade680d7bec 100644 --- a/storage/ndb/src/common/util/version.c +++ b/storage/ndb/src/common/util/version.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/Makefile.am b/storage/ndb/src/cw/Makefile.am index d9a40002062..8debc54b778 100644 --- a/storage/ndb/src/cw/Makefile.am +++ b/storage/ndb/src/cw/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp index b1d599dda63..0ea940e7ffe 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h index 692248cf9ea..37eacbdd99e 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc index 41d75b2b282..9b5b6729fae 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc @@ -89,7 +89,7 @@ FONT 8, "MS Sans Serif" BEGIN LTEXT "NDB Cluster Process Control Applet v1.0",IDC_STATIC,7,8, 213,8,SS_NOPREFIX - LTEXT "Copyright (C) 2003 MySQL AB", + LTEXT "Copyright (c) 2003, 2005 MySQL AB IDC_STATIC,7,20,213,20 DEFPUSHBUTTON "OK",IDOK,185,55,41,16,WS_GROUP END diff --git a/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp b/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp index 8feadf9462c..519fb5e23e5 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp +++ b/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp index 2515c6f1b54..479323cefd3 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp +++ b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h index 830735d4c09..ec311265c66 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h +++ b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp index 28cd75550c8..48a3e475c1a 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp +++ b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h index 6e87f3819de..c231f126a54 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h +++ b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/C++/resource.h b/storage/ndb/src/cw/cpcc-win32/C++/resource.h index 9bcd7d53b6f..c2dfcf4fb67 100644 --- a/storage/ndb/src/cw/cpcc-win32/C++/resource.h +++ b/storage/ndb/src/cw/cpcc-win32/C++/resource.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs b/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs index b19875b97ef..9bc1a010e8d 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs index 5ee35e5e90e..7c6ef4a717d 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs index 506cb6777f0..7e5aa124f58 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs index a126c632ffd..664206599b2 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs index 80a8daee2d0..217c2e9d2aa 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs b/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs index a780190f86c..57090f8c161 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs index eac12d4868e..6feee5c5b41 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs index ab8d58ed11f..99b4e0fa177 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs b/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs index 41929c104d0..386395af495 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs b/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs index 6e070875b25..03a41d87b41 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs index 9025f122994..baff6712a1f 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs index 25d0d9947d6..a6ff62d6dac 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs b/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs index 4261efc8a29..aba1ed6bf1a 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs b/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs index 5258ad290fc..2423e481927 100644 --- a/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs +++ b/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/APIService.cpp b/storage/ndb/src/cw/cpcd/APIService.cpp index f60abc08817..e38099931b4 100644 --- a/storage/ndb/src/cw/cpcd/APIService.cpp +++ b/storage/ndb/src/cw/cpcd/APIService.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/APIService.hpp b/storage/ndb/src/cw/cpcd/APIService.hpp index c13d0d886b4..238280d3147 100644 --- a/storage/ndb/src/cw/cpcd/APIService.hpp +++ b/storage/ndb/src/cw/cpcd/APIService.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/CPCD.cpp b/storage/ndb/src/cw/cpcd/CPCD.cpp index 24afb0ea0b5..abad3c7a8b6 100644 --- a/storage/ndb/src/cw/cpcd/CPCD.cpp +++ b/storage/ndb/src/cw/cpcd/CPCD.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/CPCD.hpp b/storage/ndb/src/cw/cpcd/CPCD.hpp index 4d48bba096f..f3168a5e365 100644 --- a/storage/ndb/src/cw/cpcd/CPCD.hpp +++ b/storage/ndb/src/cw/cpcd/CPCD.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/Makefile.am b/storage/ndb/src/cw/cpcd/Makefile.am index efc828e21a9..45c9f8f762d 100644 --- a/storage/ndb/src/cw/cpcd/Makefile.am +++ b/storage/ndb/src/cw/cpcd/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/Monitor.cpp b/storage/ndb/src/cw/cpcd/Monitor.cpp index 7afbb8d7959..c82902b69de 100644 --- a/storage/ndb/src/cw/cpcd/Monitor.cpp +++ b/storage/ndb/src/cw/cpcd/Monitor.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/Process.cpp b/storage/ndb/src/cw/cpcd/Process.cpp index de61e54888d..40b27612f82 100644 --- a/storage/ndb/src/cw/cpcd/Process.cpp +++ b/storage/ndb/src/cw/cpcd/Process.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/common.cpp b/storage/ndb/src/cw/cpcd/common.cpp index aaadaeed2e3..224b44b5aff 100644 --- a/storage/ndb/src/cw/cpcd/common.cpp +++ b/storage/ndb/src/cw/cpcd/common.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/common.hpp b/storage/ndb/src/cw/cpcd/common.hpp index 044a7eb67c3..8da2425a7e0 100644 --- a/storage/ndb/src/cw/cpcd/common.hpp +++ b/storage/ndb/src/cw/cpcd/common.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/cpcd/main.cpp b/storage/ndb/src/cw/cpcd/main.cpp index d5c31d610cb..24c188b6914 100644 --- a/storage/ndb/src/cw/cpcd/main.cpp +++ b/storage/ndb/src/cw/cpcd/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/test/socketclient/socketClientTest.cpp b/storage/ndb/src/cw/test/socketclient/socketClientTest.cpp index a3da256a7ad..5fc9669536e 100644 --- a/storage/ndb/src/cw/test/socketclient/socketClientTest.cpp +++ b/storage/ndb/src/cw/test/socketclient/socketClientTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/util/ClientInterface.cpp b/storage/ndb/src/cw/util/ClientInterface.cpp index bc74698de76..ea06b25423f 100644 --- a/storage/ndb/src/cw/util/ClientInterface.cpp +++ b/storage/ndb/src/cw/util/ClientInterface.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/util/ClientInterface.hpp b/storage/ndb/src/cw/util/ClientInterface.hpp index 3496595145e..26b0d447929 100644 --- a/storage/ndb/src/cw/util/ClientInterface.hpp +++ b/storage/ndb/src/cw/util/ClientInterface.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/util/SocketRegistry.cpp b/storage/ndb/src/cw/util/SocketRegistry.cpp index ab94f772501..46f34c8d3d9 100644 --- a/storage/ndb/src/cw/util/SocketRegistry.cpp +++ b/storage/ndb/src/cw/util/SocketRegistry.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/util/SocketRegistry.hpp b/storage/ndb/src/cw/util/SocketRegistry.hpp index 0166232d4c8..ad590b528eb 100644 --- a/storage/ndb/src/cw/util/SocketRegistry.hpp +++ b/storage/ndb/src/cw/util/SocketRegistry.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/util/SocketService.cpp b/storage/ndb/src/cw/util/SocketService.cpp index 7b423e5546e..5dead5d4035 100644 --- a/storage/ndb/src/cw/util/SocketService.cpp +++ b/storage/ndb/src/cw/util/SocketService.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/cw/util/SocketService.hpp b/storage/ndb/src/cw/util/SocketService.hpp index 770d5d8ec96..8e7f6efec84 100644 --- a/storage/ndb/src/cw/util/SocketService.hpp +++ b/storage/ndb/src/cw/util/SocketService.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/SimBlockList.cpp b/storage/ndb/src/kernel/SimBlockList.cpp index e5dd02250b9..63dbf9d9c35 100644 --- a/storage/ndb/src/kernel/SimBlockList.cpp +++ b/storage/ndb/src/kernel/SimBlockList.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp index 5cc486ff83b..07ae36a257c 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.hpp b/storage/ndb/src/kernel/blocks/backup/Backup.hpp index e28b322adb3..4b66d804148 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.hpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp b/storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp index 20f8f6650be..ccc779c91f2 100644 --- a/storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp +++ b/storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp b/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp index 2cd2a8a2bee..92e7185f144 100644 --- a/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp +++ b/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp b/storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp index bb0bbd6d770..ed5ee201f3e 100644 --- a/storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp +++ b/storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/backup/Makefile.am b/storage/ndb/src/kernel/blocks/backup/Makefile.am index 4594e0fe717..92a1694f9e8 100644 --- a/storage/ndb/src/kernel/blocks/backup/Makefile.am +++ b/storage/ndb/src/kernel/blocks/backup/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/backup/read.cpp b/storage/ndb/src/kernel/blocks/backup/read.cpp index ebe769ede24..db32c821924 100644 --- a/storage/ndb/src/kernel/blocks/backup/read.cpp +++ b/storage/ndb/src/kernel/blocks/backup/read.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2006 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2003-2005 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 6c869435bfa..d8af1676c2f 100644 --- a/storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp b/storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp index bc88f1a0c63..f162045fdb1 100644 --- a/storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp +++ b/storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp b/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp index 21114c6a155..4771f0ecdfe 100644 --- a/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp +++ b/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp b/storage/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp index 9ba164d264c..a4c5f55c150 100644 --- a/storage/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp +++ b/storage/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index 1805d6ef4f8..6ace73f2b4d 100644 --- a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp index 1189b23c14d..9d86bd61f8a 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdict/Makefile.am b/storage/ndb/src/kernel/blocks/dbdict/Makefile.am index 0ee3df7036d..ff94acf3a4e 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Makefile.am +++ b/storage/ndb/src/kernel/blocks/dbdict/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdict/Master_AddTable.sfl b/storage/ndb/src/kernel/blocks/dbdict/Master_AddTable.sfl index 89dfd56fd40..7f2cb6087a4 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Master_AddTable.sfl +++ b/storage/ndb/src/kernel/blocks/dbdict/Master_AddTable.sfl @@ -1,4 +1,4 @@ -// Copyright (C) 2004 MySQL AB +// Copyright (c) 2004-2006 MySQL AB // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdict/SchemaFile.hpp b/storage/ndb/src/kernel/blocks/dbdict/SchemaFile.hpp index b66e15b3ff1..1fe416f536d 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/SchemaFile.hpp +++ b/storage/ndb/src/kernel/blocks/dbdict/SchemaFile.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdict/Slave_AddTable.sfl b/storage/ndb/src/kernel/blocks/dbdict/Slave_AddTable.sfl index 4c018ea5460..82b7a90539b 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Slave_AddTable.sfl +++ b/storage/ndb/src/kernel/blocks/dbdict/Slave_AddTable.sfl @@ -1,4 +1,4 @@ -// Copyright (C) 2004 MySQL AB +// Copyright (c) 2004-2006 MySQL AB // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp b/storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp index 44326e213d0..a616326bb2d 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp +++ b/storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp b/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp index b0bbdefff55..bdf1d9cd8e2 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp +++ b/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp index 6ce281434c2..b67bcdafa14 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index e2b1058242d..c0d3703ca20 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdih/Makefile.am b/storage/ndb/src/kernel/blocks/dbdih/Makefile.am index 1c84714289d..f53cb83370b 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/Makefile.am +++ b/storage/ndb/src/kernel/blocks/dbdih/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdih/Sysfile.hpp b/storage/ndb/src/kernel/blocks/dbdih/Sysfile.hpp index 48daf42675a..54170853137 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/Sysfile.hpp +++ b/storage/ndb/src/kernel/blocks/dbdih/Sysfile.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp b/storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp index ea4c5c61bb4..a50dfe0e384 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbdih/printSysfile/printSysfile.cpp b/storage/ndb/src/kernel/blocks/dbdih/printSysfile/printSysfile.cpp index 8ef69cff388..31ba4f6b574 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/printSysfile/printSysfile.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/printSysfile/printSysfile.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index 62add0cf503..f39e593fad2 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index b3a3d512da7..cf4beaa7b63 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dblqh/Makefile.am b/storage/ndb/src/kernel/blocks/dblqh/Makefile.am index b545096dc83..029a190e5a8 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/Makefile.am +++ b/storage/ndb/src/kernel/blocks/dblqh/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp b/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp index e5df14aea9a..7fbb34ba797 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.cpp b/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.cpp index 6c4b26ecf17..bf2a736967f 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.hpp b/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.hpp index 49d69354b2a..fde901241ad 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.hpp +++ b/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp index db9f1454548..74d9cefcecf 100644 --- a/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp +++ b/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp b/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp index 3bba771f3f0..5a5bc657291 100644 --- a/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp +++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 7bd61dfe8b3..b88717bf1fa 100644 --- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/AttributeOffset.hpp b/storage/ndb/src/kernel/blocks/dbtup/AttributeOffset.hpp index df4897ac718..e13670a7bc2 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/AttributeOffset.hpp +++ b/storage/ndb/src/kernel/blocks/dbtup/AttributeOffset.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp index decb47e9758..b5f03d9e472 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp +++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupAbort.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupAbort.cpp index 93a160a4df3..f45e72fa1d6 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupAbort.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupAbort.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupBuffer.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupBuffer.cpp index adac4d3d460..e037b1daae2 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupBuffer.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupBuffer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp index f56e772c8b9..49c6e8592e6 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp index 8e532ae97b5..f5432c446af 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp index 3a3c1155657..fff8c08f4f4 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp index 8c096681b58..5a95a55eea2 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp index 900a02cfd72..d547c94c723 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp index 74c7d38bd64..c83e3014b1d 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp index 0a4477db0d0..4e8fd314df1 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp index 176efac8058..70c3e05002c 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupPagMan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupPagMan.cpp index 24806062fcf..2d31896e3d7 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupPagMan.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupPagMan.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp index cde63091cfb..93111bef70b 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index 64f81dc11ab..511d6fa9423 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp index 4c5fb7b645f..188c63dfb0a 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp index a1e350853ce..fc2f7e9e3c2 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp index 6406bdefe1e..ef78bab6252 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp index 0ae6d0f4ac6..9b202d4efc5 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp index 1929901f86e..a316ba040cc 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/Makefile.am b/storage/ndb/src/kernel/blocks/dbtup/Makefile.am index 7feda3d8ac5..4436cee959b 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Makefile.am +++ b/storage/ndb/src/kernel/blocks/dbtup/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp b/storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp index 972c912c8fa..975f0ebcf76 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp b/storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp index 8f9af424f24..b5f17398813 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp +++ b/storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp b/storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp index 9d64910381a..63b1c497958 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp b/storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp index 7ebbde93ac7..e3951eb607a 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp b/storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp index 44aa6182b54..e7587d74a80 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp +++ b/storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp b/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp index 67ce7a1760a..651303b7b5f 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp +++ b/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp index 95c7b417da9..9caf3c34b16 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp index f5e0615697b..21a1d60d6d2 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp index f1654aaaeef..f628b4647b6 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp index 391adb1e930..849992d79b5 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp index 0c68008edd6..8eb7dfabe55 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp index 13485a31414..73027c5a828 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp index 8cef61038a6..a505eb39fbf 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp index f7b93401252..80eec415ea9 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp index fe59b8bba2c..82b95bac062 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp b/storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp index 970ee794281..4055378811d 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp +++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp b/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp index f34bc41af06..78e006a0d9a 100644 --- a/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp +++ b/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/dbutil/DbUtil.hpp b/storage/ndb/src/kernel/blocks/dbutil/DbUtil.hpp index fceb8232a28..1a54f9823a1 100644 --- a/storage/ndb/src/kernel/blocks/dbutil/DbUtil.hpp +++ b/storage/ndb/src/kernel/blocks/dbutil/DbUtil.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/diskpage.cpp b/storage/ndb/src/kernel/blocks/diskpage.cpp index 50e9b6e53cb..d68db267c23 100644 --- a/storage/ndb/src/kernel/blocks/diskpage.cpp +++ b/storage/ndb/src/kernel/blocks/diskpage.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/diskpage.hpp b/storage/ndb/src/kernel/blocks/diskpage.hpp index 4119c328e35..b2665d83e95 100644 --- a/storage/ndb/src/kernel/blocks/diskpage.hpp +++ b/storage/ndb/src/kernel/blocks/diskpage.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/lgman.hpp b/storage/ndb/src/kernel/blocks/lgman.hpp index d2706818144..e8404955949 100644 --- a/storage/ndb/src/kernel/blocks/lgman.hpp +++ b/storage/ndb/src/kernel/blocks/lgman.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/mutexes.hpp b/storage/ndb/src/kernel/blocks/mutexes.hpp index 2eb248b3d5e..f904756335f 100644 --- a/storage/ndb/src/kernel/blocks/mutexes.hpp +++ b/storage/ndb/src/kernel/blocks/mutexes.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp b/storage/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp index 4db07591b60..9860c00afa0 100644 --- a/storage/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp +++ b/storage/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp index ae5afa7a57b..8ba058df835 100644 --- a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp +++ b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index 56ecc8ddc39..7e5f8813da2 100644 --- a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrSysTable.cpp b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrSysTable.cpp index 323a94c3937..404efb3360e 100644 --- a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrSysTable.cpp +++ b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrSysTable.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp index e4a01753acd..692e81f038b 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFileTest/AsyncFileTest.cpp b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFileTest/AsyncFileTest.cpp index 45b53b2693e..561905df2f3 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFileTest/AsyncFileTest.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFileTest/AsyncFileTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.cpp b/storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.cpp index 1202d14d699..cc0980e7c8a 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.hpp b/storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.hpp index 668b0e1b70e..75540e4ad5f 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/CircularIndex.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp b/storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp index 1749f551b99..b12031a2aad 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/Filename.hpp b/storage/ndb/src/kernel/blocks/ndbfs/Filename.hpp index 182e915a3fe..fc97acdb8a9 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/Filename.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/Filename.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.cpp b/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.cpp index fa84a52414e..4e295774c9b 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp b/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp index 411e7064efa..647059f8a84 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp b/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp index 2ef4d5019ab..940045b397d 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp index 26bf8878852..a118dde3db2 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp index 302a46ff674..cd821c2f6ec 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/OpenFiles.hpp b/storage/ndb/src/kernel/blocks/ndbfs/OpenFiles.hpp index f32ab915a92..a1f072649db 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/OpenFiles.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/OpenFiles.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/Pool.hpp b/storage/ndb/src/kernel/blocks/ndbfs/Pool.hpp index de0b4d1f437..ad82b90d763 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/Pool.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/Pool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp b/storage/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp index 85970773e7f..a7b5a2871de 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/pgman.cpp b/storage/ndb/src/kernel/blocks/pgman.cpp index 21295944eab..f1b287a6ed6 100644 --- a/storage/ndb/src/kernel/blocks/pgman.cpp +++ b/storage/ndb/src/kernel/blocks/pgman.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/pgman.hpp b/storage/ndb/src/kernel/blocks/pgman.hpp index e3bf0fa5780..859743c806d 100644 --- a/storage/ndb/src/kernel/blocks/pgman.hpp +++ b/storage/ndb/src/kernel/blocks/pgman.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/print_file.cpp b/storage/ndb/src/kernel/blocks/print_file.cpp index 8b9723418b0..6d869e13000 100644 --- a/storage/ndb/src/kernel/blocks/print_file.cpp +++ b/storage/ndb/src/kernel/blocks/print_file.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp b/storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp index 6a76ce5217a..29d34bd3f9d 100644 --- a/storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp +++ b/storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp b/storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp index 2f03bd56694..e7f64209414 100644 --- a/storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp +++ b/storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index 23e7829481e..250a499f069 100644 --- a/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/qmgr/timer.hpp b/storage/ndb/src/kernel/blocks/qmgr/timer.hpp index 09b6de7b0db..11c47e7ee27 100644 --- a/storage/ndb/src/kernel/blocks/qmgr/timer.hpp +++ b/storage/ndb/src/kernel/blocks/qmgr/timer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/record_types.hpp b/storage/ndb/src/kernel/blocks/record_types.hpp index 8eeace52299..d8bf8e3384f 100644 --- a/storage/ndb/src/kernel/blocks/record_types.hpp +++ b/storage/ndb/src/kernel/blocks/record_types.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/restore.cpp b/storage/ndb/src/kernel/blocks/restore.cpp index efc4bc1948a..07db366a161 100644 --- a/storage/ndb/src/kernel/blocks/restore.cpp +++ b/storage/ndb/src/kernel/blocks/restore.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/restore.hpp b/storage/ndb/src/kernel/blocks/restore.hpp index 4385be85fe4..d3a2eabe5c3 100644 --- a/storage/ndb/src/kernel/blocks/restore.hpp +++ b/storage/ndb/src/kernel/blocks/restore.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/suma/Suma.hpp b/storage/ndb/src/kernel/blocks/suma/Suma.hpp index 675706d5431..b62b8a37651 100644 --- a/storage/ndb/src/kernel/blocks/suma/Suma.hpp +++ b/storage/ndb/src/kernel/blocks/suma/Suma.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/suma/SumaInit.cpp b/storage/ndb/src/kernel/blocks/suma/SumaInit.cpp index 0248833978c..a5f4e2f8eb2 100644 --- a/storage/ndb/src/kernel/blocks/suma/SumaInit.cpp +++ b/storage/ndb/src/kernel/blocks/suma/SumaInit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/trix/Trix.cpp b/storage/ndb/src/kernel/blocks/trix/Trix.cpp index 30dd75be385..302d833b222 100644 --- a/storage/ndb/src/kernel/blocks/trix/Trix.cpp +++ b/storage/ndb/src/kernel/blocks/trix/Trix.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/trix/Trix.hpp b/storage/ndb/src/kernel/blocks/trix/Trix.hpp index d806397682d..24d72b7004b 100644 --- a/storage/ndb/src/kernel/blocks/trix/Trix.hpp +++ b/storage/ndb/src/kernel/blocks/trix/Trix.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/tsman.cpp b/storage/ndb/src/kernel/blocks/tsman.cpp index ce5797cf209..67ede021cac 100644 --- a/storage/ndb/src/kernel/blocks/tsman.cpp +++ b/storage/ndb/src/kernel/blocks/tsman.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/blocks/tsman.hpp b/storage/ndb/src/kernel/blocks/tsman.hpp index 20019e6d4d1..579b6669b9c 100644 --- a/storage/ndb/src/kernel/blocks/tsman.hpp +++ b/storage/ndb/src/kernel/blocks/tsman.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/error/ErrorHandlingMacros.hpp b/storage/ndb/src/kernel/error/ErrorHandlingMacros.hpp index de85127e638..80e6de8f413 100644 --- a/storage/ndb/src/kernel/error/ErrorHandlingMacros.hpp +++ b/storage/ndb/src/kernel/error/ErrorHandlingMacros.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/error/ErrorReporter.cpp b/storage/ndb/src/kernel/error/ErrorReporter.cpp index 43307d43139..a2325d9ac93 100644 --- a/storage/ndb/src/kernel/error/ErrorReporter.cpp +++ b/storage/ndb/src/kernel/error/ErrorReporter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/error/ErrorReporter.hpp b/storage/ndb/src/kernel/error/ErrorReporter.hpp index a32270e85cf..84bc2b49817 100644 --- a/storage/ndb/src/kernel/error/ErrorReporter.hpp +++ b/storage/ndb/src/kernel/error/ErrorReporter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/error/Makefile.am b/storage/ndb/src/kernel/error/Makefile.am index 6db5c0e4ede..06002ec9d62 100644 --- a/storage/ndb/src/kernel/error/Makefile.am +++ b/storage/ndb/src/kernel/error/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/error/TimeModule.cpp b/storage/ndb/src/kernel/error/TimeModule.cpp index 2be734842ba..0a43c5f6fec 100644 --- a/storage/ndb/src/kernel/error/TimeModule.cpp +++ b/storage/ndb/src/kernel/error/TimeModule.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/error/TimeModule.hpp b/storage/ndb/src/kernel/error/TimeModule.hpp index 870e12eebc2..9b0e1c9922d 100644 --- a/storage/ndb/src/kernel/error/TimeModule.hpp +++ b/storage/ndb/src/kernel/error/TimeModule.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/error/ndbd_exit_codes.c b/storage/ndb/src/kernel/error/ndbd_exit_codes.c index b36ea3af8ee..11617a32bbc 100644 --- a/storage/ndb/src/kernel/error/ndbd_exit_codes.c +++ b/storage/ndb/src/kernel/error/ndbd_exit_codes.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/main.cpp b/storage/ndb/src/kernel/main.cpp index 641ebe70e24..91cab939b2b 100644 --- a/storage/ndb/src/kernel/main.cpp +++ b/storage/ndb/src/kernel/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Array.hpp b/storage/ndb/src/kernel/vm/Array.hpp index 770dd47f048..2dbc230c56a 100644 --- a/storage/ndb/src/kernel/vm/Array.hpp +++ b/storage/ndb/src/kernel/vm/Array.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ArrayPool.hpp b/storage/ndb/src/kernel/vm/ArrayPool.hpp index 5aba0ad0f16..76ea558548d 100644 --- a/storage/ndb/src/kernel/vm/ArrayPool.hpp +++ b/storage/ndb/src/kernel/vm/ArrayPool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/CArray.hpp b/storage/ndb/src/kernel/vm/CArray.hpp index b06a04bde24..2c5996ccca9 100644 --- a/storage/ndb/src/kernel/vm/CArray.hpp +++ b/storage/ndb/src/kernel/vm/CArray.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Callback.hpp b/storage/ndb/src/kernel/vm/Callback.hpp index 4cf67858ca0..d29bcea021d 100644 --- a/storage/ndb/src/kernel/vm/Callback.hpp +++ b/storage/ndb/src/kernel/vm/Callback.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ClusterConfiguration.cpp b/storage/ndb/src/kernel/vm/ClusterConfiguration.cpp index 0f854f3504b..57cbea6df3e 100644 --- a/storage/ndb/src/kernel/vm/ClusterConfiguration.cpp +++ b/storage/ndb/src/kernel/vm/ClusterConfiguration.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ClusterConfiguration.hpp b/storage/ndb/src/kernel/vm/ClusterConfiguration.hpp index 40509b63f19..10e48792567 100644 --- a/storage/ndb/src/kernel/vm/ClusterConfiguration.hpp +++ b/storage/ndb/src/kernel/vm/ClusterConfiguration.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp index 72770d35cde..9f46ee62e56 100644 --- a/storage/ndb/src/kernel/vm/Configuration.cpp +++ b/storage/ndb/src/kernel/vm/Configuration.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Configuration.hpp b/storage/ndb/src/kernel/vm/Configuration.hpp index 918a889a171..a49515d126f 100644 --- a/storage/ndb/src/kernel/vm/Configuration.hpp +++ b/storage/ndb/src/kernel/vm/Configuration.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DLCFifoList.hpp b/storage/ndb/src/kernel/vm/DLCFifoList.hpp index ce9e422ebd6..bbd8472aaf3 100644 --- a/storage/ndb/src/kernel/vm/DLCFifoList.hpp +++ b/storage/ndb/src/kernel/vm/DLCFifoList.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DLCHashTable.hpp b/storage/ndb/src/kernel/vm/DLCHashTable.hpp index b8229b449c7..dceb0735a3c 100644 --- a/storage/ndb/src/kernel/vm/DLCHashTable.hpp +++ b/storage/ndb/src/kernel/vm/DLCHashTable.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DLFifoList.hpp b/storage/ndb/src/kernel/vm/DLFifoList.hpp index da92390dd8f..24c326e2d39 100644 --- a/storage/ndb/src/kernel/vm/DLFifoList.hpp +++ b/storage/ndb/src/kernel/vm/DLFifoList.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DLHashTable.hpp b/storage/ndb/src/kernel/vm/DLHashTable.hpp index b9d5f7c597f..b5beae8123b 100644 --- a/storage/ndb/src/kernel/vm/DLHashTable.hpp +++ b/storage/ndb/src/kernel/vm/DLHashTable.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DLHashTable2.hpp b/storage/ndb/src/kernel/vm/DLHashTable2.hpp index 05340317adb..100acdc480c 100644 --- a/storage/ndb/src/kernel/vm/DLHashTable2.hpp +++ b/storage/ndb/src/kernel/vm/DLHashTable2.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DLList.hpp b/storage/ndb/src/kernel/vm/DLList.hpp index 7184cfb6b9e..84253774155 100644 --- a/storage/ndb/src/kernel/vm/DLList.hpp +++ b/storage/ndb/src/kernel/vm/DLList.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DataBuffer.hpp b/storage/ndb/src/kernel/vm/DataBuffer.hpp index cb9d6a85c88..b9fe50f843e 100644 --- a/storage/ndb/src/kernel/vm/DataBuffer.hpp +++ b/storage/ndb/src/kernel/vm/DataBuffer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DynArr256.cpp b/storage/ndb/src/kernel/vm/DynArr256.cpp index 4e73bb8830b..6146d0663a4 100644 --- a/storage/ndb/src/kernel/vm/DynArr256.cpp +++ b/storage/ndb/src/kernel/vm/DynArr256.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/DynArr256.hpp b/storage/ndb/src/kernel/vm/DynArr256.hpp index 780dee7e4bf..187bcc7c895 100644 --- a/storage/ndb/src/kernel/vm/DynArr256.hpp +++ b/storage/ndb/src/kernel/vm/DynArr256.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Emulator.cpp b/storage/ndb/src/kernel/vm/Emulator.cpp index e706dff154a..f99b9ca4eca 100644 --- a/storage/ndb/src/kernel/vm/Emulator.cpp +++ b/storage/ndb/src/kernel/vm/Emulator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Emulator.hpp b/storage/ndb/src/kernel/vm/Emulator.hpp index 1ef98b72efb..dbb46939d37 100644 --- a/storage/ndb/src/kernel/vm/Emulator.hpp +++ b/storage/ndb/src/kernel/vm/Emulator.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/FastScheduler.cpp b/storage/ndb/src/kernel/vm/FastScheduler.cpp index 588887d1f63..db0a8e8e6cf 100644 --- a/storage/ndb/src/kernel/vm/FastScheduler.cpp +++ b/storage/ndb/src/kernel/vm/FastScheduler.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/FastScheduler.hpp b/storage/ndb/src/kernel/vm/FastScheduler.hpp index 0151007ea3e..851bd531f55 100644 --- a/storage/ndb/src/kernel/vm/FastScheduler.hpp +++ b/storage/ndb/src/kernel/vm/FastScheduler.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/GlobalData.hpp b/storage/ndb/src/kernel/vm/GlobalData.hpp index 51fdd21ed84..a33c51ca1fc 100644 --- a/storage/ndb/src/kernel/vm/GlobalData.hpp +++ b/storage/ndb/src/kernel/vm/GlobalData.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/KeyDescriptor.hpp b/storage/ndb/src/kernel/vm/KeyDescriptor.hpp index bab1316ae4a..14e44b34ebe 100644 --- a/storage/ndb/src/kernel/vm/KeyDescriptor.hpp +++ b/storage/ndb/src/kernel/vm/KeyDescriptor.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/KeyTable.hpp b/storage/ndb/src/kernel/vm/KeyTable.hpp index 56dbdc698b2..9653327c253 100644 --- a/storage/ndb/src/kernel/vm/KeyTable.hpp +++ b/storage/ndb/src/kernel/vm/KeyTable.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/KeyTable2.hpp b/storage/ndb/src/kernel/vm/KeyTable2.hpp index e781d10c92e..fb3f781ab4b 100644 --- a/storage/ndb/src/kernel/vm/KeyTable2.hpp +++ b/storage/ndb/src/kernel/vm/KeyTable2.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/KeyTable2Ref.hpp b/storage/ndb/src/kernel/vm/KeyTable2Ref.hpp index 3d8bd00e2e2..9a618f985d1 100644 --- a/storage/ndb/src/kernel/vm/KeyTable2Ref.hpp +++ b/storage/ndb/src/kernel/vm/KeyTable2Ref.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/LinearPool.hpp b/storage/ndb/src/kernel/vm/LinearPool.hpp index 49de4533f32..6368445fd9a 100644 --- a/storage/ndb/src/kernel/vm/LinearPool.hpp +++ b/storage/ndb/src/kernel/vm/LinearPool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/LongSignal.hpp b/storage/ndb/src/kernel/vm/LongSignal.hpp index dc2c8bd31d3..6536a40f3cc 100644 --- a/storage/ndb/src/kernel/vm/LongSignal.hpp +++ b/storage/ndb/src/kernel/vm/LongSignal.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Makefile.am b/storage/ndb/src/kernel/vm/Makefile.am index 4964b4ea85a..1fc28685210 100644 --- a/storage/ndb/src/kernel/vm/Makefile.am +++ b/storage/ndb/src/kernel/vm/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Mutex.cpp b/storage/ndb/src/kernel/vm/Mutex.cpp index 250eff19b64..c6614774555 100644 --- a/storage/ndb/src/kernel/vm/Mutex.cpp +++ b/storage/ndb/src/kernel/vm/Mutex.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Mutex.hpp b/storage/ndb/src/kernel/vm/Mutex.hpp index ec177a75707..5817e426057 100644 --- a/storage/ndb/src/kernel/vm/Mutex.hpp +++ b/storage/ndb/src/kernel/vm/Mutex.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/NdbdSuperPool.cpp b/storage/ndb/src/kernel/vm/NdbdSuperPool.cpp index 717c354a180..c5f0a94c2b3 100644 --- a/storage/ndb/src/kernel/vm/NdbdSuperPool.cpp +++ b/storage/ndb/src/kernel/vm/NdbdSuperPool.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/NdbdSuperPool.hpp b/storage/ndb/src/kernel/vm/NdbdSuperPool.hpp index 2e9287e5ab1..a59e75802ba 100644 --- a/storage/ndb/src/kernel/vm/NdbdSuperPool.hpp +++ b/storage/ndb/src/kernel/vm/NdbdSuperPool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Pool.cpp b/storage/ndb/src/kernel/vm/Pool.cpp index f252a601ac2..4226a5d935e 100644 --- a/storage/ndb/src/kernel/vm/Pool.cpp +++ b/storage/ndb/src/kernel/vm/Pool.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Pool.hpp b/storage/ndb/src/kernel/vm/Pool.hpp index a4e062078fb..608c7327d6c 100644 --- a/storage/ndb/src/kernel/vm/Pool.hpp +++ b/storage/ndb/src/kernel/vm/Pool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Prio.hpp b/storage/ndb/src/kernel/vm/Prio.hpp index 3f14a3a6c74..3a958572682 100644 --- a/storage/ndb/src/kernel/vm/Prio.hpp +++ b/storage/ndb/src/kernel/vm/Prio.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/RWPool.cpp b/storage/ndb/src/kernel/vm/RWPool.cpp index 056b2149e2a..a3693749040 100644 --- a/storage/ndb/src/kernel/vm/RWPool.cpp +++ b/storage/ndb/src/kernel/vm/RWPool.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/RWPool.hpp b/storage/ndb/src/kernel/vm/RWPool.hpp index 13001b4d9dc..f65219a3268 100644 --- a/storage/ndb/src/kernel/vm/RWPool.hpp +++ b/storage/ndb/src/kernel/vm/RWPool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/RequestTracker.hpp b/storage/ndb/src/kernel/vm/RequestTracker.hpp index cfd2a413231..5379833c8a0 100644 --- a/storage/ndb/src/kernel/vm/RequestTracker.hpp +++ b/storage/ndb/src/kernel/vm/RequestTracker.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Rope.cpp b/storage/ndb/src/kernel/vm/Rope.cpp index 35812845668..ea4c6703570 100644 --- a/storage/ndb/src/kernel/vm/Rope.cpp +++ b/storage/ndb/src/kernel/vm/Rope.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/Rope.hpp b/storage/ndb/src/kernel/vm/Rope.hpp index 6cd7f962cc7..4fe8bd197f4 100644 --- a/storage/ndb/src/kernel/vm/Rope.hpp +++ b/storage/ndb/src/kernel/vm/Rope.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SLFifoList.hpp b/storage/ndb/src/kernel/vm/SLFifoList.hpp index 7bd4baca515..d85bef39b12 100644 --- a/storage/ndb/src/kernel/vm/SLFifoList.hpp +++ b/storage/ndb/src/kernel/vm/SLFifoList.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SLList.hpp b/storage/ndb/src/kernel/vm/SLList.hpp index f4e9440d078..5c451feb4db 100644 --- a/storage/ndb/src/kernel/vm/SLList.hpp +++ b/storage/ndb/src/kernel/vm/SLList.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SafeCounter.cpp b/storage/ndb/src/kernel/vm/SafeCounter.cpp index 1623514f8f4..044db0048eb 100644 --- a/storage/ndb/src/kernel/vm/SafeCounter.cpp +++ b/storage/ndb/src/kernel/vm/SafeCounter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SafeCounter.hpp b/storage/ndb/src/kernel/vm/SafeCounter.hpp index 093fd25c296..62d82663f70 100644 --- a/storage/ndb/src/kernel/vm/SafeCounter.hpp +++ b/storage/ndb/src/kernel/vm/SafeCounter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SectionReader.cpp b/storage/ndb/src/kernel/vm/SectionReader.cpp index 44d70c2ec16..a05b9ec1c3c 100644 --- a/storage/ndb/src/kernel/vm/SectionReader.cpp +++ b/storage/ndb/src/kernel/vm/SectionReader.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SectionReader.hpp b/storage/ndb/src/kernel/vm/SectionReader.hpp index 6297b08f76a..bbf60ce7519 100644 --- a/storage/ndb/src/kernel/vm/SectionReader.hpp +++ b/storage/ndb/src/kernel/vm/SectionReader.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SignalCounter.hpp b/storage/ndb/src/kernel/vm/SignalCounter.hpp index b72c88cbf29..5f968eae489 100644 --- a/storage/ndb/src/kernel/vm/SignalCounter.hpp +++ b/storage/ndb/src/kernel/vm/SignalCounter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SimBlockList.hpp b/storage/ndb/src/kernel/vm/SimBlockList.hpp index b820a53c026..7886ca7cabb 100644 --- a/storage/ndb/src/kernel/vm/SimBlockList.hpp +++ b/storage/ndb/src/kernel/vm/SimBlockList.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SimplePropertiesSection.cpp b/storage/ndb/src/kernel/vm/SimplePropertiesSection.cpp index 1159ddd9ca7..9145d9c6d8d 100644 --- a/storage/ndb/src/kernel/vm/SimplePropertiesSection.cpp +++ b/storage/ndb/src/kernel/vm/SimplePropertiesSection.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp index 2963b8a02ad..807d22aec49 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp index 31f219718e5..00bcf1277d8 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SuperPool.cpp b/storage/ndb/src/kernel/vm/SuperPool.cpp index ddaff73b289..98eede0b37f 100644 --- a/storage/ndb/src/kernel/vm/SuperPool.cpp +++ b/storage/ndb/src/kernel/vm/SuperPool.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/SuperPool.hpp b/storage/ndb/src/kernel/vm/SuperPool.hpp index 8fc6fc4ca80..d8c94c7aa0b 100644 --- a/storage/ndb/src/kernel/vm/SuperPool.hpp +++ b/storage/ndb/src/kernel/vm/SuperPool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ThreadConfig.cpp b/storage/ndb/src/kernel/vm/ThreadConfig.cpp index 935e489da7c..a22e751b472 100644 --- a/storage/ndb/src/kernel/vm/ThreadConfig.cpp +++ b/storage/ndb/src/kernel/vm/ThreadConfig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ThreadConfig.hpp b/storage/ndb/src/kernel/vm/ThreadConfig.hpp index 64b22e46025..cfdb0c58d7e 100644 --- a/storage/ndb/src/kernel/vm/ThreadConfig.hpp +++ b/storage/ndb/src/kernel/vm/ThreadConfig.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/TimeQueue.cpp b/storage/ndb/src/kernel/vm/TimeQueue.cpp index bb8c7a74edf..403a148c173 100644 --- a/storage/ndb/src/kernel/vm/TimeQueue.cpp +++ b/storage/ndb/src/kernel/vm/TimeQueue.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/TimeQueue.hpp b/storage/ndb/src/kernel/vm/TimeQueue.hpp index 53e9c6ef95e..a60fb302aab 100644 --- a/storage/ndb/src/kernel/vm/TimeQueue.hpp +++ b/storage/ndb/src/kernel/vm/TimeQueue.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/TransporterCallback.cpp b/storage/ndb/src/kernel/vm/TransporterCallback.cpp index 398b7965156..4a28b572db8 100644 --- a/storage/ndb/src/kernel/vm/TransporterCallback.cpp +++ b/storage/ndb/src/kernel/vm/TransporterCallback.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/VMSignal.cpp b/storage/ndb/src/kernel/vm/VMSignal.cpp index cee9aa2911b..c500a6872e8 100644 --- a/storage/ndb/src/kernel/vm/VMSignal.cpp +++ b/storage/ndb/src/kernel/vm/VMSignal.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/VMSignal.hpp b/storage/ndb/src/kernel/vm/VMSignal.hpp index e92335dbfa2..21db10915ab 100644 --- a/storage/ndb/src/kernel/vm/VMSignal.hpp +++ b/storage/ndb/src/kernel/vm/VMSignal.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/WOPool.cpp b/storage/ndb/src/kernel/vm/WOPool.cpp index e318001da30..b2fa59c527b 100644 --- a/storage/ndb/src/kernel/vm/WOPool.cpp +++ b/storage/ndb/src/kernel/vm/WOPool.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/WOPool.hpp b/storage/ndb/src/kernel/vm/WOPool.hpp index f38716b98f3..bbda9185e74 100644 --- a/storage/ndb/src/kernel/vm/WOPool.hpp +++ b/storage/ndb/src/kernel/vm/WOPool.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/WaitQueue.hpp b/storage/ndb/src/kernel/vm/WaitQueue.hpp index fd9bf366d2a..1f965bc64c5 100644 --- a/storage/ndb/src/kernel/vm/WaitQueue.hpp +++ b/storage/ndb/src/kernel/vm/WaitQueue.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/WatchDog.cpp b/storage/ndb/src/kernel/vm/WatchDog.cpp index a7f5e8f5c2b..ff9a32688b1 100644 --- a/storage/ndb/src/kernel/vm/WatchDog.cpp +++ b/storage/ndb/src/kernel/vm/WatchDog.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/WatchDog.hpp b/storage/ndb/src/kernel/vm/WatchDog.hpp index 1d91c2451c3..ab11d2eec8d 100644 --- a/storage/ndb/src/kernel/vm/WatchDog.hpp +++ b/storage/ndb/src/kernel/vm/WatchDog.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/al_test/arrayListTest.cpp b/storage/ndb/src/kernel/vm/al_test/arrayListTest.cpp index 08a73084d53..c8381368704 100644 --- a/storage/ndb/src/kernel/vm/al_test/arrayListTest.cpp +++ b/storage/ndb/src/kernel/vm/al_test/arrayListTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/al_test/arrayPoolTest.cpp b/storage/ndb/src/kernel/vm/al_test/arrayPoolTest.cpp index 835b35994ce..dbc7acb16ef 100644 --- a/storage/ndb/src/kernel/vm/al_test/arrayPoolTest.cpp +++ b/storage/ndb/src/kernel/vm/al_test/arrayPoolTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/al_test/main.cpp b/storage/ndb/src/kernel/vm/al_test/main.cpp index efdc16b1cbc..84715d7a808 100644 --- a/storage/ndb/src/kernel/vm/al_test/main.cpp +++ b/storage/ndb/src/kernel/vm/al_test/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/bench_pool.cpp b/storage/ndb/src/kernel/vm/bench_pool.cpp index dab4078fefc..0736e8d5743 100644 --- a/storage/ndb/src/kernel/vm/bench_pool.cpp +++ b/storage/ndb/src/kernel/vm/bench_pool.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ndbd_malloc.cpp b/storage/ndb/src/kernel/vm/ndbd_malloc.cpp index 21a26ff11d8..d85a7a77fea 100644 --- a/storage/ndb/src/kernel/vm/ndbd_malloc.cpp +++ b/storage/ndb/src/kernel/vm/ndbd_malloc.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ndbd_malloc.hpp b/storage/ndb/src/kernel/vm/ndbd_malloc.hpp index dbdd6b53a0e..19b183a5cfd 100644 --- a/storage/ndb/src/kernel/vm/ndbd_malloc.hpp +++ b/storage/ndb/src/kernel/vm/ndbd_malloc.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp b/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp index e2100e66baa..b223e6991dc 100644 --- a/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp +++ b/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp b/storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp index 78e41f1cabd..290a625075b 100644 --- a/storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp +++ b/storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/pc.hpp b/storage/ndb/src/kernel/vm/pc.hpp index cf03f676ae1..ed7291e174f 100644 --- a/storage/ndb/src/kernel/vm/pc.hpp +++ b/storage/ndb/src/kernel/vm/pc.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/testCopy/rr.cpp b/storage/ndb/src/kernel/vm/testCopy/rr.cpp index 362cd1d5136..a8527aca8a1 100644 --- a/storage/ndb/src/kernel/vm/testCopy/rr.cpp +++ b/storage/ndb/src/kernel/vm/testCopy/rr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/testCopy/testCopy.cpp b/storage/ndb/src/kernel/vm/testCopy/testCopy.cpp index 521f93f4df5..4c3e8b5e871 100644 --- a/storage/ndb/src/kernel/vm/testCopy/testCopy.cpp +++ b/storage/ndb/src/kernel/vm/testCopy/testCopy.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp b/storage/ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp index 1ebdd4c176b..04d89ad6517 100644 --- a/storage/ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp +++ b/storage/ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/testLongSig/testLongSig.cpp b/storage/ndb/src/kernel/vm/testLongSig/testLongSig.cpp index 0d2a0e80113..e837fd28573 100644 --- a/storage/ndb/src/kernel/vm/testLongSig/testLongSig.cpp +++ b/storage/ndb/src/kernel/vm/testLongSig/testLongSig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/testSimplePropertiesSection/test.cpp b/storage/ndb/src/kernel/vm/testSimplePropertiesSection/test.cpp index feabe769a31..57744bc731b 100644 --- a/storage/ndb/src/kernel/vm/testSimplePropertiesSection/test.cpp +++ b/storage/ndb/src/kernel/vm/testSimplePropertiesSection/test.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/kernel/vm/testSuperPool.cpp b/storage/ndb/src/kernel/vm/testSuperPool.cpp index 5ee13681901..a925a78a6b9 100644 --- a/storage/ndb/src/kernel/vm/testSuperPool.cpp +++ b/storage/ndb/src/kernel/vm/testSuperPool.cpp @@ -6,7 +6,7 @@ _eof_ exit $? #endif -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/LocalConfig.cpp b/storage/ndb/src/mgmapi/LocalConfig.cpp index 476e2d6dd84..0f746364f07 100644 --- a/storage/ndb/src/mgmapi/LocalConfig.cpp +++ b/storage/ndb/src/mgmapi/LocalConfig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/LocalConfig.hpp b/storage/ndb/src/mgmapi/LocalConfig.hpp index 7a583077913..dee4a40731f 100644 --- a/storage/ndb/src/mgmapi/LocalConfig.hpp +++ b/storage/ndb/src/mgmapi/LocalConfig.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/Makefile.am b/storage/ndb/src/mgmapi/Makefile.am index 96ee65d7d9e..65e9692797f 100644 --- a/storage/ndb/src/mgmapi/Makefile.am +++ b/storage/ndb/src/mgmapi/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp index 662e5c22f48..d69ced68e01 100644 --- a/storage/ndb/src/mgmapi/mgmapi.cpp +++ b/storage/ndb/src/mgmapi/mgmapi.cpp @@ -1,4 +1,4 @@ - /* Copyright (C) 2003 MySQL AB + /* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/mgmapi_configuration.cpp b/storage/ndb/src/mgmapi/mgmapi_configuration.cpp index 553b079a22f..018400d64c5 100644 --- a/storage/ndb/src/mgmapi/mgmapi_configuration.cpp +++ b/storage/ndb/src/mgmapi/mgmapi_configuration.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2005 MySQL AB +/* Copyright (c) 2004-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/mgmapi_configuration.hpp b/storage/ndb/src/mgmapi/mgmapi_configuration.hpp index 6088114016e..fd88ffaaa1b 100644 --- a/storage/ndb/src/mgmapi/mgmapi_configuration.hpp +++ b/storage/ndb/src/mgmapi/mgmapi_configuration.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/mgmapi_internal.h b/storage/ndb/src/mgmapi/mgmapi_internal.h index 192bc57afd9..9223b8b3b71 100644 --- a/storage/ndb/src/mgmapi/mgmapi_internal.h +++ b/storage/ndb/src/mgmapi/mgmapi_internal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/ndb_logevent.cpp b/storage/ndb/src/mgmapi/ndb_logevent.cpp index fbf026fd79d..445815c6267 100644 --- a/storage/ndb/src/mgmapi/ndb_logevent.cpp +++ b/storage/ndb/src/mgmapi/ndb_logevent.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/ndb_logevent.hpp b/storage/ndb/src/mgmapi/ndb_logevent.hpp index df0a657e9b1..db4a3a621fa 100644 --- a/storage/ndb/src/mgmapi/ndb_logevent.hpp +++ b/storage/ndb/src/mgmapi/ndb_logevent.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/test/keso.c b/storage/ndb/src/mgmapi/test/keso.c index 922bace6b91..0ef3de50bde 100644 --- a/storage/ndb/src/mgmapi/test/keso.c +++ b/storage/ndb/src/mgmapi/test/keso.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmapi/test/mgmSrvApi.cpp b/storage/ndb/src/mgmapi/test/mgmSrvApi.cpp index 5a8acbfadc5..c7ff6b3d7a5 100644 --- a/storage/ndb/src/mgmapi/test/mgmSrvApi.cpp +++ b/storage/ndb/src/mgmapi/test/mgmSrvApi.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp index 7057525efc7..fd8ea851021 100644 --- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmclient/Makefile.am b/storage/ndb/src/mgmclient/Makefile.am index 41f659cf68d..c0e97b519ab 100644 --- a/storage/ndb/src/mgmclient/Makefile.am +++ b/storage/ndb/src/mgmclient/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmclient/main.cpp b/storage/ndb/src/mgmclient/main.cpp index fbd81c71700..593b6a9842a 100644 --- a/storage/ndb/src/mgmclient/main.cpp +++ b/storage/ndb/src/mgmclient/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmclient/ndb_mgmclient.h b/storage/ndb/src/mgmclient/ndb_mgmclient.h index edb57e25ccb..d4247871c41 100644 --- a/storage/ndb/src/mgmclient/ndb_mgmclient.h +++ b/storage/ndb/src/mgmclient/ndb_mgmclient.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmclient/ndb_mgmclient.hpp b/storage/ndb/src/mgmclient/ndb_mgmclient.hpp index e21f57ba323..5b20c7072c5 100644 --- a/storage/ndb/src/mgmclient/ndb_mgmclient.hpp +++ b/storage/ndb/src/mgmclient/ndb_mgmclient.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmclient/test_cpcd/test_cpcd.cpp b/storage/ndb/src/mgmclient/test_cpcd/test_cpcd.cpp index b70d75e5fbe..1b5122f6bbe 100644 --- a/storage/ndb/src/mgmclient/test_cpcd/test_cpcd.cpp +++ b/storage/ndb/src/mgmclient/test_cpcd/test_cpcd.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/Config.cpp b/storage/ndb/src/mgmsrv/Config.cpp index 0bbf3580b5c..82bfaf5f0c7 100644 --- a/storage/ndb/src/mgmsrv/Config.cpp +++ b/storage/ndb/src/mgmsrv/Config.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/Config.hpp b/storage/ndb/src/mgmsrv/Config.hpp index dd052b264d7..4c75b956d4a 100644 --- a/storage/ndb/src/mgmsrv/Config.hpp +++ b/storage/ndb/src/mgmsrv/Config.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp index 6e560ff2701..813a27e7590 100644 --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.hpp b/storage/ndb/src/mgmsrv/ConfigInfo.hpp index 94543dbdc5e..d0ba44e77fd 100644 --- a/storage/ndb/src/mgmsrv/ConfigInfo.hpp +++ b/storage/ndb/src/mgmsrv/ConfigInfo.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/InitConfigFileParser.hpp b/storage/ndb/src/mgmsrv/InitConfigFileParser.hpp index 64ccead1d33..7703b8526c5 100644 --- a/storage/ndb/src/mgmsrv/InitConfigFileParser.hpp +++ b/storage/ndb/src/mgmsrv/InitConfigFileParser.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp index 184d51bad78..4d916fad9b9 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp index 90287554ef8..564a70e37f7 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp b/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp index cc101eacc22..0f713bbb95a 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/MgmtSrvrGeneralSignalHandling.cpp b/storage/ndb/src/mgmsrv/MgmtSrvrGeneralSignalHandling.cpp index a8fd443497f..92cd03a35cd 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvrGeneralSignalHandling.cpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvrGeneralSignalHandling.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/Services.cpp b/storage/ndb/src/mgmsrv/Services.cpp index eeae61025b1..5d28f33697e 100644 --- a/storage/ndb/src/mgmsrv/Services.cpp +++ b/storage/ndb/src/mgmsrv/Services.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/Services.hpp b/storage/ndb/src/mgmsrv/Services.hpp index 76f839e3aab..e417fabd9af 100644 --- a/storage/ndb/src/mgmsrv/Services.hpp +++ b/storage/ndb/src/mgmsrv/Services.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/SignalQueue.cpp b/storage/ndb/src/mgmsrv/SignalQueue.cpp index d1c29dc617d..08bf1c05906 100644 --- a/storage/ndb/src/mgmsrv/SignalQueue.cpp +++ b/storage/ndb/src/mgmsrv/SignalQueue.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/SignalQueue.hpp b/storage/ndb/src/mgmsrv/SignalQueue.hpp index cb0ed2e4ea1..78f5b0bfb8c 100644 --- a/storage/ndb/src/mgmsrv/SignalQueue.hpp +++ b/storage/ndb/src/mgmsrv/SignalQueue.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/convertStrToInt.cpp b/storage/ndb/src/mgmsrv/convertStrToInt.cpp index 4622a76e3db..75cb5f3f863 100644 --- a/storage/ndb/src/mgmsrv/convertStrToInt.cpp +++ b/storage/ndb/src/mgmsrv/convertStrToInt.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/convertStrToInt.hpp b/storage/ndb/src/mgmsrv/convertStrToInt.hpp index 163f8198932..3f4e79f1cde 100644 --- a/storage/ndb/src/mgmsrv/convertStrToInt.hpp +++ b/storage/ndb/src/mgmsrv/convertStrToInt.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/main.cpp b/storage/ndb/src/mgmsrv/main.cpp index 16c560868ef..09fae66997e 100644 --- a/storage/ndb/src/mgmsrv/main.cpp +++ b/storage/ndb/src/mgmsrv/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/mgmsrv/mkconfig/mkconfig.cpp b/storage/ndb/src/mgmsrv/mkconfig/mkconfig.cpp index 5e8a03aacd1..e4a5baeab6f 100644 --- a/storage/ndb/src/mgmsrv/mkconfig/mkconfig.cpp +++ b/storage/ndb/src/mgmsrv/mkconfig/mkconfig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/API.hpp b/storage/ndb/src/ndbapi/API.hpp index ca8473d99d8..7731c4d137a 100644 --- a/storage/ndb/src/ndbapi/API.hpp +++ b/storage/ndb/src/ndbapi/API.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/ClusterMgr.cpp b/storage/ndb/src/ndbapi/ClusterMgr.cpp index f5cc44f70d7..91d92551304 100644 --- a/storage/ndb/src/ndbapi/ClusterMgr.cpp +++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/ClusterMgr.hpp b/storage/ndb/src/ndbapi/ClusterMgr.hpp index 0a261eb202f..a8be500de71 100644 --- a/storage/ndb/src/ndbapi/ClusterMgr.hpp +++ b/storage/ndb/src/ndbapi/ClusterMgr.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/DictCache.hpp b/storage/ndb/src/ndbapi/DictCache.hpp index 9250ec7b196..ed0f33e726b 100644 --- a/storage/ndb/src/ndbapi/DictCache.hpp +++ b/storage/ndb/src/ndbapi/DictCache.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/Makefile.am b/storage/ndb/src/ndbapi/Makefile.am index 8ff427772b0..83b7f88a682 100644 --- a/storage/ndb/src/ndbapi/Makefile.am +++ b/storage/ndb/src/ndbapi/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/Ndb.cpp b/storage/ndb/src/ndbapi/Ndb.cpp index e6a1c2cfcfd..2c9a0274581 100644 --- a/storage/ndb/src/ndbapi/Ndb.cpp +++ b/storage/ndb/src/ndbapi/Ndb.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbApiSignal.cpp b/storage/ndb/src/ndbapi/NdbApiSignal.cpp index b19b112ee2c..524851ddeb0 100644 --- a/storage/ndb/src/ndbapi/NdbApiSignal.cpp +++ b/storage/ndb/src/ndbapi/NdbApiSignal.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbApiSignal.hpp b/storage/ndb/src/ndbapi/NdbApiSignal.hpp index bd07f2665bf..8fe96cd724f 100644 --- a/storage/ndb/src/ndbapi/NdbApiSignal.hpp +++ b/storage/ndb/src/ndbapi/NdbApiSignal.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbBlob.cpp b/storage/ndb/src/ndbapi/NdbBlob.cpp index f3d1dbe3dd1..19a28b44d73 100644 --- a/storage/ndb/src/ndbapi/NdbBlob.cpp +++ b/storage/ndb/src/ndbapi/NdbBlob.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbBlobImpl.hpp b/storage/ndb/src/ndbapi/NdbBlobImpl.hpp index 74e3473d3c4..7fedafab68a 100644 --- a/storage/ndb/src/ndbapi/NdbBlobImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbBlobImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbDictionary.cpp b/storage/ndb/src/ndbapi/NdbDictionary.cpp index a4395fc4b9c..ae6c2367329 100644 --- a/storage/ndb/src/ndbapi/NdbDictionary.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionary.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 0d226a97621..cebb62f7d7c 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp index aa9bd174471..02fabfe5c88 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbErrorOut.cpp b/storage/ndb/src/ndbapi/NdbErrorOut.cpp index 703abbb8c9e..8201c302ecd 100644 --- a/storage/ndb/src/ndbapi/NdbErrorOut.cpp +++ b/storage/ndb/src/ndbapi/NdbErrorOut.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbImpl.hpp b/storage/ndb/src/ndbapi/NdbImpl.hpp index 39787b1d4be..8f3edda9b9b 100644 --- a/storage/ndb/src/ndbapi/NdbImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbIndexOperation.cpp b/storage/ndb/src/ndbapi/NdbIndexOperation.cpp index 921769f09e3..70893dc4f76 100644 --- a/storage/ndb/src/ndbapi/NdbIndexOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbIndexOperation.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbIndexStat.cpp b/storage/ndb/src/ndbapi/NdbIndexStat.cpp index 0ce96b1b4d9..68c99a039bf 100644 --- a/storage/ndb/src/ndbapi/NdbIndexStat.cpp +++ b/storage/ndb/src/ndbapi/NdbIndexStat.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbLinHash.hpp b/storage/ndb/src/ndbapi/NdbLinHash.hpp index f0399d30233..0e7ae6c42f6 100644 --- a/storage/ndb/src/ndbapi/NdbLinHash.hpp +++ b/storage/ndb/src/ndbapi/NdbLinHash.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbOperation.cpp b/storage/ndb/src/ndbapi/NdbOperation.cpp index ddaf5d0b233..7f737e63926 100644 --- a/storage/ndb/src/ndbapi/NdbOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbOperation.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbOperationDefine.cpp b/storage/ndb/src/ndbapi/NdbOperationDefine.cpp index 21a6185347e..f12a7dfc2f9 100644 --- a/storage/ndb/src/ndbapi/NdbOperationDefine.cpp +++ b/storage/ndb/src/ndbapi/NdbOperationDefine.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbOperationExec.cpp b/storage/ndb/src/ndbapi/NdbOperationExec.cpp index cd1ac44d82c..9d4c66df384 100644 --- a/storage/ndb/src/ndbapi/NdbOperationExec.cpp +++ b/storage/ndb/src/ndbapi/NdbOperationExec.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbOperationInt.cpp b/storage/ndb/src/ndbapi/NdbOperationInt.cpp index f69211cb78b..3debcea5eac 100644 --- a/storage/ndb/src/ndbapi/NdbOperationInt.cpp +++ b/storage/ndb/src/ndbapi/NdbOperationInt.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbOperationScan.cpp b/storage/ndb/src/ndbapi/NdbOperationScan.cpp index aad24159455..208e84b61b4 100644 --- a/storage/ndb/src/ndbapi/NdbOperationScan.cpp +++ b/storage/ndb/src/ndbapi/NdbOperationScan.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbOperationSearch.cpp b/storage/ndb/src/ndbapi/NdbOperationSearch.cpp index 605c66d9859..11c72da4d32 100644 --- a/storage/ndb/src/ndbapi/NdbOperationSearch.cpp +++ b/storage/ndb/src/ndbapi/NdbOperationSearch.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbPool.cpp b/storage/ndb/src/ndbapi/NdbPool.cpp index 9a83cade52b..cf09a4b1634 100644 --- a/storage/ndb/src/ndbapi/NdbPool.cpp +++ b/storage/ndb/src/ndbapi/NdbPool.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbPoolImpl.cpp b/storage/ndb/src/ndbapi/NdbPoolImpl.cpp index e5d1b000601..b9c6b293422 100644 --- a/storage/ndb/src/ndbapi/NdbPoolImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbPoolImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbPoolImpl.hpp b/storage/ndb/src/ndbapi/NdbPoolImpl.hpp index f4dbaf009cb..1f7a45f5625 100644 --- a/storage/ndb/src/ndbapi/NdbPoolImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbPoolImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbRecAttr.cpp b/storage/ndb/src/ndbapi/NdbRecAttr.cpp index 38ca14085f0..7acedf7078e 100644 --- a/storage/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/storage/ndb/src/ndbapi/NdbRecAttr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbReceiver.cpp b/storage/ndb/src/ndbapi/NdbReceiver.cpp index 5a311bcbefe..4fab9944a5f 100644 --- a/storage/ndb/src/ndbapi/NdbReceiver.cpp +++ b/storage/ndb/src/ndbapi/NdbReceiver.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbScanFilter.cpp b/storage/ndb/src/ndbapi/NdbScanFilter.cpp index 25f74ce71a4..f361c8e1e6f 100644 --- a/storage/ndb/src/ndbapi/NdbScanFilter.cpp +++ b/storage/ndb/src/ndbapi/NdbScanFilter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbScanOperation.cpp b/storage/ndb/src/ndbapi/NdbScanOperation.cpp index 96a3ce4332e..30ebd34b36c 100644 --- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbTransaction.cpp b/storage/ndb/src/ndbapi/NdbTransaction.cpp index 17c7188bff2..d7baa75925f 100644 --- a/storage/ndb/src/ndbapi/NdbTransaction.cpp +++ b/storage/ndb/src/ndbapi/NdbTransaction.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbTransactionScan.cpp b/storage/ndb/src/ndbapi/NdbTransactionScan.cpp index a2bbf45fbb5..ed7ffbd34b2 100644 --- a/storage/ndb/src/ndbapi/NdbTransactionScan.cpp +++ b/storage/ndb/src/ndbapi/NdbTransactionScan.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbUtil.cpp b/storage/ndb/src/ndbapi/NdbUtil.cpp index c0087e51777..8ba04c55cce 100644 --- a/storage/ndb/src/ndbapi/NdbUtil.cpp +++ b/storage/ndb/src/ndbapi/NdbUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbUtil.hpp b/storage/ndb/src/ndbapi/NdbUtil.hpp index f76b21cfceb..9332ed3927c 100644 --- a/storage/ndb/src/ndbapi/NdbUtil.hpp +++ b/storage/ndb/src/ndbapi/NdbUtil.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/NdbWaiter.hpp b/storage/ndb/src/ndbapi/NdbWaiter.hpp index 8a82564dbac..826511f690e 100644 --- a/storage/ndb/src/ndbapi/NdbWaiter.hpp +++ b/storage/ndb/src/ndbapi/NdbWaiter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. diff --git a/storage/ndb/src/ndbapi/Ndberr.cpp b/storage/ndb/src/ndbapi/Ndberr.cpp index 8fda3887cc1..a1d95de7f43 100644 --- a/storage/ndb/src/ndbapi/Ndberr.cpp +++ b/storage/ndb/src/ndbapi/Ndberr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/Ndbif.cpp b/storage/ndb/src/ndbapi/Ndbif.cpp index aa50a87dea8..212b25fb2ab 100644 --- a/storage/ndb/src/ndbapi/Ndbif.cpp +++ b/storage/ndb/src/ndbapi/Ndbif.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/Ndbinit.cpp b/storage/ndb/src/ndbapi/Ndbinit.cpp index 1863aff8136..7ed7ae9b7d2 100644 --- a/storage/ndb/src/ndbapi/Ndbinit.cpp +++ b/storage/ndb/src/ndbapi/Ndbinit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/Ndblist.cpp b/storage/ndb/src/ndbapi/Ndblist.cpp index a9e9124edd0..ed1ddf3e30f 100644 --- a/storage/ndb/src/ndbapi/Ndblist.cpp +++ b/storage/ndb/src/ndbapi/Ndblist.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/ObjectMap.cpp b/storage/ndb/src/ndbapi/ObjectMap.cpp index c87911a10d4..69faa2da610 100644 --- a/storage/ndb/src/ndbapi/ObjectMap.cpp +++ b/storage/ndb/src/ndbapi/ObjectMap.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/ObjectMap.hpp b/storage/ndb/src/ndbapi/ObjectMap.hpp index bc171649840..929e8b17799 100644 --- a/storage/ndb/src/ndbapi/ObjectMap.hpp +++ b/storage/ndb/src/ndbapi/ObjectMap.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/SignalSender.cpp b/storage/ndb/src/ndbapi/SignalSender.cpp index 70e65200942..c3b2f9f0a17 100644 --- a/storage/ndb/src/ndbapi/SignalSender.cpp +++ b/storage/ndb/src/ndbapi/SignalSender.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/SignalSender.hpp b/storage/ndb/src/ndbapi/SignalSender.hpp index 4cad759a334..77ad95f9c89 100644 --- a/storage/ndb/src/ndbapi/SignalSender.hpp +++ b/storage/ndb/src/ndbapi/SignalSender.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/TransporterFacade.cpp b/storage/ndb/src/ndbapi/TransporterFacade.cpp index 22eee859ef3..155d0ab8c9a 100644 --- a/storage/ndb/src/ndbapi/TransporterFacade.cpp +++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/TransporterFacade.hpp b/storage/ndb/src/ndbapi/TransporterFacade.hpp index 23fea8792f7..3d5b36fa8ea 100644 --- a/storage/ndb/src/ndbapi/TransporterFacade.hpp +++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp index 38744fbdeba..a96237cd115 100644 --- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp index ba488c56ec7..2e058140f40 100644 --- a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp +++ b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c index 363e25fc519..fc1bb1f7b7a 100644 --- a/storage/ndb/src/ndbapi/ndberror.c +++ b/storage/ndb/src/ndbapi/ndberror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/signal-sender/SignalSender.cpp b/storage/ndb/src/ndbapi/signal-sender/SignalSender.cpp index faca172a93e..f43d160ce0b 100644 --- a/storage/ndb/src/ndbapi/signal-sender/SignalSender.cpp +++ b/storage/ndb/src/ndbapi/signal-sender/SignalSender.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/src/ndbapi/signal-sender/SignalSender.hpp b/storage/ndb/src/ndbapi/signal-sender/SignalSender.hpp index e1ed4ba68ed..ee140f05e49 100644 --- a/storage/ndb/src/ndbapi/signal-sender/SignalSender.hpp +++ b/storage/ndb/src/ndbapi/signal-sender/SignalSender.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/Makefile.am b/storage/ndb/test/Makefile.am index c746f526769..b871536db5f 100644 --- a/storage/ndb/test/Makefile.am +++ b/storage/ndb/test/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/AtrtClient.hpp b/storage/ndb/test/include/AtrtClient.hpp index 5728aca2500..759a303e645 100644 --- a/storage/ndb/test/include/AtrtClient.hpp +++ b/storage/ndb/test/include/AtrtClient.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/CpcClient.hpp b/storage/ndb/test/include/CpcClient.hpp index a743499566f..7be1bd0d641 100644 --- a/storage/ndb/test/include/CpcClient.hpp +++ b/storage/ndb/test/include/CpcClient.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/DbUtil.hpp b/storage/ndb/test/include/DbUtil.hpp index d865c92f9a3..a24451ad879 100755 --- a/storage/ndb/test/include/DbUtil.hpp +++ b/storage/ndb/test/include/DbUtil.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2007 MySQL AB +/* Copyright (c) 2007, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/HugoAsynchTransactions.hpp b/storage/ndb/test/include/HugoAsynchTransactions.hpp index bc79b8d5134..1674e6269ab 100644 --- a/storage/ndb/test/include/HugoAsynchTransactions.hpp +++ b/storage/ndb/test/include/HugoAsynchTransactions.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/HugoCalculator.hpp b/storage/ndb/test/include/HugoCalculator.hpp index 4cae35e0197..6d6607bae46 100644 --- a/storage/ndb/test/include/HugoCalculator.hpp +++ b/storage/ndb/test/include/HugoCalculator.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/HugoOperations.hpp b/storage/ndb/test/include/HugoOperations.hpp index 91e593a2b26..be8347b8e70 100644 --- a/storage/ndb/test/include/HugoOperations.hpp +++ b/storage/ndb/test/include/HugoOperations.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/HugoTransactions.hpp b/storage/ndb/test/include/HugoTransactions.hpp index e8f7b33e0ed..d3ce242621d 100644 --- a/storage/ndb/test/include/HugoTransactions.hpp +++ b/storage/ndb/test/include/HugoTransactions.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT.hpp b/storage/ndb/test/include/NDBT.hpp index 144ea00871b..9b61e8e0fde 100644 --- a/storage/ndb/test/include/NDBT.hpp +++ b/storage/ndb/test/include/NDBT.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_DataSet.hpp b/storage/ndb/test/include/NDBT_DataSet.hpp index b5f91cb50c3..8500277c260 100644 --- a/storage/ndb/test/include/NDBT_DataSet.hpp +++ b/storage/ndb/test/include/NDBT_DataSet.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_DataSetTransaction.hpp b/storage/ndb/test/include/NDBT_DataSetTransaction.hpp index bf57ae85ccc..75f1162553c 100644 --- a/storage/ndb/test/include/NDBT_DataSetTransaction.hpp +++ b/storage/ndb/test/include/NDBT_DataSetTransaction.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_Error.hpp b/storage/ndb/test/include/NDBT_Error.hpp index faec0cdadfc..9ad3b247569 100644 --- a/storage/ndb/test/include/NDBT_Error.hpp +++ b/storage/ndb/test/include/NDBT_Error.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_Output.hpp b/storage/ndb/test/include/NDBT_Output.hpp index 397a3912c23..54c7cb62281 100644 --- a/storage/ndb/test/include/NDBT_Output.hpp +++ b/storage/ndb/test/include/NDBT_Output.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_ResultRow.hpp b/storage/ndb/test/include/NDBT_ResultRow.hpp index 58a36e83d33..3cb63ea4b34 100644 --- a/storage/ndb/test/include/NDBT_ResultRow.hpp +++ b/storage/ndb/test/include/NDBT_ResultRow.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_ReturnCodes.h b/storage/ndb/test/include/NDBT_ReturnCodes.h index b48fccdb12d..b54a006338c 100644 --- a/storage/ndb/test/include/NDBT_ReturnCodes.h +++ b/storage/ndb/test/include/NDBT_ReturnCodes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_Stats.hpp b/storage/ndb/test/include/NDBT_Stats.hpp index 55785f633ec..4f0d9daf37a 100644 --- a/storage/ndb/test/include/NDBT_Stats.hpp +++ b/storage/ndb/test/include/NDBT_Stats.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_Table.hpp b/storage/ndb/test/include/NDBT_Table.hpp index 5b9c245e7a3..276544f5955 100644 --- a/storage/ndb/test/include/NDBT_Table.hpp +++ b/storage/ndb/test/include/NDBT_Table.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_Tables.hpp b/storage/ndb/test/include/NDBT_Tables.hpp index f9ae783927e..d90a1fd92c2 100644 --- a/storage/ndb/test/include/NDBT_Tables.hpp +++ b/storage/ndb/test/include/NDBT_Tables.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_Test.hpp b/storage/ndb/test/include/NDBT_Test.hpp index ad09f04e814..59c6d29aab1 100644 --- a/storage/ndb/test/include/NDBT_Test.hpp +++ b/storage/ndb/test/include/NDBT_Test.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NDBT_Thread.hpp b/storage/ndb/test/include/NDBT_Thread.hpp index 5b724991b29..e58dbf7bd5d 100644 --- a/storage/ndb/test/include/NDBT_Thread.hpp +++ b/storage/ndb/test/include/NDBT_Thread.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbBackup.hpp b/storage/ndb/test/include/NdbBackup.hpp index 9903fe0c6a6..ea1119b13b1 100644 --- a/storage/ndb/test/include/NdbBackup.hpp +++ b/storage/ndb/test/include/NdbBackup.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbConfig.hpp b/storage/ndb/test/include/NdbConfig.hpp index efd7e260ac0..278af987c0c 100644 --- a/storage/ndb/test/include/NdbConfig.hpp +++ b/storage/ndb/test/include/NdbConfig.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbGrep.hpp b/storage/ndb/test/include/NdbGrep.hpp index 3115ef27693..fc38c12cc2c 100644 --- a/storage/ndb/test/include/NdbGrep.hpp +++ b/storage/ndb/test/include/NdbGrep.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbMixRestarter.hpp b/storage/ndb/test/include/NdbMixRestarter.hpp index f4f91ad2b48..42dc1e09639 100644 --- a/storage/ndb/test/include/NdbMixRestarter.hpp +++ b/storage/ndb/test/include/NdbMixRestarter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbRestarter.hpp b/storage/ndb/test/include/NdbRestarter.hpp index 9780c0cd1ae..a3738c7fd18 100644 --- a/storage/ndb/test/include/NdbRestarter.hpp +++ b/storage/ndb/test/include/NdbRestarter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbRestarts.hpp b/storage/ndb/test/include/NdbRestarts.hpp index fdba34bcc0b..5c911c79519 100644 --- a/storage/ndb/test/include/NdbRestarts.hpp +++ b/storage/ndb/test/include/NdbRestarts.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbSchemaCon.hpp b/storage/ndb/test/include/NdbSchemaCon.hpp index 10df5f6be0b..abc5815f7f3 100644 --- a/storage/ndb/test/include/NdbSchemaCon.hpp +++ b/storage/ndb/test/include/NdbSchemaCon.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbSchemaOp.hpp b/storage/ndb/test/include/NdbSchemaOp.hpp index 6cdc0e61b66..c5753bc9190 100644 --- a/storage/ndb/test/include/NdbSchemaOp.hpp +++ b/storage/ndb/test/include/NdbSchemaOp.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbTest.hpp b/storage/ndb/test/include/NdbTest.hpp index 105147af7de..6e122fd2f6f 100644 --- a/storage/ndb/test/include/NdbTest.hpp +++ b/storage/ndb/test/include/NdbTest.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/NdbTimer.hpp b/storage/ndb/test/include/NdbTimer.hpp index 94a39522434..718613f63e9 100644 --- a/storage/ndb/test/include/NdbTimer.hpp +++ b/storage/ndb/test/include/NdbTimer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/TestNdbEventOperation.hpp b/storage/ndb/test/include/TestNdbEventOperation.hpp index a25e89f704d..abb3b0b949c 100644 --- a/storage/ndb/test/include/TestNdbEventOperation.hpp +++ b/storage/ndb/test/include/TestNdbEventOperation.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/UtilTransactions.hpp b/storage/ndb/test/include/UtilTransactions.hpp index 193398c3da2..34ffe42e36f 100644 --- a/storage/ndb/test/include/UtilTransactions.hpp +++ b/storage/ndb/test/include/UtilTransactions.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/include/getarg.h b/storage/ndb/test/include/getarg.h index 64a0b9f0e14..110d808ff73 100644 --- a/storage/ndb/test/include/getarg.h +++ b/storage/ndb/test/include/getarg.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/InsertRecs.cpp b/storage/ndb/test/ndbapi/InsertRecs.cpp index 41f17da3aae..e4f6e2ab707 100644 --- a/storage/ndb/test/ndbapi/InsertRecs.cpp +++ b/storage/ndb/test/ndbapi/InsertRecs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/Makefile.am b/storage/ndb/test/ndbapi/Makefile.am index 81bb346417f..4cc7bebd5f4 100644 --- a/storage/ndb/test/ndbapi/Makefile.am +++ b/storage/ndb/test/ndbapi/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004-2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ScanFilter.hpp b/storage/ndb/test/ndbapi/ScanFilter.hpp index aa866648bf6..e387195c123 100644 --- a/storage/ndb/test/ndbapi/ScanFilter.hpp +++ b/storage/ndb/test/ndbapi/ScanFilter.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ScanFunctions.hpp b/storage/ndb/test/ndbapi/ScanFunctions.hpp index 7cb984f4157..5888bed5b79 100644 --- a/storage/ndb/test/ndbapi/ScanFunctions.hpp +++ b/storage/ndb/test/ndbapi/ScanFunctions.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ScanInterpretTest.hpp b/storage/ndb/test/ndbapi/ScanInterpretTest.hpp index d0c2acc621f..a08b0a08836 100644 --- a/storage/ndb/test/ndbapi/ScanInterpretTest.hpp +++ b/storage/ndb/test/ndbapi/ScanInterpretTest.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/TraceNdbApi.cpp b/storage/ndb/test/ndbapi/TraceNdbApi.cpp index 42a424c96f1..bc65bfb7139 100644 --- a/storage/ndb/test/ndbapi/TraceNdbApi.cpp +++ b/storage/ndb/test/ndbapi/TraceNdbApi.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/VerifyNdbApi.cpp b/storage/ndb/test/ndbapi/VerifyNdbApi.cpp index 89aaf2ff734..774f5db8439 100644 --- a/storage/ndb/test/ndbapi/VerifyNdbApi.cpp +++ b/storage/ndb/test/ndbapi/VerifyNdbApi.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/acid.cpp b/storage/ndb/test/ndbapi/acid.cpp index 375a3d4e412..3ea65f3df2e 100644 --- a/storage/ndb/test/ndbapi/acid.cpp +++ b/storage/ndb/test/ndbapi/acid.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/acid2.cpp b/storage/ndb/test/ndbapi/acid2.cpp index c798e1f98c8..1817bfeba89 100644 --- a/storage/ndb/test/ndbapi/acid2.cpp +++ b/storage/ndb/test/ndbapi/acid2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp b/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp index 644405636ba..65eb11ff8d3 100644 --- a/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp +++ b/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/adoInsertRecs.cpp b/storage/ndb/test/ndbapi/adoInsertRecs.cpp index 6e33d93fa41..70705f7f8d8 100644 --- a/storage/ndb/test/ndbapi/adoInsertRecs.cpp +++ b/storage/ndb/test/ndbapi/adoInsertRecs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/asyncGenerator.cpp b/storage/ndb/test/ndbapi/asyncGenerator.cpp index 16dd8ae74ce..3b5bbfe0d8a 100644 --- a/storage/ndb/test/ndbapi/asyncGenerator.cpp +++ b/storage/ndb/test/ndbapi/asyncGenerator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/Bank.cpp b/storage/ndb/test/ndbapi/bank/Bank.cpp index 3a6f02f4bc4..9f9ef5d0f39 100644 --- a/storage/ndb/test/ndbapi/bank/Bank.cpp +++ b/storage/ndb/test/ndbapi/bank/Bank.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/Bank.hpp b/storage/ndb/test/ndbapi/bank/Bank.hpp index ef6e6976092..b04c8e917e5 100644 --- a/storage/ndb/test/ndbapi/bank/Bank.hpp +++ b/storage/ndb/test/ndbapi/bank/Bank.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/BankLoad.cpp b/storage/ndb/test/ndbapi/bank/BankLoad.cpp index 985391c0066..3b70bcf2284 100644 --- a/storage/ndb/test/ndbapi/bank/BankLoad.cpp +++ b/storage/ndb/test/ndbapi/bank/BankLoad.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/Makefile.am b/storage/ndb/test/ndbapi/bank/Makefile.am index 8e6c0f23eea..414c383c0fe 100644 --- a/storage/ndb/test/ndbapi/bank/Makefile.am +++ b/storage/ndb/test/ndbapi/bank/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/bankCreator.cpp b/storage/ndb/test/ndbapi/bank/bankCreator.cpp index 7666facf0b9..4aacc9530b2 100644 --- a/storage/ndb/test/ndbapi/bank/bankCreator.cpp +++ b/storage/ndb/test/ndbapi/bank/bankCreator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/bankMakeGL.cpp b/storage/ndb/test/ndbapi/bank/bankMakeGL.cpp index 776e4b47ff4..3bc4ca0e570 100644 --- a/storage/ndb/test/ndbapi/bank/bankMakeGL.cpp +++ b/storage/ndb/test/ndbapi/bank/bankMakeGL.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/bankSumAccounts.cpp b/storage/ndb/test/ndbapi/bank/bankSumAccounts.cpp index a2f7787f560..26c9e435557 100644 --- a/storage/ndb/test/ndbapi/bank/bankSumAccounts.cpp +++ b/storage/ndb/test/ndbapi/bank/bankSumAccounts.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/bankTimer.cpp b/storage/ndb/test/ndbapi/bank/bankTimer.cpp index 7546f56cee4..b50f9ec1761 100644 --- a/storage/ndb/test/ndbapi/bank/bankTimer.cpp +++ b/storage/ndb/test/ndbapi/bank/bankTimer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/bankTransactionMaker.cpp b/storage/ndb/test/ndbapi/bank/bankTransactionMaker.cpp index 95e9c43fe5b..9415e9d6094 100644 --- a/storage/ndb/test/ndbapi/bank/bankTransactionMaker.cpp +++ b/storage/ndb/test/ndbapi/bank/bankTransactionMaker.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp b/storage/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp index 8f57ea55443..36d77f4b1b3 100644 --- a/storage/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp +++ b/storage/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bank/testBank.cpp b/storage/ndb/test/ndbapi/bank/testBank.cpp index 47a5c14e8a3..0720395830f 100644 --- a/storage/ndb/test/ndbapi/bank/testBank.cpp +++ b/storage/ndb/test/ndbapi/bank/testBank.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/asyncGenerator.cpp b/storage/ndb/test/ndbapi/bench/asyncGenerator.cpp index 2a71711f146..03bb9a625cd 100644 --- a/storage/ndb/test/ndbapi/bench/asyncGenerator.cpp +++ b/storage/ndb/test/ndbapi/bench/asyncGenerator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/dbGenerator.h b/storage/ndb/test/ndbapi/bench/dbGenerator.h index 3e1a3e6704a..08fba6762c9 100644 --- a/storage/ndb/test/ndbapi/bench/dbGenerator.h +++ b/storage/ndb/test/ndbapi/bench/dbGenerator.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/dbPopulate.cpp b/storage/ndb/test/ndbapi/bench/dbPopulate.cpp index 89c312ab636..acb1771b591 100644 --- a/storage/ndb/test/ndbapi/bench/dbPopulate.cpp +++ b/storage/ndb/test/ndbapi/bench/dbPopulate.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/dbPopulate.h b/storage/ndb/test/ndbapi/bench/dbPopulate.h index a7220b671b1..86146dc8a9a 100644 --- a/storage/ndb/test/ndbapi/bench/dbPopulate.h +++ b/storage/ndb/test/ndbapi/bench/dbPopulate.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/macros.h b/storage/ndb/test/ndbapi/bench/macros.h index d50183d1749..b9d8825319a 100644 --- a/storage/ndb/test/ndbapi/bench/macros.h +++ b/storage/ndb/test/ndbapi/bench/macros.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp b/storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp index 5e488436d9a..c9eb8d1ade3 100644 --- a/storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp +++ b/storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/mainPopulate.cpp b/storage/ndb/test/ndbapi/bench/mainPopulate.cpp index 8189821723c..d91aa46ba4e 100644 --- a/storage/ndb/test/ndbapi/bench/mainPopulate.cpp +++ b/storage/ndb/test/ndbapi/bench/mainPopulate.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_async1.cpp b/storage/ndb/test/ndbapi/bench/ndb_async1.cpp index e532744ac93..39d016a60eb 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_async1.cpp +++ b/storage/ndb/test/ndbapi/bench/ndb_async1.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_async2.cpp b/storage/ndb/test/ndbapi/bench/ndb_async2.cpp index 14422f6617b..a52d0ee3716 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_async2.cpp +++ b/storage/ndb/test/ndbapi/bench/ndb_async2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_error.hpp b/storage/ndb/test/ndbapi/bench/ndb_error.hpp index 1874213c6da..377cbd7968a 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_error.hpp +++ b/storage/ndb/test/ndbapi/bench/ndb_error.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_schema.hpp b/storage/ndb/test/ndbapi/bench/ndb_schema.hpp index 6a73e6131cd..918baeb0d3c 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_schema.hpp +++ b/storage/ndb/test/ndbapi/bench/ndb_schema.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_user_transaction.cpp b/storage/ndb/test/ndbapi/bench/ndb_user_transaction.cpp index 37de6dadc90..2579db35054 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_user_transaction.cpp +++ b/storage/ndb/test/ndbapi/bench/ndb_user_transaction.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_user_transaction2.cpp b/storage/ndb/test/ndbapi/bench/ndb_user_transaction2.cpp index bb27bfe3600..1365b00b594 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_user_transaction2.cpp +++ b/storage/ndb/test/ndbapi/bench/ndb_user_transaction2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_user_transaction3.cpp b/storage/ndb/test/ndbapi/bench/ndb_user_transaction3.cpp index d193b21fa11..d4bc83bc370 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_user_transaction3.cpp +++ b/storage/ndb/test/ndbapi/bench/ndb_user_transaction3.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_user_transaction4.cpp b/storage/ndb/test/ndbapi/bench/ndb_user_transaction4.cpp index 5df4717eb6d..8ce5a87a813 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_user_transaction4.cpp +++ b/storage/ndb/test/ndbapi/bench/ndb_user_transaction4.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_user_transaction5.cpp b/storage/ndb/test/ndbapi/bench/ndb_user_transaction5.cpp index d76f6afd3f9..d55f273f891 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_user_transaction5.cpp +++ b/storage/ndb/test/ndbapi/bench/ndb_user_transaction5.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/ndb_user_transaction6.cpp b/storage/ndb/test/ndbapi/bench/ndb_user_transaction6.cpp index 4f705ee5047..e60df8797f9 100644 --- a/storage/ndb/test/ndbapi/bench/ndb_user_transaction6.cpp +++ b/storage/ndb/test/ndbapi/bench/ndb_user_transaction6.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/testData.h b/storage/ndb/test/ndbapi/bench/testData.h index 0327656de73..469d46fb680 100644 --- a/storage/ndb/test/ndbapi/bench/testData.h +++ b/storage/ndb/test/ndbapi/bench/testData.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/testDefinitions.h b/storage/ndb/test/ndbapi/bench/testDefinitions.h index e2705b55a34..f217fde784d 100644 --- a/storage/ndb/test/ndbapi/bench/testDefinitions.h +++ b/storage/ndb/test/ndbapi/bench/testDefinitions.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/userInterface.cpp b/storage/ndb/test/ndbapi/bench/userInterface.cpp index 651963cb95a..91a128fb37d 100644 --- a/storage/ndb/test/ndbapi/bench/userInterface.cpp +++ b/storage/ndb/test/ndbapi/bench/userInterface.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bench/userInterface.h b/storage/ndb/test/ndbapi/bench/userInterface.h index 5492b012553..94dbcf67ba6 100644 --- a/storage/ndb/test/ndbapi/bench/userInterface.h +++ b/storage/ndb/test/ndbapi/bench/userInterface.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/benchronja.cpp b/storage/ndb/test/ndbapi/benchronja.cpp index 73ee324a888..cd067e083e3 100644 --- a/storage/ndb/test/ndbapi/benchronja.cpp +++ b/storage/ndb/test/ndbapi/benchronja.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/bulk_copy.cpp b/storage/ndb/test/ndbapi/bulk_copy.cpp index 3828a833fc6..2a9517c90f2 100644 --- a/storage/ndb/test/ndbapi/bulk_copy.cpp +++ b/storage/ndb/test/ndbapi/bulk_copy.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/cdrserver.cpp b/storage/ndb/test/ndbapi/cdrserver.cpp index 1a39edcfaec..f2168eaca06 100644 --- a/storage/ndb/test/ndbapi/cdrserver.cpp +++ b/storage/ndb/test/ndbapi/cdrserver.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/celloDb.cpp b/storage/ndb/test/ndbapi/celloDb.cpp index 243930056f7..af600ea73fa 100644 --- a/storage/ndb/test/ndbapi/celloDb.cpp +++ b/storage/ndb/test/ndbapi/celloDb.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/create_all_tabs.cpp b/storage/ndb/test/ndbapi/create_all_tabs.cpp index 1820af6fec2..f5eeebbb66c 100644 --- a/storage/ndb/test/ndbapi/create_all_tabs.cpp +++ b/storage/ndb/test/ndbapi/create_all_tabs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/create_tab.cpp b/storage/ndb/test/ndbapi/create_tab.cpp index c8c7dd6e27f..fbbcfe2e68a 100644 --- a/storage/ndb/test/ndbapi/create_tab.cpp +++ b/storage/ndb/test/ndbapi/create_tab.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/drop_all_tabs.cpp b/storage/ndb/test/ndbapi/drop_all_tabs.cpp index cebd257cc29..26406970202 100644 --- a/storage/ndb/test/ndbapi/drop_all_tabs.cpp +++ b/storage/ndb/test/ndbapi/drop_all_tabs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/flexAsynch.cpp b/storage/ndb/test/ndbapi/flexAsynch.cpp index 1f52315482f..48307beec2a 100644 --- a/storage/ndb/test/ndbapi/flexAsynch.cpp +++ b/storage/ndb/test/ndbapi/flexAsynch.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/flexBench.cpp b/storage/ndb/test/ndbapi/flexBench.cpp index eedc8ec3e76..5a5df2933c1 100644 --- a/storage/ndb/test/ndbapi/flexBench.cpp +++ b/storage/ndb/test/ndbapi/flexBench.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/flexHammer.cpp b/storage/ndb/test/ndbapi/flexHammer.cpp index 1b0097cf84b..7daf968688b 100644 --- a/storage/ndb/test/ndbapi/flexHammer.cpp +++ b/storage/ndb/test/ndbapi/flexHammer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/flexScan.cpp b/storage/ndb/test/ndbapi/flexScan.cpp index 105dfeedfff..7278dbed540 100644 --- a/storage/ndb/test/ndbapi/flexScan.cpp +++ b/storage/ndb/test/ndbapi/flexScan.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/flexTT.cpp b/storage/ndb/test/ndbapi/flexTT.cpp index 4373102f77e..c6e96bc757a 100644 --- a/storage/ndb/test/ndbapi/flexTT.cpp +++ b/storage/ndb/test/ndbapi/flexTT.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/flexTimedAsynch.cpp b/storage/ndb/test/ndbapi/flexTimedAsynch.cpp index b6301e59df2..06ae9e14c1d 100644 --- a/storage/ndb/test/ndbapi/flexTimedAsynch.cpp +++ b/storage/ndb/test/ndbapi/flexTimedAsynch.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/flex_bench_mysql.cpp b/storage/ndb/test/ndbapi/flex_bench_mysql.cpp index 5d4e7ece7c7..f6fcca760b8 100644 --- a/storage/ndb/test/ndbapi/flex_bench_mysql.cpp +++ b/storage/ndb/test/ndbapi/flex_bench_mysql.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/index.cpp b/storage/ndb/test/ndbapi/index.cpp index 1326f9fee75..6dd4a33bfd6 100644 --- a/storage/ndb/test/ndbapi/index.cpp +++ b/storage/ndb/test/ndbapi/index.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/index2.cpp b/storage/ndb/test/ndbapi/index2.cpp index 8c7ea26fead..8f081be2712 100644 --- a/storage/ndb/test/ndbapi/index2.cpp +++ b/storage/ndb/test/ndbapi/index2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/initronja.cpp b/storage/ndb/test/ndbapi/initronja.cpp index 28ffa9f211d..ca3b7ea5e10 100644 --- a/storage/ndb/test/ndbapi/initronja.cpp +++ b/storage/ndb/test/ndbapi/initronja.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/interpreterInTup.cpp b/storage/ndb/test/ndbapi/interpreterInTup.cpp index 4d4ef75f81d..83c194c31c7 100644 --- a/storage/ndb/test/ndbapi/interpreterInTup.cpp +++ b/storage/ndb/test/ndbapi/interpreterInTup.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/mainAsyncGenerator.cpp b/storage/ndb/test/ndbapi/mainAsyncGenerator.cpp index b9c623c4793..10b5ac037ff 100644 --- a/storage/ndb/test/ndbapi/mainAsyncGenerator.cpp +++ b/storage/ndb/test/ndbapi/mainAsyncGenerator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/msa.cpp b/storage/ndb/test/ndbapi/msa.cpp index 2db694f4dbb..edbcc504772 100644 --- a/storage/ndb/test/ndbapi/msa.cpp +++ b/storage/ndb/test/ndbapi/msa.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_async1.cpp b/storage/ndb/test/ndbapi/ndb_async1.cpp index e532744ac93..399a1930dde 100644 --- a/storage/ndb/test/ndbapi/ndb_async1.cpp +++ b/storage/ndb/test/ndbapi/ndb_async1.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_async2.cpp b/storage/ndb/test/ndbapi/ndb_async2.cpp index 9aa5ef0ae87..006090100a4 100644 --- a/storage/ndb/test/ndbapi/ndb_async2.cpp +++ b/storage/ndb/test/ndbapi/ndb_async2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_user_populate.cpp b/storage/ndb/test/ndbapi/ndb_user_populate.cpp index 9aea13932ec..d43ea291bda 100644 --- a/storage/ndb/test/ndbapi/ndb_user_populate.cpp +++ b/storage/ndb/test/ndbapi/ndb_user_populate.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_user_transaction.cpp b/storage/ndb/test/ndbapi/ndb_user_transaction.cpp index 37de6dadc90..86cf43cd518 100644 --- a/storage/ndb/test/ndbapi/ndb_user_transaction.cpp +++ b/storage/ndb/test/ndbapi/ndb_user_transaction.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_user_transaction2.cpp b/storage/ndb/test/ndbapi/ndb_user_transaction2.cpp index bb27bfe3600..d86cef5ec09 100644 --- a/storage/ndb/test/ndbapi/ndb_user_transaction2.cpp +++ b/storage/ndb/test/ndbapi/ndb_user_transaction2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_user_transaction3.cpp b/storage/ndb/test/ndbapi/ndb_user_transaction3.cpp index d193b21fa11..c7d3b6aa86c 100644 --- a/storage/ndb/test/ndbapi/ndb_user_transaction3.cpp +++ b/storage/ndb/test/ndbapi/ndb_user_transaction3.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_user_transaction4.cpp b/storage/ndb/test/ndbapi/ndb_user_transaction4.cpp index 5df4717eb6d..6607f2041ba 100644 --- a/storage/ndb/test/ndbapi/ndb_user_transaction4.cpp +++ b/storage/ndb/test/ndbapi/ndb_user_transaction4.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_user_transaction5.cpp b/storage/ndb/test/ndbapi/ndb_user_transaction5.cpp index d76f6afd3f9..378f8f7d930 100644 --- a/storage/ndb/test/ndbapi/ndb_user_transaction5.cpp +++ b/storage/ndb/test/ndbapi/ndb_user_transaction5.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/ndb_user_transaction6.cpp b/storage/ndb/test/ndbapi/ndb_user_transaction6.cpp index 4f705ee5047..e36e9011c85 100644 --- a/storage/ndb/test/ndbapi/ndb_user_transaction6.cpp +++ b/storage/ndb/test/ndbapi/ndb_user_transaction6.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/restarter.cpp b/storage/ndb/test/ndbapi/restarter.cpp index 089f6834375..017f603496f 100644 --- a/storage/ndb/test/ndbapi/restarter.cpp +++ b/storage/ndb/test/ndbapi/restarter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/restarter2.cpp b/storage/ndb/test/ndbapi/restarter2.cpp index f14f703f29f..feaf717e3a3 100644 --- a/storage/ndb/test/ndbapi/restarter2.cpp +++ b/storage/ndb/test/ndbapi/restarter2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/restarts.cpp b/storage/ndb/test/ndbapi/restarts.cpp index 9269953fe4a..d5184224e7f 100644 --- a/storage/ndb/test/ndbapi/restarts.cpp +++ b/storage/ndb/test/ndbapi/restarts.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/size.cpp b/storage/ndb/test/ndbapi/size.cpp index b9cf44e1a35..935bdfea2c4 100644 --- a/storage/ndb/test/ndbapi/size.cpp +++ b/storage/ndb/test/ndbapi/size.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testBackup.cpp b/storage/ndb/test/ndbapi/testBackup.cpp index 23796bf289c..7f232f8e64e 100644 --- a/storage/ndb/test/ndbapi/testBackup.cpp +++ b/storage/ndb/test/ndbapi/testBackup.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testBasic.cpp b/storage/ndb/test/ndbapi/testBasic.cpp index ac23ceaad18..07d3b0e291e 100644 --- a/storage/ndb/test/ndbapi/testBasic.cpp +++ b/storage/ndb/test/ndbapi/testBasic.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testBasicAsynch.cpp b/storage/ndb/test/ndbapi/testBasicAsynch.cpp index c7e5c187218..fb94168cf2e 100644 --- a/storage/ndb/test/ndbapi/testBasicAsynch.cpp +++ b/storage/ndb/test/ndbapi/testBasicAsynch.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testBlobs.cpp b/storage/ndb/test/ndbapi/testBlobs.cpp index d9c657a0a29..2f77f93fa7c 100644 --- a/storage/ndb/test/ndbapi/testBlobs.cpp +++ b/storage/ndb/test/ndbapi/testBlobs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testDataBuffers.cpp b/storage/ndb/test/ndbapi/testDataBuffers.cpp index 92e97f4e6e1..3b0218ca090 100644 --- a/storage/ndb/test/ndbapi/testDataBuffers.cpp +++ b/storage/ndb/test/ndbapi/testDataBuffers.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testDeadlock.cpp b/storage/ndb/test/ndbapi/testDeadlock.cpp index 045abf66d98..72b79d46cce 100644 --- a/storage/ndb/test/ndbapi/testDeadlock.cpp +++ b/storage/ndb/test/ndbapi/testDeadlock.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testDict.cpp b/storage/ndb/test/ndbapi/testDict.cpp index ae940074067..20de97a04eb 100644 --- a/storage/ndb/test/ndbapi/testDict.cpp +++ b/storage/ndb/test/ndbapi/testDict.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testGrepVerify.cpp b/storage/ndb/test/ndbapi/testGrepVerify.cpp index 461ee249985..126978454c5 100644 --- a/storage/ndb/test/ndbapi/testGrepVerify.cpp +++ b/storage/ndb/test/ndbapi/testGrepVerify.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testIndex.cpp b/storage/ndb/test/ndbapi/testIndex.cpp index bd9ff7ac607..2b38b864de7 100644 --- a/storage/ndb/test/ndbapi/testIndex.cpp +++ b/storage/ndb/test/ndbapi/testIndex.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testIndexStat.cpp b/storage/ndb/test/ndbapi/testIndexStat.cpp index 0e15cdd80d1..83f144aae71 100644 --- a/storage/ndb/test/ndbapi/testIndexStat.cpp +++ b/storage/ndb/test/ndbapi/testIndexStat.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testInterpreter.cpp b/storage/ndb/test/ndbapi/testInterpreter.cpp index 22b810107b4..21b199bb84f 100644 --- a/storage/ndb/test/ndbapi/testInterpreter.cpp +++ b/storage/ndb/test/ndbapi/testInterpreter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testMgm.cpp b/storage/ndb/test/ndbapi/testMgm.cpp index e43972c8c29..1d645c0fcde 100644 --- a/storage/ndb/test/ndbapi/testMgm.cpp +++ b/storage/ndb/test/ndbapi/testMgm.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testNDBT.cpp b/storage/ndb/test/ndbapi/testNDBT.cpp index 9c911b9a9d9..2c3b4e9c278 100644 --- a/storage/ndb/test/ndbapi/testNDBT.cpp +++ b/storage/ndb/test/ndbapi/testNDBT.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testNdbApi.cpp b/storage/ndb/test/ndbapi/testNdbApi.cpp index c05a2417bca..88ccc4bb375 100644 --- a/storage/ndb/test/ndbapi/testNdbApi.cpp +++ b/storage/ndb/test/ndbapi/testNdbApi.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testNodeRestart.cpp b/storage/ndb/test/ndbapi/testNodeRestart.cpp index 17c81fd0a26..1cf402f3bdd 100644 --- a/storage/ndb/test/ndbapi/testNodeRestart.cpp +++ b/storage/ndb/test/ndbapi/testNodeRestart.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testOIBasic.cpp b/storage/ndb/test/ndbapi/testOIBasic.cpp index 4e1c8400768..5f27ae271fe 100644 --- a/storage/ndb/test/ndbapi/testOIBasic.cpp +++ b/storage/ndb/test/ndbapi/testOIBasic.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testOperations.cpp b/storage/ndb/test/ndbapi/testOperations.cpp index 95be2b988e1..1788d4d67e0 100644 --- a/storage/ndb/test/ndbapi/testOperations.cpp +++ b/storage/ndb/test/ndbapi/testOperations.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testOrderedIndex.cpp b/storage/ndb/test/ndbapi/testOrderedIndex.cpp index 60eaca3248b..e5703296a16 100644 --- a/storage/ndb/test/ndbapi/testOrderedIndex.cpp +++ b/storage/ndb/test/ndbapi/testOrderedIndex.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testPartitioning.cpp b/storage/ndb/test/ndbapi/testPartitioning.cpp index b141d4d2c28..aa19eef4b00 100644 --- a/storage/ndb/test/ndbapi/testPartitioning.cpp +++ b/storage/ndb/test/ndbapi/testPartitioning.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testReadPerf.cpp b/storage/ndb/test/ndbapi/testReadPerf.cpp index 17ef60c1849..347ef1d3c0c 100644 --- a/storage/ndb/test/ndbapi/testReadPerf.cpp +++ b/storage/ndb/test/ndbapi/testReadPerf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testRestartGci.cpp b/storage/ndb/test/ndbapi/testRestartGci.cpp index 7fac47fe3fb..9f1ddfbae3b 100644 --- a/storage/ndb/test/ndbapi/testRestartGci.cpp +++ b/storage/ndb/test/ndbapi/testRestartGci.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testSRBank.cpp b/storage/ndb/test/ndbapi/testSRBank.cpp index d0dbadbda75..1eab0063a2e 100644 --- a/storage/ndb/test/ndbapi/testSRBank.cpp +++ b/storage/ndb/test/ndbapi/testSRBank.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testScan.cpp b/storage/ndb/test/ndbapi/testScan.cpp index df6dbe2e550..40ef77cd7b1 100644 --- a/storage/ndb/test/ndbapi/testScan.cpp +++ b/storage/ndb/test/ndbapi/testScan.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testScanInterpreter.cpp b/storage/ndb/test/ndbapi/testScanInterpreter.cpp index ae7859d7328..553c2aac613 100644 --- a/storage/ndb/test/ndbapi/testScanInterpreter.cpp +++ b/storage/ndb/test/ndbapi/testScanInterpreter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testScanPerf.cpp b/storage/ndb/test/ndbapi/testScanPerf.cpp index 837b96a5c96..ab843408801 100644 --- a/storage/ndb/test/ndbapi/testScanPerf.cpp +++ b/storage/ndb/test/ndbapi/testScanPerf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testSystemRestart.cpp b/storage/ndb/test/ndbapi/testSystemRestart.cpp index 0f9100f67fa..dd3baba2b22 100644 --- a/storage/ndb/test/ndbapi/testSystemRestart.cpp +++ b/storage/ndb/test/ndbapi/testSystemRestart.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testTimeout.cpp b/storage/ndb/test/ndbapi/testTimeout.cpp index e5831ffee79..52f42daf4e2 100644 --- a/storage/ndb/test/ndbapi/testTimeout.cpp +++ b/storage/ndb/test/ndbapi/testTimeout.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/testTransactions.cpp b/storage/ndb/test/ndbapi/testTransactions.cpp index b9477ddd7dd..14bb3e735f7 100644 --- a/storage/ndb/test/ndbapi/testTransactions.cpp +++ b/storage/ndb/test/ndbapi/testTransactions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/test_event.cpp b/storage/ndb/test/ndbapi/test_event.cpp index a7504166065..03017dae883 100644 --- a/storage/ndb/test/ndbapi/test_event.cpp +++ b/storage/ndb/test/ndbapi/test_event.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/test_event_merge.cpp b/storage/ndb/test/ndbapi/test_event_merge.cpp index d40b985adc2..e87dca36694 100644 --- a/storage/ndb/test/ndbapi/test_event_merge.cpp +++ b/storage/ndb/test/ndbapi/test_event_merge.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbapi/userInterface.cpp b/storage/ndb/test/ndbapi/userInterface.cpp index de5509cdfb7..11aab9bccc1 100644 --- a/storage/ndb/test/ndbapi/userInterface.cpp +++ b/storage/ndb/test/ndbapi/userInterface.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/ndbnet/test.run b/storage/ndb/test/ndbnet/test.run index 195a657aeb5..e0c136f3754 100644 --- a/storage/ndb/test/ndbnet/test.run +++ b/storage/ndb/test/ndbnet/test.run @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/ndbnet/testError.run b/storage/ndb/test/ndbnet/testError.run index 6ace2cbbd20..22539004486 100644 --- a/storage/ndb/test/ndbnet/testError.run +++ b/storage/ndb/test/ndbnet/testError.run @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/ndbnet/testMNF.run b/storage/ndb/test/ndbnet/testMNF.run index 2903313f306..da438911758 100644 --- a/storage/ndb/test/ndbnet/testMNF.run +++ b/storage/ndb/test/ndbnet/testMNF.run @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/ndbnet/testNR.run b/storage/ndb/test/ndbnet/testNR.run index 5019f597b42..0c9a9d7898a 100644 --- a/storage/ndb/test/ndbnet/testNR.run +++ b/storage/ndb/test/ndbnet/testNR.run @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/ndbnet/testNR1.run b/storage/ndb/test/ndbnet/testNR1.run index a02b487b663..cb6fb48c08b 100644 --- a/storage/ndb/test/ndbnet/testNR1.run +++ b/storage/ndb/test/ndbnet/testNR1.run @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/ndbnet/testNR4.run b/storage/ndb/test/ndbnet/testNR4.run index 378d2743145..b665f6eb6af 100644 --- a/storage/ndb/test/ndbnet/testNR4.run +++ b/storage/ndb/test/ndbnet/testNR4.run @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/ndbnet/testSRhang.run b/storage/ndb/test/ndbnet/testSRhang.run index 570ed897eef..c76af0d9ba4 100644 --- a/storage/ndb/test/ndbnet/testSRhang.run +++ b/storage/ndb/test/ndbnet/testSRhang.run @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/ndbnet/testTR295.run b/storage/ndb/test/ndbnet/testTR295.run index df26000cbda..236e568bcf8 100644 --- a/storage/ndb/test/ndbnet/testTR295.run +++ b/storage/ndb/test/ndbnet/testTR295.run @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/newtonapi/basic_test/basic/basic.cpp b/storage/ndb/test/newtonapi/basic_test/basic/basic.cpp index 23c9d38cbdc..b1268a6f837 100644 --- a/storage/ndb/test/newtonapi/basic_test/basic/basic.cpp +++ b/storage/ndb/test/newtonapi/basic_test/basic/basic.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/newtonapi/basic_test/bulk_read/br_test.cpp b/storage/ndb/test/newtonapi/basic_test/bulk_read/br_test.cpp index 7b447b29e05..9dd5b5e7b03 100644 --- a/storage/ndb/test/newtonapi/basic_test/bulk_read/br_test.cpp +++ b/storage/ndb/test/newtonapi/basic_test/bulk_read/br_test.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/newtonapi/basic_test/common.cpp b/storage/ndb/test/newtonapi/basic_test/common.cpp index d393394dcc9..28ae60d2cd6 100644 --- a/storage/ndb/test/newtonapi/basic_test/common.cpp +++ b/storage/ndb/test/newtonapi/basic_test/common.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/newtonapi/basic_test/common.hpp b/storage/ndb/test/newtonapi/basic_test/common.hpp index d76d1cf1733..3cac2ee92fd 100644 --- a/storage/ndb/test/newtonapi/basic_test/common.hpp +++ b/storage/ndb/test/newtonapi/basic_test/common.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/newtonapi/basic_test/ptr_binding/ptr_binding_test.cpp b/storage/ndb/test/newtonapi/basic_test/ptr_binding/ptr_binding_test.cpp index 754dad25dba..b12071f2764 100644 --- a/storage/ndb/test/newtonapi/basic_test/ptr_binding/ptr_binding_test.cpp +++ b/storage/ndb/test/newtonapi/basic_test/ptr_binding/ptr_binding_test.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/newtonapi/basic_test/too_basic.cpp b/storage/ndb/test/newtonapi/basic_test/too_basic.cpp index f751967c181..74a3845cae8 100644 --- a/storage/ndb/test/newtonapi/basic_test/too_basic.cpp +++ b/storage/ndb/test/newtonapi/basic_test/too_basic.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/newtonapi/perf_test/perf.cpp b/storage/ndb/test/newtonapi/perf_test/perf.cpp index 23484dbdac2..229af493254 100644 --- a/storage/ndb/test/newtonapi/perf_test/perf.cpp +++ b/storage/ndb/test/newtonapi/perf_test/perf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/SQL99_test/SQL99_test.cpp b/storage/ndb/test/odbc/SQL99_test/SQL99_test.cpp index fb77220773d..f3aafc7ead1 100644 --- a/storage/ndb/test/odbc/SQL99_test/SQL99_test.cpp +++ b/storage/ndb/test/odbc/SQL99_test/SQL99_test.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/SQL99_test/SQL99_test.h b/storage/ndb/test/odbc/SQL99_test/SQL99_test.h index 0af4e79be47..768ccd5ef56 100644 --- a/storage/ndb/test/odbc/SQL99_test/SQL99_test.h +++ b/storage/ndb/test/odbc/SQL99_test/SQL99_test.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE.cpp b/storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE.cpp index 4f5f8455349..eada867d355 100644 --- a/storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE.cpp +++ b/storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE_HDBC.cpp b/storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE_HDBC.cpp index 7154409efa5..30e72b34f1f 100644 --- a/storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE_HDBC.cpp +++ b/storage/ndb/test/odbc/client/NDBT_ALLOCHANDLE_HDBC.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/NDBT_SQLConnect.cpp b/storage/ndb/test/odbc/client/NDBT_SQLConnect.cpp index 11522d7cf5a..79ef3db1329 100644 --- a/storage/ndb/test/odbc/client/NDBT_SQLConnect.cpp +++ b/storage/ndb/test/odbc/client/NDBT_SQLConnect.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/NDBT_SQLPrepare.cpp b/storage/ndb/test/odbc/client/NDBT_SQLPrepare.cpp index ce4300caf75..36be44b147a 100644 --- a/storage/ndb/test/odbc/client/NDBT_SQLPrepare.cpp +++ b/storage/ndb/test/odbc/client/NDBT_SQLPrepare.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLAllocEnvTest.cpp b/storage/ndb/test/odbc/client/SQLAllocEnvTest.cpp index e44672b2dbc..a5e3abc2f80 100644 --- a/storage/ndb/test/odbc/client/SQLAllocEnvTest.cpp +++ b/storage/ndb/test/odbc/client/SQLAllocEnvTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLAllocHandleTest.cpp b/storage/ndb/test/odbc/client/SQLAllocHandleTest.cpp index b66f7ebc2f6..7b657dcfa44 100644 --- a/storage/ndb/test/odbc/client/SQLAllocHandleTest.cpp +++ b/storage/ndb/test/odbc/client/SQLAllocHandleTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLAllocHandleTest_bf.cpp b/storage/ndb/test/odbc/client/SQLAllocHandleTest_bf.cpp index fc9a9d504ba..c26fb63d8f1 100644 --- a/storage/ndb/test/odbc/client/SQLAllocHandleTest_bf.cpp +++ b/storage/ndb/test/odbc/client/SQLAllocHandleTest_bf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLBindColTest.cpp b/storage/ndb/test/odbc/client/SQLBindColTest.cpp index aa6effe1831..ced99a1ca4f 100644 --- a/storage/ndb/test/odbc/client/SQLBindColTest.cpp +++ b/storage/ndb/test/odbc/client/SQLBindColTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLBindParameterTest.cpp b/storage/ndb/test/odbc/client/SQLBindParameterTest.cpp index 913c1d82230..2bdef1eb0ec 100644 --- a/storage/ndb/test/odbc/client/SQLBindParameterTest.cpp +++ b/storage/ndb/test/odbc/client/SQLBindParameterTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLCancelTest.cpp b/storage/ndb/test/odbc/client/SQLCancelTest.cpp index 355dc4f3189..b4749cc1334 100644 --- a/storage/ndb/test/odbc/client/SQLCancelTest.cpp +++ b/storage/ndb/test/odbc/client/SQLCancelTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLCloseCursorTest.cpp b/storage/ndb/test/odbc/client/SQLCloseCursorTest.cpp index e6a630319d5..186d770526f 100644 --- a/storage/ndb/test/odbc/client/SQLCloseCursorTest.cpp +++ b/storage/ndb/test/odbc/client/SQLCloseCursorTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLColAttributeTest.cpp b/storage/ndb/test/odbc/client/SQLColAttributeTest.cpp index ade640173fe..52c6983d9e5 100644 --- a/storage/ndb/test/odbc/client/SQLColAttributeTest.cpp +++ b/storage/ndb/test/odbc/client/SQLColAttributeTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLColAttributeTest1.cpp b/storage/ndb/test/odbc/client/SQLColAttributeTest1.cpp index 45b1dd15967..818ca90ced0 100644 --- a/storage/ndb/test/odbc/client/SQLColAttributeTest1.cpp +++ b/storage/ndb/test/odbc/client/SQLColAttributeTest1.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLColAttributeTest2.cpp b/storage/ndb/test/odbc/client/SQLColAttributeTest2.cpp index fb1f2a9aa4a..ae251e7e63d 100644 --- a/storage/ndb/test/odbc/client/SQLColAttributeTest2.cpp +++ b/storage/ndb/test/odbc/client/SQLColAttributeTest2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLColAttributeTest3.cpp b/storage/ndb/test/odbc/client/SQLColAttributeTest3.cpp index ef4943a8cdb..44be0c87081 100644 --- a/storage/ndb/test/odbc/client/SQLColAttributeTest3.cpp +++ b/storage/ndb/test/odbc/client/SQLColAttributeTest3.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLConnectTest.cpp b/storage/ndb/test/odbc/client/SQLConnectTest.cpp index 1adbd865f0c..372e08b3a98 100644 --- a/storage/ndb/test/odbc/client/SQLConnectTest.cpp +++ b/storage/ndb/test/odbc/client/SQLConnectTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLCopyDescTest.cpp b/storage/ndb/test/odbc/client/SQLCopyDescTest.cpp index d944da5acbb..4fe5e4c590a 100644 --- a/storage/ndb/test/odbc/client/SQLCopyDescTest.cpp +++ b/storage/ndb/test/odbc/client/SQLCopyDescTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLDescribeColTest.cpp b/storage/ndb/test/odbc/client/SQLDescribeColTest.cpp index abb31b53c5b..5ca8b3f1485 100644 --- a/storage/ndb/test/odbc/client/SQLDescribeColTest.cpp +++ b/storage/ndb/test/odbc/client/SQLDescribeColTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLDisconnectTest.cpp b/storage/ndb/test/odbc/client/SQLDisconnectTest.cpp index 700fadfed33..4fe5bf6ee22 100644 --- a/storage/ndb/test/odbc/client/SQLDisconnectTest.cpp +++ b/storage/ndb/test/odbc/client/SQLDisconnectTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLDriverConnectTest.cpp b/storage/ndb/test/odbc/client/SQLDriverConnectTest.cpp index 376b0970f2e..9077ce4d305 100644 --- a/storage/ndb/test/odbc/client/SQLDriverConnectTest.cpp +++ b/storage/ndb/test/odbc/client/SQLDriverConnectTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLEndTranTest.cpp b/storage/ndb/test/odbc/client/SQLEndTranTest.cpp index 953336ec909..a40c967ad59 100644 --- a/storage/ndb/test/odbc/client/SQLEndTranTest.cpp +++ b/storage/ndb/test/odbc/client/SQLEndTranTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLErrorTest.cpp b/storage/ndb/test/odbc/client/SQLErrorTest.cpp index f4effa464c8..5f0f06fee2e 100644 --- a/storage/ndb/test/odbc/client/SQLErrorTest.cpp +++ b/storage/ndb/test/odbc/client/SQLErrorTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLExecDirectTest.cpp b/storage/ndb/test/odbc/client/SQLExecDirectTest.cpp index d0b7955f928..69ab1f06b32 100644 --- a/storage/ndb/test/odbc/client/SQLExecDirectTest.cpp +++ b/storage/ndb/test/odbc/client/SQLExecDirectTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLExecuteTest.cpp b/storage/ndb/test/odbc/client/SQLExecuteTest.cpp index bcff66ff287..859612116ea 100644 --- a/storage/ndb/test/odbc/client/SQLExecuteTest.cpp +++ b/storage/ndb/test/odbc/client/SQLExecuteTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLFetchScrollTest.cpp b/storage/ndb/test/odbc/client/SQLFetchScrollTest.cpp index 1a92ac058a8..6923b28216c 100644 --- a/storage/ndb/test/odbc/client/SQLFetchScrollTest.cpp +++ b/storage/ndb/test/odbc/client/SQLFetchScrollTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLFetchTest.cpp b/storage/ndb/test/odbc/client/SQLFetchTest.cpp index 0dcb3571bf7..58331645cbd 100644 --- a/storage/ndb/test/odbc/client/SQLFetchTest.cpp +++ b/storage/ndb/test/odbc/client/SQLFetchTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLFreeHandleTest.cpp b/storage/ndb/test/odbc/client/SQLFreeHandleTest.cpp index d8ab766a362..a106be11785 100644 --- a/storage/ndb/test/odbc/client/SQLFreeHandleTest.cpp +++ b/storage/ndb/test/odbc/client/SQLFreeHandleTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLFreeStmtTest.cpp b/storage/ndb/test/odbc/client/SQLFreeStmtTest.cpp index ce804283358..5d7829b4939 100644 --- a/storage/ndb/test/odbc/client/SQLFreeStmtTest.cpp +++ b/storage/ndb/test/odbc/client/SQLFreeStmtTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetConnectAttrTest.cpp b/storage/ndb/test/odbc/client/SQLGetConnectAttrTest.cpp index 7eb6432904e..aca8dab7be2 100644 --- a/storage/ndb/test/odbc/client/SQLGetConnectAttrTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetConnectAttrTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetCursorNameTest.cpp b/storage/ndb/test/odbc/client/SQLGetCursorNameTest.cpp index da66d976f34..9eb864d3874 100644 --- a/storage/ndb/test/odbc/client/SQLGetCursorNameTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetCursorNameTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetDataTest.cpp b/storage/ndb/test/odbc/client/SQLGetDataTest.cpp index 12b7969c092..b921b4ca4c2 100644 --- a/storage/ndb/test/odbc/client/SQLGetDataTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetDataTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetDescFieldTest.cpp b/storage/ndb/test/odbc/client/SQLGetDescFieldTest.cpp index 0bae4ae58b2..a20aa7f3dc7 100644 --- a/storage/ndb/test/odbc/client/SQLGetDescFieldTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetDescFieldTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetDescRecTest.cpp b/storage/ndb/test/odbc/client/SQLGetDescRecTest.cpp index 46ecbfeaa83..d11340ccfaa 100644 --- a/storage/ndb/test/odbc/client/SQLGetDescRecTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetDescRecTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetDiagFieldTest.cpp b/storage/ndb/test/odbc/client/SQLGetDiagFieldTest.cpp index c8d381abd56..c42449685a3 100644 --- a/storage/ndb/test/odbc/client/SQLGetDiagFieldTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetDiagFieldTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetDiagRecSimpleTest.cpp b/storage/ndb/test/odbc/client/SQLGetDiagRecSimpleTest.cpp index 22a4e07f470..d0e228cf1b9 100644 --- a/storage/ndb/test/odbc/client/SQLGetDiagRecSimpleTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetDiagRecSimpleTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetDiagRecTest.cpp b/storage/ndb/test/odbc/client/SQLGetDiagRecTest.cpp index 2a8aed12a57..6e588ae9f32 100644 --- a/storage/ndb/test/odbc/client/SQLGetDiagRecTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetDiagRecTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetEnvAttrTest.cpp b/storage/ndb/test/odbc/client/SQLGetEnvAttrTest.cpp index 0c6b2ab51b8..b6b94ed3a71 100644 --- a/storage/ndb/test/odbc/client/SQLGetEnvAttrTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetEnvAttrTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetFunctionsTest.cpp b/storage/ndb/test/odbc/client/SQLGetFunctionsTest.cpp index 917f63d7e18..8aa36108257 100644 --- a/storage/ndb/test/odbc/client/SQLGetFunctionsTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetFunctionsTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetInfoTest.cpp b/storage/ndb/test/odbc/client/SQLGetInfoTest.cpp index 0322cc47250..17e728c5f4c 100644 --- a/storage/ndb/test/odbc/client/SQLGetInfoTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetInfoTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetStmtAttrTest.cpp b/storage/ndb/test/odbc/client/SQLGetStmtAttrTest.cpp index 4a268ce99c1..156ab84ecb4 100644 --- a/storage/ndb/test/odbc/client/SQLGetStmtAttrTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetStmtAttrTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLGetTypeInfoTest.cpp b/storage/ndb/test/odbc/client/SQLGetTypeInfoTest.cpp index fb114d06c26..bbffc95638d 100644 --- a/storage/ndb/test/odbc/client/SQLGetTypeInfoTest.cpp +++ b/storage/ndb/test/odbc/client/SQLGetTypeInfoTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLMoreResultsTest.cpp b/storage/ndb/test/odbc/client/SQLMoreResultsTest.cpp index 8b7ed0e4581..4fa6f3d4e95 100644 --- a/storage/ndb/test/odbc/client/SQLMoreResultsTest.cpp +++ b/storage/ndb/test/odbc/client/SQLMoreResultsTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLNumResultColsTest.cpp b/storage/ndb/test/odbc/client/SQLNumResultColsTest.cpp index ca70d42018e..760d2fadbcf 100644 --- a/storage/ndb/test/odbc/client/SQLNumResultColsTest.cpp +++ b/storage/ndb/test/odbc/client/SQLNumResultColsTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLParamDataTest.cpp b/storage/ndb/test/odbc/client/SQLParamDataTest.cpp index e502a9e15fa..8a7576a17a1 100644 --- a/storage/ndb/test/odbc/client/SQLParamDataTest.cpp +++ b/storage/ndb/test/odbc/client/SQLParamDataTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLPrepareTest.cpp b/storage/ndb/test/odbc/client/SQLPrepareTest.cpp index aa20b1992a2..6b6dd68e12b 100644 --- a/storage/ndb/test/odbc/client/SQLPrepareTest.cpp +++ b/storage/ndb/test/odbc/client/SQLPrepareTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLPutDataTest.cpp b/storage/ndb/test/odbc/client/SQLPutDataTest.cpp index ea1a34651c3..23520eec9d2 100644 --- a/storage/ndb/test/odbc/client/SQLPutDataTest.cpp +++ b/storage/ndb/test/odbc/client/SQLPutDataTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLRowCountTest.cpp b/storage/ndb/test/odbc/client/SQLRowCountTest.cpp index 1cc2929c2dc..3134288443d 100644 --- a/storage/ndb/test/odbc/client/SQLRowCountTest.cpp +++ b/storage/ndb/test/odbc/client/SQLRowCountTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLSetConnectAttrTest.cpp b/storage/ndb/test/odbc/client/SQLSetConnectAttrTest.cpp index 4e5f08a4a4c..1259c95c368 100644 --- a/storage/ndb/test/odbc/client/SQLSetConnectAttrTest.cpp +++ b/storage/ndb/test/odbc/client/SQLSetConnectAttrTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLSetCursorNameTest.cpp b/storage/ndb/test/odbc/client/SQLSetCursorNameTest.cpp index 8676ab6eddf..62ebb6ed954 100644 --- a/storage/ndb/test/odbc/client/SQLSetCursorNameTest.cpp +++ b/storage/ndb/test/odbc/client/SQLSetCursorNameTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLSetDescFieldTest.cpp b/storage/ndb/test/odbc/client/SQLSetDescFieldTest.cpp index 9ea93013312..eae63a2c67f 100644 --- a/storage/ndb/test/odbc/client/SQLSetDescFieldTest.cpp +++ b/storage/ndb/test/odbc/client/SQLSetDescFieldTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLSetDescRecTest.cpp b/storage/ndb/test/odbc/client/SQLSetDescRecTest.cpp index 52a6b81ee84..605401314d1 100644 --- a/storage/ndb/test/odbc/client/SQLSetDescRecTest.cpp +++ b/storage/ndb/test/odbc/client/SQLSetDescRecTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLSetEnvAttrTest.cpp b/storage/ndb/test/odbc/client/SQLSetEnvAttrTest.cpp index e843c5509b8..546465bbd39 100644 --- a/storage/ndb/test/odbc/client/SQLSetEnvAttrTest.cpp +++ b/storage/ndb/test/odbc/client/SQLSetEnvAttrTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLSetStmtAttrTest.cpp b/storage/ndb/test/odbc/client/SQLSetStmtAttrTest.cpp index dc37fc64e1c..5d7bba5e75f 100644 --- a/storage/ndb/test/odbc/client/SQLSetStmtAttrTest.cpp +++ b/storage/ndb/test/odbc/client/SQLSetStmtAttrTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLTablesTest.cpp b/storage/ndb/test/odbc/client/SQLTablesTest.cpp index ff55f217d0a..39944412e5d 100644 --- a/storage/ndb/test/odbc/client/SQLTablesTest.cpp +++ b/storage/ndb/test/odbc/client/SQLTablesTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/SQLTransactTest.cpp b/storage/ndb/test/odbc/client/SQLTransactTest.cpp index d7444794d5a..cd7cbb3491b 100644 --- a/storage/ndb/test/odbc/client/SQLTransactTest.cpp +++ b/storage/ndb/test/odbc/client/SQLTransactTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/common.hpp b/storage/ndb/test/odbc/client/common.hpp index 1eb61f44bd9..7e775f83120 100644 --- a/storage/ndb/test/odbc/client/common.hpp +++ b/storage/ndb/test/odbc/client/common.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/client/main.cpp b/storage/ndb/test/odbc/client/main.cpp index 187ac96c6a7..53f89b196e7 100644 --- a/storage/ndb/test/odbc/client/main.cpp +++ b/storage/ndb/test/odbc/client/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/driver/testOdbcDriver.cpp b/storage/ndb/test/odbc/driver/testOdbcDriver.cpp index bdda4d447f8..566e71b1a10 100644 --- a/storage/ndb/test/odbc/driver/testOdbcDriver.cpp +++ b/storage/ndb/test/odbc/driver/testOdbcDriver.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/odbc/test_compiler/test_compiler.cpp b/storage/ndb/test/odbc/test_compiler/test_compiler.cpp index d64d8f2a63d..61cbada926a 100644 --- a/storage/ndb/test/odbc/test_compiler/test_compiler.cpp +++ b/storage/ndb/test/odbc/test_compiler/test_compiler.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/run-test/atrt-analyze-result.sh b/storage/ndb/test/run-test/atrt-analyze-result.sh index 9a482faee86..cdfb20ad04a 100755 --- a/storage/ndb/test/run-test/atrt-analyze-result.sh +++ b/storage/ndb/test/run-test/atrt-analyze-result.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/run-test/atrt-clear-result.sh b/storage/ndb/test/run-test/atrt-clear-result.sh index 7eeb54daef3..81a239a4449 100755 --- a/storage/ndb/test/run-test/atrt-clear-result.sh +++ b/storage/ndb/test/run-test/atrt-clear-result.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/run-test/atrt-gather-result.sh b/storage/ndb/test/run-test/atrt-gather-result.sh index 36989d04c07..c064d8cbee6 100755 --- a/storage/ndb/test/run-test/atrt-gather-result.sh +++ b/storage/ndb/test/run-test/atrt-gather-result.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005, 2007 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/run-test/atrt-setup.sh b/storage/ndb/test/run-test/atrt-setup.sh index 786b1d812de..a2784bee862 100755 --- a/storage/ndb/test/run-test/atrt-setup.sh +++ b/storage/ndb/test/run-test/atrt-setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/run-test/atrt-testBackup b/storage/ndb/test/run-test/atrt-testBackup index 2ed6f70b7aa..040c0e22aeb 100755 --- a/storage/ndb/test/run-test/atrt-testBackup +++ b/storage/ndb/test/run-test/atrt-testBackup @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/run-test/atrt.hpp b/storage/ndb/test/run-test/atrt.hpp index 39f7e1a7bf2..9e75d9bf96e 100644 --- a/storage/ndb/test/run-test/atrt.hpp +++ b/storage/ndb/test/run-test/atrt.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2007 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2003-2005, 2007 MySQL AB, 2008 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/storage/ndb/test/run-test/daily-devel-tests.txt b/storage/ndb/test/run-test/daily-devel-tests.txt index dc17e31de6a..1fe9b0d502e 100644 --- a/storage/ndb/test/run-test/daily-devel-tests.txt +++ b/storage/ndb/test/run-test/daily-devel-tests.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2004, 2005 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/run-test/main.cpp b/storage/ndb/test/run-test/main.cpp index b5c4385f5d3..0ace5b96472 100644 --- a/storage/ndb/test/run-test/main.cpp +++ b/storage/ndb/test/run-test/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/run-test/make-index.sh b/storage/ndb/test/run-test/make-index.sh index f13ac098567..98db29b8c40 100755 --- a/storage/ndb/test/run-test/make-index.sh +++ b/storage/ndb/test/run-test/make-index.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/storage/ndb/test/src/CpcClient.cpp b/storage/ndb/test/src/CpcClient.cpp index d5dfd01327e..300808e967f 100644 --- a/storage/ndb/test/src/CpcClient.cpp +++ b/storage/ndb/test/src/CpcClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/DbUtil.cpp b/storage/ndb/test/src/DbUtil.cpp index a52f45b46a7..f42bf781883 100755 --- a/storage/ndb/test/src/DbUtil.cpp +++ b/storage/ndb/test/src/DbUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB +/* Copyright (c) 2007, 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/HugoAsynchTransactions.cpp b/storage/ndb/test/src/HugoAsynchTransactions.cpp index 0a5991d9e20..11df6b36a19 100644 --- a/storage/ndb/test/src/HugoAsynchTransactions.cpp +++ b/storage/ndb/test/src/HugoAsynchTransactions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/HugoCalculator.cpp b/storage/ndb/test/src/HugoCalculator.cpp index 1589d4a9eb0..e37c93b5c04 100644 --- a/storage/ndb/test/src/HugoCalculator.cpp +++ b/storage/ndb/test/src/HugoCalculator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/HugoOperations.cpp b/storage/ndb/test/src/HugoOperations.cpp index 93a9eaf435a..067389de4c3 100644 --- a/storage/ndb/test/src/HugoOperations.cpp +++ b/storage/ndb/test/src/HugoOperations.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/HugoTransactions.cpp b/storage/ndb/test/src/HugoTransactions.cpp index 0e5f7cd8115..878ba08978e 100644 --- a/storage/ndb/test/src/HugoTransactions.cpp +++ b/storage/ndb/test/src/HugoTransactions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/Makefile.am b/storage/ndb/test/src/Makefile.am index 1e4f30c3f39..1e9d0585c10 100644 --- a/storage/ndb/test/src/Makefile.am +++ b/storage/ndb/test/src/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004-2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NDBT_Error.cpp b/storage/ndb/test/src/NDBT_Error.cpp index c291a81a0df..afeedc1fb8c 100644 --- a/storage/ndb/test/src/NDBT_Error.cpp +++ b/storage/ndb/test/src/NDBT_Error.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NDBT_Output.cpp b/storage/ndb/test/src/NDBT_Output.cpp index e08a3d996eb..c625ed1bade 100644 --- a/storage/ndb/test/src/NDBT_Output.cpp +++ b/storage/ndb/test/src/NDBT_Output.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NDBT_ResultRow.cpp b/storage/ndb/test/src/NDBT_ResultRow.cpp index cdd7c65e7aa..a14950010f8 100644 --- a/storage/ndb/test/src/NDBT_ResultRow.cpp +++ b/storage/ndb/test/src/NDBT_ResultRow.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NDBT_ReturnCodes.cpp b/storage/ndb/test/src/NDBT_ReturnCodes.cpp index 5cd5eed3af7..857bc6d5ffc 100644 --- a/storage/ndb/test/src/NDBT_ReturnCodes.cpp +++ b/storage/ndb/test/src/NDBT_ReturnCodes.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NDBT_Table.cpp b/storage/ndb/test/src/NDBT_Table.cpp index 1787bef9aba..61d5df8b88b 100644 --- a/storage/ndb/test/src/NDBT_Table.cpp +++ b/storage/ndb/test/src/NDBT_Table.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NDBT_Tables.cpp b/storage/ndb/test/src/NDBT_Tables.cpp index 9c94dcc18d1..389d03a703e 100644 --- a/storage/ndb/test/src/NDBT_Tables.cpp +++ b/storage/ndb/test/src/NDBT_Tables.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NDBT_Test.cpp b/storage/ndb/test/src/NDBT_Test.cpp index 69f3723ca75..6e356d88aff 100644 --- a/storage/ndb/test/src/NDBT_Test.cpp +++ b/storage/ndb/test/src/NDBT_Test.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NDBT_Thread.cpp b/storage/ndb/test/src/NDBT_Thread.cpp index ff6785724ba..2bc53ca167f 100644 --- a/storage/ndb/test/src/NDBT_Thread.cpp +++ b/storage/ndb/test/src/NDBT_Thread.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NdbBackup.cpp b/storage/ndb/test/src/NdbBackup.cpp index 3fb4de461f0..73f3bffa7db 100644 --- a/storage/ndb/test/src/NdbBackup.cpp +++ b/storage/ndb/test/src/NdbBackup.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NdbConfig.cpp b/storage/ndb/test/src/NdbConfig.cpp index ecb2030e63c..fd40a8b6384 100644 --- a/storage/ndb/test/src/NdbConfig.cpp +++ b/storage/ndb/test/src/NdbConfig.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NdbGrep.cpp b/storage/ndb/test/src/NdbGrep.cpp index 99bcede63c8..9ff5c113963 100644 --- a/storage/ndb/test/src/NdbGrep.cpp +++ b/storage/ndb/test/src/NdbGrep.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NdbMixRestarter.cpp b/storage/ndb/test/src/NdbMixRestarter.cpp index 81631afaa1a..6e2afeb0752 100644 --- a/storage/ndb/test/src/NdbMixRestarter.cpp +++ b/storage/ndb/test/src/NdbMixRestarter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NdbRestarter.cpp b/storage/ndb/test/src/NdbRestarter.cpp index 1acd28dab23..cfc320344fb 100644 --- a/storage/ndb/test/src/NdbRestarter.cpp +++ b/storage/ndb/test/src/NdbRestarter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NdbRestarts.cpp b/storage/ndb/test/src/NdbRestarts.cpp index 86e71f4b3fc..1a6ed421dfc 100644 --- a/storage/ndb/test/src/NdbRestarts.cpp +++ b/storage/ndb/test/src/NdbRestarts.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NdbSchemaCon.cpp b/storage/ndb/test/src/NdbSchemaCon.cpp index 1e1b4028fc1..4404eac6f91 100644 --- a/storage/ndb/test/src/NdbSchemaCon.cpp +++ b/storage/ndb/test/src/NdbSchemaCon.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/NdbSchemaOp.cpp b/storage/ndb/test/src/NdbSchemaOp.cpp index 9e19426c615..9b254e4b518 100644 --- a/storage/ndb/test/src/NdbSchemaOp.cpp +++ b/storage/ndb/test/src/NdbSchemaOp.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/src/UtilTransactions.cpp b/storage/ndb/test/src/UtilTransactions.cpp index 776ffd176b3..8b5a1decbf8 100644 --- a/storage/ndb/test/src/UtilTransactions.cpp +++ b/storage/ndb/test/src/UtilTransactions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/Makefile.am b/storage/ndb/test/tools/Makefile.am index da715caa1cb..a78a8d61bad 100644 --- a/storage/ndb/test/tools/Makefile.am +++ b/storage/ndb/test/tools/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2005 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/copy_tab.cpp b/storage/ndb/test/tools/copy_tab.cpp index 3a511995f48..28ee6a0efdf 100644 --- a/storage/ndb/test/tools/copy_tab.cpp +++ b/storage/ndb/test/tools/copy_tab.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/cpcc.cpp b/storage/ndb/test/tools/cpcc.cpp index f26f0ec4cd9..fe9dfc484ed 100644 --- a/storage/ndb/test/tools/cpcc.cpp +++ b/storage/ndb/test/tools/cpcc.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/create_index.cpp b/storage/ndb/test/tools/create_index.cpp index 450d88124e7..ed71654c7d6 100644 --- a/storage/ndb/test/tools/create_index.cpp +++ b/storage/ndb/test/tools/create_index.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoCalculator.cpp b/storage/ndb/test/tools/hugoCalculator.cpp index eedd8cd6e46..f40235317a6 100644 --- a/storage/ndb/test/tools/hugoCalculator.cpp +++ b/storage/ndb/test/tools/hugoCalculator.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoFill.cpp b/storage/ndb/test/tools/hugoFill.cpp index 20ceb61b066..ce5ebdad23b 100644 --- a/storage/ndb/test/tools/hugoFill.cpp +++ b/storage/ndb/test/tools/hugoFill.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoLoad.cpp b/storage/ndb/test/tools/hugoLoad.cpp index ae21869a305..ea4620ec620 100644 --- a/storage/ndb/test/tools/hugoLoad.cpp +++ b/storage/ndb/test/tools/hugoLoad.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoLockRecords.cpp b/storage/ndb/test/tools/hugoLockRecords.cpp index ddc77061446..d7e0620b101 100644 --- a/storage/ndb/test/tools/hugoLockRecords.cpp +++ b/storage/ndb/test/tools/hugoLockRecords.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoPkDelete.cpp b/storage/ndb/test/tools/hugoPkDelete.cpp index aa8e6c654a7..f8cadc9ba9c 100644 --- a/storage/ndb/test/tools/hugoPkDelete.cpp +++ b/storage/ndb/test/tools/hugoPkDelete.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoPkRead.cpp b/storage/ndb/test/tools/hugoPkRead.cpp index 232f55b35b8..956dff90533 100644 --- a/storage/ndb/test/tools/hugoPkRead.cpp +++ b/storage/ndb/test/tools/hugoPkRead.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoPkReadRecord.cpp b/storage/ndb/test/tools/hugoPkReadRecord.cpp index 32cd732d317..aab9ba5bfea 100644 --- a/storage/ndb/test/tools/hugoPkReadRecord.cpp +++ b/storage/ndb/test/tools/hugoPkReadRecord.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoPkUpdate.cpp b/storage/ndb/test/tools/hugoPkUpdate.cpp index 3fa87da3145..69ea15eae4b 100644 --- a/storage/ndb/test/tools/hugoPkUpdate.cpp +++ b/storage/ndb/test/tools/hugoPkUpdate.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoScanRead.cpp b/storage/ndb/test/tools/hugoScanRead.cpp index aa3ecf46e5a..a8dd2838eca 100644 --- a/storage/ndb/test/tools/hugoScanRead.cpp +++ b/storage/ndb/test/tools/hugoScanRead.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/hugoScanUpdate.cpp b/storage/ndb/test/tools/hugoScanUpdate.cpp index 05c1b7292ac..c61183b9341 100644 --- a/storage/ndb/test/tools/hugoScanUpdate.cpp +++ b/storage/ndb/test/tools/hugoScanUpdate.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/listen.cpp b/storage/ndb/test/tools/listen.cpp index e51b213195b..b67cd4f378e 100644 --- a/storage/ndb/test/tools/listen.cpp +++ b/storage/ndb/test/tools/listen.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/rep_latency.cpp b/storage/ndb/test/tools/rep_latency.cpp index 5ca9a1a1190..b10296c977a 100644 --- a/storage/ndb/test/tools/rep_latency.cpp +++ b/storage/ndb/test/tools/rep_latency.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/restart.cpp b/storage/ndb/test/tools/restart.cpp index 6fb16ef1d34..6e1176cc48c 100644 --- a/storage/ndb/test/tools/restart.cpp +++ b/storage/ndb/test/tools/restart.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/transproxy.cpp b/storage/ndb/test/tools/transproxy.cpp index b6aa3d2f313..be85483bcc1 100644 --- a/storage/ndb/test/tools/transproxy.cpp +++ b/storage/ndb/test/tools/transproxy.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/test/tools/verify_index.cpp b/storage/ndb/test/tools/verify_index.cpp index 567f029aa06..9fe43a28cdf 100644 --- a/storage/ndb/test/tools/verify_index.cpp +++ b/storage/ndb/test/tools/verify_index.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/Makefile.am b/storage/ndb/tools/Makefile.am index de0f36963bf..be2c82b0c52 100644 --- a/storage/ndb/tools/Makefile.am +++ b/storage/ndb/tools/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/clean-links.sh b/storage/ndb/tools/clean-links.sh index 84052a619d0..3489f30d77d 100755 --- a/storage/ndb/tools/clean-links.sh +++ b/storage/ndb/tools/clean-links.sh @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/delete_all.cpp b/storage/ndb/tools/delete_all.cpp index 1bf89f5a32f..2c2fe0c184e 100644 --- a/storage/ndb/tools/delete_all.cpp +++ b/storage/ndb/tools/delete_all.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/desc.cpp b/storage/ndb/tools/desc.cpp index 831005139de..e99c4c0ef8c 100644 --- a/storage/ndb/tools/desc.cpp +++ b/storage/ndb/tools/desc.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/drop_index.cpp b/storage/ndb/tools/drop_index.cpp index ec88f331a80..6312a893b2b 100644 --- a/storage/ndb/tools/drop_index.cpp +++ b/storage/ndb/tools/drop_index.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/drop_tab.cpp b/storage/ndb/tools/drop_tab.cpp index 8d07afbbf50..88d5306da7e 100644 --- a/storage/ndb/tools/drop_tab.cpp +++ b/storage/ndb/tools/drop_tab.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/listTables.cpp b/storage/ndb/tools/listTables.cpp index 45129cb34af..87cd5944805 100644 --- a/storage/ndb/tools/listTables.cpp +++ b/storage/ndb/tools/listTables.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/make-errors.pl b/storage/ndb/tools/make-errors.pl index ac9c7d1d58a..67bb8bcaaa6 100644 --- a/storage/ndb/tools/make-errors.pl +++ b/storage/ndb/tools/make-errors.pl @@ -1,6 +1,6 @@ #! /usr/local/bin/perl -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/make-links.sh b/storage/ndb/tools/make-links.sh index 6008406ad6a..03457b16bfa 100755 --- a/storage/ndb/tools/make-links.sh +++ b/storage/ndb/tools/make-links.sh @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/ndb_config.cpp b/storage/ndb/tools/ndb_config.cpp index af36103f947..0f110c859fa 100644 --- a/storage/ndb/tools/ndb_config.cpp +++ b/storage/ndb/tools/ndb_config.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/ndb_error_reporter b/storage/ndb/tools/ndb_error_reporter index 1af3bf83469..ef1c2682c4b 100644 --- a/storage/ndb/tools/ndb_error_reporter +++ b/storage/ndb/tools/ndb_error_reporter @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/ndb_test_platform.cpp b/storage/ndb/tools/ndb_test_platform.cpp index 27b50df5188..0c4f4310798 100644 --- a/storage/ndb/tools/ndb_test_platform.cpp +++ b/storage/ndb/tools/ndb_test_platform.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/ndbsql.cpp b/storage/ndb/tools/ndbsql.cpp index c243209afdd..87f1ff40d36 100644 --- a/storage/ndb/tools/ndbsql.cpp +++ b/storage/ndb/tools/ndbsql.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2005 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/Restore.cpp b/storage/ndb/tools/restore/Restore.cpp index f599bb21978..3e5b59e3180 100644 --- a/storage/ndb/tools/restore/Restore.cpp +++ b/storage/ndb/tools/restore/Restore.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/Restore.hpp b/storage/ndb/tools/restore/Restore.hpp index f6de9245509..26f062d09a0 100644 --- a/storage/ndb/tools/restore/Restore.hpp +++ b/storage/ndb/tools/restore/Restore.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/consumer.cpp b/storage/ndb/tools/restore/consumer.cpp index e7ce561c5f0..067f803308b 100644 --- a/storage/ndb/tools/restore/consumer.cpp +++ b/storage/ndb/tools/restore/consumer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/consumer.hpp b/storage/ndb/tools/restore/consumer.hpp index 4121cc4e1b4..870efb7346f 100644 --- a/storage/ndb/tools/restore/consumer.hpp +++ b/storage/ndb/tools/restore/consumer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/consumer_printer.cpp b/storage/ndb/tools/restore/consumer_printer.cpp index 721e0332381..7cb750c8ac6 100644 --- a/storage/ndb/tools/restore/consumer_printer.cpp +++ b/storage/ndb/tools/restore/consumer_printer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/consumer_printer.hpp b/storage/ndb/tools/restore/consumer_printer.hpp index 688d60af308..032c0018325 100644 --- a/storage/ndb/tools/restore/consumer_printer.hpp +++ b/storage/ndb/tools/restore/consumer_printer.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/consumer_restore.hpp b/storage/ndb/tools/restore/consumer_restore.hpp index 8694cbffb0c..094c1d92112 100644 --- a/storage/ndb/tools/restore/consumer_restore.hpp +++ b/storage/ndb/tools/restore/consumer_restore.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/ndb_nodegroup_map.h b/storage/ndb/tools/restore/ndb_nodegroup_map.h index 120057605ea..cd6932fcb35 100644 --- a/storage/ndb/tools/restore/ndb_nodegroup_map.h +++ b/storage/ndb/tools/restore/ndb_nodegroup_map.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp index 7db77524ad8..81c58e96fc7 100644 --- a/storage/ndb/tools/restore/restore_main.cpp +++ b/storage/ndb/tools/restore/restore_main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/rgrep b/storage/ndb/tools/rgrep index b1ed4fb6f5e..5c033d5169f 100755 --- a/storage/ndb/tools/rgrep +++ b/storage/ndb/tools/rgrep @@ -1,6 +1,6 @@ #!/vobs/wds/swt/bin/perl -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004, 2005 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/select_all.cpp b/storage/ndb/tools/select_all.cpp index 23d5f95f3f7..3ae5ef40daa 100644 --- a/storage/ndb/tools/select_all.cpp +++ b/storage/ndb/tools/select_all.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/select_count.cpp b/storage/ndb/tools/select_count.cpp index 73982e886b5..5fadc81abe7 100644 --- a/storage/ndb/tools/select_count.cpp +++ b/storage/ndb/tools/select_count.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/ndb/tools/waiter.cpp b/storage/ndb/tools/waiter.cpp index fc2a4b368b1..476f3bf81c9 100644 --- a/storage/ndb/tools/waiter.cpp +++ b/storage/ndb/tools/waiter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/strings/bchange.c b/strings/bchange.c index 13d491844f7..6854331d64e 100644 --- a/strings/bchange.c +++ b/strings/bchange.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/bfill.c b/strings/bfill.c index e6c1c3e0ed0..05089c84090 100644 --- a/strings/bfill.c +++ b/strings/bfill.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2002, 2006 MySQL AB +/* Copyright (c) 2000-2002 MySQL AB Use is subject to license terms. This library is free software; you can redistribute it and/or diff --git a/strings/bmove.c b/strings/bmove.c index f7f29271de1..43068dc7000 100644 --- a/strings/bmove.c +++ b/strings/bmove.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2002, 2006 MySQL AB +/* Copyright (c) 2000-2002 MySQL AB Use is subject to license terms. This library is free software; you can redistribute it and/or diff --git a/strings/bmove512.c b/strings/bmove512.c index bd863f82071..14643538e60 100644 --- a/strings/bmove512.c +++ b/strings/bmove512.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2003, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/bmove_upp-sparc.s b/strings/bmove_upp-sparc.s index f745f0fc613..a61140320a2 100644 --- a/strings/bmove_upp-sparc.s +++ b/strings/bmove_upp-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000, 2002 MySQL AB +! Copyright (c) 2000, 2002, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/bmove_upp.c b/strings/bmove_upp.c index 48af2e43737..f411029fefa 100644 --- a/strings/bmove_upp.c +++ b/strings/bmove_upp.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 92d7b5f48c8..41381770089 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 082868600b2..eef6a65ee18 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2002-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 26a3bac7964..efb1f88cec0 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 004a09866aa..87c53717fd9 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public diff --git a/strings/ctype.c b/strings/ctype.c index ecb827cc778..1de656d2bd3 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2007 MySQL AB, 2008, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/strings/do_ctype.c b/strings/do_ctype.c index fed00c82624..cc2e4a79937 100644 --- a/strings/do_ctype.c +++ b/strings/do_ctype.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2002, 2006, 2007 MySQL AB +/* Copyright (c) 2000-2002, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/int2str.c b/strings/int2str.c index 8f039d1d5cd..073b3bed69d 100644 --- a/strings/int2str.c +++ b/strings/int2str.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2004, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/is_prefix.c b/strings/is_prefix.c index e3cff258a24..3f3ece4fa9b 100644 --- a/strings/is_prefix.c +++ b/strings/is_prefix.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006 MySQL AB +/* Copyright (c) 2000, 2001 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/llstr.c b/strings/llstr.c index 0734137f3c4..1df2ab865fe 100644 --- a/strings/llstr.c +++ b/strings/llstr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2004, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/longlong2str-x86.s b/strings/longlong2str-x86.s index 3de43a96e78..ce820878e5c 100644 --- a/strings/longlong2str-x86.s +++ b/strings/longlong2str-x86.s @@ -1,4 +1,4 @@ -# Copyright (C) 2000 MySQL AB +# Copyright (c) 2000-2002, 2004, 2005 MySQL AB # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. diff --git a/strings/longlong2str.c b/strings/longlong2str.c index 10e9dc568f8..6c96e2ce35d 100644 --- a/strings/longlong2str.c +++ b/strings/longlong2str.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2004, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/longlong2str_asm.c b/strings/longlong2str_asm.c index a6a64d7d249..b9a6b35309d 100644 --- a/strings/longlong2str_asm.c +++ b/strings/longlong2str_asm.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2005, 2006 MySQL AB +/* Copyright (c) 2005 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/macros.asm b/strings/macros.asm index 1eedcfbb15f..93af58ea247 100644 --- a/strings/macros.asm +++ b/strings/macros.asm @@ -1,4 +1,4 @@ -; Copyright (C) 2000 MySQL AB +; Copyright (c) 2000, 2006 MySQL AB ; ; This library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Library General Public diff --git a/strings/my_strtoll10-x86.s b/strings/my_strtoll10-x86.s index f73428de7de..d16287fe17a 100644 --- a/strings/my_strtoll10-x86.s +++ b/strings/my_strtoll10-x86.s @@ -1,4 +1,4 @@ -# Copyright (C) 2003 MySQL AB +# Copyright (c) 2003, 2005, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 7309a2ed20d..0f94302fdeb 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2007 MySQL AB +/* Copyright (c) 2003-2005, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/ptr_cmp.asm b/strings/ptr_cmp.asm index b2a020d8a37..925aa46e292 100644 --- a/strings/ptr_cmp.asm +++ b/strings/ptr_cmp.asm @@ -1,4 +1,4 @@ -; Copyright (C) 2000 MySQL AB +; Copyright (c) 2000, 2006 MySQL AB ; ; This library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Library General Public diff --git a/strings/r_strinstr.c b/strings/r_strinstr.c index 3d97fe3959c..ed766163dee 100644 --- a/strings/r_strinstr.c +++ b/strings/r_strinstr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2004, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/str2int.c b/strings/str2int.c index 925880fd83e..2c40fc62528 100644 --- a/strings/str2int.c +++ b/strings/str2int.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2003, 2006 MySQL AB +/* Copyright (c) 2000-2003 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/str_alloc.c b/strings/str_alloc.c index 9e870950c27..6368ae5bd17 100644 --- a/strings/str_alloc.c +++ b/strings/str_alloc.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2005, 2006 MySQL AB +/* Copyright (c) 2005 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strappend-sparc.s b/strings/strappend-sparc.s index d5add816eb0..9c58ffd7a1f 100644 --- a/strings/strappend-sparc.s +++ b/strings/strappend-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000, 2002 MySQL AB +! Copyright (c) 2000, 2002, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/strappend.c b/strings/strappend.c index 980cc26af74..b617579c51f 100644 --- a/strings/strappend.c +++ b/strings/strappend.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strcend.c b/strings/strcend.c index 0ff48223500..6c5be8d541c 100644 --- a/strings/strcend.c +++ b/strings/strcend.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006 MySQL AB +/* Copyright (c) 2000, 2001 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strcont.c b/strings/strcont.c index 71755ca4f9a..b12045d45a4 100644 --- a/strings/strcont.c +++ b/strings/strcont.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strend-sparc.s b/strings/strend-sparc.s index f264fcef32f..8cfa1af00d3 100644 --- a/strings/strend-sparc.s +++ b/strings/strend-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000, 2002 MySQL AB +! Copyright (c) 2000, 2002, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/strend.c b/strings/strend.c index 89178d2a662..3e72d6cc8c8 100644 --- a/strings/strend.c +++ b/strings/strend.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2002, 2006 MySQL AB +/* Copyright (c) 2000-2002 MySQL AB Use is subject to license terms. This library is free software; you can redistribute it and/or diff --git a/strings/strfill.c b/strings/strfill.c index 16fad9f3670..72ee526582d 100644 --- a/strings/strfill.c +++ b/strings/strfill.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strings-not-used.h b/strings/strings-not-used.h index 3efaa8ab6eb..5763f32e0ca 100644 --- a/strings/strings-not-used.h +++ b/strings/strings-not-used.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/strings/strings-x86.s b/strings/strings-x86.s index db7bb0c1274..3af8ec024dc 100644 --- a/strings/strings-x86.s +++ b/strings/strings-x86.s @@ -1,4 +1,4 @@ -# Copyright (C) 2000 MySQL AB +# Copyright (c) 2000, 2002-2004 MySQL AB # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. diff --git a/strings/strings.asm b/strings/strings.asm index 2224025cc72..24f7fed6a71 100644 --- a/strings/strings.asm +++ b/strings/strings.asm @@ -1,4 +1,4 @@ -; Copyright (C) 2000, 2003 MySQL AB +; Copyright (c) 2000, 2003, 2006 MySQL AB ; ; This library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Library General Public diff --git a/strings/strinstr-sparc.s b/strings/strinstr-sparc.s index 5278aff6aa7..c39b2793a34 100644 --- a/strings/strinstr-sparc.s +++ b/strings/strinstr-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000 MySQL AB +! Copyright (c) 2000, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/strinstr.c b/strings/strinstr.c index c95dfe9d711..a2a6218d2b9 100644 --- a/strings/strinstr.c +++ b/strings/strinstr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2004, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strmake-sparc.s b/strings/strmake-sparc.s index 36db8efd402..68f30da6e53 100644 --- a/strings/strmake-sparc.s +++ b/strings/strmake-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000, 2002 MySQL AB +! Copyright (c) 2000, 2002, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/strmake.c b/strings/strmake.c index 1a5ad2286df..6e437fca487 100644 --- a/strings/strmake.c +++ b/strings/strmake.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2003, 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2001, 2003, 2007, 2008 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strmov-sparc.s b/strings/strmov-sparc.s index f124da2dc9f..b472aad5d90 100644 --- a/strings/strmov-sparc.s +++ b/strings/strmov-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000, 2002 MySQL AB +! Copyright (c) 2000, 2002, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/strmov.c b/strings/strmov.c index e670654eb95..84e73570e05 100644 --- a/strings/strmov.c +++ b/strings/strmov.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2001 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strnlen.c b/strings/strnlen.c index 4826c17ff19..1d35ed66edc 100644 --- a/strings/strnlen.c +++ b/strings/strnlen.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strnmov-sparc.s b/strings/strnmov-sparc.s index df0c4bebf03..a4b6cdd0bc0 100644 --- a/strings/strnmov-sparc.s +++ b/strings/strnmov-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000, 2002 MySQL AB +! Copyright (c) 2000, 2002, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/strnmov.c b/strings/strnmov.c index 64cc46e3c05..4af52a75777 100644 --- a/strings/strnmov.c +++ b/strings/strnmov.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB +/* Copyright (c) 2000, 2001, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strstr-sparc.s b/strings/strstr-sparc.s index 2a6590c9c93..0593c1ddf61 100644 --- a/strings/strstr-sparc.s +++ b/strings/strstr-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000, 2002 MySQL AB +! Copyright (c) 2000, 2002, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/strstr.c b/strings/strstr.c index 8c7be350bb6..292dd94d53d 100644 --- a/strings/strstr.c +++ b/strings/strstr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2002, 2004, 2006 MySQL AB +/* Copyright (c) 2000-2002, 2004 MySQL AB Use is subject to license terms. This library is free software; you can redistribute it and/or diff --git a/strings/strto.c b/strings/strto.c index 8255c38f52e..4d05e8eaf71 100644 --- a/strings/strto.c +++ b/strings/strto.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2004, 2006, 2007 MySQL AB +/* Copyright (c) 2000-2004, 2007 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strtol.c b/strings/strtol.c index 7b4d13f8778..90490f9c75b 100644 --- a/strings/strtol.c +++ b/strings/strtol.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2004, 2006 MySQL AB +/* Copyright (c) 2000, 2001, 2004 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strtoll.c b/strings/strtoll.c index 0858b21865e..06070cb4c9b 100644 --- a/strings/strtoll.c +++ b/strings/strtoll.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2003, 2004, 2006 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2004 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strtoul.c b/strings/strtoul.c index 2c5ef0867fd..fbfa4d5ba64 100644 --- a/strings/strtoul.c +++ b/strings/strtoul.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2004, 2006 MySQL AB +/* Copyright (c) 2000, 2001, 2004 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strtoull.c b/strings/strtoull.c index 819d9ab9d72..aad0207cff3 100644 --- a/strings/strtoull.c +++ b/strings/strtoull.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2003, 2004, 2006 MySQL AB +/* Copyright (c) 2000, 2001, 2003, 2004 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/strings/strxmov-sparc.s b/strings/strxmov-sparc.s index 11ae49a876b..8a7032f67c6 100644 --- a/strings/strxmov-sparc.s +++ b/strings/strxmov-sparc.s @@ -1,4 +1,4 @@ -! Copyright (C) 2000, 2002 MySQL AB +! Copyright (c) 2000, 2002, 2006 MySQL AB ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public diff --git a/strings/strxmov.asm b/strings/strxmov.asm index ad5d0dd3db0..20273da868f 100644 --- a/strings/strxmov.asm +++ b/strings/strxmov.asm @@ -1,4 +1,4 @@ -; Copyright (C) 2000 MySQL AB +; Copyright (c) 2000, 2006 MySQL AB ; ; This library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Library General Public diff --git a/strings/strxmov.c b/strings/strxmov.c index c5963170c91..51206300857 100644 --- a/strings/strxmov.c +++ b/strings/strxmov.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2002, 2006 MySQL AB +/* Copyright (c) 2000-2002 MySQL AB Use is subject to license terms. This library is free software; you can redistribute it and/or diff --git a/strings/strxnmov.c b/strings/strxnmov.c index f9db76c0264..6c0182d97d7 100644 --- a/strings/strxnmov.c +++ b/strings/strxnmov.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000-2002, 2005-2007 MySQL AB +/* Copyright (c) 2000-2002, 2005, 2007 MySQL AB Use is subject to license terms. This library is free software; you can redistribute it and/or diff --git a/strings/t_ctype.h b/strings/t_ctype.h index af4f3ebbaa1..31c366a9ab4 100644 --- a/strings/t_ctype.h +++ b/strings/t_ctype.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/strings/udiv.c b/strings/udiv.c index c7780dde64a..5c2415536f1 100644 --- a/strings/udiv.c +++ b/strings/udiv.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2001, 2006 MySQL AB +/* Copyright (c) 2000, 2001 MySQL AB Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/support-files/MacOSX/Makefile.am b/support-files/MacOSX/Makefile.am index 4ee5b90263c..7b8a5818453 100644 --- a/support-files/MacOSX/Makefile.am +++ b/support-files/MacOSX/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2003-2006 MySQL AB +# Copyright (c) 2003-2006, 2008 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/support-files/MySQL-shared-compat.spec.sh b/support-files/MySQL-shared-compat.spec.sh index 14a98616863..176831613c3 100644 --- a/support-files/MySQL-shared-compat.spec.sh +++ b/support-files/MySQL-shared-compat.spec.sh @@ -7,7 +7,7 @@ # separate "MySQL-shared" package. This spec file simply repackages two # already existing MySQL-shared RPMs into a single package. # -# Copyright (C) 2003 MySQL AB +# Copyright (c) 2003-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free diff --git a/support-files/RHEL4-SElinux/Makefile.am b/support-files/RHEL4-SElinux/Makefile.am index 960a1fea554..65e018f1f77 100644 --- a/support-files/RHEL4-SElinux/Makefile.am +++ b/support-files/RHEL4-SElinux/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2001, 2003-2006 MySQL AB +# Copyright (c) 2000, 2001, 2003-2007 MySQL AB # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 395010b3773..115a1380e32 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2093fc0da36..68ed2be30bf 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/Makefile.am b/tests/Makefile.am index 3da18683f85..dfc4cfbc897 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,4 @@ -# Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. -# Use is subject to license terms. +# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/tests/connect_test.c b/tests/connect_test.c index a0f2d7561d1..6dc2375e2dc 100644 --- a/tests/connect_test.c +++ b/tests/connect_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tests/fork_big.pl b/tests/fork_big.pl index a674f7f7164..21590f870c4 100755 --- a/tests/fork_big.pl +++ b/tests/fork_big.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2001 MySQL AB +# Copyright (c) 2001, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl index 0d4aee7c774..3595166048a 100644 --- a/tests/fork_big2.pl +++ b/tests/fork_big2.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2002, 2005 MySQL AB +# Copyright (c) 2002, 2003, 2005, 2006 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/insert_test.c b/tests/insert_test.c index bb7b0a2f928..28f794044b8 100644 --- a/tests/insert_test.c +++ b/tests/insert_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tests/list_test.c b/tests/list_test.c index 8b752c8b6e4..7e739438865 100644 --- a/tests/list_test.c +++ b/tests/list_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tests/select_test.c b/tests/select_test.c index 5a9021c4dd6..a27f03f3b35 100644 --- a/tests/select_test.c +++ b/tests/select_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2002-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tests/showdb_test.c b/tests/showdb_test.c index 4be48c28205..1ad9577c699 100644 --- a/tests/showdb_test.c +++ b/tests/showdb_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003, 2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tests/ssl_test.c b/tests/ssl_test.c index ad6bc925cc6..b75c6f66760 100644 --- a/tests/ssl_test.c +++ b/tests/ssl_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003, 2004, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tests/thread_test.c b/tests/thread_test.c index 8e1c58ebbec..0b80451bee8 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2004, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/unittest/mytap/Makefile.am b/unittest/mytap/Makefile.am index c02bcd3b49d..62f38a787fb 100644 --- a/unittest/mytap/Makefile.am +++ b/unittest/mytap/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/unittest/mytap/t/Makefile.am b/unittest/mytap/t/Makefile.am index e89a088bb3a..aa58f5a1d40 100644 --- a/unittest/mytap/t/Makefile.am +++ b/unittest/mytap/t/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt index 164bcde7c4b..9a275fac3c9 100755 --- a/vio/CMakeLists.txt +++ b/vio/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006-2008 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/vio/test-ssl.c b/vio/test-ssl.c index 855dc5fbb3e..a74c6739ee0 100644 --- a/vio/test-ssl.c +++ b/vio/test-ssl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/vio/test-sslclient.c b/vio/test-sslclient.c index e1b8461397b..4bfd2ca32a3 100644 --- a/vio/test-sslclient.c +++ b/vio/test-sslclient.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/vio/test-sslserver.c b/vio/test-sslserver.c index f55b5bae53a..ea92946c9fe 100644 --- a/vio/test-sslserver.c +++ b/vio/test-sslserver.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2004, 2006, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/vio/viosocket.c b/vio/viosocket.c index 9633a01f689..c969a14bd34 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/vio/viossl.c b/vio/viossl.c index 143d108d3d7..0ac96387bef 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 037c34802e9..5d31d1dde56 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -1,6 +1,5 @@ /* - Copyright (c) 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/vio/viotest-ssl.c b/vio/viotest-ssl.c index b8abbac4ed6..7fe652d118e 100644 --- a/vio/viotest-ssl.c +++ b/vio/viotest-ssl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2003, 2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/win/build-nmake-x64.bat b/win/build-nmake-x64.bat index f73574ac8de..3a68f37415f 100644 --- a/win/build-nmake-x64.bat +++ b/win/build-nmake-x64.bat @@ -1,6 +1,6 @@ @echo off -REM Copyright (C) 2006 MySQL AB +REM Copyright (c) 2006, 2007 MySQL AB REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/win/build-nmake.bat b/win/build-nmake.bat index 89505c08313..803c32ae02c 100644 --- a/win/build-nmake.bat +++ b/win/build-nmake.bat @@ -1,6 +1,6 @@ @echo off -REM Copyright (C) 2006 MySQL AB +REM Copyright (c) 2006, 2007 MySQL AB REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/win/build-vs71.bat b/win/build-vs71.bat index 159b1ec97d1..ec67415945b 100755 --- a/win/build-vs71.bat +++ b/win/build-vs71.bat @@ -1,6 +1,6 @@ @echo off -REM Copyright (C) 2006 MySQL AB +REM Copyright (c) 2006, 2007 MySQL AB REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/win/build-vs8.bat b/win/build-vs8.bat index ff0eeb0a8cb..1e36cf55a8c 100755 --- a/win/build-vs8.bat +++ b/win/build-vs8.bat @@ -1,6 +1,6 @@ @echo off -REM Copyright (C) 2006 MySQL AB +REM Copyright (c) 2006, 2007 MySQL AB REM REM This program is free software; you can redistribute it and/or modify REM it under the terms of the GNU General Public License as published by diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 43235b631f6..9978ff8c2c7 100755 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006, 2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/zlib/Makefile.am b/zlib/Makefile.am index edcbd5f4a75..8ccbb606d17 100644 --- a/zlib/Makefile.am +++ b/zlib/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004-2007 MySQL AB # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by From fd4ea8b0942cd6c709f3931a3afc280c5fa16a1c Mon Sep 17 00:00:00 2001 From: Harin Vadodaria Date: Tue, 26 Feb 2013 21:23:06 +0530 Subject: [PATCH 091/273] Bug#16372927: STACK OVERFLOW WITH LONG DATABASE NAME IN GRANT STATEMENT Description: A missing length check causes problem while copying source to destination when lower_case_table_names is set to a value other than 0. This patch fixes the issue by ensuring that requried bound check is performed. --- sql/sql_acl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 17000e40b97..df31feccb26 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3475,7 +3475,8 @@ bool mysql_grant(THD *thd, const char *db, List &list, if (lower_case_table_names && db) { - strmov(tmp_db,db); + strnmov(tmp_db,db,NAME_LEN); + tmp_db[NAME_LEN]= '\0'; my_casedn_str(files_charset_info, tmp_db); db=tmp_db; } From d065d727042f3c0689bc3ac8320836e166886410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 27 Feb 2013 10:00:50 +0200 Subject: [PATCH 092/273] Bug#16400920 INNODB TRIES TO PASS EMPTY BUFFER TO ZLIB, GETS Z_BUF_ERROR page_zip_compress_node_ptrs(): Do not attempt to invoke deflate() with c_stream->avail_in, because it will result in Z_BUF_ERROR (and page_zip_compress() failure and unnecessary further splits of the node pointer page). A node pointer record can have empty payload, provided that all key fields are empty. Approved by Jimmy Yang --- storage/innodb_plugin/ChangeLog | 8 +++++++- storage/innodb_plugin/page/page0zip.c | 11 ++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index d1953ec6d61..a05b38d8fc2 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,6 +1,12 @@ +2013-02-27 The InnoDB Team + + * page/page0zip.c: + Fix Bug#16400920 INNODB TRIES TO PASS EMPTY BUFFER TO ZLIB, + GETS Z_BUF_ERROR + 2013-01-21 The InnoDB Team - * buf/buf0buf.cc, handler/ha_innodb.cc: + * buf/buf0buf.c, handler/ha_innodb.cc: Fix Bug#16067973 DROP TABLE IS SLOW WHEN IT DECOMPRESSES COMPRESSED-ONLY PAGES diff --git a/storage/innodb_plugin/page/page0zip.c b/storage/innodb_plugin/page/page0zip.c index 546401ccec0..2330af8d6b3 100644 --- a/storage/innodb_plugin/page/page0zip.c +++ b/storage/innodb_plugin/page/page0zip.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -837,11 +837,12 @@ page_zip_compress_node_ptrs( c_stream->next_in = (byte*) rec; c_stream->avail_in = rec_offs_data_size(offsets) - REC_NODE_PTR_SIZE; - ut_ad(c_stream->avail_in); - err = deflate(c_stream, Z_NO_FLUSH); - if (UNIV_UNLIKELY(err != Z_OK)) { - break; + if (c_stream->avail_in) { + err = deflate(c_stream, Z_NO_FLUSH); + if (UNIV_UNLIKELY(err != Z_OK)) { + break; + } } ut_ad(!c_stream->avail_in); From e1e43631f86828b90e4f80eb1b76501676ff565f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Feb 2013 12:44:58 -0600 Subject: [PATCH 093/273] Bug #16305265 HANG IN RENAME TABLE This is a deadlock that will also be fixed in the server by Bug #11844915 - HANG IN THDVAR MUTEX ACQUISITION. So this is a simple alternate method of fixing the same problem, but from within InnoDB. The simple change is to make rename table start a transaction before locking dict_sys->mutex since thd_supports_xa() can call THDVAR which can lock a mutex, LOCK_global_system_variables, that is used in the server by many other activities. At least one of those, sys_var::update(), can call back into InnoDB and try to lock dict_sys->mutex while holding LOCK_global_system_variables. The other bug fix for 11844915 eliminates the use of LOCK_global_system_variables for calls to THDVAR. Approved by marko in http://rb.no.oracle.com/rb/r/2000/ --- storage/innobase/handler/ha_innodb.cc | 8 +++++++- storage/innobase/row/row0mysql.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 65d6726b5bf..997fdb6244c 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7599,12 +7599,18 @@ innobase_rename_table( DEBUG_SYNC_C("innodb_rename_table_ready"); /* Serialize data dictionary operations with dictionary mutex: - no deadlocks can occur then in these operations */ + no deadlocks can occur then in these operations. Start the + transaction first to avoid a possible deadlock in the server. */ + trx_start_if_not_started(trx); if (lock_and_commit) { row_mysql_lock_data_dictionary(trx); } + /* Flag this transaction as a dictionary operation, so that + the data dictionary will be locked in crash recovery. */ + trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); + error = row_rename_table_for_mysql( norm_from, norm_to, trx, lock_and_commit); diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 73da6215f0d..77fa6518b35 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -3840,6 +3840,7 @@ row_rename_table_for_mysql( ut_a(old_name != NULL); ut_a(new_name != NULL); + ut_ad(trx->conc_state == TRX_ACTIVE); if (srv_created_new_raw || srv_force_recovery) { fputs("InnoDB: A new raw disk partition was initialized or\n" @@ -3864,7 +3865,6 @@ row_rename_table_for_mysql( } trx->op_info = "renaming table"; - trx_start_if_not_started(trx); old_is_tmp = row_is_mysql_tmp_table_name(old_name); new_is_tmp = row_is_mysql_tmp_table_name(new_name); From f8cd565dd70c64337ed3015cc63f5ec5d1b5e203 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Wed, 27 Feb 2013 23:21:34 +0400 Subject: [PATCH 094/273] Bug #16311231: MISSING DATA ON SUBQUERY WITH WHERE + XOR IN IN-CLAUSE USING MYISAM OR MEMORY ENGINE Backport from 5.6. Original message: The coincidences caused a data loss: * The query has IN subqueries nested twice, * the WHERE clause of the inner subquery refers to the outer field, and the whole WHERE clause returns FALSE, * the inner subquery has a LEFT JOIN that joins a single row with a row of NULLs; one of that NULL columns represents the select list of the subquery. Normally, that inner subquery should return empty record set. However, in our case: * the Item_is_not_null_test item goes constant, since its underlying field is NULL (because of LEFT JOIN ... ON FALSE of const table row with a row of nulls); * we evaluate Item_is_not_null_test::val_int() as a part of fake HAVING expression of the transformed subquery; * as far as the underlying field is NULL, we optimize out the whole fake HAVING expression as FALSE as well as a whole subquery with a zero result: Impossible HAVING noticed after reading const tables"; * thus, the optimizer ignores the presence of the WHERE clause (the WHERE expression is FALSE in our case, so the subquery should return empty set); * however, during the evaluation of the Item_is_not_null_test::val_int() in the optimizer, it marked its "owner" with the "was_null" flag -- that forced the subquery to return UNKNOWN instead of empty set. That caused a wrong result. The problem is a regression of the small cleanup in the fix for the bug11827369 (the Item_is_not_null_test part) that conflicts with optimizations in the fix for the bug11752543. Before that regression the Item_is_not_null_test items never were constants. The fix is the rollback of Item_is_not_null_test parts of the bug11827369 fix. --- sql/item_cmpfunc.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 9775cf732f5..50b8ec2cb32 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4591,7 +4591,7 @@ longlong Item_is_not_null_test::val_int() { DBUG_ASSERT(fixed == 1); DBUG_ENTER("Item_is_not_null_test::val_int"); - if (const_item_cache) + if (!used_tables_cache && !with_subselect) { owner->was_null|= (!cached_value); DBUG_PRINT("info", ("cached: %ld", (long) cached_value)); @@ -4612,12 +4612,10 @@ longlong Item_is_not_null_test::val_int() */ void Item_is_not_null_test::update_used_tables() { - const_item_cache= false; if (!args[0]->maybe_null) { used_tables_cache= 0; /* is always true */ cached_value= (longlong) 1; - const_item_cache= true; } else { @@ -4626,7 +4624,6 @@ void Item_is_not_null_test::update_used_tables() { /* Remember if the value is always NULL or never NULL */ cached_value= (longlong) !args[0]->is_null(); - const_item_cache= true; } } } From 94b1b6533d56541787683f79ccf9b23995c3a7b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Feb 2013 14:50:42 +0530 Subject: [PATCH 095/273] From 99f83c66841749a3e7507cc38a86c05823f5f2c7 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 28 Feb 2013 13:19:15 +0100 Subject: [PATCH 096/273] Bug#16414644 ASSERTION FAILED: SIZE == PFS_ALLOCATED_MEMORY Before this fix, the command SHOW ENGINE PERFORMANCE_SCHEMA STATUS could report wrong amount of memory allocated, when the amount of memory used exceeds 4GB. The problem is that size computations are not done using size_t, so that overflows do occur, truncating the results. This fix compute memory sizes properly with size_t. Tested manually. No test script provided, as the script would need to allocate too much memory for the test. --- storage/perfschema/pfs_engine_table.cc | 8 ++++---- storage/perfschema/pfs_global.cc | 4 ++-- storage/perfschema/pfs_global.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc index 38f6df3003d..2c9951e3f46 100644 --- a/storage/perfschema/pfs_engine_table.cc +++ b/storage/perfschema/pfs_engine_table.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -512,7 +512,7 @@ bool pfs_show_status(handlerton *hton, THD *thd, uint buflen; const char *name; int i; - uint size; + size_t size; DBUG_ENTER("pfs_show_status"); @@ -526,7 +526,7 @@ bool pfs_show_status(handlerton *hton, THD *thd, if (stat != HA_ENGINE_STATUS) DBUG_RETURN(false); - uint total_memory= 0; + size_t total_memory= 0; for (i=0; /* empty */; i++) { @@ -763,7 +763,7 @@ bool pfs_show_status(handlerton *hton, THD *thd, break; } - buflen= int10_to_str(size, buf, 10) - buf; + buflen= longlong10_to_str(size, buf, 10) - buf; if (print(thd, PERFORMANCE_SCHEMA_str.str, PERFORMANCE_SCHEMA_str.length, name, strlen(name), diff --git a/storage/perfschema/pfs_global.cc b/storage/perfschema/pfs_global.cc index fa57f335325..335f57c69c6 100644 --- a/storage/perfschema/pfs_global.cc +++ b/storage/perfschema/pfs_global.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ #include bool pfs_initialized= false; -ulonglong pfs_allocated_memory= 0; +size_t pfs_allocated_memory= 0; /** Memory allocation for the performance schema. diff --git a/storage/perfschema/pfs_global.h b/storage/perfschema/pfs_global.h index c0c0490a380..5a3cc342b7d 100644 --- a/storage/perfschema/pfs_global.h +++ b/storage/perfschema/pfs_global.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ */ extern bool pfs_initialized; -extern ulonglong pfs_allocated_memory; +extern size_t pfs_allocated_memory; void *pfs_malloc(size_t size, myf flags); #define PFS_MALLOC_ARRAY(n, T, f) \ From 5c22652bab3993d1d448349077a27521be30017b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Feb 2013 14:36:00 +0100 Subject: [PATCH 097/273] Updated mysql.spec.sh file for br16298542 --- support-files/mysql.spec.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index bac22fc96a9..ab26a7b6b8f 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -286,11 +286,12 @@ documentation and the manual for more information. Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases Requires: %{distro_requires} -Provides: msqlormysql MySQL MySQL-server -Conflicts: mysql mysql-server mysql-advanced mysql-server-advanced Obsoletes: MySQL MySQL-server +Obsoletes: mysql mysql-server mysql-advanced mysql-server-advanced Obsoletes: MySQL-server-classic MySQL-server-community MySQL-server-enterprise Obsoletes: MySQL-server-advanced MySQL-server-advanced-gpl MySQL-server-enterprise-gpl +Provides: msqlormysql MySQL MySQL-server +Provides: mysql %description -n MySQL-server%{product_suffix} The MySQL(TM) software delivers a very fast, multi-threaded, multi-user, @@ -320,11 +321,12 @@ package "MySQL-client%{product_suffix}" as well! %package -n MySQL-client%{product_suffix} Summary: MySQL - Client Group: Applications/Databases -Provides: MySQL-client -Conflicts: mysql mysql-advanced +Obsoletes: mysql mysql-advanced Obsoletes: MySQL-client Obsoletes: MySQL-client-classic MySQL-client-community MySQL-client-enterprise Obsoletes: MySQL-client-advanced MySQL-client-advanced-gpl MySQL-client-enterprise-gpl +Provides: MySQL-client +Provides: mysql %description -n MySQL-client%{product_suffix} This package contains the standard MySQL clients and administration tools. @@ -336,12 +338,12 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ Summary: MySQL - Test suite Group: Applications/Databases Requires: MySQL-client perl -Provides: MySQL-test Conflicts: mysql-test mysql-test-advanced Obsoletes: MySQL-test Obsoletes: mysql-bench MySQL-bench Obsoletes: MySQL-test-classic MySQL-test-community MySQL-test-enterprise Obsoletes: MySQL-test-advanced MySQL-test-advanced-gpl MySQL-test-enterprise-gpl +Provides: MySQL-test AutoReqProv: no %description -n MySQL-test%{product_suffix} @@ -353,11 +355,11 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ %package -n MySQL-devel%{product_suffix} Summary: MySQL - Development header files and libraries Group: Applications/Databases -Provides: MySQL-devel Conflicts: mysql-devel mysql-embedded-devel mysql-devel-advanced mysql-embedded-devel-advanced Obsoletes: MySQL-devel Obsoletes: MySQL-devel-classic MySQL-devel-community MySQL-devel-enterprise Obsoletes: MySQL-devel-advanced MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl +Provides: MySQL-devel %description -n MySQL-devel%{product_suffix} This package contains the development header files and libraries necessary @@ -369,12 +371,12 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ %package -n MySQL-shared%{product_suffix} Summary: MySQL - Shared libraries Group: Applications/Databases -Provides: MySQL-shared Obsoletes: MySQL-shared-standard MySQL-shared-pro Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl Obsoletes: MySQL-shared-pro-gpl-cert MySQL-shared Obsoletes: MySQL-shared-classic MySQL-shared-community MySQL-shared-enterprise Obsoletes: MySQL-shared-advanced MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl +Provides: MySQL-shared %description -n MySQL-shared%{product_suffix} This package contains the shared libraries (*.so*) which certain languages @@ -385,12 +387,12 @@ and applications need to dynamically load and use MySQL. Summary: MySQL - Embedded library Group: Applications/Databases Requires: MySQL-devel -Provides: MySQL-embedded Conflicts: mysql-embedded mysql-embedded-advanced Obsoletes: MySQL-embedded Obsoletes: MySQL-embedded-pro Obsoletes: MySQL-embedded-classic MySQL-embedded-community MySQL-embedded-enterprise Obsoletes: MySQL-embedded-advanced MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl +Provides: MySQL-embedded %description -n MySQL-embedded%{product_suffix} This package contains the MySQL server as an embedded library. From 759519034e9f635b5ed30faa9230f3e41b5b19ad Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Feb 2013 14:49:54 +0100 Subject: [PATCH 098/273] Updated release number in mysql.spec.sh file for br16298542 --- support-files/mysql.spec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index ab26a7b6b8f..3a63e7082f6 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -30,7 +30,7 @@ %define mysqld_group mysql %define mysqldatadir /var/lib/mysql -%define release 1 +%define release 2 # # Macros we use which are not available in all supported versions of RPM From a4a50271a6717d48a7721da7231b05620e2a8519 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Thu, 28 Feb 2013 14:52:47 +0100 Subject: [PATCH 099/273] Bug#16385711: HANDLER, CREATE TABLE IF NOT EXISTS, PROBLEM AFTER MYSQL_HA_FIND This problem occured if a prepared statement tried to create a table for which there already existed a view with the same name while a SQL handler was opened. Before DDL statements are executed, mysql_ha_rm_tables() is called to remove any matching tables from the internal list of opened SQL handler tables. This match was done on TABLE_LIST::db and TABLE_LIST::table_name. This is problematic for views (which use TABLE_LIST::view_db and TABLE_LIST::view_name) and anonymous derived tables. This patch fixes the problem by skipping TABLE_LISTs representing anonymous derived tables and using get_db_name()/get_table_name() which handles views when looking for SQL handler tables to remove. --- sql/sql_handler.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index e7973850194..5c0a7ec184b 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -820,10 +820,15 @@ static TABLE_LIST *mysql_ha_find(THD *thd, TABLE_LIST *tables) hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i); for (tables= first; tables; tables= tables->next_local) { - if ((! *tables->db || - ! my_strcasecmp(&my_charset_latin1, hash_tables->db, tables->db)) && - ! my_strcasecmp(&my_charset_latin1, hash_tables->table_name, - tables->table_name)) + if (tables->is_anonymous_derived_table()) + continue; + if ((! *tables->get_db_name() || + ! my_strcasecmp(&my_charset_latin1, + hash_tables->get_db_name(), + tables->get_db_name())) && + ! my_strcasecmp(&my_charset_latin1, + hash_tables->get_table_name(), + tables->get_table_name())) break; } if (tables) From 0ebb72b50814c2ffec28bc9d0b02947c263d2e9b Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Fri, 1 Mar 2013 15:01:32 +0530 Subject: [PATCH 100/273] BUG#11753923-SQL THREAD CRASHES ON DISK FULL Fixing post push issue Simulator name used needs to be changed to make it work properly. Analysis: Debug control list addition (ListAddDel function dbug.c file) code was written in such a way that if new element is subset of already existing element, then the new element is not added. i.e., set @@global.debug = '+d,abcd', is existing in the list then you cannot add "a" or "ab" or "abc" in the list. --- mysys/errors.c | 4 ++-- mysys/my_write.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mysys/errors.c b/mysys/errors.c index b518b442d6b..ddd65836b30 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -117,7 +117,7 @@ void wait_for_free_space(const char *filename, int errors) MY_WAIT_FOR_USER_TO_FIX_PANIC, MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC ); } - DBUG_EXECUTE_IF("simulate_file_write_error_once", + DBUG_EXECUTE_IF("simulate_no_free_space_error", { (void) sleep(1); return; diff --git a/mysys/my_write.c b/mysys/my_write.c index c474b86c60e..ef15e9a55b6 100644 --- a/mysys/my_write.c +++ b/mysys/my_write.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags) if (unlikely(!Count)) DBUG_RETURN(0); - DBUG_EXECUTE_IF ("simulate_file_write_error_once", + DBUG_EXECUTE_IF ("simulate_no_free_space_error", { DBUG_SET("+d,simulate_file_write_error");}); for (;;) { @@ -67,7 +67,7 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags) { wait_for_free_space(my_filename(Filedes), errors); errors++; - DBUG_EXECUTE_IF("simulate_file_write_error_once", + DBUG_EXECUTE_IF("simulate_no_free_space_error", { DBUG_SET("-d,simulate_file_write_error");}); continue; } From 429e589256ac48f8b195360d858e7bbd1a3023e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Mar 2013 14:11:24 +0100 Subject: [PATCH 101/273] Updated mysql.spec.sh file for br16298542 --- support-files/MySQL-shared-compat.spec.sh | 2 +- support-files/mysql.spec.sh | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/support-files/MySQL-shared-compat.spec.sh b/support-files/MySQL-shared-compat.spec.sh index b8b27863b3d..9e9bc26e294 100644 --- a/support-files/MySQL-shared-compat.spec.sh +++ b/support-files/MySQL-shared-compat.spec.sh @@ -42,7 +42,7 @@ Autoreqprov: on Version: %{version_cur} Release: 1 BuildRoot: %{_tmppath}/%{name}-%{version}-build -Obsoletes: MySQL-shared, mysql-shared +Obsoletes: mysql-shared Provides: MySQL-shared Summary: MySQL shared client libraries for MySQL %{version}, %{version41}, %{version40} and %{version3} # We simply use the "MySQL-shared" subpackages as input sources instead of diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 3a63e7082f6..226ff5d0dfc 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -286,10 +286,9 @@ documentation and the manual for more information. Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases Requires: %{distro_requires} -Obsoletes: MySQL MySQL-server Obsoletes: mysql mysql-server mysql-advanced mysql-server-advanced Obsoletes: MySQL-server-classic MySQL-server-community MySQL-server-enterprise -Obsoletes: MySQL-server-advanced MySQL-server-advanced-gpl MySQL-server-enterprise-gpl +Obsoletes: MySQL-server-advanced-gpl MySQL-server-enterprise-gpl Provides: msqlormysql MySQL MySQL-server Provides: mysql @@ -322,9 +321,8 @@ package "MySQL-client%{product_suffix}" as well! Summary: MySQL - Client Group: Applications/Databases Obsoletes: mysql mysql-advanced -Obsoletes: MySQL-client Obsoletes: MySQL-client-classic MySQL-client-community MySQL-client-enterprise -Obsoletes: MySQL-client-advanced MySQL-client-advanced-gpl MySQL-client-enterprise-gpl +Obsoletes: MySQL-client-advanced-gpl MySQL-client-enterprise-gpl Provides: MySQL-client Provides: mysql @@ -339,10 +337,9 @@ Summary: MySQL - Test suite Group: Applications/Databases Requires: MySQL-client perl Conflicts: mysql-test mysql-test-advanced -Obsoletes: MySQL-test Obsoletes: mysql-bench MySQL-bench Obsoletes: MySQL-test-classic MySQL-test-community MySQL-test-enterprise -Obsoletes: MySQL-test-advanced MySQL-test-advanced-gpl MySQL-test-enterprise-gpl +Obsoletes: MySQL-test-advanced-gpl MySQL-test-enterprise-gpl Provides: MySQL-test AutoReqProv: no @@ -356,9 +353,8 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ Summary: MySQL - Development header files and libraries Group: Applications/Databases Conflicts: mysql-devel mysql-embedded-devel mysql-devel-advanced mysql-embedded-devel-advanced -Obsoletes: MySQL-devel Obsoletes: MySQL-devel-classic MySQL-devel-community MySQL-devel-enterprise -Obsoletes: MySQL-devel-advanced MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl +Obsoletes: MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl Provides: MySQL-devel %description -n MySQL-devel%{product_suffix} @@ -373,9 +369,9 @@ Summary: MySQL - Shared libraries Group: Applications/Databases Obsoletes: MySQL-shared-standard MySQL-shared-pro Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl -Obsoletes: MySQL-shared-pro-gpl-cert MySQL-shared +Obsoletes: MySQL-shared-pro-gpl-cert Obsoletes: MySQL-shared-classic MySQL-shared-community MySQL-shared-enterprise -Obsoletes: MySQL-shared-advanced MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl +Obsoletes: MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl Provides: MySQL-shared %description -n MySQL-shared%{product_suffix} @@ -388,10 +384,9 @@ Summary: MySQL - Embedded library Group: Applications/Databases Requires: MySQL-devel Conflicts: mysql-embedded mysql-embedded-advanced -Obsoletes: MySQL-embedded Obsoletes: MySQL-embedded-pro Obsoletes: MySQL-embedded-classic MySQL-embedded-community MySQL-embedded-enterprise -Obsoletes: MySQL-embedded-advanced MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl +Obsoletes: MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl Provides: MySQL-embedded %description -n MySQL-embedded%{product_suffix} From 8ac9ee0801ccfa5b4a8da7da1d4c8212dd137ab6 Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Tue, 5 Mar 2013 16:16:34 +0100 Subject: [PATCH 102/273] Updated Code for Bug#16235828 --- support-files/mysql.spec.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 226ff5d0dfc..b64796fa4ea 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -716,13 +716,16 @@ if [ -d $mysql_datadir ] ; then echo "MySQL RPM upgrade to version $NEW_VERSION" > $STATUS_FILE echo "'pre' step running at `date`" >> $STATUS_FILE echo >> $STATUS_FILE - echo "ERR file(s):" >> $STATUS_FILE - ls -ltr $mysql_datadir/*.err >> $STATUS_FILE - echo >> $STATUS_FILE - echo "Latest 'Version' line in latest file:" >> $STATUS_FILE - grep '^Version' `ls -tr $mysql_datadir/*.err | tail -1` | \ + fcount=`ls -ltr $mysql_datadir/*.err 2>/dev/null | wc -l` + if [ $fcount -gt 0 ] ; then + echo "ERR file(s):" >> $STATUS_FILE + ls -ltr $mysql_datadir/*.err >> $STATUS_FILE + echo >> $STATUS_FILE + echo "Latest 'Version' line in latest file:" >> $STATUS_FILE + grep '^Version' `ls -tr $mysql_datadir/*.err | tail -1` | \ tail -1 >> $STATUS_FILE - echo >> $STATUS_FILE + echo >> $STATUS_FILE + fi if [ -n "$SERVER_TO_START" ] ; then # There is only one PID file, race possibility ignored From f3abc36db615bf0f46da4f6b51e7cbc8b151b7cb Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Wed, 6 Mar 2013 16:33:26 +0100 Subject: [PATCH 103/273] Added fix for Bug#16445097 --- support-files/mysql.spec.sh | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index b64796fa4ea..fadfadf51c1 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -286,10 +286,13 @@ documentation and the manual for more information. Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases Requires: %{distro_requires} +Obsoletes: MySQL < %{version}-%{release} +Obsoletes: MySQL-server < %{version}-%{release} +Obsoletes: MySQL-server-advanced < %{version}-%{release} Obsoletes: mysql mysql-server mysql-advanced mysql-server-advanced Obsoletes: MySQL-server-classic MySQL-server-community MySQL-server-enterprise Obsoletes: MySQL-server-advanced-gpl MySQL-server-enterprise-gpl -Provides: msqlormysql MySQL MySQL-server +Provides: msqlormysql MySQL MySQL-server MySQL-server-advanced Provides: mysql %description -n MySQL-server%{product_suffix} @@ -321,9 +324,11 @@ package "MySQL-client%{product_suffix}" as well! Summary: MySQL - Client Group: Applications/Databases Obsoletes: mysql mysql-advanced +Obsoletes: MySQL-client < %{version}-%{release} +Obsoletes: MySQL-client-advanced < %{version}-%{release} Obsoletes: MySQL-client-classic MySQL-client-community MySQL-client-enterprise Obsoletes: MySQL-client-advanced-gpl MySQL-client-enterprise-gpl -Provides: MySQL-client +Provides: MySQL-client MySQL-client-advanced Provides: mysql %description -n MySQL-client%{product_suffix} @@ -338,9 +343,11 @@ Group: Applications/Databases Requires: MySQL-client perl Conflicts: mysql-test mysql-test-advanced Obsoletes: mysql-bench MySQL-bench +Obsoletes: MySQL-test < %{version}-%{release} +Obsoletes: MySQL-test-advanced < %{version}-%{release} Obsoletes: MySQL-test-classic MySQL-test-community MySQL-test-enterprise Obsoletes: MySQL-test-advanced-gpl MySQL-test-enterprise-gpl -Provides: MySQL-test +Provides: MySQL-test MySQL-test-advanced AutoReqProv: no %description -n MySQL-test%{product_suffix} @@ -353,9 +360,11 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ Summary: MySQL - Development header files and libraries Group: Applications/Databases Conflicts: mysql-devel mysql-embedded-devel mysql-devel-advanced mysql-embedded-devel-advanced +Obsoletes: MySQL-devel < %{version}-%{release} +Obsoletes: MySQL-devel-advanced < %{version}-%{release} Obsoletes: MySQL-devel-classic MySQL-devel-community MySQL-devel-enterprise Obsoletes: MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl -Provides: MySQL-devel +Provides: MySQL-devel MySQL-devel-advanced %description -n MySQL-devel%{product_suffix} This package contains the development header files and libraries necessary @@ -369,10 +378,12 @@ Summary: MySQL - Shared libraries Group: Applications/Databases Obsoletes: MySQL-shared-standard MySQL-shared-pro Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl +Obsoletes: MySQL-shared < %{version}-%{release} +Obsoletes: MySQL-shared-advanced < %{version}-%{release} Obsoletes: MySQL-shared-pro-gpl-cert Obsoletes: MySQL-shared-classic MySQL-shared-community MySQL-shared-enterprise Obsoletes: MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl -Provides: MySQL-shared +Provides: MySQL-shared MySQL-shared-advanced %description -n MySQL-shared%{product_suffix} This package contains the shared libraries (*.so*) which certain languages @@ -385,9 +396,11 @@ Group: Applications/Databases Requires: MySQL-devel Conflicts: mysql-embedded mysql-embedded-advanced Obsoletes: MySQL-embedded-pro +Obsoletes: MySQL-embedded < %{version}-%{release} +Obsoletes: MySQL-embedded-advanced < %{version}-%{release} Obsoletes: MySQL-embedded-classic MySQL-embedded-community MySQL-embedded-enterprise Obsoletes: MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl -Provides: MySQL-embedded +Provides: MySQL-embedded MySQL-embedded-advanced %description -n MySQL-embedded%{product_suffix} This package contains the MySQL server as an embedded library. From b9f88d8ed30ae7c2f26a99ee81e5a15c9e97643e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Mar 2013 15:51:20 +0530 Subject: [PATCH 104/273] From 061f3d1b53a6d93f69391ad81fcf5c2ebabed671 Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Thu, 21 Mar 2013 14:59:57 +0100 Subject: [PATCH 105/273] Added SuSE RPM Build fix --- support-files/mysql.spec.sh | 158 ++++++++++++++++++++++++------------ 1 file changed, 106 insertions(+), 52 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index b5bee9915b7..39630c15ef0 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -247,9 +247,9 @@ Distribution: %{distro_description} License: Copyright (c) 2000, @MYSQL_COPYRIGHT_YEAR@, %{mysql_vendor}. All rights reserved. Under %{license_type} license as shown in the Description field. Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src_dir}.tar.gz URL: http://www.mysql.com/ -Packager: MySQL Release Engineering +Packager: MySQL Release Engineering Vendor: %{mysql_vendor} -Provides: msqlormysql MySQL-server mysql +Provides: msqlormysql MySQL-server BuildRequires: %{distro_buildreq} # Regression tests may take a long time, override the default to skip them @@ -283,17 +283,25 @@ documentation and the manual for more information. ############################################################################## %package -n MySQL-server%{product_suffix} -Summary: MySQL: a very fast and reliable SQL database server -Group: Applications/Databases -Requires: %{distro_requires} +Summary: MySQL: a very fast and reliable SQL database server +Group: Applications/Databases +Requires: %{distro_requires} +%if %{defined susever} +Provides: msqlormysql MySQL MySQL-server +Conflicts: mysql mysql-server mysql-advanced mysql-server-advanced +Obsoletes: MySQL MySQL-server +Obsoletes: MySQL-server-classic MySQL-server-community MySQL-server-enterprise +Obsoletes: MySQL-server-advanced MySQL-server-advanced-gpl MySQL-server-enterprise-gpl +%else Obsoletes: MySQL < %{version}-%{release} Obsoletes: MySQL-server < %{version}-%{release} Obsoletes: MySQL-server-advanced < %{version}-%{release} -Obsoletes: mysql mysql-server mysql-advanced mysql-server-advanced -Obsoletes: MySQL-server-classic MySQL-server-community MySQL-server-enterprise -Obsoletes: MySQL-server-advanced-gpl MySQL-server-enterprise-gpl -Provides: msqlormysql MySQL MySQL-server MySQL-server-advanced -Provides: mysql +Obsoletes: mysql mysql-server mysql-advanced mysql-server-advanced +Obsoletes: MySQL-server-classic MySQL-server-community MySQL-server-enterprise +Obsoletes: MySQL-server-advanced-gpl MySQL-server-enterprise-gpl +Provides: msqlormysql MySQL MySQL-server MySQL-server-advanced +Provides: mysql +%endif %description -n MySQL-server%{product_suffix} The MySQL(TM) software delivers a very fast, multi-threaded, multi-user, @@ -321,15 +329,23 @@ package "MySQL-client%{product_suffix}" as well! # ---------------------------------------------------------------------------- %package -n MySQL-client%{product_suffix} -Summary: MySQL - Client -Group: Applications/Databases -Obsoletes: mysql mysql-advanced -Obsoletes: MySQL-client < %{version}-%{release} -Obsoletes: MySQL-client-advanced < %{version}-%{release} -Obsoletes: MySQL-client-classic MySQL-client-community MySQL-client-enterprise -Obsoletes: MySQL-client-advanced-gpl MySQL-client-enterprise-gpl -Provides: MySQL-client MySQL-client-advanced -Provides: mysql +Summary: MySQL - Client +Group: Applications/Databases +%if %{defined susever} +Provides: MySQL-client +Conflicts: mysql mysql-advanced +Obsoletes: MySQL-client +Obsoletes: MySQL-client-classic MySQL-client-community MySQL-client-enterprise +Obsoletes: MySQL-client-advanced MySQL-client-advanced-gpl MySQL-client-enterprise-gpl +%else +Obsoletes: mysql mysql-advanced +Obsoletes: MySQL-client < %{version}-%{release} +Obsoletes: MySQL-client-advanced < %{version}-%{release} +Obsoletes: MySQL-client-classic MySQL-client-community MySQL-client-enterprise +Obsoletes: MySQL-client-advanced-gpl MySQL-client-enterprise-gpl +Provides: MySQL-client MySQL-client-advanced +Provides: mysql +%endif %description -n MySQL-client%{product_suffix} This package contains the standard MySQL clients and administration tools. @@ -338,17 +354,28 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ # ---------------------------------------------------------------------------- %package -n MySQL-test%{product_suffix} -Summary: MySQL - Test suite -Group: Applications/Databases -Requires: MySQL-client perl -Conflicts: mysql-test mysql-test-advanced -Obsoletes: mysql-bench MySQL-bench +Summary: MySQL - Test suite +Group: Applications/Databases +%if %{defined susever} +Requires: MySQL-client perl +Provides: MySQL-test +Conflicts: mysql-test mysql-test-advanced +Obsoletes: MySQL-test +Obsoletes: mysql-bench MySQL-bench +Obsoletes: MySQL-test-classic MySQL-test-community MySQL-test-enterprise +Obsoletes: MySQL-test-advanced MySQL-test-advanced-gpl MySQL-test-enterprise-gpl +AutoReqProv: no +%else +Requires: MySQL-client perl +Conflicts: mysql-test mysql-test-advanced +Obsoletes: mysql-bench MySQL-bench Obsoletes: MySQL-test < %{version}-%{release} Obsoletes: MySQL-test-advanced < %{version}-%{release} -Obsoletes: MySQL-test-classic MySQL-test-community MySQL-test-enterprise -Obsoletes: MySQL-test-advanced-gpl MySQL-test-enterprise-gpl -Provides: MySQL-test MySQL-test-advanced -AutoReqProv: no +Obsoletes: MySQL-test-classic MySQL-test-community MySQL-test-enterprise +Obsoletes: MySQL-test-advanced-gpl MySQL-test-enterprise-gpl +Provides: MySQL-test MySQL-test-advanced +AutoReqProv: no +%endif %description -n MySQL-test%{product_suffix} This package contains the MySQL regression test suite. @@ -357,14 +384,22 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ # ---------------------------------------------------------------------------- %package -n MySQL-devel%{product_suffix} -Summary: MySQL - Development header files and libraries -Group: Applications/Databases -Conflicts: mysql-devel mysql-embedded-devel mysql-devel-advanced mysql-embedded-devel-advanced +Summary: MySQL - Development header files and libraries +Group: Applications/Databases +%if %{defined susever} +Provides: MySQL-devel +Conflicts: mysql-devel mysql-embedded-devel mysql-devel-advanced mysql-embedded-devel-advanced +Obsoletes: MySQL-devel +Obsoletes: MySQL-devel-classic MySQL-devel-community MySQL-devel-enterprise +Obsoletes: MySQL-devel-advanced MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl +%else +Conflicts: mysql-devel mysql-embedded-devel mysql-devel-advanced mysql-embedded-devel-advanced Obsoletes: MySQL-devel < %{version}-%{release} Obsoletes: MySQL-devel-advanced < %{version}-%{release} -Obsoletes: MySQL-devel-classic MySQL-devel-community MySQL-devel-enterprise -Obsoletes: MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl -Provides: MySQL-devel MySQL-devel-advanced +Obsoletes: MySQL-devel-classic MySQL-devel-community MySQL-devel-enterprise +Obsoletes: MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl +Provides: MySQL-devel MySQL-devel-advanced +%endif %description -n MySQL-devel%{product_suffix} This package contains the development header files and libraries necessary @@ -374,16 +409,25 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ # ---------------------------------------------------------------------------- %package -n MySQL-shared%{product_suffix} -Summary: MySQL - Shared libraries -Group: Applications/Databases -Obsoletes: MySQL-shared-standard MySQL-shared-pro -Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl -Obsoletes: MySQL-shared < %{version}-%{release} +Summary: MySQL - Shared libraries +Group: Applications/Databases +%if %{defined susever} +Provides: MySQL-shared +Obsoletes: MySQL-shared-standard MySQL-shared-pro +Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl +Obsoletes: MySQL-shared-pro-gpl-cert MySQL-shared +Obsoletes: MySQL-shared-classic MySQL-shared-community MySQL-shared-enterprise +Obsoletes: MySQL-shared-advanced MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl +%else +Obsoletes: MySQL-shared-standard MySQL-shared-pro +Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl +Obsoletes: MySQL-shared < %{version}-%{release} Obsoletes: MySQL-shared-advanced < %{version}-%{release} -Obsoletes: MySQL-shared-pro-gpl-cert -Obsoletes: MySQL-shared-classic MySQL-shared-community MySQL-shared-enterprise -Obsoletes: MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl -Provides: MySQL-shared MySQL-shared-advanced +Obsoletes: MySQL-shared-pro-gpl-cert +Obsoletes: MySQL-shared-classic MySQL-shared-community MySQL-shared-enterprise +Obsoletes: MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl +Provides: MySQL-shared MySQL-shared-advanced +%endif %description -n MySQL-shared%{product_suffix} This package contains the shared libraries (*.so*) which certain languages @@ -391,16 +435,26 @@ and applications need to dynamically load and use MySQL. # ---------------------------------------------------------------------------- %package -n MySQL-embedded%{product_suffix} -Summary: MySQL - Embedded library -Group: Applications/Databases -Requires: MySQL-devel -Conflicts: mysql-embedded mysql-embedded-advanced -Obsoletes: MySQL-embedded-pro -Obsoletes: MySQL-embedded < %{version}-%{release} +Summary: MySQL - Embedded library +Group: Applications/Databases +%if %{defined susever} +Requires: MySQL-devel +Provides: MySQL-embedded +Conflicts: mysql-embedded mysql-embedded-advanced +Obsoletes: MySQL-embedded +Obsoletes: MySQL-embedded-pro +Obsoletes: MySQL-embedded-classic MySQL-embedded-community MySQL-embedded-enterprise +Obsoletes: MySQL-embedded-advanced MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl +%else +Requires: MySQL-devel +Conflicts: mysql-embedded mysql-embedded-advanced +Obsoletes: MySQL-embedded-pro +Obsoletes: MySQL-embedded < %{version}-%{release} Obsoletes: MySQL-embedded-advanced < %{version}-%{release} -Obsoletes: MySQL-embedded-classic MySQL-embedded-community MySQL-embedded-enterprise -Obsoletes: MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl -Provides: MySQL-embedded MySQL-embedded-advanced +Obsoletes: MySQL-embedded-classic MySQL-embedded-community MySQL-embedded-enterprise +Obsoletes: MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl +Provides: MySQL-embedded MySQL-embedded-advanced +%endif %description -n MySQL-embedded%{product_suffix} This package contains the MySQL server as an embedded library. From 5a781ff2ad6a55511f628c424a526936caf2c1c6 Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Mon, 25 Mar 2013 13:50:21 +0100 Subject: [PATCH 106/273] Reverted MySQL Release Engineering mail address --- support-files/mysql.spec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 39630c15ef0..b439d2c1956 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -247,7 +247,7 @@ Distribution: %{distro_description} License: Copyright (c) 2000, @MYSQL_COPYRIGHT_YEAR@, %{mysql_vendor}. All rights reserved. Under %{license_type} license as shown in the Description field. Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src_dir}.tar.gz URL: http://www.mysql.com/ -Packager: MySQL Release Engineering +Packager: MySQL Release Engineering Vendor: %{mysql_vendor} Provides: msqlormysql MySQL-server BuildRequires: %{distro_buildreq} From 80c0891588dd8aef2a0e08864b00067ffd9de5ce Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Apr 2013 09:58:51 +0300 Subject: [PATCH 107/273] MDEV-4326 fix. Removed "optimization" which caused preoblems on second execution of PS with string parameter in LIMIT clause. Fixed test_bug43560 to be able to skipp it if connection is UNIX socket. --- sql/sql_prepare.cc | 2 +- tests/mysql_client_test.c | 110 +++++++++++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 0c1c33dcee0..733fc00bf20 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -787,7 +787,7 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array, if (param->state == Item_param::NO_VALUE) DBUG_RETURN(1); - if (param->limit_clause_param && param->item_type != Item::INT_ITEM) + if (param->limit_clause_param) { param->set_int(param->val_int(), MY_INT64_NUM_DECIMAL_DIGITS); param->item_type= Item::INT_ITEM; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 462575ac456..0e18ca12c42 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16750,7 +16750,11 @@ static void test_bug43560(void) fprintf(stdout, "Skipping test_bug43560: server not DEBUG version\n"); DBUG_VOID_RETURN; } - + if (opt_unix_socket) + { + fprintf(stdout, "Skipping test_bug43560: connected via UNIX socket\n"); + DBUG_VOID_RETURN; + } /* Set up a separate connection for this test to avoid messing up the general MYSQL object used in other subtests. Use TCP protocol to avoid @@ -17541,6 +17545,109 @@ static void test_bug13001491() myquery(rc); } +static void test_mdev4326() +{ + MYSQL_STMT *stmt; + MYSQL_BIND bind; + char query[]= "SELECT * FROM mysql.user LIMIT ?"; + char str_data[]= "1"; + unsigned long length= 0; + int int_data= 1; + int rc, count; + my_bool is_null= 0; + my_bool error= 0; + myheader("test_mdev4326"); + + rc= mysql_change_user(mysql, opt_user, opt_password, "mysql"); + myquery(rc); + + rc= mysql_query(mysql, "SET GLOBAL general_log = 1"); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + check_stmt(stmt); + + /* Numeric parameter test */ + + rc= mysql_stmt_prepare(stmt, query, strlen(query)); + check_execute(stmt, rc); + check_stmt(stmt); + verify_param_count(stmt, 1); + + memset((char *)&bind, 0, sizeof(bind)); + bind.buffer_type= MYSQL_TYPE_LONG; + bind.buffer= (char *)&int_data; + bind.is_null= &is_null; + bind.length= &length; + bind.error= &error; + + rc= mysql_stmt_bind_param(stmt, &bind); + check_execute(stmt, rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + count= 0; + while (!(rc= mysql_stmt_fetch(stmt))) + count++; + DIE_UNLESS(count == 1); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + count= 0; + while (!(rc= mysql_stmt_fetch(stmt))) + count++; + DIE_UNLESS(count == 1); + int_data= 0; + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + count= 0; + while (!(rc= mysql_stmt_fetch(stmt))) + count++; + DIE_UNLESS(count == 0); + rc= mysql_stmt_close(stmt); + check_execute(stmt, rc); + + /* String parameter test */ + + stmt= mysql_stmt_init(mysql); + rc= mysql_stmt_prepare(stmt, query, strlen(query)); + check_execute(stmt, rc); + check_stmt(stmt); + verify_param_count(stmt, 1); + + memset((char *)&bind, 0, sizeof(bind)); + bind.buffer_type= MYSQL_TYPE_STRING; + bind.buffer= (char *)str_data; + length= bind.buffer_length= sizeof(str_data); + bind.is_null= &is_null; + bind.length= &length; + bind.error= &error; + + rc= mysql_stmt_bind_param(stmt, &bind); + check_execute(stmt, rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + count= 0; + while (!(rc= mysql_stmt_fetch(stmt))) + count++; + DIE_UNLESS(count == 1); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + count= 0; + while (!(rc= mysql_stmt_fetch(stmt))) + count++; + DIE_UNLESS(count == 1); + str_data[0]= '0'; + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + count= 0; + while (!(rc= mysql_stmt_fetch(stmt))) + count++; + DIE_UNLESS(count == 0); + rc= mysql_stmt_close(stmt); + check_execute(stmt, rc); + + rc= mysql_change_user(mysql, opt_user, opt_password, current_db); + myquery(rc); +} static struct my_tests_st my_tests[]= { { "disable_query_logs", disable_query_logs }, @@ -17790,6 +17897,7 @@ static struct my_tests_st my_tests[]= { { "test_bug58036", test_bug58036 }, { "test_bug56976", test_bug56976 }, { "test_bug13001491", test_bug13001491 }, + { "test_mdev4326", test_mdev4326 }, { 0, 0 } }; From e5055e22f1f311fa48457cfcc97b72e93a37329f Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Fri, 12 Apr 2013 12:11:38 +0200 Subject: [PATCH 108/273] Updated mysql.spec.sh for rpm-uln --- packaging/rpm-uln/mysql.spec.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/packaging/rpm-uln/mysql.spec.sh b/packaging/rpm-uln/mysql.spec.sh index 3e2c5c3f11c..ec195bc9e16 100644 --- a/packaging/rpm-uln/mysql.spec.sh +++ b/packaging/rpm-uln/mysql.spec.sh @@ -268,11 +268,12 @@ Requires: bash Provides: mysql # MySQL (with caps) is upstream's spelling of their own RPMs for mysql -Conflicts: MySQL +Obsoletes: MySQL # mysql-cluster used to be built from this SRPM, but no more Obsoletes: mysql-cluster < 5.1.44 # We need cross-product "Obsoletes:" to allow cross-product upgrades: -Obsoletes: mysql mysql-advanced +Obsoletes: mysql < %{version}-%{release} +Obsoletes: mysql-advanced < %{version}-%{release} # Working around perl dependency checking bug in rpm FTTB. Remove later. %global __perl_requires %{SOURCE999} @@ -295,8 +296,9 @@ further info. Summary: The shared libraries required for MySQL clients Group: Applications/Databases Requires: /sbin/ldconfig +Obsoletes: mysql-libs < %{version}-%{release} +Obsoletes: mysql-libs-advanced < %{version}-%{release} Provides: mysql-libs -Obsoletes: mysql-libs mysql-libs-advanced %description -n mysql-libs%{product_suffix} The mysql-libs package provides the essential shared libraries for any @@ -318,9 +320,10 @@ Requires(preun): initscripts Requires(postun): initscripts # mysqlhotcopy needs DBI/DBD support Requires: perl-DBI, perl-DBD-MySQL +Obsoletes: MySQL-server +Obsoletes: mysql-server < %{version}-%{release} +Obsoletes: mysql-server-advanced < %{version}-%{release} Provides: mysql-server -Conflicts: MySQL-server -Obsoletes: mysql-server mysql-server-advanced %description -n mysql-server%{product_suffix} MySQL is a multi-user, multi-threaded SQL database server. MySQL is a @@ -334,9 +337,10 @@ Summary: Files for development of MySQL applications Group: Applications/Databases Requires: mysql%{product_suffix} = %{version}-%{release} Requires: openssl-devel +Obsoletes: MySQL-devel +Obsoletes: mysql-devel < %{version}-%{release} +Obsoletes: mysql-devel-advanced < %{version}-%{release} Provides: mysql-devel -Conflicts: MySQL-devel -Obsoletes: mysql-devel mysql-devel-advanced %description -n mysql-devel%{product_suffix} MySQL is a multi-user, multi-threaded SQL database server. This @@ -347,8 +351,9 @@ developing MySQL client applications. Summary: MySQL as an embeddable library Group: Applications/Databases +Obsoletes: mysql-embedded < %{version}-%{release} +Obsoletes: mysql-embedded-advanced < %{version}-%{release} Provides: mysql-embedded -Obsoletes: mysql-embedded mysql-embedded-advanced %description -n mysql-embedded%{product_suffix} MySQL is a multi-user, multi-threaded SQL database server. This @@ -362,8 +367,9 @@ Summary: Development files for MySQL as an embeddable library Group: Applications/Databases Requires: mysql-embedded%{product_suffix} = %{version}-%{release} Requires: mysql-devel%{product_suffix} = %{version}-%{release} +Obsoletes: mysql-embedded-devel < %{version}-%{release} +Obsoletes: mysql-embedded-devel-advanced < %{version}-%{release} Provides: mysql-embedded-devel -Obsoletes: mysql-embedded-devel mysql-embedded-devel-advanced %description -n mysql-embedded-devel%{product_suffix} MySQL is a multi-user, multi-threaded SQL database server. This @@ -376,9 +382,10 @@ Summary: The test suite distributed with MySQL Group: Applications/Databases Requires: mysql%{product_suffix} = %{version}-%{release} Requires: mysql-server%{product_suffix} = %{version}-%{release} +Obsoletes: MySQL-test +Obsoletes: mysql-test < %{version}-%{release} +Obsoletes: mysql-test-advanced < %{version}-%{release} Provides: mysql-test -Conflicts: MySQL-test -Obsoletes: mysql-test mysql-test-advanced %description -n mysql-test%{product_suffix} MySQL is a multi-user, multi-threaded SQL database server. This From 07315d36030bd1cbe6acfeb3e8f60c49ba876a10 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 17 Apr 2013 19:42:34 +0200 Subject: [PATCH 109/273] strmake_buf(X,Y) helper, equivalent to strmake(X,Y,sizeof(X)-1) with a bit of lame protection against abuse. --- client/mysql.cc | 22 +++++++++--------- client/mysqltest.cc | 3 +-- include/m_string.h | 9 ++++++++ libmysqld/lib_sql.cc | 13 +++++------ mysys/mf_format.c | 2 +- mysys/my_thr_init.c | 2 +- sql-common/client.c | 4 ++-- sql/handler.cc | 2 +- sql/item.cc | 2 +- sql/log.cc | 27 +++++++++------------- sql/mysql_install_db.cc | 2 +- sql/mysqld.cc | 18 +++++++-------- sql/rpl_rli.cc | 18 +++++---------- sql/slave.cc | 16 +++++-------- sql/sql_acl.cc | 17 +++++++------- sql/sql_base.cc | 4 ++-- sql/sql_class.cc | 2 +- sql/sql_connect.cc | 2 +- sql/sql_error.cc | 4 ++-- sql/sql_insert.cc | 3 +-- sql/sql_plugin_compat.h | 4 ++-- sql/sql_repl.cc | 35 ++++++++++++----------------- sql/tztime.cc | 4 ++-- storage/federated/ha_federated.cc | 2 +- storage/federatedx/ha_federatedx.cc | 2 +- storage/maria/ma_recovery.c | 2 +- storage/myisammrg/ha_myisammrg.cc | 2 +- 27 files changed, 102 insertions(+), 121 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index ad792abc23f..3cd078ac1ce 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1635,7 +1635,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), { switch(optid) { case OPT_CHARSETS_DIR: - strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir) - 1); + strmake_buf(mysql_charsets_dir, argument); charsets_dir = mysql_charsets_dir; break; case OPT_DELIMITER: @@ -1648,7 +1648,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), /* Check that delimiter does not contain a backslash */ if (!strstr(argument, "\\")) { - strmake(delimiter, argument, sizeof(delimiter) - 1); + strmake_buf(delimiter, argument); } else { @@ -1680,7 +1680,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), if (argument && strlen(argument)) { default_pager_set= 1; - strmake(pager, argument, sizeof(pager) - 1); + strmake_buf(pager, argument); strmov(default_pager, pager); } else if (default_pager_set) @@ -2961,7 +2961,7 @@ com_charset(String *buffer __attribute__((unused)), char *line) { char buff[256], *param; CHARSET_INFO * new_cs; - strmake(buff, line, sizeof(buff) - 1); + strmake_buf(buff, line); param= get_arg(buff, 0); if (!param || !*param) { @@ -3198,7 +3198,7 @@ static void init_tee(const char *file_name) return; } OUTFILE = new_outfile; - strmake(outfile, file_name, FN_REFLEN-1); + strmake_buf(outfile, file_name); tee_fprintf(stdout, "Logging to file '%s'\n", file_name); opt_outfile= 1; return; @@ -3827,7 +3827,7 @@ com_tee(String *buffer __attribute__((unused)), /* eliminate the spaces before the parameters */ while (my_isspace(charset_info,*param)) param++; - end= strmake(file_name, param, sizeof(file_name) - 1); + end= strmake_buf(file_name, param); /* remove end space from command line */ while (end > file_name && (my_isspace(charset_info,end[-1]) || my_iscntrl(charset_info,end[-1]))) @@ -3888,7 +3888,7 @@ com_pager(String *buffer __attribute__((unused)), } else { - end= strmake(pager_name, param, sizeof(pager_name)-1); + end= strmake_buf(pager_name, param); while (end > pager_name && (my_isspace(charset_info,end[-1]) || my_iscntrl(charset_info,end[-1]))) end--; @@ -4101,7 +4101,7 @@ static int com_source(String *buffer __attribute__((unused)), INFO_ERROR, 0); while (my_isspace(charset_info,*param)) param++; - end=strmake(source_name,param,sizeof(source_name)-1); + end=strmake_buf(source_name, param); while (end > source_name && (my_isspace(charset_info,end[-1]) || my_iscntrl(charset_info,end[-1]))) end--; @@ -4154,7 +4154,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) { char buff[256], *tmp; - strmake(buff, line, sizeof(buff) - 1); + strmake_buf(buff, line); tmp= get_arg(buff, 0); if (!tmp || !*tmp) @@ -4171,7 +4171,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) return 0; } } - strmake(delimiter, tmp, sizeof(delimiter) - 1); + strmake_buf(delimiter, tmp); delimiter_length= (int)strlen(delimiter); delimiter_str= delimiter; return 0; @@ -4185,7 +4185,7 @@ com_use(String *buffer __attribute__((unused)), char *line) int select_db; bzero(buff, sizeof(buff)); - strmake(buff, line, sizeof(buff) - 1); + strmake_buf(buff, line); tmp= get_arg(buff, 0); if (!tmp || !*tmp) { diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 8c6c1cb3408..2dde607a016 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -6335,8 +6335,7 @@ void do_delimiter(struct st_command* command) if (!(*p)) die("Can't set empty delimiter"); - strmake(delimiter, p, sizeof(delimiter) - 1); - delimiter_length= strlen(delimiter); + delimiter_length= strmake_buf(delimiter, p) - delimiter; DBUG_PRINT("exit", ("delimiter: %s", delimiter)); command->last_argument= p + delimiter_length; diff --git a/include/m_string.h b/include/m_string.h index 9efa0376942..990f78eb555 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -108,6 +108,15 @@ extern char *strcend(const char *, pchar); extern char *strfill(char * s,size_t len,pchar fill); extern char *strmake(char *dst,const char *src,size_t length); +#if !defined(__GNUC__) || (__GNUC__ < 4) +#define strmake_buf(D,S) strmake(D, S, sizeof(D) - 1) +#else +#define strmake_buf(D,S) ({ \ + compile_time_assert(sizeof(D) != sizeof(char*)); \ + strmake(D, S, sizeof(D) - 1); \ + }) +#endif + #ifndef strmov extern char *strmov(char *dst,const char *src); #endif diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 298907b2644..e73fe4b8b77 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -90,7 +90,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data) NET *net= &mysql->net; struct embedded_query_result *ei= data->embedded_info; net->last_errno= ei->last_errno; - strmake(net->last_error, ei->info, sizeof(net->last_error)-1); + strmake_buf(net->last_error, ei->info); memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate)); mysql->server_status= ei->server_status; my_free(data); @@ -703,8 +703,8 @@ int check_embedded_connection(MYSQL *mysql, const char *db) thd->update_charset(); Security_context *sctx= thd->security_ctx; sctx->host_or_ip= sctx->host= (char*) my_localhost; - strmake(sctx->priv_host, (char*) my_localhost, MAX_HOSTNAME-1); - strmake(sctx->priv_user, mysql->user, USERNAME_LENGTH-1); + strmake_buf(sctx->priv_host, (char*) my_localhost); + strmake_buf(sctx->priv_user, mysql->user); sctx->user= my_strdup(mysql->user, MYF(0)); sctx->proxy_user[0]= 0; sctx->master_access= GLOBAL_ACLS; // Full rights @@ -772,7 +772,7 @@ int check_embedded_connection(MYSQL *mysql, const char *db) return 0; err: - strmake(net->last_error, thd->main_da.message(), sizeof(net->last_error)-1); + strmake_buf(net->last_error, thd->main_da.message()); memcpy(net->sqlstate, mysql_errno_to_sqlstate(thd->main_da.sql_errno()), sizeof(net->sqlstate)-1); @@ -1119,8 +1119,7 @@ net_send_ok(THD *thd, data->embedded_info->affected_rows= affected_rows; data->embedded_info->insert_id= id; if (message) - strmake(data->embedded_info->info, message, - sizeof(data->embedded_info->info)-1); + strmake_buf(data->embedded_info->info, message); bool error= write_eof_packet(thd, server_status, statement_warn_count); thd->cur_data= 0; @@ -1171,7 +1170,7 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, err, strlen(err), system_charset_info, &error); /* Converted error message is always null-terminated. */ - strmake(ei->info, converted_err, sizeof(ei->info)-1); + strmake_buf(ei->info, converted_err); strmov(ei->sqlstate, sqlstate); ei->server_status= thd->server_status; thd->cur_data= 0; diff --git a/mysys/mf_format.c b/mysys/mf_format.c index 2b2356c08df..d20ce882459 100644 --- a/mysys/mf_format.c +++ b/mysys/mf_format.c @@ -46,7 +46,7 @@ char * fn_format(char * to, const char *name, const char *dir, else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(dev)) { /* Put 'dir' before the given path */ - strmake(buff,dev,sizeof(buff)-1); + strmake_buf(buff, dev); pos=convert_dirname(dev,dir,NullS); strmake(pos,buff,sizeof(buff)-1- (int) (pos-dev)); } diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index ac16189f3a7..b9ad379f4c4 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -446,7 +446,7 @@ const char *my_thread_name(void) { my_thread_id id= my_thread_dbug_id(); sprintf(name_buff,"T@%lu", (ulong) id); - strmake(tmp->name,name_buff,THREAD_NAME_SIZE); + strmake_buf(tmp->name, name_buff); } return tmp->name; } diff --git a/sql-common/client.c b/sql-common/client.c index 976c09d7a70..c81fe6a8a69 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -776,7 +776,7 @@ restart: len-=2; if (protocol_41(mysql) && (char) pos[0] == '#') { - strmake(net->sqlstate, (char*) pos+1, SQLSTATE_LENGTH); + strmake_buf(net->sqlstate, (char*) pos+1); pos+= SQLSTATE_LENGTH+1; } else @@ -3120,7 +3120,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, bzero((char*) &UNIXaddr, sizeof(UNIXaddr)); UNIXaddr.sun_family= AF_UNIX; - strmake(UNIXaddr.sun_path, unix_socket, sizeof(UNIXaddr.sun_path)-1); + strmake_buf(UNIXaddr.sun_path, unix_socket); if (connect_sync_or_async(mysql, net, sock, (struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr))) { diff --git a/sql/handler.cc b/sql/handler.cc index 058e219f76c..a4505b807c2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2097,7 +2097,7 @@ handle_condition(THD *, { *cond_hdl= NULL; /* Grab the error message */ - strmake(buff, msg, sizeof(buff)-1); + strmake_buf(buff, msg); return TRUE; } diff --git a/sql/item.cc b/sql/item.cc index 54f66375030..9475979aeef 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4413,7 +4413,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list) if (db_name && lower_case_table_names) { /* Convert database to lower case for comparison */ - strmake(name_buff, db_name, sizeof(name_buff)-1); + strmake_buf(name_buff, db_name); my_casedn_str(files_charset_info, name_buff); db_name= name_buff; } diff --git a/sql/log.cc b/sql/log.cc index 112a02bd29e..a73d9fcd079 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -172,7 +172,7 @@ Silence_log_table_errors::handle_condition(THD *, MYSQL_ERROR ** cond_hdl) { *cond_hdl= NULL; - strmake(m_message, msg, sizeof(m_message)-1); + strmake_buf(m_message, msg); return TRUE; } @@ -3183,8 +3183,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, mysql_file_sync(log_file.file, MYF(MY_WME|MY_SYNC_FILESIZE))) goto err; mysql_mutex_lock(&LOCK_commit_ordered); - strmake(last_commit_pos_file, log_file_name, - sizeof(last_commit_pos_file)-1); + strmake_buf(last_commit_pos_file, log_file_name); last_commit_pos_offset= my_b_tell(&log_file); mysql_mutex_unlock(&LOCK_commit_ordered); @@ -3253,7 +3252,7 @@ int MYSQL_BIN_LOG::get_current_log(LOG_INFO* linfo) int MYSQL_BIN_LOG::raw_get_current_log(LOG_INFO* linfo) { - strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1); + strmake_buf(linfo->log_file_name, log_file_name); linfo->pos = my_b_tell(&log_file); return 0; } @@ -3691,8 +3690,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included) Reset rli's coordinates to the current log. */ rli->event_relay_log_pos= BIN_LOG_HEADER_SIZE; - strmake(rli->event_relay_log_name,rli->linfo.log_file_name, - sizeof(rli->event_relay_log_name)-1); + strmake_buf(rli->event_relay_log_name,rli->linfo.log_file_name); /* If we removed the rli->group_relay_log_name file, @@ -3702,8 +3700,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included) if (included) { rli->group_relay_log_pos = BIN_LOG_HEADER_SIZE; - strmake(rli->group_relay_log_name,rli->linfo.log_file_name, - sizeof(rli->group_relay_log_name)-1); + strmake_buf(rli->group_relay_log_name,rli->linfo.log_file_name); rli->notify_group_relay_log_name_update(); } @@ -4213,9 +4210,7 @@ int MYSQL_BIN_LOG::purge_logs_before_date(time_t purge_time) else { if (stat_area.st_mtime < purge_time) - strmake(to_log, - log_info.log_file_name, - sizeof(log_info.log_file_name) - 1); + strmake_buf(to_log, log_info.log_file_name); else break; } @@ -4830,8 +4825,7 @@ binlog_start_consistent_snapshot(handlerton *hton, THD *thd) binlog_cache_mngr *const cache_mngr= thd->binlog_setup_trx_data(); /* Server layer calls us with LOCK_commit_ordered locked, so this is safe. */ - strmake(cache_mngr->last_commit_pos_file, mysql_bin_log.last_commit_pos_file, - sizeof(cache_mngr->last_commit_pos_file)-1); + strmake_buf(cache_mngr->last_commit_pos_file, mysql_bin_log.last_commit_pos_file); cache_mngr->last_commit_pos_offset= mysql_bin_log.last_commit_pos_offset; trans_register_ha(thd, TRUE, hton); @@ -6023,8 +6017,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader) current->error= write_transaction_or_stmt(current); - strmake(cache_mngr->last_commit_pos_file, log_file_name, - sizeof(cache_mngr->last_commit_pos_file)-1); + strmake_buf(cache_mngr->last_commit_pos_file, log_file_name); commit_offset= my_b_write_tell(&log_file); cache_mngr->last_commit_pos_offset= commit_offset; if (cache_mngr->using_xa && cache_mngr->xa_xid) @@ -7402,7 +7395,7 @@ int TC_LOG_BINLOG::open(const char *opt_name) do { - strmake(log_name, log_info.log_file_name, sizeof(log_name)-1); + strmake_buf(log_name, log_info.log_file_name); } while (!(error= find_next_log(&log_info, 1))); if (error != LOG_INFO_EOF) @@ -7710,7 +7703,7 @@ static void set_binlog_snapshot_file(const char *src) { int dir_len = dirname_length(src); - strmake(binlog_snapshot_file, src + dir_len, sizeof(binlog_snapshot_file)-1); + strmake_buf(binlog_snapshot_file, src + dir_len); } /* diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 6e2c6ec07f3..5d523abb8ae 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -377,7 +377,7 @@ static int register_service() static void clean_directory(const char *dir) { char dir2[MAX_PATH+2]; - *(strmake(dir2, dir, MAX_PATH+1)+1)= 0; + *(strmake_buf(dir2, dir)+1)= 0; SHFILEOPSTRUCT fileop; fileop.hwnd= NULL; /* no status display */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5e8492f3490..dfabbcfb82c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3468,7 +3468,7 @@ static int init_common_variables() WideCharToMultiByte(CP_UTF8,0, wtz_name, -1, system_time_zone, sizeof(system_time_zone) - 1, NULL, NULL); #else - strmake(system_time_zone, tz_name, sizeof(system_time_zone)-1); + strmake_buf(system_time_zone, tz_name); #endif /* _WIN32 */ #endif /* HAVE_TZNAME */ @@ -7332,8 +7332,8 @@ static int mysql_init_variables(void) /* Set directory paths */ mysql_real_data_home_len= - strmake(mysql_real_data_home, get_relative_path(MYSQL_DATADIR), - sizeof(mysql_real_data_home)-1) - mysql_real_data_home; + strmake_buf(mysql_real_data_home, + get_relative_path(MYSQL_DATADIR)) - mysql_real_data_home; /* Replication parameters */ master_info_file= (char*) "master.info", relay_log_info_file= (char*) "relay-log.info"; @@ -7436,7 +7436,7 @@ static int mysql_init_variables(void) const char *tmpenv; if (!(tmpenv = getenv("MY_BASEDIR_VERSION"))) tmpenv = DEFAULT_MYSQL_HOME; - (void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1); + strmake_buf(mysql_home, tmpenv); #endif return 0; } @@ -7475,7 +7475,7 @@ mysqld_get_one_option(int optid, global_system_variables.tx_isolation= ISO_SERIALIZABLE; break; case 'b': - strmake(mysql_home,argument,sizeof(mysql_home)-1); + strmake_buf(mysql_home, argument); break; case 'C': if (default_collation_name == compiled_default_collation_name) @@ -7486,7 +7486,7 @@ mysqld_get_one_option(int optid, opt_log=1; break; case 'h': - strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1); + strmake_buf(mysql_real_data_home, argument); /* Correct pointer set by my_getopt (for embedded library) */ mysql_real_data_home_ptr= mysql_real_data_home; break; @@ -7497,7 +7497,7 @@ mysqld_get_one_option(int optid, sql_print_warning("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user); break; case 'L': - strmake(lc_messages_dir, argument, sizeof(lc_messages_dir)-1); + strmake_buf(lc_messages_dir, argument); break; case OPT_BINLOG_FORMAT: binlog_format_used= true; @@ -8182,7 +8182,7 @@ static int fix_paths(void) char *sharedir=get_relative_path(SHAREDIR); if (test_if_hard_path(sharedir)) - strmake(buff,sharedir,sizeof(buff)-1); /* purecov: tested */ + strmake_buf(buff, sharedir); /* purecov: tested */ else strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS); convert_dirname(buff,buff,NullS); @@ -8190,7 +8190,7 @@ static int fix_paths(void) /* If --character-sets-dir isn't given, use shared library dir */ if (charsets_dir) - strmake(mysql_charsets_dir, charsets_dir, sizeof(mysql_charsets_dir)-1); + strmake_buf(mysql_charsets_dir, charsets_dir); else strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff, CHARSET_DIR, NullS); diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index cbd7ac8f5ef..e03d46606d5 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -309,8 +309,7 @@ Failed to open the existing relay log info file '%s' (errno %d)", msg="Error reading slave log configuration"; goto err; } - strmake(rli->event_relay_log_name,rli->group_relay_log_name, - sizeof(rli->event_relay_log_name)-1); + strmake_buf(rli->event_relay_log_name,rli->group_relay_log_name); rli->group_relay_log_pos= rli->event_relay_log_pos= relay_log_pos; rli->group_master_log_pos= master_log_pos; @@ -528,10 +527,8 @@ int init_relay_log_pos(Relay_log_info* rli,const char* log, *errmsg="Could not find target log during relay log initialization"; goto err; } - strmake(rli->group_relay_log_name,rli->linfo.log_file_name, - sizeof(rli->group_relay_log_name)-1); - strmake(rli->event_relay_log_name,rli->linfo.log_file_name, - sizeof(rli->event_relay_log_name)-1); + strmake_buf(rli->group_relay_log_name,rli->linfo.log_file_name); + strmake_buf(rli->event_relay_log_name,rli->linfo.log_file_name); if (rli->relay_log.is_active(rli->linfo.log_file_name)) { /* @@ -871,8 +868,7 @@ void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos, mysql_mutex_lock(&data_lock); inc_event_relay_log_pos(); group_relay_log_pos= event_relay_log_pos; - strmake(group_relay_log_name,event_relay_log_name, - sizeof(group_relay_log_name)-1); + strmake_buf(group_relay_log_name,event_relay_log_name); notify_group_relay_log_name_update(); @@ -1005,10 +1001,8 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset, goto err; } /* Save name of used relay log file */ - strmake(rli->group_relay_log_name, rli->relay_log.get_log_fname(), - sizeof(rli->group_relay_log_name)-1); - strmake(rli->event_relay_log_name, rli->relay_log.get_log_fname(), - sizeof(rli->event_relay_log_name)-1); + strmake_buf(rli->group_relay_log_name, rli->relay_log.get_log_fname()); + strmake_buf(rli->event_relay_log_name, rli->relay_log.get_log_fname()); rli->group_relay_log_pos= rli->event_relay_log_pos= BIN_LOG_HEADER_SIZE; if (count_relay_log_space(rli)) { diff --git a/sql/slave.cc b/sql/slave.cc index 0a162f6fbaa..02ab69af0e8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -359,16 +359,13 @@ int init_recovery(Master_info* mi, const char** errmsg) { mi->master_log_pos= max(BIN_LOG_HEADER_SIZE, rli->group_master_log_pos); - strmake(mi->master_log_name, rli->group_master_log_name, - sizeof(mi->master_log_name)-1); + strmake_buf(mi->master_log_name, rli->group_master_log_name); sql_print_warning("Recovery from master pos %ld and file %s.", (ulong) mi->master_log_pos, mi->master_log_name); - strmake(rli->group_relay_log_name, rli->relay_log.get_log_fname(), - sizeof(rli->group_relay_log_name)-1); - strmake(rli->event_relay_log_name, rli->relay_log.get_log_fname(), - sizeof(mi->rli.event_relay_log_name)-1); + strmake_buf(rli->group_relay_log_name, rli->relay_log.get_log_fname()); + strmake_buf(rli->event_relay_log_name, rli->relay_log.get_log_fname()); rli->group_relay_log_pos= rli->event_relay_log_pos= BIN_LOG_HEADER_SIZE; } @@ -3588,8 +3585,8 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, mysql_mutex_lock(&rli->data_lock); if (rli->slave_skip_counter) { - strmake(saved_log_name, rli->group_relay_log_name, FN_REFLEN - 1); - strmake(saved_master_log_name, rli->group_master_log_name, FN_REFLEN - 1); + strmake_buf(saved_log_name, rli->group_relay_log_name); + strmake_buf(saved_master_log_name, rli->group_master_log_name); saved_log_pos= rli->group_relay_log_pos; saved_master_log_pos= rli->group_master_log_pos; saved_skip= rli->slave_skip_counter; @@ -5223,8 +5220,7 @@ static Log_event* next_event(Relay_log_info* rli) goto err; } rli->event_relay_log_pos = BIN_LOG_HEADER_SIZE; - strmake(rli->event_relay_log_name,rli->linfo.log_file_name, - sizeof(rli->event_relay_log_name)-1); + strmake_buf(rli->event_relay_log_name,rli->linfo.log_file_name); flush_relay_log_info(rli); } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index d1cdf35bb5a..a5ab5c1a816 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1435,12 +1435,12 @@ bool acl_getroot(Security_context *sctx, char *user, char *host, sctx->master_access= acl_user->access; if (acl_user->user) - strmake(sctx->priv_user, user, USERNAME_LENGTH); + strmake_buf(sctx->priv_user, user); else *sctx->priv_user= 0; if (acl_user->host.hostname) - strmake(sctx->priv_host, acl_user->host.hostname, MAX_HOSTNAME - 1); + strmake_buf(sctx->priv_host, acl_user->host.hostname); else *sctx->priv_host= 0; } @@ -8325,10 +8325,9 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio) mpvio->auth_info.user_name= sctx->user; mpvio->auth_info.user_name_length= strlen(sctx->user); mpvio->auth_info.auth_string= mpvio->acl_user->auth_string.str; - mpvio->auth_info.auth_string_length= - (unsigned long) mpvio->acl_user->auth_string.length; - strmake(mpvio->auth_info.authenticated_as, mpvio->acl_user->user ? - mpvio->acl_user->user : "", USERNAME_LENGTH); + mpvio->auth_info.auth_string_length= (unsigned long) mpvio->acl_user->auth_string.length; + strmake_buf(mpvio->auth_info.authenticated_as, mpvio->acl_user->user ? + mpvio->acl_user->user : ""); DBUG_PRINT("info", ("exit: user=%s, auth_string=%s, authenticated as=%s" "plugin=%s", @@ -8412,7 +8411,7 @@ static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length) /* Clear variables that are allocated */ thd->user_connect= 0; - strmake(sctx->priv_user, sctx->user, USERNAME_LENGTH); + strmake_buf(sctx->priv_user, sctx->user); if (thd->make_lex_string(&mpvio->db, db_buff, db_len, 0) == 0) DBUG_RETURN(1); /* The error is set by make_lex_string(). */ @@ -9229,12 +9228,12 @@ bool acl_authenticate(THD *thd, uint connect_errors, sctx->master_access= acl_user->access; if (acl_user->user) - strmake(sctx->priv_user, acl_user->user, USERNAME_LENGTH - 1); + strmake_buf(sctx->priv_user, acl_user->user); else *sctx->priv_user= 0; if (acl_user->host.hostname) - strmake(sctx->priv_host, acl_user->host.hostname, MAX_HOSTNAME - 1); + strmake_buf(sctx->priv_host, acl_user->host.hostname); else *sctx->priv_host= 0; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a02294236f7..56c2a613b1e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6914,7 +6914,7 @@ find_field_in_tables(THD *thd, Item_ident *item, We can't do this in Item_field as this would change the 'name' of the item which may be used in the select list */ - strmake(name_buff, db, sizeof(name_buff)-1); + strmake_buf(name_buff, db); my_casedn_str(files_charset_info, name_buff); db= name_buff; } @@ -8487,7 +8487,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, We can't do this in Item_field as this would change the 'name' of the item which may be used in the select list */ - strmake(name_buff, db_name, sizeof(name_buff)-1); + strmake_buf(name_buff, db_name); my_casedn_str(files_charset_info, name_buff); db_name= name_buff; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 33dc4218e95..7b3e10c73f1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2536,7 +2536,7 @@ select_export::prepare(List &list, SELECT_LEX_UNIT *u) bool string_results= FALSE, non_string_results= FALSE; unit= u; if ((uint) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN) - strmake(path,exchange->file_name,FN_REFLEN-1); + strmake_buf(path,exchange->file_name); write_cs= exchange->cs ? exchange->cs : &my_charset_bin; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 9f6185280cd..7e0b659a3e4 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -435,7 +435,7 @@ void init_user_stats(USER_STATS *user_stats, memcpy(user_stats->user, user, user_length); user_stats->user[user_length]= 0; user_stats->user_name_length= user_length; - strmake(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user)-1); + strmake_buf(user_stats->priv_user, priv_user); user_stats->total_connections= total_connections; user_stats->concurrent_connections= concurrent_connections; diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 06da6250e71..61281af1d0a 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -367,7 +367,7 @@ Diagnostics_area::set_ok_status(THD *thd, ulonglong affected_rows_arg, m_affected_rows= affected_rows_arg; m_last_insert_id= last_insert_id_arg; if (message_arg) - strmake(m_message, message_arg, sizeof(m_message) - 1); + strmake_buf(m_message, message_arg); else m_message[0]= '\0'; m_status= DA_OK; @@ -435,7 +435,7 @@ Diagnostics_area::set_error_status(THD *thd, uint sql_errno_arg, m_sql_errno= sql_errno_arg; memcpy(m_sqlstate, sqlstate, SQLSTATE_LENGTH); m_sqlstate[SQLSTATE_LENGTH]= '\0'; - strmake(m_message, message_arg, sizeof(m_message)-1); + strmake_buf(m_message, message_arg); m_status= DA_ERROR; DBUG_VOID_RETURN; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index fc6151e44d9..bda443de3c3 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2011,8 +2011,7 @@ public: DBUG_ENTER("Delayed_insert constructor"); thd.security_ctx->user=(char*) delayed_user; thd.security_ctx->host=(char*) my_localhost; - strmake(thd.security_ctx->priv_user, thd.security_ctx->user, - USERNAME_LENGTH); + strmake_buf(thd.security_ctx->priv_user, thd.security_ctx->user); thd.current_tablenr=0; thd.command=COM_DELAYED_INSERT; thd.lex->current_select= 0; // for my_message_sql diff --git a/sql/sql_plugin_compat.h b/sql/sql_plugin_compat.h index 8c6014f8dc6..5c7bb620575 100644 --- a/sql/sql_plugin_compat.h +++ b/sql/sql_plugin_compat.h @@ -16,9 +16,9 @@ /* old plugin api structures, used for backward compatibility */ #define upgrade_var(X) latest->X= X -#define upgrade_str(X) strmake(latest->X, X, sizeof(X)) +#define upgrade_str(X) strmake_buf(latest->X, X) #define downgrade_var(X) X= latest->X -#define downgrade_str(X) strmake(X, latest->X, sizeof(X)-1) +#define downgrade_str(X) strmake_buf(X, latest->X) /**************************************************************/ /* Authentication API, version 0x0100 *************************/ diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 4e5eef14d69..d2f942643a9 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1272,8 +1272,7 @@ int start_slave(THD* thd , Master_info* mi, bool net_report) We don't check thd->lex->mi.log_file_name for NULL here since it is checked in sql_yacc.yy */ - strmake(mi->rli.until_log_name, thd->lex->mi.log_file_name, - sizeof(mi->rli.until_log_name)-1); + strmake_buf(mi->rli.until_log_name, thd->lex->mi.log_file_name); } else if (thd->lex->mi.relay_log_pos) { @@ -1281,8 +1280,7 @@ int start_slave(THD* thd , Master_info* mi, bool net_report) slave_errno=ER_BAD_SLAVE_UNTIL_COND; mi->rli.until_condition= Relay_log_info::UNTIL_RELAY_POS; mi->rli.until_log_pos= thd->lex->mi.relay_log_pos; - strmake(mi->rli.until_log_name, thd->lex->mi.relay_log_name, - sizeof(mi->rli.until_log_name)-1); + strmake_buf(mi->rli.until_log_name, thd->lex->mi.relay_log_name); } else mi->rli.clear_until_condition(); @@ -1639,9 +1637,9 @@ bool change_master(THD* thd, Master_info* mi) /* Before processing the command, save the previous state. */ - strmake(saved_host, mi->host, HOSTNAME_LENGTH); + strmake_buf(saved_host, mi->host); saved_port= mi->port; - strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1); + strmake_buf(saved_log_name, mi->master_log_name); saved_log_pos= mi->master_log_pos; /* @@ -1656,8 +1654,7 @@ bool change_master(THD* thd, Master_info* mi) } if (lex_mi->log_file_name) - strmake(mi->master_log_name, lex_mi->log_file_name, - sizeof(mi->master_log_name)-1); + strmake_buf(mi->master_log_name, lex_mi->log_file_name); if (lex_mi->pos) { mi->master_log_pos= lex_mi->pos; @@ -1721,15 +1718,15 @@ bool change_master(THD* thd, Master_info* mi) (lex_mi->ssl_verify_server_cert == LEX_MASTER_INFO::LEX_MI_ENABLE); if (lex_mi->ssl_ca) - strmake(mi->ssl_ca, lex_mi->ssl_ca, sizeof(mi->ssl_ca)-1); + strmake_buf(mi->ssl_ca, lex_mi->ssl_ca); if (lex_mi->ssl_capath) - strmake(mi->ssl_capath, lex_mi->ssl_capath, sizeof(mi->ssl_capath)-1); + strmake_buf(mi->ssl_capath, lex_mi->ssl_capath); if (lex_mi->ssl_cert) - strmake(mi->ssl_cert, lex_mi->ssl_cert, sizeof(mi->ssl_cert)-1); + strmake_buf(mi->ssl_cert, lex_mi->ssl_cert); if (lex_mi->ssl_cipher) - strmake(mi->ssl_cipher, lex_mi->ssl_cipher, sizeof(mi->ssl_cipher)-1); + strmake_buf(mi->ssl_cipher, lex_mi->ssl_cipher); if (lex_mi->ssl_key) - strmake(mi->ssl_key, lex_mi->ssl_key, sizeof(mi->ssl_key)-1); + strmake_buf(mi->ssl_key, lex_mi->ssl_key); #ifndef HAVE_OPENSSL if (lex_mi->ssl || lex_mi->ssl_ca || lex_mi->ssl_capath || lex_mi->ssl_cert || lex_mi->ssl_cipher || lex_mi->ssl_key || @@ -1743,10 +1740,8 @@ bool change_master(THD* thd, Master_info* mi) need_relay_log_purge= 0; char relay_log_name[FN_REFLEN]; mi->rli.relay_log.make_log_name(relay_log_name, lex_mi->relay_log_name); - strmake(mi->rli.group_relay_log_name, relay_log_name, - sizeof(mi->rli.group_relay_log_name)-1); - strmake(mi->rli.event_relay_log_name, relay_log_name, - sizeof(mi->rli.event_relay_log_name)-1); + strmake_buf(mi->rli.group_relay_log_name, relay_log_name); + strmake_buf(mi->rli.event_relay_log_name, relay_log_name); } if (lex_mi->relay_log_pos) @@ -1782,8 +1777,7 @@ bool change_master(THD* thd, Master_info* mi) */ mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, mi->rli.group_master_log_pos); - strmake(mi->master_log_name, mi->rli.group_master_log_name, - sizeof(mi->master_log_name)-1); + strmake_buf(mi->master_log_name, mi->rli.group_master_log_name); } /* Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never @@ -1836,8 +1830,7 @@ bool change_master(THD* thd, Master_info* mi) */ mi->rli.group_master_log_pos= mi->master_log_pos; DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); - strmake(mi->rli.group_master_log_name,mi->master_log_name, - sizeof(mi->rli.group_master_log_name)-1); + strmake_buf(mi->rli.group_master_log_name,mi->master_log_name); if (!mi->rli.group_master_log_name[0]) // uninitialized case mi->rli.group_master_log_pos=0; diff --git a/sql/tztime.cc b/sql/tztime.cc index 0e793290bba..95a1001485b 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2559,7 +2559,7 @@ main(int argc, char **argv) if (argc == 2) { - root_name_end= strmake(fullname, argv[1], FN_REFLEN); + root_name_end= strmake_buf(fullname, argv[1]); printf("TRUNCATE TABLE time_zone;\n"); printf("TRUNCATE TABLE time_zone_name;\n"); @@ -2713,7 +2713,7 @@ main(int argc, char **argv) (int)t, (int)t1); /* Let us load time zone description */ - str_end= strmake(fullname, TZDIR, FN_REFLEN); + str_end= strmake_buf(fullname, TZDIR); strmake(str_end, "/MET", FN_REFLEN - (str_end - fullname)); if (tz_load(fullname, &tz_info, &tz_storage)) diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index c0bf0acb523..55394e859c5 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -3243,7 +3243,7 @@ int ha_federated::stash_remote_error() if (!mysql) DBUG_RETURN(remote_error_number); remote_error_number= mysql_errno(mysql); - strmake(remote_error_buf, mysql_error(mysql), sizeof(remote_error_buf)-1); + strmake_buf(remote_error_buf, mysql_error(mysql)); if (remote_error_number == ER_DUP_ENTRY || remote_error_number == ER_DUP_KEY) DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index f6d9b3a4014..eb4d7f11d33 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -3439,7 +3439,7 @@ int ha_federatedx::stash_remote_error() if (!io) DBUG_RETURN(remote_error_number); remote_error_number= io->error_code(); - strmake(remote_error_buf, io->error_str(), sizeof(remote_error_buf)-1); + strmake_buf(remote_error_buf, io->error_str()); if (remote_error_number == ER_DUP_ENTRY || remote_error_number == ER_DUP_KEY) DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 9ac42f885b5..0f3fb0f8a1e 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -3304,7 +3304,7 @@ static LSN parse_checkpoint_record(LSN lsn) first_log_write_lsn= lsn_korr(ptr); ptr+= LSN_STORE_SIZE; name_len= strlen((char *)ptr) + 1; - strmake(name, (char *)ptr, sizeof(name)-1); + strmake_buf(name, (char *)ptr); ptr+= name_len; if (new_table(sid, name, first_log_write_lsn)) return LSN_ERROR; diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index bf27e7c2284..2b571675aef 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -1470,7 +1470,7 @@ static void split_file_name(const char *file_name, char buff[FN_REFLEN]; db->length= 0; - strmake(buff, file_name, sizeof(buff)-1); + strmake_buf(buff, file_name); dir_length= dirname_length(buff); if (dir_length > 1) { From 84ce6832e64305a769fb424d272311468b5d1d0d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 18 Apr 2013 22:17:29 +0200 Subject: [PATCH 110/273] MDEV-4332 Increase username length from 16 characters --- include/mysql_com.h | 2 +- mysql-test/r/grant_4332.result | 97 ++++++++++++++++ mysql-test/r/status_user.result | 2 +- .../suite/funcs_1/r/is_columns_is.result | 4 +- .../funcs_1/r/is_columns_is_embedded.result | 4 +- .../rpl/r/rpl_password_boundaries.result | 6 +- .../suite/rpl/t/rpl_password_boundaries.test | 2 +- mysql-test/t/grant_4332.test | 107 ++++++++++++++++++ sql/event_db_repository.cc | 2 +- sql/item_strfunc.cc | 2 + sql/item_strfunc.h | 6 +- sql/rpl_mi.h | 2 +- sql/sp.cc | 2 +- sql/sql_acl.cc | 6 +- sql/sql_repl.cc | 16 +-- sql/sql_show.cc | 2 +- sql/sql_yacc.yy | 4 +- tests/mysql_client_test.c | 9 +- 18 files changed, 244 insertions(+), 31 deletions(-) create mode 100644 mysql-test/r/grant_4332.result create mode 100644 mysql-test/t/grant_4332.test diff --git a/include/mysql_com.h b/include/mysql_com.h index 4a28e145546..fdd75556033 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -24,7 +24,7 @@ #define HOSTNAME_LENGTH 60 #define SYSTEM_CHARSET_MBMAXLEN 3 #define NAME_CHAR_LEN 64 /* Field/table name length */ -#define USERNAME_CHAR_LENGTH 16 +#define USERNAME_CHAR_LENGTH 128 #define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN) #define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN) diff --git a/mysql-test/r/grant_4332.result b/mysql-test/r/grant_4332.result new file mode 100644 index 00000000000..f0286173b4c --- /dev/null +++ b/mysql-test/r/grant_4332.result @@ -0,0 +1,97 @@ +set global event_scheduler = on; +select user(); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def user() 253 77 14 N 1 31 8 +user() +root@localhost +create user a17aaaaaaaaaaaaa0@localhost; +ERROR HY000: String 'a17aaaaaaaaaaaaa0' is too long for user name (should be no longer than 16) +alter table mysql.user modify User char(80) binary not null default ''; +alter table mysql.db modify User char(80) binary not null default ''; +alter table mysql.tables_priv modify User char(80) binary not null default ''; +alter table mysql.columns_priv modify User char(80) binary not null default ''; +alter table mysql.procs_priv modify User char(80) binary not null default ''; +alter table mysql.proc modify definer char(141) collate utf8_bin not null default ''; +alter table mysql.event modify definer char(141) collate utf8_bin not null default ''; +flush privileges; +select user(); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def user() 253 141 14 N 1 31 8 +user() +root@localhost +create user a17aaaaaaaaaaaaa0@localhost; +grant usage on *.* to a17aaaaaaaaaaaaa0@localhost; +grant select on mysql.user to b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost; +grant select(User) on mysql.tables_priv to c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost; +select user(), current_user(); +user() current_user() +a17aaaaaaaaaaaaa0@localhost a17aaaaaaaaaaaaa0@localhost +show grants; +Grants for a17aaaaaaaaaaaaa0@localhost +GRANT USAGE ON *.* TO 'a17aaaaaaaaaaaaa0'@'localhost' +select user(), current_user(); +user() current_user() +b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost +show grants; +Grants for b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost +GRANT USAGE ON *.* TO 'b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0'@'localhost' +GRANT SELECT ON `mysql`.`user` TO 'b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0'@'localhost' +select user,host from mysql.user where user like '%0'; +user host +a17aaaaaaaaaaaaa0 localhost +b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0 localhost +c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0 localhost +select user,host from mysql.db; +ERROR 42000: SELECT command denied to user 'b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'@'localhost' for table 'db' +select user(), current_user(); +user() current_user() +c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost +show grants; +Grants for c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost +GRANT USAGE ON *.* TO 'c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0'@'localhost' +GRANT SELECT (User) ON `mysql`.`tables_priv` TO 'c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0'@'localhost' +select user from mysql.tables_priv; +user +b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0 +c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0 +select user,host from mysql.tables_priv; +ERROR 42000: SELECT command denied to user 'c80ccccccccccccccccccccccccccccccccccccccccccccc'@'localhost' for column 'host' in table 'tables_priv' +create procedure test.p1() select user(), current_user(), user from mysql.tables_priv; +show create procedure test.p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 CREATE DEFINER=`c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0`@`localhost` PROCEDURE `p1`() +select user(), current_user(), user from mysql.tables_priv latin1 latin1_swedish_ci latin1_swedish_ci +create table test.t1 (a text); +create event e1 on schedule every 1 second +do insert test.t1 values (concat(user(), ' ', current_user())); +call test.p1(); +user() current_user() user +root@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0 +root@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0 +select * from t1 limit 1; +a +event_scheduler@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost +grant usage on *.* to d81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0@lodalhost; +ERROR HY000: String 'd81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' is too long for user name (should be no longer than 80) +drop user d81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0@lodalhost; +ERROR HY000: String 'd81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' is too long for user name (should be no longer than 80) +drop user c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost; +drop user b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost; +drop user a17aaaaaaaaaaaaa0@localhost; +set global event_scheduler = off; +drop event e1; +drop procedure test.p1; +drop table t1; +alter table mysql.user modify User char(16) binary not null default ''; +alter table mysql.db modify User char(16) binary not null default ''; +alter table mysql.tables_priv modify User char(16) binary not null default ''; +alter table mysql.columns_priv modify User char(16) binary not null default ''; +alter table mysql.procs_priv modify User char(16) binary not null default ''; +alter table mysql.proc modify definer char(77) collate utf8_bin not null default ''; +alter table mysql.event modify definer char(77) collate utf8_bin not null default ''; +flush privileges; +select user(); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def user() 253 77 14 N 1 31 8 +user() +root@localhost diff --git a/mysql-test/r/status_user.result b/mysql-test/r/status_user.result index f43e217b8a5..39579799431 100644 --- a/mysql-test/r/status_user.result +++ b/mysql-test/r/status_user.result @@ -27,7 +27,7 @@ ACCESS_DENIED bigint(21) NO 0 EMPTY_QUERIES bigint(21) NO 0 show columns from information_schema.user_statistics; Field Type Null Key Default Extra -USER varchar(48) NO +USER varchar(128) NO TOTAL_CONNECTIONS int(11) NO 0 CONCURRENT_CONNECTIONS int(11) NO 0 CONNECTED_TIME int(11) NO 0 diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index 4da7eeb2ada..5707dcbb3db 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -398,7 +398,7 @@ def information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19 def information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select def information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL NULL utf8 utf8_general_ci varchar(48) select +def information_schema USER_STATISTICS USER 1 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128) select def information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select def information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) select def information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select @@ -844,7 +844,7 @@ NULL information_schema TRIGGERS CREATED datetime NULL NULL NULL NULL datetime 3.0000 information_schema USER_PRIVILEGES TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema USER_PRIVILEGES PRIVILEGE_TYPE varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema USER_PRIVILEGES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3) -3.0000 information_schema USER_STATISTICS USER varchar 48 144 utf8 utf8_general_ci varchar(48) +3.0000 information_schema USER_STATISTICS USER varchar 128 384 utf8 utf8_general_ci varchar(128) NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS int NULL NULL NULL NULL int(11) NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS int NULL NULL NULL NULL int(11) NULL information_schema USER_STATISTICS CONNECTED_TIME int NULL NULL NULL NULL int(11) diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index 3fb4d97748c..61b98480d4f 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -399,7 +399,7 @@ def information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19 def information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) def information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) def information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) -def information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL NULL utf8 utf8_general_ci varchar(48) +def information_schema USER_STATISTICS USER 1 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128) def information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) def information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) def information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) @@ -849,7 +849,7 @@ NULL information_schema TRIGGERS CREATED datetime NULL NULL NULL NULL datetime 3.0000 information_schema USER_PRIVILEGES TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema USER_PRIVILEGES PRIVILEGE_TYPE varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema USER_PRIVILEGES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3) -3.0000 information_schema USER_STATISTICS USER varchar 48 144 utf8 utf8_general_ci varchar(48) +3.0000 information_schema USER_STATISTICS USER varchar 128 384 utf8 utf8_general_ci varchar(128) NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS int NULL NULL NULL NULL int(11) NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS int NULL NULL NULL NULL int(11) NULL information_schema USER_STATISTICS CONNECTED_TIME int NULL NULL NULL NULL int(11) diff --git a/mysql-test/suite/rpl/r/rpl_password_boundaries.result b/mysql-test/suite/rpl/r/rpl_password_boundaries.result index 71f32f492a2..a0ccc0ce33c 100644 --- a/mysql-test/suite/rpl/r/rpl_password_boundaries.result +++ b/mysql-test/suite/rpl/r/rpl_password_boundaries.result @@ -24,10 +24,10 @@ set sql_log_bin=1; include/stop_slave.inc change master to master_user='rpl33',master_password='0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef!'; ERROR HY000: String '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef012345' is too long for MASTER_PASSWORD (should be no longer than 96) -change master to master_user='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; -ERROR HY000: String 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for MASTER_USER (should be no longer than 47) +change master to master_user='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; +ERROR HY000: String 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for MASTER_USER (should be no longer than 128) change master to master_host='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'; -ERROR HY000: String 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbb' is too long for MASTER_HOST (should be no longer than 180) +ERROR HY000: String 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbb' is too long for MASTER_HOST (should be no longer than 60) [ on master ] set sql_log_bin=0; grant replication slave on *.* to rpl16cyr@127.0.0.1 identified by 'воттакойужпарольвоттакойужпарольвоттакойужпароль'; diff --git a/mysql-test/suite/rpl/t/rpl_password_boundaries.test b/mysql-test/suite/rpl/t/rpl_password_boundaries.test index cf8abfbda11..d812ab5efc8 100644 --- a/mysql-test/suite/rpl/t/rpl_password_boundaries.test +++ b/mysql-test/suite/rpl/t/rpl_password_boundaries.test @@ -53,7 +53,7 @@ change master to master_user='rpl33',master_password='0123456789abcdef0123456789 # Check also master_user and master_host --error ER_WRONG_STRING_LENGTH -change master to master_user='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; +change master to master_user='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; --error ER_WRONG_STRING_LENGTH change master to master_host='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'; diff --git a/mysql-test/t/grant_4332.test b/mysql-test/t/grant_4332.test new file mode 100644 index 00000000000..4d8d769680d --- /dev/null +++ b/mysql-test/t/grant_4332.test @@ -0,0 +1,107 @@ +# +# MDEV-4332 Increase username length from 16 characters +# + +# user names here have the pattern +# 0 +# where '0' at the end is the end-of-name marker + +--source include/not_embedded.inc + +set global event_scheduler = on; + +--enable_metadata +select user(); +--disable_metadata + +--error ER_WRONG_STRING_LENGTH +create user a17aaaaaaaaaaaaa0@localhost; + +alter table mysql.user modify User char(80) binary not null default ''; +alter table mysql.db modify User char(80) binary not null default ''; +alter table mysql.tables_priv modify User char(80) binary not null default ''; +alter table mysql.columns_priv modify User char(80) binary not null default ''; +alter table mysql.procs_priv modify User char(80) binary not null default ''; +alter table mysql.proc modify definer char(141) collate utf8_bin not null default ''; +alter table mysql.event modify definer char(141) collate utf8_bin not null default ''; +flush privileges; + +--enable_metadata +select user(); +--disable_metadata + +create user a17aaaaaaaaaaaaa0@localhost; +grant usage on *.* to a17aaaaaaaaaaaaa0@localhost; +grant select on mysql.user to b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost; +grant select(User) on mysql.tables_priv to c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost; + +connect (a17,localhost,a17aaaaaaaaaaaaa0,,); +connect (b64,localhost,b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0,,); +connect (c80,localhost,c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0,,); + +connection a17; +select user(), current_user(); +show grants; + +connection b64; +select user(), current_user(); +show grants; +select user,host from mysql.user where user like '%0'; +--error ER_TABLEACCESS_DENIED_ERROR +select user,host from mysql.db; + +connection c80; +select user(), current_user(); +show grants; +select user from mysql.tables_priv; +--error ER_COLUMNACCESS_DENIED_ERROR +select user,host from mysql.tables_priv; + +create procedure test.p1() select user(), current_user(), user from mysql.tables_priv; + +show create procedure test.p1; + +create table test.t1 (a text); +create event e1 on schedule every 1 second + do insert test.t1 values (concat(user(), ' ', current_user())); + +connection default; + +call test.p1(); + +disconnect a17; +disconnect b64; +disconnect c80; + +let $wait_timeout= 10; +let $wait_condition= SELECT 1 from t1; +--source include/wait_condition.inc + +select * from t1 limit 1; +--error ER_WRONG_STRING_LENGTH +grant usage on *.* to d81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0@lodalhost; + +--error ER_WRONG_STRING_LENGTH +drop user d81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0@lodalhost; +drop user c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost; +drop user b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost; +drop user a17aaaaaaaaaaaaa0@localhost; + +set global event_scheduler = off; +drop event e1; +drop procedure test.p1; +drop table t1; + +alter table mysql.user modify User char(16) binary not null default ''; +alter table mysql.db modify User char(16) binary not null default ''; +alter table mysql.tables_priv modify User char(16) binary not null default ''; +alter table mysql.columns_priv modify User char(16) binary not null default ''; +alter table mysql.procs_priv modify User char(16) binary not null default ''; +alter table mysql.proc modify definer char(77) collate utf8_bin not null default ''; +alter table mysql.event modify definer char(77) collate utf8_bin not null default ''; +flush privileges; + +--enable_metadata +select user(); +--disable_metadata + diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 14927a66915..37dff0da714 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -55,7 +55,7 @@ const TABLE_FIELD_TYPE event_table_fields[ET_FIELD_COUNT] = }, { { C_STRING_WITH_LEN("definer") }, - { C_STRING_WITH_LEN("char(77)") }, + { C_STRING_WITH_LEN("char(") }, { C_STRING_WITH_LEN("utf8") } }, { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b1f351696b7..a18ded2de80 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -59,6 +59,8 @@ C_MODE_START #include "../mysys/my_static.h" // For soundex_map C_MODE_END +size_t username_char_length= 16; + /** @todo Remove this. It is not safe to use a shared String object. */ diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 13c1a399230..77179195283 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -25,6 +25,8 @@ #pragma interface /* gcc class implementation */ #endif +extern size_t username_char_length; + class MY_LOCALE; class Item_str_func :public Item_func @@ -494,8 +496,8 @@ public: bool fix_fields(THD *thd, Item **ref); void fix_length_and_dec() { - max_length= (USERNAME_LENGTH + - (HOSTNAME_LENGTH + 1) * SYSTEM_CHARSET_MBMAXLEN); + max_length= (username_char_length + + HOSTNAME_LENGTH + 1) * SYSTEM_CHARSET_MBMAXLEN; } const char *func_name() const { return "user"; } const char *fully_qualified_func_name() const { return "user()"; } diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 64525f81603..f9c8c8ea5b2 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -67,7 +67,7 @@ class Master_info : public Slave_reporting_capability /* the variables below are needed because we can change masters on the fly */ char master_log_name[FN_REFLEN]; char host[HOSTNAME_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1]; - char user[USERNAME_LENGTH*+1]; + char user[USERNAME_LENGTH+1]; char password[MAX_PASSWORD_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1]; bool ssl; // enables use of SSL connection if true char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN]; diff --git a/sql/sp.cc b/sql/sp.cc index 726d70ffe2a..13f027493b4 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -114,7 +114,7 @@ TABLE_FIELD_TYPE proc_table_fields[MYSQL_PROC_FIELD_COUNT] = }, { { C_STRING_WITH_LEN("definer") }, - { C_STRING_WITH_LEN("char(77)") }, + { C_STRING_WITH_LEN("char(") }, { C_STRING_WITH_LEN("utf8") } }, { diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index a5ab5c1a816..d331c4b00ea 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -828,6 +828,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) table->use_all_columns(); (void) my_init_dynamic_array(&acl_users,sizeof(ACL_USER),50,100); + username_char_length= min(table->field[1]->char_length(), USERNAME_CHAR_LENGTH); password_length= table->field[2]->field_length / table->field[2]->charset()->mbmaxlen; if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH_323) @@ -8626,14 +8627,15 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, /* Clip username to allowed length in characters (not bytes). This is - mostly for backward compatibility. + mostly for backward compatibility (to truncate long usernames, as + old 5.1 did) */ { CHARSET_INFO *cs= system_charset_info; int err; user_len= (uint) cs->cset->well_formed_len(cs, user, user + user_len, - USERNAME_CHAR_LENGTH, &err); + username_char_length, &err); user[user_len]= '\0'; } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index d2f942643a9..b8a12b1ea8a 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1555,14 +1555,15 @@ void kill_zombie_dump_threads(uint32 slave_server_id) */ static bool get_string_parameter(char *to, const char *from, size_t length, - const char *name) + const char *name, CHARSET_INFO *cs) { if (from) // Empty paramaters allowed { - size_t from_length; - if ((from_length= strlen(from)) > length) + size_t from_length= strlen(from); + uint from_numchars= cs->cset->numchars(cs, from, from + from_length); + if (from_numchars > length / cs->mbmaxlen) { - my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, (int) length); + my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, length / cs->mbmaxlen); return 1; } memcpy(to, from, from_length+1); @@ -1662,11 +1663,12 @@ bool change_master(THD* thd, Master_info* mi) DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); if (get_string_parameter(mi->host, lex_mi->host, sizeof(mi->host)-1, - "MASTER_HOST") || + "MASTER_HOST", system_charset_info) || get_string_parameter(mi->user, lex_mi->user, sizeof(mi->user)-1, - "MASTER_USER") || + "MASTER_USER", system_charset_info) || get_string_parameter(mi->password, lex_mi->password, - sizeof(mi->password)-1, "MASTER_PASSWORD")) + sizeof(mi->password)-1, "MASTER_PASSWORD", + &my_charset_bin)) { ret= TRUE; goto err; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 055dfa95b8b..2ebaeec61bc 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -7041,7 +7041,7 @@ struct schema_table_ref ST_FIELD_INFO user_stats_fields_info[]= { - {"USER", USERNAME_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE}, + {"USER", USERNAME_CHAR_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE}, {"TOTAL_CONNECTIONS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections",SKIP_OPEN_TABLE}, {"CONCURRENT_CONNECTIONS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections",SKIP_OPEN_TABLE}, {"CONNECTED_TIME", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time",SKIP_OPEN_TABLE}, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 79056702e54..8f88f3304e6 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -12887,7 +12887,7 @@ user: $$->auth= empty_lex_str; if (check_string_char_length(&$$->user, ER(ER_USERNAME), - USERNAME_CHAR_LENGTH, + username_char_length, system_charset_info, 0)) MYSQL_YYABORT; } @@ -12902,7 +12902,7 @@ user: $$->auth= empty_lex_str; if (check_string_char_length(&$$->user, ER(ER_USERNAME), - USERNAME_CHAR_LENGTH, + username_char_length, system_charset_info, 0) || check_host_name(&$$->host)) MYSQL_YYABORT; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index f3f25a4ec90..d726563f86a 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16903,13 +16903,14 @@ static void test_bug31418() */ #define LARGE_BUFFER_SIZE 2048 +#define OLD_USERNAME_CHAR_LENGTH 16 static void test_bug31669() { int rc; static char buff[LARGE_BUFFER_SIZE+1]; #ifndef EMBEDDED_LIBRARY - static char user[USERNAME_CHAR_LENGTH+1]; + static char user[OLD_USERNAME_CHAR_LENGTH+1]; static char db[NAME_CHAR_LEN+1]; static char query[LARGE_BUFFER_SIZE*2]; #endif @@ -16946,7 +16947,7 @@ static void test_bug31669() myquery(rc); memset(user, 'b', sizeof(user)); - user[USERNAME_CHAR_LENGTH]= 0; + user[OLD_USERNAME_CHAR_LENGTH]= 0; memset(buff, 'c', sizeof(buff)); buff[LARGE_BUFFER_SIZE]= 0; strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'%' IDENTIFIED BY " @@ -16965,11 +16966,11 @@ static void test_bug31669() rc= mysql_change_user(conn, user, buff, db); DIE_UNLESS(!rc); - user[USERNAME_CHAR_LENGTH-1]= 'a'; + user[OLD_USERNAME_CHAR_LENGTH-1]= 'a'; rc= mysql_change_user(conn, user, buff, db); DIE_UNLESS(rc); - user[USERNAME_CHAR_LENGTH-1]= 'b'; + user[OLD_USERNAME_CHAR_LENGTH-1]= 'b'; buff[LARGE_BUFFER_SIZE-1]= 'd'; rc= mysql_change_user(conn, user, buff, db); DIE_UNLESS(rc); From 4d78392be5649d06c8d1c6b57c9e4ec95b84df5f Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 19 Apr 2013 12:08:55 +0200 Subject: [PATCH 111/273] MDEV-4398 - Change default for innodb_use_fallocate to FALSE, due to bugs in older Linux kernels (posix_fallocate() does not always guarantee that file size is like one specified) --- .../suite/sys_vars/r/innodb_use_fallocate_basic.result | 10 +++++----- storage/innobase/handler/ha_innodb.cc | 2 +- storage/xtradb/handler/ha_innodb.cc | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/innodb_use_fallocate_basic.result b/mysql-test/suite/sys_vars/r/innodb_use_fallocate_basic.result index 7ea55fba0a4..57b4b9eb94c 100644 --- a/mysql-test/suite/sys_vars/r/innodb_use_fallocate_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_use_fallocate_basic.result @@ -1,20 +1,20 @@ select @@global.innodb_use_fallocate; @@global.innodb_use_fallocate -1 +0 select @@session.innodb_use_fallocate; ERROR HY000: Variable 'innodb_use_fallocate' is a GLOBAL variable show global variables like 'innodb_use_fallocate'; Variable_name Value -innodb_use_fallocate ON +innodb_use_fallocate OFF show session variables like 'innodb_use_fallocate'; Variable_name Value -innodb_use_fallocate ON +innodb_use_fallocate OFF select * from information_schema.global_variables where variable_name='innodb_use_fallocate'; VARIABLE_NAME VARIABLE_VALUE -INNODB_USE_FALLOCATE ON +INNODB_USE_FALLOCATE OFF select * from information_schema.session_variables where variable_name='innodb_use_fallocate'; VARIABLE_NAME VARIABLE_VALUE -INNODB_USE_FALLOCATE ON +INNODB_USE_FALLOCATE OFF set global innodb_use_fallocate=1; ERROR HY000: Variable 'innodb_use_fallocate' is a read only variable set session innodb_use_fallocate=1; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index abce3c93f68..19a6512a14f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -11420,7 +11420,7 @@ static MYSQL_SYSVAR_BOOL(use_atomic_writes, innobase_use_atomic_writes, static MYSQL_SYSVAR_BOOL(use_fallocate, innobase_use_fallocate, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "Preallocate files fast, using operating system functionality. On POSIX systems, posix_fallocate system call is used.", - NULL, NULL, TRUE); + NULL, NULL, FALSE); static MYSQL_SYSVAR_ULONG(io_capacity, srv_io_capacity, PLUGIN_VAR_RQCMDARG, diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index c194dc38889..18912b499ae 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -12661,7 +12661,7 @@ static MYSQL_SYSVAR_BOOL(use_atomic_writes, innobase_use_atomic_writes, static MYSQL_SYSVAR_BOOL(use_fallocate, innobase_use_fallocate, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "Preallocate files fast, using operating system functionality. On POSIX systems, posix_fallocate system call is used.", - NULL, NULL, TRUE); + NULL, NULL, FALSE); static MYSQL_SYSVAR_ULONG(io_capacity, srv_io_capacity, PLUGIN_VAR_RQCMDARG, From b9b3d5330adf00f40e099ab079a0b0be1bcb8875 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 19 Apr 2013 12:50:16 +0200 Subject: [PATCH 112/273] MDEV-260 auditing table accesses --- include/mysql/plugin_audit.h | 46 +++++++++- include/mysql/plugin_audit.h.pp | 21 +++++ mysql-test/suite/plugins/r/audit_null.result | 73 +++++++++++++++- mysql-test/suite/plugins/t/audit_null.test | 29 +++++++ plugin/audit_null/audit_null.c | 89 +++++++++++++------ sql/handler.cc | 13 ++- sql/handler.h | 1 + sql/sql_audit.cc | 32 ++++++- sql/sql_audit.h | 91 +++++++++++++++++++- sql/sql_table.cc | 10 +++ 10 files changed, 372 insertions(+), 33 deletions(-) diff --git a/include/mysql/plugin_audit.h b/include/mysql/plugin_audit.h index eee32a9e523..86b6dea5668 100644 --- a/include/mysql/plugin_audit.h +++ b/include/mysql/plugin_audit.h @@ -25,7 +25,7 @@ #define MYSQL_AUDIT_CLASS_MASK_SIZE 1 -#define MYSQL_AUDIT_INTERFACE_VERSION 0x0300 +#define MYSQL_AUDIT_INTERFACE_VERSION 0x0301 /************************************************************************* @@ -97,6 +97,50 @@ struct mysql_event_connection unsigned int database_length; }; +/* + AUDIT CLASS : TABLE + + LOCK occurs when a connection "locks" (this does not necessarily mean a table + lock and also happens for row-locking engines) the table at the beginning of + a statement. This event is generated at the beginning of every statement for + every affected table, unless there's a LOCK TABLES statement in effect (in + which case it is generated once for LOCK TABLES and then is suppressed until + the tables are unlocked). + + CREATE/DROP/RENAME occur when a table is created, dropped, or renamed. +*/ + +#define MYSQL_AUDIT_TABLE_CLASS 15 +#define MYSQL_AUDIT_TABLE_CLASSMASK (1 << MYSQL_AUDIT_TABLE_CLASS) +#define MYSQL_AUDIT_TABLE_LOCK 0 +#define MYSQL_AUDIT_TABLE_CREATE 1 +#define MYSQL_AUDIT_TABLE_DROP 2 +#define MYSQL_AUDIT_TABLE_RENAME 3 +#define MYSQL_AUDIT_TABLE_ALTER 4 + +struct mysql_event_table +{ + unsigned int event_subclass; + unsigned long thread_id; + const char *user; + const char *priv_user; + const char *priv_host; + const char *external_user; + const char *proxy_user; + const char *host; + const char *ip; + const char *database; + unsigned int database_length; + const char *table; + unsigned int table_length; + /* for MYSQL_AUDIT_TABLE_LOCK, true if read-only, false if read/write */ + int read_only; + /* for MYSQL_AUDIT_TABLE_RENAME */ + const char *new_database; + unsigned int new_database_length; + const char *new_table; + unsigned int new_table_length; +}; /************************************************************************* Here we define the descriptor structure, that is referred from diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index f19d5fe797c..cb8435a1ec7 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -279,6 +279,27 @@ struct mysql_event_connection const char *database; unsigned int database_length; }; +struct mysql_event_table +{ + unsigned int event_subclass; + unsigned long thread_id; + const char *user; + const char *priv_user; + const char *priv_host; + const char *external_user; + const char *proxy_user; + const char *host; + const char *ip; + const char *database; + unsigned int database_length; + const char *table; + unsigned int table_length; + int read_only; + const char *new_database; + unsigned int new_database_length; + const char *new_table; + unsigned int new_table_length; +}; struct st_mysql_audit { int interface_version; diff --git a/mysql-test/suite/plugins/r/audit_null.result b/mysql-test/suite/plugins/r/audit_null.result index 4cf648510e6..76aef454b94 100644 --- a/mysql-test/suite/plugins/r/audit_null.result +++ b/mysql-test/suite/plugins/r/audit_null.result @@ -1,5 +1,6 @@ set @old_global_general_log=@@global.general_log; set global general_log=OFF; +grant select on *.* to testuser@localhost; install plugin audit_null soname 'adt_null'; select 1; 1 @@ -18,12 +19,82 @@ concat("test1", x) test1-12 show status like 'audit_null%'; Variable_name Value -Audit_null_called 19 +Audit_null_called 21 Audit_null_general_error 1 Audit_null_general_log 7 Audit_null_general_result 5 +create table t1 (a int); +insert t1 values (1), (2); +select * from t1; +a +1 +2 +rename table t1 to t2; +alter table t2 add column b int; +create definer=testuser@localhost view v1 as select t2.a+1, t2_copy.a+2 from t2, t2 as t2_copy; +select * from v1; +t2.a+1 t2_copy.a+2 +2 3 +3 3 +2 4 +3 4 +drop view v1; +create temporary table t2 (a date); +insert t2 values ('2020-10-09'); +select * from t2; +a +2020-10-09 +drop table t2; +explain select distinct * from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using temporary +select distinct * from t2; +a b +1 NULL +2 NULL +drop table t2; uninstall plugin audit_null; Warnings: Warning 1620 Plugin is busy and will be uninstalled on shutdown drop procedure au1; +drop user testuser@localhost; set global general_log=@old_global_general_log; +root[root] @ localhost [] >> select 1 +root[root] @ localhost [] >> select foobar +root[root] @ localhost [] >> show status like 'audit_null%' +root[root] @ localhost [] >> create procedure au1(x char(16)) select concat("test1", x) +root[root] @ localhost [] mysql.proc : write +root[root] @ localhost [] >> call au1("-12") +root[root] @ localhost [] mysql.proc : read +root[root] @ localhost [] >> select concat("test1", NAME_CONST('x',_latin1'-12' COLLATE 'latin1_swedish_ci')) +root[root] @ localhost [] >> show status like 'audit_null%' +root[root] @ localhost [] >> create table t1 (a int) +root[root] @ localhost [] test.t1 : create +root[root] @ localhost [] >> insert t1 values (1), (2) +root[root] @ localhost [] test.t1 : write +root[root] @ localhost [] >> select * from t1 +root[root] @ localhost [] test.t1 : read +root[root] @ localhost [] >> rename table t1 to t2 +root[root] @ localhost [] test.t1 : rename to test.t2 +root[root] @ localhost [] >> alter table t2 add column b int +root[root] @ localhost [] test.t2 : alter +root[root] @ localhost [] test.t2 : read +root[root] @ localhost [] >> create definer=testuser@localhost view v1 as select t2.a+1, t2_copy.a+2 from t2, t2 as t2_copy +root[root] @ localhost [] test.t2 : read +root[root] @ localhost [] test.t2 : read +root[root] @ localhost [] >> select * from v1 +root[root] @ localhost [] test.t2 : read +root[root] @ localhost [] test.t2 : read +root[root] @ localhost [] >> drop view v1 +root[root] @ localhost [] >> create temporary table t2 (a date) +root[root] @ localhost [] >> insert t2 values ('2020-10-09') +root[root] @ localhost [] >> select * from t2 +root[root] @ localhost [] >> drop table t2 +root[root] @ localhost [] >> explain select distinct * from t2 +root[root] @ localhost [] test.t2 : read +root[root] @ localhost [] >> select distinct * from t2 +root[root] @ localhost [] test.t2 : read +root[root] @ localhost [] >> drop table t2 +root[root] @ localhost [] test.t2 : drop +root[root] @ localhost [] >> uninstall plugin audit_null +root[root] @ localhost [] mysql.plugin : write diff --git a/mysql-test/suite/plugins/t/audit_null.test b/mysql-test/suite/plugins/t/audit_null.test index 428fd0c276e..47491668529 100644 --- a/mysql-test/suite/plugins/t/audit_null.test +++ b/mysql-test/suite/plugins/t/audit_null.test @@ -8,6 +8,8 @@ if (!$ADT_NULL_SO) { set @old_global_general_log=@@global.general_log; set global general_log=OFF; +grant select on *.* to testuser@localhost; + --disable_ps_protocol install plugin audit_null soname 'adt_null'; @@ -22,9 +24,36 @@ call au1("-12"); show status like 'audit_null%'; +create table t1 (a int); +insert t1 values (1), (2); +select * from t1; +rename table t1 to t2; +alter table t2 add column b int; + +create definer=testuser@localhost view v1 as select t2.a+1, t2_copy.a+2 from t2, t2 as t2_copy; +select * from v1; +drop view v1; + +# temp table generates no audit events +create temporary table t2 (a date); +insert t2 values ('2020-10-09'); +select * from t2; +drop table t2; + +# internal temp table generates no audit events +explain select distinct * from t2; +select distinct * from t2; + +drop table t2; + uninstall plugin audit_null; --enable_ps_protocol drop procedure au1; +drop user testuser@localhost; set global general_log=@old_global_general_log; +let $MYSQLD_DATADIR= `SELECT @@datadir`; +--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ /#sql2-[-0-9a-f_]*/#sql2-temporary/ +cat_file $MYSQLD_DATADIR/audit_null_tables.log; + diff --git a/plugin/audit_null/audit_null.c b/plugin/audit_null/audit_null.c index be0c70fbd35..916c7187a57 100644 --- a/plugin/audit_null/audit_null.c +++ b/plugin/audit_null/audit_null.c @@ -22,11 +22,12 @@ #define __attribute__(A) #endif -static volatile int number_of_calls; /* for SHOW STATUS, see below */ -static volatile int number_of_calls_general_log; -static volatile int number_of_calls_general_error; -static volatile int number_of_calls_general_result; +static volatile int ncalls; /* for SHOW STATUS, see below */ +static volatile int ncalls_general_log; +static volatile int ncalls_general_error; +static volatile int ncalls_general_result; +FILE *f; /* Initialize the plugin at server start or plugin installation. @@ -44,11 +45,16 @@ static volatile int number_of_calls_general_result; static int audit_null_plugin_init(void *arg __attribute__((unused))) { - number_of_calls= 0; - number_of_calls_general_log= 0; - number_of_calls_general_error= 0; - number_of_calls_general_result= 0; - return(0); + ncalls= 0; + ncalls_general_log= 0; + ncalls_general_error= 0; + ncalls_general_result= 0; + + f = fopen("audit_null_tables.log", "w"); + if (!f) + return 1; + + return 0; } @@ -67,7 +73,8 @@ static int audit_null_plugin_init(void *arg __attribute__((unused))) static int audit_null_plugin_deinit(void *arg __attribute__((unused))) { - return(0); + fclose(f); + return 0; } @@ -86,7 +93,7 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)), const void *event) { /* prone to races, oh well */ - number_of_calls++; + ncalls++; if (event_class == MYSQL_AUDIT_GENERAL_CLASS) { const struct mysql_event_general *event_general= @@ -94,18 +101,56 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)), switch (event_general->event_subclass) { case MYSQL_AUDIT_GENERAL_LOG: - number_of_calls_general_log++; + ncalls_general_log++; + fprintf(f, "%s\t>> %s\n", event_general->general_user, + event_general->general_query); break; case MYSQL_AUDIT_GENERAL_ERROR: - number_of_calls_general_error++; + ncalls_general_error++; break; case MYSQL_AUDIT_GENERAL_RESULT: - number_of_calls_general_result++; + ncalls_general_result++; break; default: break; } } + else + if (event_class == MYSQL_AUDIT_TABLE_CLASS) + { + const struct mysql_event_table *event_table= + (const struct mysql_event_table *) event; + const char *ip= event_table->ip ? event_table->ip : ""; + const char *op= 0; + char buf[1024]; + + switch (event_table->event_subclass) + { + case MYSQL_AUDIT_TABLE_LOCK: + op= event_table->read_only ? "read" : "write"; + break; + case MYSQL_AUDIT_TABLE_CREATE: + op= "create"; + break; + case MYSQL_AUDIT_TABLE_DROP: + op= "drop"; + break; + case MYSQL_AUDIT_TABLE_ALTER: + op= "alter"; + break; + case MYSQL_AUDIT_TABLE_RENAME: + snprintf(buf, sizeof(buf), "rename to %s.%s", + event_table->new_database, event_table->new_table); + buf[sizeof(buf)-1]= 0; + op= buf; + break; + } + + fprintf(f, "%s[%s] @ %s [%s]\t%s.%s : %s\n", + event_table->priv_user, event_table->user, + event_table->host, ip, + event_table->database, event_table->table, op); + } } @@ -115,10 +160,8 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)), static struct st_mysql_audit audit_null_descriptor= { - MYSQL_AUDIT_INTERFACE_VERSION, /* interface version */ - NULL, /* release_thd function */ - audit_null_notify, /* notify function */ - { (unsigned long) MYSQL_AUDIT_GENERAL_CLASSMASK } /* class mask */ + MYSQL_AUDIT_INTERFACE_VERSION, NULL, audit_null_notify, + { MYSQL_AUDIT_GENERAL_CLASSMASK | MYSQL_AUDIT_TABLE_CLASSMASK } }; /* @@ -127,12 +170,10 @@ static struct st_mysql_audit audit_null_descriptor= static struct st_mysql_show_var simple_status[]= { - { "Audit_null_called", (char *) &number_of_calls, SHOW_INT }, - { "Audit_null_general_log", (char *) &number_of_calls_general_log, SHOW_INT }, - { "Audit_null_general_error", (char *) &number_of_calls_general_error, - SHOW_INT }, - { "Audit_null_general_result", (char *) &number_of_calls_general_result, - SHOW_INT }, + { "Audit_null_called", (char *) &ncalls, SHOW_INT }, + { "Audit_null_general_log", (char *) &ncalls_general_log, SHOW_INT }, + { "Audit_null_general_error", (char *) &ncalls_general_error, SHOW_INT }, + { "Audit_null_general_result", (char *) &ncalls_general_result, SHOW_INT }, { 0, 0, 0} }; diff --git a/sql/handler.cc b/sql/handler.cc index a4505b807c2..355226b0e25 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -43,6 +43,7 @@ #include "myisam.h" #include "probes_mysql.h" #include "debug_sync.h" // DEBUG_SYNC +#include "sql_audit.h" #ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" @@ -3689,7 +3690,6 @@ int handler::ha_delete_table(const char *name) { mark_trx_read_write(); - return delete_table(name); } @@ -3722,8 +3722,11 @@ int handler::ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info) { mark_trx_read_write(); - - return create(name, form, info); + int error= create(name, form, info); + if (!error && + !(info->options & (HA_LEX_CREATE_TMP_TABLE | HA_CREATE_TMP_ALTER))) + mysql_audit_create_table(form); + return error; } @@ -5099,7 +5102,11 @@ int handler::ha_external_lock(THD *thd, int lock_type) int error= external_lock(thd, lock_type); if (error == 0) + { cached_table_flags= table_flags(); + if (table_share->tmp_table == NO_TMP_TABLE) + mysql_audit_external_lock(thd, table_share, lock_type); + } if (MYSQL_HANDLER_RDLOCK_DONE_ENABLED() || MYSQL_HANDLER_WRLOCK_DONE_ENABLED() || diff --git a/sql/handler.h b/sql/handler.h index 4a91d989e52..af9574d82f8 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -318,6 +318,7 @@ #define HA_LEX_CREATE_TMP_TABLE 1 #define HA_LEX_CREATE_IF_NOT_EXISTS 2 #define HA_LEX_CREATE_TABLE_LIKE 4 +#define HA_CREATE_TMP_ALTER 8 #define HA_MAX_REC_LENGTH 65535 /* Table caching type */ diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc index 523f07592bc..8e17f49df28 100644 --- a/sql/sql_audit.cc +++ b/sql/sql_audit.cc @@ -31,8 +31,7 @@ unsigned long mysql_global_audit_mask[MYSQL_AUDIT_CLASS_MASK_SIZE]; static mysql_mutex_t LOCK_audit_mask; -static void event_class_dispatch(THD *thd, unsigned int event_class, - const void *event); +static void event_class_dispatch(THD *, unsigned int, const void *); static inline @@ -111,9 +110,36 @@ static void connection_class_handler(THD *thd, uint event_subclass, va_list ap) } +static void table_class_handler(THD *thd, uint event_subclass, va_list ap) +{ + mysql_event_table event; + event.event_subclass= event_subclass; + event.read_only= va_arg(ap, int); + event.thread_id= va_arg(ap, unsigned long); + event.user= va_arg(ap, const char *); + event.priv_user= va_arg(ap, const char *); + event.priv_host= va_arg(ap, const char *); + event.external_user= va_arg(ap, const char *); + event.proxy_user= va_arg(ap, const char *); + event.host= va_arg(ap, const char *); + event.ip= va_arg(ap, const char *); + event.database= va_arg(ap, const char *); + event.database_length= va_arg(ap, unsigned int); + event.table= va_arg(ap, const char *); + event.table_length= va_arg(ap, unsigned int); + event.new_database= va_arg(ap, const char *); + event.new_database_length= va_arg(ap, unsigned int); + event.new_table= va_arg(ap, const char *); + event.new_table_length= va_arg(ap, unsigned int); + event_class_dispatch(thd, MYSQL_AUDIT_TABLE_CLASS, &event); +} + + static audit_handler_t audit_handlers[] = { - general_class_handler, connection_class_handler + general_class_handler, connection_class_handler, + 0,0,0,0,0,0,0,0,0,0,0,0,0, /* placeholders */ + table_class_handler }; static const uint audit_handlers_count= diff --git a/sql/sql_audit.h b/sql/sql_audit.h index 46afe4b7596..75b338a16c8 100644 --- a/sql/sql_audit.h +++ b/sql/sql_audit.h @@ -43,17 +43,23 @@ static inline bool mysql_audit_general_enabled() return mysql_global_audit_mask[0] & MYSQL_AUDIT_GENERAL_CLASSMASK; } +static inline bool mysql_audit_table_enabled() +{ + return mysql_global_audit_mask[0] & MYSQL_AUDIT_TABLE_CLASSMASK; +} + #else static inline void mysql_audit_notify(THD *thd, uint event_class, uint event_subtype, ...) { } #define mysql_audit_general_enabled() 0 +#define mysql_audit_table_enabled() 0 #endif extern void mysql_audit_release(THD *thd); #define MAX_USER_HOST_SIZE 512 static inline uint make_user_name(THD *thd, char *buf) { - Security_context *sctx= thd->security_ctx; + const Security_context *sctx= thd->security_ctx; return strxnmov(buf, MAX_USER_HOST_SIZE, sctx->priv_user[0] ? sctx->priv_user : "", "[", sctx->user ? sctx->user : "", "] @ ", @@ -174,4 +180,87 @@ void mysql_audit_general(THD *thd, uint event_subtype, (thd)->security_ctx->ip ? strlen((thd)->security_ctx->ip) : 0,\ (thd)->db, (thd)->db ? strlen((thd)->db) : 0) +static inline +void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock) +{ + if (lock != F_UNLCK && mysql_audit_table_enabled()) + { + const Security_context *sctx= thd->security_ctx; + mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, MYSQL_AUDIT_TABLE_LOCK, + (int)(lock == F_RDLCK), (ulong)thd->thread_id, + sctx->user, sctx->priv_user, sctx->priv_host, + sctx->external_user, sctx->proxy_user, sctx->host, + sctx->ip, share->db.str, (uint)share->db.length, + share->table_name.str, (uint)share->table_name.length, + 0,0,0,0); + } +} + +static inline +void mysql_audit_create_table(TABLE *table) +{ + if (mysql_audit_table_enabled()) + { + THD *thd= table->in_use; + const TABLE_SHARE *share= table->s; + const Security_context *sctx= thd->security_ctx; + mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, MYSQL_AUDIT_TABLE_CREATE, + 0, (ulong)thd->thread_id, + sctx->user, sctx->priv_user, sctx->priv_host, + sctx->external_user, sctx->proxy_user, sctx->host, + sctx->ip, share->db.str, (uint)share->db.length, + share->table_name.str, (uint)share->table_name.length, + 0,0,0,0); + } +} + +static inline +void mysql_audit_drop_table(THD *thd, TABLE_LIST *table) +{ + if (mysql_audit_table_enabled()) + { + const Security_context *sctx= thd->security_ctx; + mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, MYSQL_AUDIT_TABLE_DROP, + 0, (ulong)thd->thread_id, + sctx->user, sctx->priv_user, sctx->priv_host, + sctx->external_user, sctx->proxy_user, sctx->host, + sctx->ip, table->db, (uint)table->db_length, + table->table_name, (uint)table->table_name_length, + 0,0,0,0); + } +} + +static inline +void mysql_audit_rename_table(THD *thd, const char *old_db, const char *old_tb, + const char *new_db, const char *new_tb) +{ + if (mysql_audit_table_enabled()) + { + const Security_context *sctx= thd->security_ctx; + mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, MYSQL_AUDIT_TABLE_RENAME, + 0, (ulong)thd->thread_id, + sctx->user, sctx->priv_user, sctx->priv_host, + sctx->external_user, sctx->proxy_user, sctx->host, + sctx->ip, + old_db, (uint)strlen(old_db), old_tb, (uint)strlen(old_tb), + new_db, (uint)strlen(new_db), new_tb, (uint)strlen(new_tb)); + } +} + +static inline +void mysql_audit_alter_table(THD *thd, TABLE_LIST *table) +{ + if (mysql_audit_table_enabled()) + { + const Security_context *sctx= thd->security_ctx; + mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, MYSQL_AUDIT_TABLE_ALTER, + 0, (ulong)thd->thread_id, + sctx->user, sctx->priv_user, sctx->priv_host, + sctx->external_user, sctx->proxy_user, sctx->host, + sctx->ip, table->db, (uint)table->db_length, + table->table_name, (uint)table->table_name_length, + 0,0,0,0); + } +} + #endif /* SQL_AUDIT_INCLUDED */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0effe2a7351..85c557acbfa 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -54,6 +54,7 @@ #include "sql_show.h" #include "transaction.h" #include "datadict.h" // dd_frm_type() +#include "sql_audit.h" #ifdef __WIN__ #include @@ -2344,6 +2345,10 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, wrong_tables.append(','); wrong_tables.append(String(table->table_name,system_charset_info)); } + else + { + mysql_audit_drop_table(thd, table); + } DBUG_PRINT("table", ("table: 0x%lx s: 0x%lx", (long) table->table, table->table ? (long) table->table->s : (long) -1)); @@ -4728,6 +4733,8 @@ mysql_rename_table(handlerton *base, const char *old_db, my_error(ER_NOT_SUPPORTED_YET, MYF(0), "ALTER TABLE"); else if (error) my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error); + else if (!(flags & FN_IS_TMP)) + mysql_audit_rename_table(thd, old_db, old_name, new_db, new_name); DBUG_RETURN(error != 0); } @@ -6054,6 +6061,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, mysql_ha_rm_tables(thd, table_list); + mysql_audit_alter_table(thd, table_list); + /* DISCARD/IMPORT TABLESPACE is always alone in an ALTER TABLE */ if (alter_info->tablespace_op != NO_TABLESPACE_OP) /* Conditionally writes to binlog. */ @@ -6716,6 +6725,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, HA_OPTION_PACK_RECORD)); } tmp_disable_binlog(thd); + create_info->options|=HA_CREATE_TMP_ALTER; error= mysql_create_table_no_lock(thd, new_db, tmp_name, create_info, alter_info, From b54e5850d425f73a51f3210981cd609b604e9698 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Apr 2013 16:22:39 +0200 Subject: [PATCH 113/273] MDEV-4396: Fix sporadic failure of test innodb.innodb_bug14676111 The problem was that xtradb has innodb_purge_threads default 1 (plain innodb defaults to 0). The test sets a special debug variable and relies on it to force purge to happen. But when using background purge threads, this does not work, the debug code is not made to handle this, so occasionally the test times out waiting for the purge to occur. Fix by explicitly setting innodb_purgee_threads=0 for this test. --- mysql-test/suite/innodb/t/innodb_bug14676111-master.opt | 1 + mysql-test/suite/innodb/t/innodb_bug14676111.test | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 mysql-test/suite/innodb/t/innodb_bug14676111-master.opt diff --git a/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt b/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt new file mode 100644 index 00000000000..e16b9b0b895 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt @@ -0,0 +1 @@ +--loose-innodb-purge-threads=0 diff --git a/mysql-test/suite/innodb/t/innodb_bug14676111.test b/mysql-test/suite/innodb/t/innodb_bug14676111.test index fadd111fdc9..41862b8105e 100644 --- a/mysql-test/suite/innodb/t/innodb_bug14676111.test +++ b/mysql-test/suite/innodb/t/innodb_bug14676111.test @@ -3,6 +3,11 @@ -- source include/have_innodb.inc -- source include/have_debug.inc +# Note that this test needs to be able to manipulate how/when purge is done +# using @@innodb_limit_optimistic_insert_debug. This does not work with +# background purge threads, so we disabled them in the -master.opt (they are +# off by default in normal 5.5 innodb but on by default in xtradb) + if (`select count(*)=0 from information_schema.global_variables where variable_name = 'INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG'`) { --skip Test requires InnoDB built with UNIV_DEBUG definition. From 203264ddc9c399fa4a86b589ae638eccfb66e9ed Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Apr 2013 13:16:35 +0200 Subject: [PATCH 114/273] Fix unsigned/signed conversion bug in event type during mysql_binlog_send(). Since event types can be >=128 and are read from a (possibly signed) char pointer, we need to cast to unsigned char before extending to int, or we will get an incorrect negative number. This was done in the main code path already, but there is a rare case where we check for new events first without a lock and then again with the lock. If the second check succeeds because a new event turns up at just the right time, then we took a code path that was missing the correct unsigned char cast, leading to incorrect handling of events for old slave servers and possibly other grief. (This was found from a sporadic failure in Buildbot of test case rpl_mariadb_slave_capability). --- sql/sql_repl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index b8a12b1ea8a..be9717cdc65 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1026,7 +1026,8 @@ impossible position"; mysql_mutex_unlock(log_lock); read_packet = 1; p_coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET); - event_type= (Log_event_type)((*packet)[LOG_EVENT_OFFSET+ev_offset]); + event_type= + (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]); break; case LOG_READ_EOF: From 1d130cc6970073b5459801b51a2b87e4f08bd97c Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 25 Apr 2013 15:11:59 +0200 Subject: [PATCH 115/273] Fix build on Windows --- plugin/audit_null/audit_null.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/audit_null/audit_null.c b/plugin/audit_null/audit_null.c index 916c7187a57..fd4cd1d1e87 100644 --- a/plugin/audit_null/audit_null.c +++ b/plugin/audit_null/audit_null.c @@ -22,6 +22,10 @@ #define __attribute__(A) #endif +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + static volatile int ncalls; /* for SHOW STATUS, see below */ static volatile int ncalls_general_log; static volatile int ncalls_general_error; From f225f5485c0ebd15d4496994ac78e41fc3b39d10 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 27 Apr 2013 23:28:48 -0700 Subject: [PATCH 116/273] Fixed bug mdev-4340. The function make_join_statistics checks whether eq_ref access uses only constant expressions, and, if this is the case the function performs constant row substitution. The code of this check must take into account hidden components of extended secondary keys. --- mysql-test/r/innodb_ext_key.result | 122 ++++++++++++++++++++++++++++ mysql-test/t/innodb_ext_key.test | 123 +++++++++++++++++++++++++++++ sql/sql_select.cc | 11 ++- 3 files changed, 254 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/innodb_ext_key.result b/mysql-test/r/innodb_ext_key.result index 0da4feaf26f..4a6b902e869 100644 --- a/mysql-test/r/innodb_ext_key.result +++ b/mysql-test/r/innodb_ext_key.result @@ -865,6 +865,128 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where 1 SIMPLE t3 ref PRIMARY,col1 col1 12 test.t1.a,test.t1.a,test.t1.a # Using index drop table t1,t2,t3; +# +# Bug mdev-4340: performance regression with extended_keys=on +# +set @save_optimizer_switch=@@optimizer_switch; +CREATE TABLE t1 ( +page_id int(8) unsigned NOT NULL AUTO_INCREMENT, +page_namespace int(11) NOT NULL DEFAULT '0', +page_title varbinary(255) NOT NULL DEFAULT '', +page_restrictions tinyblob NOT NULL, +page_counter bigint(20) unsigned NOT NULL DEFAULT '0', +page_is_redirect tinyint(1) unsigned NOT NULL DEFAULT '0', +page_is_new tinyint(1) unsigned NOT NULL DEFAULT '0', +page_random double unsigned NOT NULL DEFAULT '0', +page_touched varbinary(14) NOT NULL DEFAULT '', +page_latest int(8) unsigned NOT NULL DEFAULT '0', +page_len int(8) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (page_id), +UNIQUE KEY name_title (page_namespace,page_title), +KEY page_random (page_random), +KEY page_len (page_len), +KEY page_redirect_namespace_len (page_is_redirect,page_namespace,page_len) +) ENGINE=InnoDB AUTO_INCREMENT=38929100 DEFAULT CHARSET=binary; +INSERT INTO t1 VALUES +(38928077,0,'Sandbox','',0,0,0,0,'',0,0),(38928078,1,'Sandbox','',0,0,0,1,'',0,0), +(38928079,2,'Sandbox','',0,0,0,2,'',0,0),(38928080,3,'Sandbox','',0,0,0,3,'',0,0), +(38928081,4,'Sandbox','',0,0,0,4,'',0,0),(38928082,5,'Sandbox','',0,0,0,5,'',0,0); +CREATE TABLE t2 ( +rev_id int(8) unsigned NOT NULL AUTO_INCREMENT, +rev_page int(8) unsigned NOT NULL DEFAULT '0', +rev_text_id int(8) unsigned NOT NULL DEFAULT '0', +rev_comment varbinary(255) DEFAULT NULL, +rev_user int(5) unsigned NOT NULL DEFAULT '0', +rev_user_text varbinary(255) NOT NULL DEFAULT '', +rev_timestamp varbinary(14) NOT NULL DEFAULT '', +rev_minor_edit tinyint(1) unsigned NOT NULL DEFAULT '0', +rev_deleted tinyint(1) unsigned NOT NULL DEFAULT '0', +rev_len int(8) unsigned DEFAULT NULL, +rev_parent_id int(8) unsigned DEFAULT NULL, +rev_sha1 varbinary(32) NOT NULL DEFAULT '', +PRIMARY KEY (rev_page,rev_id), +UNIQUE KEY rev_id (rev_id), +KEY rev_timestamp (rev_timestamp), +KEY page_timestamp (rev_page,rev_timestamp), +KEY user_timestamp (rev_user,rev_timestamp), +KEY usertext_timestamp (rev_user_text,rev_timestamp,rev_user,rev_deleted,rev_minor_edit,rev_text_id,rev_comment) +) ENGINE=InnoDB DEFAULT CHARSET=binary; +INSERT INTO t2 VALUES +(547116222,20,0,NULL,3,'','',0,0,NULL,NULL,''),(547117245,20,0,NULL,4,'','',0,0,NULL,NULL,''), +(547118268,20,0,NULL,5,'','',0,0,NULL,NULL,''),(547114177,21,0,NULL,1,'','',0,0,NULL,NULL,''), +(547115200,21,0,NULL,2,'','',0,0,NULL,NULL,''),(547116223,21,0,NULL,3,'','',0,0,NULL,NULL,''), +(547117246,21,0,NULL,4,'','',0,0,NULL,NULL,''),(547118269,21,0,NULL,5,'','',0,0,NULL,NULL,''), +(547114178,22,0,NULL,1,'','',0,0,NULL,NULL,''),(547115201,22,0,NULL,2,'','',0,0,NULL,NULL,''), +(547116224,22,0,NULL,3,'','',0,0,NULL,NULL,''),(547117247,22,0,NULL,4,'','',0,0,NULL,NULL,''), +(547116226,24,0,NULL,3,'','',0,0,NULL,NULL,''),(547117249,24,0,NULL,4,'','',0,0,NULL,NULL,''), +(547118272,24,0,NULL,5,'','',0,0,NULL,NULL,''),(547114181,25,0,NULL,1,'','',0,0,NULL,NULL,''), +(547115204,25,0,NULL,2,'','',0,0,NULL,NULL,''),(547116227,25,0,NULL,3,'','',0,0,NULL,NULL,''), +(547116157,978,0,NULL,2,'','',0,0,NULL,NULL,''),(547117180,978,0,NULL,3,'','',0,0,NULL,NULL,''), +(547118203,978,0,NULL,4,'','',0,0,NULL,NULL,''),(547119226,978,0,NULL,5,'','',0,0,NULL,NULL,''), +(547115135,979,0,NULL,1,'','',0,0,NULL,NULL,''),(547116158,979,0,NULL,2,'','',0,0,NULL,NULL,''), +(547116173,994,0,NULL,2,'','',0,0,NULL,NULL,''),(547117196,994,0,NULL,3,'','',0,0,NULL,NULL,''), +(547118219,994,0,NULL,4,'','',0,0,NULL,NULL,''),(547119242,994,0,NULL,5,'','',0,0,NULL,NULL,''), +(547115151,995,0,NULL,1,'','',0,0,NULL,NULL,''),(547116174,995,0,NULL,2,'','',0,0,NULL,NULL,''), +(547117197,995,0,NULL,3,'','',0,0,NULL,NULL,''),(547118220,995,0,NULL,4,'','',0,0,NULL,NULL,''), +(547118223,998,0,NULL,4,'','',0,0,NULL,NULL,''),(547119246,998,0,NULL,5,'','',0,0,NULL,NULL,''), +(547115155,999,0,NULL,1,'','',0,0,NULL,NULL,''),(547116178,999,0,NULL,2,'','',0,0,NULL,NULL,''), +(547117201,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547118224,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547119271,38928081,0,NULL,10,'','',0,0,NULL,NULL,''),(547119272,38928081,0,NULL,11,'','',0,0,NULL,NULL,''), +(547119273,38928081,0,NULL,12,'','',0,0,NULL,NULL,''),(547119274,38928081,0,NULL,13,'','',0,0,NULL,NULL,''), +(547119275,38928081,0,NULL,14,'','',0,0,NULL,NULL,''),(547119276,38928081,0,NULL,15,'','',0,0,NULL,NULL,''), +(547119277,38928081,0,NULL,16,'','',0,0,NULL,NULL,''),(547119278,38928081,0,NULL,17,'','',0,0,NULL,NULL,''), +(547119279,38928081,0,NULL,18,'','',0,0,NULL,NULL,''),(547119280,38928081,0,NULL,19,'','',0,0,NULL,NULL,''); +CREATE TABLE t3 ( +old_id int(10) unsigned NOT NULL AUTO_INCREMENT, +old_text mediumblob NOT NULL, +old_flags tinyblob NOT NULL, +PRIMARY KEY (old_id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(1,'text-0',''),(2,'text-1000',''),(3,'text-2000',''),(4,'text-3000',''), +(5,'text-4000',''),(6,'text-5000',''),(7,'text-6000',''),(8,'text-7000',''), +(9,'text-8000',''),(10,'text-9000',''),(11,'text-1',''),(12,'text-1001',''), +(13,'text-2001',''),(14,'text-3001',''),(15,'text-4001',''),(16,'text-5001',''), +(17,'text-6001',''),(18,'text-7001',''),(19,'text-8001',''),(20,'text-9001',''), +(21,'text-2',''),(22,'text-1002',''),(23,'text-2002',''),(24,'text-3002',''), +(25,'text-4002',''),(26,'text-5002',''),(27,'text-6002',''),(28,'text-7002',''), +(29,'text-8002',''),(30,'text-9002',''),(31,'text-3',''),(32,'text-1003',''), +(33,'text-2003',''),(34,'text-3003',''),(35,'text-4003',''),(36,'text-5003',''), +(37,'text-6003',''),(38,'text-7003',''),(39,'text-8003',''),(40,'text-9003',''), +(41,'text-4',''),(42,'text-1004',''),(43,'text-2004',''),(44,'text-3004',''), +(45,'text-4004',''),(46,'text-5004',''),(47,'text-6004',''),(48,'text-7004',''), +(49,'text-8004',''),(50,'text-9004',''),(51,'text-5',''),(52,'text-1005',''), +(53,'text-2005',''),(54,'text-3005',''),(55,'text-4005',''),(56,'text-5005',''), +(57,'text-6005',''),(58,'text-7005',''),(59,'text-8005',''),(60,'text-9005',''), +(61,'text-6',''),(62,'text-1006',''),(63,'text-2006',''),(64,'text-3006',''), +(65,'text-4006',''),(66,'text-5006',''),(67,'text-6006',''),(68,'text-7006',''), +(69,'text-8006',''),(70,'text-9006',''),(71,'text-7',''),(72,'text-1007',''), +(73,'text-2007',''),(74,'text-3007',''),(75,'text-4007',''),(76,'text-5007',''), +(77,'text-6007',''),(78,'text-7007',''),(79,'text-8007',''),(80,'text-9007',''), +(81,'text-8',''),(82,'text-1008',''),(83,'text-2008',''),(84,'text-3008',''), +(85,'text-4008',''),(86,'text-5008',''),(87,'text-6008',''),(88,'text-7008',''), +(89,'text-8008',''),(90,'text-9008',''),(91,'text-9',''),(92,'text-1009',''), +(93,'text-2009',''),(94,'text-3009',''),(95,'text-4009',''),(96,'text-5009',''), +(97,'text-6009',''),(98,'text-7009',''),(99,'text-8009',''),(100,'text-9009',''); +set optimizer_switch='extended_keys=off'; +EXPLAIN +SELECT * FROM t1, t2 IGNORE INDEX (PRIMARY), t3 +WHERE page_id=rev_page AND rev_text_id=old_id AND page_namespace=4 AND page_title='Sandbox' +ORDER BY rev_timestamp ASC LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY,name_title name_title 261 const,const 1 +1 SIMPLE t2 ref page_timestamp page_timestamp 4 const 10 Using where +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.rev_text_id 1 +set optimizer_switch='extended_keys=on'; +EXPLAIN +SELECT * FROM t1, t2 IGNORE INDEX (PRIMARY), t3 +WHERE page_id=rev_page AND rev_text_id=old_id AND page_namespace=4 AND page_title='Sandbox' +ORDER BY rev_timestamp ASC LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY,name_title name_title 261 const,const 1 +1 SIMPLE t2 ref page_timestamp page_timestamp 4 const 10 Using where +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.rev_text_id 1 +DROP TABLE t1,t2,t3; set optimizer_switch=@save_optimizer_switch; set optimizer_switch=@save_ext_key_optimizer_switch; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/t/innodb_ext_key.test b/mysql-test/t/innodb_ext_key.test index 31c6fca2b95..36414105917 100644 --- a/mysql-test/t/innodb_ext_key.test +++ b/mysql-test/t/innodb_ext_key.test @@ -539,6 +539,129 @@ select * from t1, t3 where t3.col1=t1.a and t3.col2=t1.a and t3.pk1=t1.a; drop table t1,t2,t3; +--echo # +--echo # Bug mdev-4340: performance regression with extended_keys=on +--echo # + +set @save_optimizer_switch=@@optimizer_switch; + +CREATE TABLE t1 ( + page_id int(8) unsigned NOT NULL AUTO_INCREMENT, + page_namespace int(11) NOT NULL DEFAULT '0', + page_title varbinary(255) NOT NULL DEFAULT '', + page_restrictions tinyblob NOT NULL, + page_counter bigint(20) unsigned NOT NULL DEFAULT '0', + page_is_redirect tinyint(1) unsigned NOT NULL DEFAULT '0', + page_is_new tinyint(1) unsigned NOT NULL DEFAULT '0', + page_random double unsigned NOT NULL DEFAULT '0', + page_touched varbinary(14) NOT NULL DEFAULT '', + page_latest int(8) unsigned NOT NULL DEFAULT '0', + page_len int(8) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (page_id), + UNIQUE KEY name_title (page_namespace,page_title), + KEY page_random (page_random), + KEY page_len (page_len), + KEY page_redirect_namespace_len (page_is_redirect,page_namespace,page_len) +) ENGINE=InnoDB AUTO_INCREMENT=38929100 DEFAULT CHARSET=binary; +INSERT INTO t1 VALUES +(38928077,0,'Sandbox','',0,0,0,0,'',0,0),(38928078,1,'Sandbox','',0,0,0,1,'',0,0), +(38928079,2,'Sandbox','',0,0,0,2,'',0,0),(38928080,3,'Sandbox','',0,0,0,3,'',0,0), +(38928081,4,'Sandbox','',0,0,0,4,'',0,0),(38928082,5,'Sandbox','',0,0,0,5,'',0,0); + +CREATE TABLE t2 ( + rev_id int(8) unsigned NOT NULL AUTO_INCREMENT, + rev_page int(8) unsigned NOT NULL DEFAULT '0', + rev_text_id int(8) unsigned NOT NULL DEFAULT '0', + rev_comment varbinary(255) DEFAULT NULL, + rev_user int(5) unsigned NOT NULL DEFAULT '0', + rev_user_text varbinary(255) NOT NULL DEFAULT '', + rev_timestamp varbinary(14) NOT NULL DEFAULT '', + rev_minor_edit tinyint(1) unsigned NOT NULL DEFAULT '0', + rev_deleted tinyint(1) unsigned NOT NULL DEFAULT '0', + rev_len int(8) unsigned DEFAULT NULL, + rev_parent_id int(8) unsigned DEFAULT NULL, + rev_sha1 varbinary(32) NOT NULL DEFAULT '', + PRIMARY KEY (rev_page,rev_id), + UNIQUE KEY rev_id (rev_id), + KEY rev_timestamp (rev_timestamp), + KEY page_timestamp (rev_page,rev_timestamp), + KEY user_timestamp (rev_user,rev_timestamp), + KEY usertext_timestamp (rev_user_text,rev_timestamp,rev_user,rev_deleted,rev_minor_edit,rev_text_id,rev_comment) +) ENGINE=InnoDB DEFAULT CHARSET=binary; +INSERT INTO t2 VALUES +(547116222,20,0,NULL,3,'','',0,0,NULL,NULL,''),(547117245,20,0,NULL,4,'','',0,0,NULL,NULL,''), +(547118268,20,0,NULL,5,'','',0,0,NULL,NULL,''),(547114177,21,0,NULL,1,'','',0,0,NULL,NULL,''), +(547115200,21,0,NULL,2,'','',0,0,NULL,NULL,''),(547116223,21,0,NULL,3,'','',0,0,NULL,NULL,''), +(547117246,21,0,NULL,4,'','',0,0,NULL,NULL,''),(547118269,21,0,NULL,5,'','',0,0,NULL,NULL,''), +(547114178,22,0,NULL,1,'','',0,0,NULL,NULL,''),(547115201,22,0,NULL,2,'','',0,0,NULL,NULL,''), +(547116224,22,0,NULL,3,'','',0,0,NULL,NULL,''),(547117247,22,0,NULL,4,'','',0,0,NULL,NULL,''), +(547116226,24,0,NULL,3,'','',0,0,NULL,NULL,''),(547117249,24,0,NULL,4,'','',0,0,NULL,NULL,''), +(547118272,24,0,NULL,5,'','',0,0,NULL,NULL,''),(547114181,25,0,NULL,1,'','',0,0,NULL,NULL,''), +(547115204,25,0,NULL,2,'','',0,0,NULL,NULL,''),(547116227,25,0,NULL,3,'','',0,0,NULL,NULL,''), +(547116157,978,0,NULL,2,'','',0,0,NULL,NULL,''),(547117180,978,0,NULL,3,'','',0,0,NULL,NULL,''), +(547118203,978,0,NULL,4,'','',0,0,NULL,NULL,''),(547119226,978,0,NULL,5,'','',0,0,NULL,NULL,''), +(547115135,979,0,NULL,1,'','',0,0,NULL,NULL,''),(547116158,979,0,NULL,2,'','',0,0,NULL,NULL,''), +(547116173,994,0,NULL,2,'','',0,0,NULL,NULL,''),(547117196,994,0,NULL,3,'','',0,0,NULL,NULL,''), +(547118219,994,0,NULL,4,'','',0,0,NULL,NULL,''),(547119242,994,0,NULL,5,'','',0,0,NULL,NULL,''), +(547115151,995,0,NULL,1,'','',0,0,NULL,NULL,''),(547116174,995,0,NULL,2,'','',0,0,NULL,NULL,''), +(547117197,995,0,NULL,3,'','',0,0,NULL,NULL,''),(547118220,995,0,NULL,4,'','',0,0,NULL,NULL,''), +(547118223,998,0,NULL,4,'','',0,0,NULL,NULL,''),(547119246,998,0,NULL,5,'','',0,0,NULL,NULL,''), +(547115155,999,0,NULL,1,'','',0,0,NULL,NULL,''),(547116178,999,0,NULL,2,'','',0,0,NULL,NULL,''), +(547117201,999,0,NULL,3,'','',0,0,NULL,NULL,''),(547118224,999,0,NULL,4,'','',0,0,NULL,NULL,''), +(547119271,38928081,0,NULL,10,'','',0,0,NULL,NULL,''),(547119272,38928081,0,NULL,11,'','',0,0,NULL,NULL,''), +(547119273,38928081,0,NULL,12,'','',0,0,NULL,NULL,''),(547119274,38928081,0,NULL,13,'','',0,0,NULL,NULL,''), +(547119275,38928081,0,NULL,14,'','',0,0,NULL,NULL,''),(547119276,38928081,0,NULL,15,'','',0,0,NULL,NULL,''), +(547119277,38928081,0,NULL,16,'','',0,0,NULL,NULL,''),(547119278,38928081,0,NULL,17,'','',0,0,NULL,NULL,''), +(547119279,38928081,0,NULL,18,'','',0,0,NULL,NULL,''),(547119280,38928081,0,NULL,19,'','',0,0,NULL,NULL,''); + +CREATE TABLE t3 ( + old_id int(10) unsigned NOT NULL AUTO_INCREMENT, + old_text mediumblob NOT NULL, + old_flags tinyblob NOT NULL, + PRIMARY KEY (old_id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(1,'text-0',''),(2,'text-1000',''),(3,'text-2000',''),(4,'text-3000',''), +(5,'text-4000',''),(6,'text-5000',''),(7,'text-6000',''),(8,'text-7000',''), +(9,'text-8000',''),(10,'text-9000',''),(11,'text-1',''),(12,'text-1001',''), +(13,'text-2001',''),(14,'text-3001',''),(15,'text-4001',''),(16,'text-5001',''), +(17,'text-6001',''),(18,'text-7001',''),(19,'text-8001',''),(20,'text-9001',''), +(21,'text-2',''),(22,'text-1002',''),(23,'text-2002',''),(24,'text-3002',''), +(25,'text-4002',''),(26,'text-5002',''),(27,'text-6002',''),(28,'text-7002',''), +(29,'text-8002',''),(30,'text-9002',''),(31,'text-3',''),(32,'text-1003',''), +(33,'text-2003',''),(34,'text-3003',''),(35,'text-4003',''),(36,'text-5003',''), +(37,'text-6003',''),(38,'text-7003',''),(39,'text-8003',''),(40,'text-9003',''), +(41,'text-4',''),(42,'text-1004',''),(43,'text-2004',''),(44,'text-3004',''), +(45,'text-4004',''),(46,'text-5004',''),(47,'text-6004',''),(48,'text-7004',''), +(49,'text-8004',''),(50,'text-9004',''),(51,'text-5',''),(52,'text-1005',''), +(53,'text-2005',''),(54,'text-3005',''),(55,'text-4005',''),(56,'text-5005',''), +(57,'text-6005',''),(58,'text-7005',''),(59,'text-8005',''),(60,'text-9005',''), +(61,'text-6',''),(62,'text-1006',''),(63,'text-2006',''),(64,'text-3006',''), +(65,'text-4006',''),(66,'text-5006',''),(67,'text-6006',''),(68,'text-7006',''), +(69,'text-8006',''),(70,'text-9006',''),(71,'text-7',''),(72,'text-1007',''), +(73,'text-2007',''),(74,'text-3007',''),(75,'text-4007',''),(76,'text-5007',''), +(77,'text-6007',''),(78,'text-7007',''),(79,'text-8007',''),(80,'text-9007',''), +(81,'text-8',''),(82,'text-1008',''),(83,'text-2008',''),(84,'text-3008',''), +(85,'text-4008',''),(86,'text-5008',''),(87,'text-6008',''),(88,'text-7008',''), +(89,'text-8008',''),(90,'text-9008',''),(91,'text-9',''),(92,'text-1009',''), +(93,'text-2009',''),(94,'text-3009',''),(95,'text-4009',''),(96,'text-5009',''), +(97,'text-6009',''),(98,'text-7009',''),(99,'text-8009',''),(100,'text-9009',''); + + +set optimizer_switch='extended_keys=off'; +EXPLAIN +SELECT * FROM t1, t2 IGNORE INDEX (PRIMARY), t3 + WHERE page_id=rev_page AND rev_text_id=old_id AND page_namespace=4 AND page_title='Sandbox' +ORDER BY rev_timestamp ASC LIMIT 10; + +set optimizer_switch='extended_keys=on'; +EXPLAIN +SELECT * FROM t1, t2 IGNORE INDEX (PRIMARY), t3 + WHERE page_id=rev_page AND rev_text_id=old_id AND page_namespace=4 AND page_title='Sandbox' +ORDER BY rev_timestamp ASC LIMIT 10; + +DROP TABLE t1,t2,t3; + set optimizer_switch=@save_optimizer_switch; set optimizer_switch=@save_ext_key_optimizer_switch; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a1d8d3c62e2..6d80ea8d212 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3523,9 +3523,16 @@ make_join_statistics(JOIN *join, List &tables_list, !table->fulltext_searched && (!embedding || (embedding->sj_on_expr && !embedding->embedding))) { + key_map base_part, base_const_ref, base_eq_part; + base_part.set_prefix(keyinfo->key_parts); + base_const_ref= const_ref; + base_const_ref.intersect(base_part); + base_eq_part= eq_part; + base_eq_part.intersect(base_part); if (table->actual_key_flags(keyinfo) & HA_NOSAME) { - if (const_ref == eq_part && + + if (base_const_ref == base_eq_part && !has_expensive_keyparts && !((outer_join & table->map) && (*s->on_expr_ref)->is_expensive())) @@ -3551,7 +3558,7 @@ make_join_statistics(JOIN *join, List &tables_list, else found_ref|= refs; // Table is const if all refs are const } - else if (const_ref == eq_part) + else if (base_const_ref == base_eq_part) s->const_keys.set_bit(key); } } From 2ffc7d73b90b1a1cd9587c8941ed91f1c91a2e78 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 28 Apr 2013 14:28:46 +0200 Subject: [PATCH 117/273] fix test on Windows --- mysql-test/suite/plugins/t/audit_null.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/plugins/t/audit_null.test b/mysql-test/suite/plugins/t/audit_null.test index 47491668529..60883bbe4f9 100644 --- a/mysql-test/suite/plugins/t/audit_null.test +++ b/mysql-test/suite/plugins/t/audit_null.test @@ -54,6 +54,6 @@ drop user testuser@localhost; set global general_log=@old_global_general_log; let $MYSQLD_DATADIR= `SELECT @@datadir`; ---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ /#sql2-[-0-9a-f_]*/#sql2-temporary/ +--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ /#sql2-[-0-9a-f_]*/#sql2-temporary/ /::1// /127.0.0.1// cat_file $MYSQLD_DATADIR/audit_null_tables.log; From 4fd74200dd8ff357b7f870ea0407ef8f3c78ff11 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 29 Apr 2013 13:50:20 +0200 Subject: [PATCH 118/273] - Adding 3 new table types: PROXY table base on another table. Used by several other types. XCOL proxy on a table having a colummn containing a list of values OCCUR proxy on a table having several columns containing the same type of values that can be put in a unique column and several rows. TBL Not new but now internally using the PROXY table class. - Fix 2 bugs in add_field: Change '=' to ' ' after the COMMENT keyword. Quote column names between '`' in the SQL string. - Update xml test result to the CONNECT version added: storage/connect/taboccur.cpp storage/connect/taboccur.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabxcl.cpp storage/connect/tabxcl.h modified: storage/connect/CMakeLists.txt storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/mycat.cc storage/connect/myconn.cpp storage/connect/mysql-test/connect/r/xml.result storage/connect/plgdbsem.h storage/connect/tabmysql.cpp storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/valblk.cpp storage/connect/valblk.h --- storage/connect/CMakeLists.txt | 4 +- storage/connect/ha_connect.cc | 252 +++++--- storage/connect/ha_connect.h | 58 +- storage/connect/mycat.cc | 20 +- storage/connect/myconn.cpp | 4 + .../connect/mysql-test/connect/r/xml.result | 2 +- storage/connect/plgdbsem.h | 14 +- storage/connect/tabmysql.cpp | 12 +- storage/connect/taboccur.cpp | 375 +++++++++++ storage/connect/taboccur.h | 145 +++++ storage/connect/tabtbl.cpp | 166 +++-- storage/connect/tabtbl.h | 49 +- storage/connect/tabutil.cpp | 596 ++++++++++++++++++ storage/connect/tabutil.h | 181 ++++++ storage/connect/tabxcl.cpp | 376 +++++++++++ storage/connect/tabxcl.h | 133 ++++ storage/connect/valblk.cpp | 66 +- storage/connect/valblk.h | 4 + 18 files changed, 2211 insertions(+), 246 deletions(-) create mode 100644 storage/connect/taboccur.cpp create mode 100644 storage/connect/taboccur.h create mode 100644 storage/connect/tabutil.cpp create mode 100644 storage/connect/tabutil.h create mode 100644 storage/connect/tabxcl.cpp create mode 100644 storage/connect/tabxcl.h diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 63943aaa03b..41930c71aa4 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -25,12 +25,14 @@ filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabmul.cpp tabsys.cpp tabvct.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp filamzip.cpp tabtbl.cpp myutil.cpp +tabutil.cpp tabxcl.cpp taboccur.cpp block.h catalog.h checklvl.h colblk.h connect.h csort.h engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h global.h ha_connect.h maputil.h msgid.h mycat.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabmul.h tabsys.h tabtbl.h tabvct.h -user_connect.h valblk.h value.h xindex.h xobject.h xtable.h) +user_connect.h valblk.h value.h xindex.h xobject.h xtable.h +tabutil.h tabxcl.h taboccur.h) # # Definitions that are shared for all OSes diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 8136e6d0263..99f81905f0c 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -122,6 +122,7 @@ #include "tabmysql.h" #endif // MYSQL_SUPPORT #include "filamdbf.h" +#include "tabxcl.h" #include "tabfmt.h" #include "reldef.h" #include "tabcol.h" @@ -156,7 +157,7 @@ extern "C" char nmfile[]; extern "C" char pdebug[]; extern "C" { - char version[]= "Version 1.01.0004 April 10, 2013"; + char version[]= "Version 1.01.0005 April 27, 2013"; #if defined(XMSG) char msglang[]; // Default message language @@ -187,44 +188,13 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, handlerton *connect_hton; /** - structure for CREATE TABLE options (table options) + CREATE TABLE option list (table options) These can be specified in the CREATE TABLE: CREATE TABLE ( ... ) {...here...} */ -struct ha_table_option_struct { - const char *type; - const char *filename; - const char *optname; - const char *tabname; - const char *tablist; - const char *dbname; - const char *separator; -//const char *connect; - const char *qchar; - const char *module; - const char *subtype; - const char *catfunc; - const char *oplist; - const char *data_charset; - ulonglong lrecl; - ulonglong elements; -//ulonglong estimate; - ulonglong multiple; - ulonglong header; - ulonglong quoted; - ulonglong ending; - ulonglong compressed; - bool mapped; - bool huge; - bool split; - bool readonly; - bool sepindex; - }; - ha_create_table_option connect_table_option_list[]= { - // These option are for stand alone Connect tables HA_TOPTION_STRING("TABLE_TYPE", type), HA_TOPTION_STRING("FILE_NAME", filename), HA_TOPTION_STRING("XFILE_NAME", optname), @@ -258,22 +228,11 @@ ha_create_table_option connect_table_option_list[]= /** - structure for CREATE TABLE options (field options) + CREATE TABLE option list (field options) These can be specified in the CREATE TABLE per field: CREATE TABLE ( field ... {...here...}, ... ) */ -struct ha_field_option_struct -{ - ulonglong offset; - ulonglong freq; // Not used by this version - ulonglong opt; // Not used by this version - ulonglong fldlen; - const char *dateformat; - const char *fieldformat; - char *special; -}; - ha_create_table_option connect_field_option_list[]= { HA_FOPTION_NUMBER("FLAG", offset, -1, 0, INT_MAX32, 1), @@ -345,9 +304,8 @@ static void init_connect_psi_keys() {} delete_table method in handler.cc */ static const char *ha_connect_exts[]= { - ".tbl", ".dnx", ".fnx", ".bnx", ".vnx", ".dbx", ".dos", ".fix", ".csv", - ".fmt", ".dbf", ".xml", ".ini", ".vec", ".odbc", ".mysql", ".dir", - ".mac", ".wmi", ".bin", ".oem", + ".dos", ".fix", ".csv",".bin", ".fmt", ".dbf", ".xml", ".ini", ".vec", + ".dnx", ".fnx", ".bnx", ".vnx", ".dbx", NULL }; @@ -708,6 +666,10 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) // Return the handler default value if (!stricmp(opname, "Dbname") || !stricmp(opname, "Database")) opval= (char*)GetDBName(NULL); // Current database + else if (!stricmp(opname, "User")) // Connected user + opval= table->in_use->main_security_ctx.user; + else if (!stricmp(opname, "Host")) // Connected user host + opval= table->in_use->main_security_ctx.host; else opval= sdef; // Caller default @@ -773,9 +735,9 @@ bool ha_connect::SetBooleanOption(char *opname, bool b) /****************************************************************************/ int ha_connect::GetIntegerOption(char *opname) { - int opval= NO_IVAL; - char *pv; - PTOS options= GetTableOptionStruct(table); + ulonglong opval= NO_IVAL; + char *pv; + PTOS options= GetTableOptionStruct(table); if (!options) ; @@ -801,9 +763,9 @@ int ha_connect::GetIntegerOption(char *opname) if (opval == NO_IVAL && options && options->oplist) if ((pv= GetListOption(xp->g, opname, options->oplist))) - opval= atoi(pv); + opval= (unsigned)atoll(pv); - return opval; + return (int)opval; } // end of GetIntegerOption /****************************************************************************/ @@ -885,13 +847,13 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) pcf->Name= (char*)fp->field_name; pcf->Prec= 0; - pcf->Opt= (fop) ? fop->opt : 0; + pcf->Opt= (fop) ? (int)fop->opt : 0; if ((pcf->Length= fp->field_length) < 0) pcf->Length= 256; // BLOB? if (fop) { - pcf->Offset= fop->offset; + pcf->Offset= (int)fop->offset; // pcf->Freq= fop->freq; pcf->Datefmt= (char*)fop->dateformat; pcf->Fieldfmt= (char*)fop->fieldformat; @@ -905,6 +867,7 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) switch (fp->type()) { case MYSQL_TYPE_BLOB: case MYSQL_TYPE_VARCHAR: + case MYSQL_TYPE_VAR_STRING: pcf->Flags |= U_VAR; case MYSQL_TYPE_STRING: pcf->Type= TYPE_STRING; @@ -941,7 +904,7 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) // Field_length is only used for DATE columns if (fop->fldlen) - pcf->Length= fop->fldlen; + pcf->Length= (int)fop->fldlen; else { int len; @@ -2688,13 +2651,18 @@ int ha_connect::delete_all_rows() bool ha_connect::check_privileges(THD *thd, PTOS options) { - if (!options->type) - options->type= "DOS"; + if (!options->type) { + if (options->tabname) + options->type= "PROXY"; + else + options->type= "DOS"; + + } // endif type switch (GetTypeID(options->type)) { case TAB_UNDEF: - case TAB_CATLG: +// case TAB_CATLG: case TAB_PLG: case TAB_JCT: case TAB_DMY: @@ -2733,13 +2701,17 @@ bool ha_connect::check_privileges(THD *thd, PTOS options) case TAB_OEM: return check_access(thd, FILE_ACL, NULL, NULL, NULL, 0, 0); + // This is temporary until a solution is found case TAB_TBL: + case TAB_XCL: + case TAB_PRX: + case TAB_OCCUR: return false; } my_printf_error(ER_UNKNOWN_ERROR, "check_privileges failed", MYF(0)); return true; -} +} // end of check_privileges // Check that two indexes are equivalent bool ha_connect::IsSameIndex(PIXDEF xp1, PIXDEF xp2) @@ -3272,8 +3244,9 @@ bool add_field(String *sql, const char *field_name, const char *type, { bool error= false; + error|= sql->append('`'); error|= sql->append(field_name); - error|= sql->append(' '); + error|= sql->append("` "); error|= sql->append(type); if (len) { error|= sql->append('('); @@ -3289,7 +3262,7 @@ bool add_field(String *sql, const char *field_name, const char *type, error|= sql->append(STRING_WITH_LEN(" NOT NULL"), system_charset_info); if (rem && *rem) { - error|= sql->append(" COMMENT='"); + error|= sql->append(" COMMENT '"); error|= sql->append_for_single_quote(rem, strlen(rem)); error|= sql->append("'"); } @@ -3314,12 +3287,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, { char spc= ',', qch= 0; const char *fncn= "?"; - const char *user, *fn, *tab, *db, *host, *pwd, *prt, *sep; // *csn; - char *dsn; + const char *user, *fn, *db, *host, *pwd, *prt, *sep, *tbl; // *csn; + char *tab, *dsn; #if defined(WIN32) char *nsp= NULL, *cls= NULL; #endif // WIN32 - int port= MYSQL_PORT, hdr= 0, mxr= 0, b= 0; + int port= 0, hdr= 0, mxr= 0, b= 0; uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL); bool ok= false, dbf= false; TABTYPE ttp= TAB_UNDEF; @@ -3338,51 +3311,101 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, sql.copy(STRING_WITH_LEN("CREATE TABLE whatever ("), system_charset_info); - user= host= pwd= prt= dsn= NULL; + user= host= pwd= prt= tbl= dsn= NULL; // Get the useful create options ttp= GetTypeID(topt->type); fn= topt->filename; - tab= topt->tabname; + tab= (char*)topt->tabname; db= topt->dbname; fncn= topt->catfunc; fnc= GetFuncID(fncn); sep= topt->separator; spc= (!sep || !strcmp(sep, "\\t")) ? '\t' : *sep; qch= topt->qchar ? *topt->qchar : topt->quoted >= 0 ? '"' : 0; - hdr= topt->header; + hdr= (int)topt->header; + tbl= topt->tablist; + if (topt->oplist) { - host= GetListOption(g,"host", topt->oplist, "localhost"); - user= GetListOption(g,"user", topt->oplist, "root"); - // Default value db can come from the DBNAME=xxx option. - db= GetListOption(g,"database", topt->oplist, db); - pwd= GetListOption(g,"password", topt->oplist); - prt= GetListOption(g,"port", topt->oplist); - port= (prt) ? atoi(prt) : MYSQL_PORT; + host= GetListOption(g,"host", topt->oplist, "localhost"); + user= GetListOption(g,"user", topt->oplist, "root"); + // Default value db can come from the DBNAME=xxx option. + db= GetListOption(g,"database", topt->oplist, db); + pwd= GetListOption(g,"password", topt->oplist); + prt= GetListOption(g,"port", topt->oplist); + port= (prt) ? atoi(prt) : MYSQL_PORT; #if defined(WIN32) - nsp= GetListOption(g,"namespace", topt->oplist); - cls= GetListOption(g,"class", topt->oplist); + nsp= GetListOption(g,"namespace", topt->oplist); + cls= GetListOption(g,"class", topt->oplist); #endif // WIN32 - mxr= atoi(GetListOption(g,"maxerr", topt->oplist, "0")); - } // endelse option_list + mxr= atoi(GetListOption(g,"maxerr", topt->oplist, "0")); + } // endif option_list if (!db) db= thd->db; // Default value // Check table type if (ttp == TAB_UNDEF) { - strcpy(g->Message, "No table_type. Was set to DOS"); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); - ttp= TAB_DOS; - topt->type= "DOS"; + if (!tab) { + strcpy(g->Message, "No table_type. Was set to DOS"); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + ttp= TAB_DOS; + topt->type= "DOS"; + } else { + strcpy(g->Message, "No table_type. Was set to PROXY"); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + ttp= TAB_PRX; + topt->type= "PROXY"; + } // endif fnc + } else if (ttp == TAB_NIY) { sprintf(g->Message, "Unsupported table type %s", topt->type); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); return HA_ERR_INTERNAL_ERROR; } // endif ttp - if (!tab && !(fnc & (FNC_TABLE | FNC_COL))) - tab= (char*)create_info->alias; + if (!tab) { + if (ttp == TAB_TBL) { + // Make tab the first table of the list + char *p; + + if (!tbl) { + strcpy(g->Message, "Missing table list"); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + return HA_ERR_INTERNAL_ERROR; + } // endif tbl + + tab= (char*)PlugSubAlloc(g, NULL, strlen(tbl) + 1); + strcpy(tab, tbl); + + if ((p= strchr(tab, ','))) + *p= 0; + + if ((p=strchr(tab, '.'))) { + *p= 0; + db= tab; + tab= p + 1; + } // endif p + + } else if (ttp != TAB_ODBC || !(fnc & (FNC_TABLE | FNC_COL))) + tab= (char*)create_info->alias; + + } // endif tab + + // Check whether a table is defined on itself + switch (ttp) { + case TAB_PRX: + case TAB_XCL: + case TAB_TBL: + case TAB_OCCUR: + if (!stricmp(tab, create_info->alias) && + !stricmp(db, thd->db)) { + sprintf(g->Message, "A %s table cannot refer to itself", topt->type); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + return HA_ERR_INTERNAL_ERROR; + } // endif tab + + } // endswitch ttp switch (ttp) { #if defined(ODBC_SUPPORT) @@ -3433,7 +3456,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= false; } else if (!user) - user= "root"; // Avoid crash + user= thd->main_security_ctx.user; break; #endif // MYSQL_SUPPORT @@ -3442,6 +3465,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= true; break; #endif // WIN32 + case TAB_PRX: + case TAB_TBL: + case TAB_XCL: + ok= true; + break; default: sprintf(g->Message, "Cannot get column info for table type %s", topt->type); } // endif ttp @@ -3453,6 +3481,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= false; } // endif supfnc + // Here we should test the flag column options when + // this function is called in case of CREATE .. SELECT + if (ok) { char *cnm, *rem; int i, len, dec, typ; @@ -3505,6 +3536,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL); break; #endif // WIN32 + case TAB_PRX: + case TAB_TBL: + case TAB_XCL: + qrp= TabColumns(g, thd, db, tab, fnc == FNC_COL); + break; default: strcpy(g->Message, "System error during assisted discovery"); break; @@ -3587,11 +3623,16 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, } // endif ttp #endif // ODBC_SUPPORT + // Make the arguments as required by add_fields type= PLGtoMYSQLtype(typ, true); + if (typ == TYPE_DATE) len= 0; + + // Now add the field if (add_field(&sql, cnm, type, len, dec, tm, rem)) b= HA_ERR_OUT_OF_MEM; + } // endfor i sql.length(sql.length()-1); // remove the trailing comma @@ -3602,59 +3643,76 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ulonglong vull; const char *vstr; bool oom= false; + switch (opt->type) { case HA_OPTION_TYPE_ULL: - vull= *(ulonglong*)(((char*)topt) + opt->offset); + vull= *(ulonglong*)(((char*)topt) + opt->offset); + if (vull != opt->def_value) { oom|= sql.append(' '); oom|= sql.append(opt->name); oom|= sql.append('='); oom|= sql.append_ulonglong(vull); - } + } // endif vull + break; case HA_OPTION_TYPE_STRING: - vstr= *(char**)(((char*)topt) + opt->offset); + vstr= *(char**)(((char*)topt) + opt->offset); + if (vstr) { oom|= sql.append(' '); oom|= sql.append(opt->name); oom|= sql.append("='"); oom|= sql.append_for_single_quote(vstr, strlen(vstr)); oom|= sql.append('\''); - } + } // endif vstr + break; case HA_OPTION_TYPE_BOOL: - vull= *(bool*)(((char*)topt) + opt->offset); + vull= *(bool*)(((char*)topt) + opt->offset); + if (vull != opt->def_value) { oom|= sql.append(' '); oom|= sql.append(opt->name); oom|= sql.append('='); oom|= sql.append(vull ? "ON" : "OFF"); - } + } // endif vull + break; default: // no enums here, good :) break; - } + } // endswitch type + if (oom) b= HA_ERR_OUT_OF_MEM; - } + + } // endfor opt if (create_info->connect_string.length) { bool oom= false; + oom|= sql.append(' '); oom|= sql.append("CONNECTION='"); oom|= sql.append_for_single_quote(create_info->connect_string.str, create_info->connect_string.length); oom|= sql.append('\''); + if (oom) b= HA_ERR_OUT_OF_MEM; - } + + } // endif string if (create_info->default_table_charset) { bool oom= false; + oom|= sql.append(' '); oom|= sql.append("CHARSET="); oom|= sql.append(create_info->default_table_charset->csname); - } + + if (oom) + b= HA_ERR_OUT_OF_MEM; + + } // endif charset if (!b) b= table_s->init_from_sql_statement_string(thd, true, @@ -3664,7 +3722,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); return HA_ERR_INTERNAL_ERROR; -} // end of pre_create +} // end of connect_assisted_discovery /** @brief diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index b8c92479543..53339d168d0 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2011 +/* Copyright (C) Olivier Bertrand 2004 - 2013 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -64,6 +64,59 @@ typedef struct ha_field_option_struct FOS, *PFOS; extern handlerton *connect_hton; +/** + structure for CREATE TABLE options (table options) + + These can be specified in the CREATE TABLE: + CREATE TABLE ( ... ) {...here...} +*/ +struct ha_table_option_struct { + const char *type; + const char *filename; + const char *optname; + const char *tabname; + const char *tablist; + const char *dbname; + const char *separator; +//const char *connect; + const char *qchar; + const char *module; + const char *subtype; + const char *catfunc; + const char *oplist; + const char *data_charset; + ulonglong lrecl; + ulonglong elements; +//ulonglong estimate; + ulonglong multiple; + ulonglong header; + ulonglong quoted; + ulonglong ending; + ulonglong compressed; + bool mapped; + bool huge; + bool split; + bool readonly; + bool sepindex; + }; + +/** + structure for CREATE TABLE options (field options) + + These can be specified in the CREATE TABLE per field: + CREATE TABLE ( field ... {...here...}, ... ) +*/ +struct ha_field_option_struct +{ + ulonglong offset; + ulonglong freq; // Not used by this version + ulonglong opt; // Not used by this version + ulonglong fldlen; + const char *dateformat; + const char *fieldformat; + char *special; +}; + /** @brief CONNECT_SHARE is a structure that will be shared among all open handlers. This example implements the minimum of what you will probably need. @@ -143,8 +196,7 @@ public: { return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_HAS_RECORDS | HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS | - HA_NO_COPY_ON_ALTER | - HA_CAN_VIRTUAL_COLUMNS | + HA_NO_COPY_ON_ALTER | HA_CAN_VIRTUAL_COLUMNS | HA_NULL_IN_KEY | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE); } diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 4db70efe27f..5a7f53977c7 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -68,7 +68,10 @@ #include "tabmac.h" #include "tabwmi.h" #endif // WIN32 +//#include "tabtbl.h" +#include "tabxcl.h" #include "tabtbl.h" +#include "taboccur.h" #if defined(XML_SUPPORT) #include "tabxml.h" #endif // XML_SUPPORT @@ -124,6 +127,10 @@ TABTYPE GetTypeID(const char *type) : (!stricmp(type, "WMI")) ? TAB_WMI #endif : (!stricmp(type, "TBL")) ? TAB_TBL + : (!stricmp(type, "XCOL")) ? TAB_XCL + : (!stricmp(type, "OCCUR")) ? TAB_OCCUR + : (!stricmp(type, "CATLG")) ? TAB_PRX // Legacy + : (!stricmp(type, "PROXY")) ? TAB_PRX : (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY; } // end of GetTypeID @@ -186,7 +193,6 @@ bool IsTypeNullable(TABTYPE type) break; } // endswitch type - return nullable; } // end of IsTypeNullable @@ -414,7 +420,7 @@ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp) PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO)); // Get a unique char identifier for type - tc= (defp->Catfunc == FNC_NO) ? GetTypeID(type) : TAB_CATLG; + tc= (defp->Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX; // Take care of the column definitions i= poff= nof= nlg= 0; @@ -443,6 +449,9 @@ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp) case TAB_INI: case TAB_MAC: case TAB_TBL: + case TAB_XCL: + case TAB_OCCUR: + case TAB_PRX: case TAB_OEM: poff = 0; // Offset represents an independant flag break; @@ -592,7 +601,7 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, // If not specified get the type of this table if (!type && !(type= Hc->GetStringOption("Type"))) - type= "DOS"; + type= (Hc->GetStringOption("Tabname")) ? "PROXY" : "DOS"; return MakeTableDesc(g, name, type); } // end of GetTableDesc @@ -636,6 +645,9 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) #endif // WIN32 case TAB_OEM: tdp= new(g) OEMDEF; break; case TAB_TBL: tdp= new(g) TBLDEF; break; + case TAB_XCL: tdp= new(g) XCLDEF; break; + case TAB_PRX: tdp= new(g) PRXDEF; break; + case TAB_OCCUR: tdp= new(g) OCCURDEF; break; #if defined(MYSQL_SUPPORT) case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; #endif // MYSQL_SUPPORT @@ -646,7 +658,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); } // endswitch - // Do make the table/view definition from XDB file information + // Do make the table/view definition if (tdp && tdp->Define(g, this, name, am)) tdp= NULL; diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 3edf07004ea..53a2496b197 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -62,6 +62,7 @@ static char *server_groups[] = { #endif // EMBEDDED extern "C" int trace; +extern MYSQL_PLUGIN_IMPORT uint mysqld_port; /************************************************************************/ /* MyColumns: constructs the result blocks containing all columns */ @@ -90,6 +91,9 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, PCOLRES crp; MYSQLC myc; + if (!port) + port = mysqld_port; + if (!info) { /********************************************************************/ /* Open the connection with the MySQL server. */ diff --git a/storage/connect/mysql-test/connect/r/xml.result b/storage/connect/mysql-test/connect/r/xml.result index e7dcf8f4c73..554039dc3f1 100644 --- a/storage/connect/mysql-test/connect/r/xml.result +++ b/storage/connect/mysql-test/connect/r/xml.result @@ -507,7 +507,7 @@ DROP TABLE t1; SET @a=LOAD_FILE('test/t1.xml'); SELECT CAST(@a AS CHAR CHARACTER SET latin1); CAST(@a AS CHAR CHARACTER SET latin1) - + ÀÁÂÃ diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 611b0067e18..a1eaf97bd10 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -69,12 +69,14 @@ enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */ TAB_WMI = 14, /* WMI tables (Windows only) */ TAB_TBL = 15, /* Collection of CONNECT tables */ TAB_OEM = 16, /* OEM implemented table */ - TAB_CATLG = 17, /* Catalog table */ - TAB_PLG = 18, /* PLG NIY */ - TAB_PIVOT = 19, /* PIVOT NIY */ - TAB_JCT = 20, /* Junction tables NIY */ - TAB_DMY = 21, /* DMY Dummy tables NIY */ - TAB_NIY = 22}; /* Table not implemented yet */ + TAB_XCL = 17, /* XCL table */ + TAB_OCCUR = 18, /* OCCUR table */ + TAB_PRX = 19, /* Proxy (catalog) table */ + TAB_PLG = 20, /* PLG NIY */ + TAB_PIVOT = 21, /* PIVOT NIY */ + TAB_JCT = 22, /* Junction tables NIY */ + TAB_DMY = 23, /* DMY Dummy tables NIY */ + TAB_NIY = 24}; /* Table not implemented yet */ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */ TYPE_AM_ROWID = 1, /* ROWID type (special column) */ diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 7b38cc8ab1b..495324b74f7 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -63,6 +63,7 @@ void PrintResult(PGLOBAL, PSEM, PQRYRES); #endif // _CONSOLE extern "C" int trace; +extern MYSQL_PLUGIN_IMPORT uint mysqld_port; /* -------------- Implementation of the MYSQLDEF class --------------- */ @@ -243,10 +244,13 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url) if ((sport = strchr(Hostname, ':'))) *sport++ = 0; - Portnumber = (sport && sport[0]) ? atoi(sport) : MYSQL_PORT; + Portnumber = (sport && sport[0]) ? atoi(sport) : mysqld_port; + + if (Username[0] == 0) + Username = Cat->GetStringCatInfo(g, "User", "*"); if (Hostname[0] == 0) - Hostname = "localhost"; + Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); if (!Database || !*Database) Database = Cat->GetStringCatInfo(g, "Database", "*"); @@ -282,9 +286,9 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Database = Cat->GetStringCatInfo(g, "Database", "*"); Tabname = Cat->GetStringCatInfo(g, "Name", Name); // Deprecated Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); - Username = Cat->GetStringCatInfo(g, "User", "root"); + Username = Cat->GetStringCatInfo(g, "User", "*"); Password = Cat->GetStringCatInfo(g, "Password", NULL); - Portnumber = Cat->GetIntCatInfo("Port", MYSQL_PORT); + Portnumber = Cat->GetIntCatInfo("Port", mysqld_port); } else if (ParseURL(g, url)) return TRUE; diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp new file mode 100644 index 00000000000..e1b83c06422 --- /dev/null +++ b/storage/connect/taboccur.cpp @@ -0,0 +1,375 @@ +/************ TabOccur CPP Declares Source Code File (.CPP) ************/ +/* Name: TABOCCUR.CPP Version 1.0 */ +/* */ +/* (C) Copyright to the author Olivier BERTRAND 2013 */ +/* */ +/* OCCUR: Table that provides a view of a source table where the */ +/* contain of several columns of the source table is placed in only */ +/* one column, the OCCUR column, this resulting into several rows. */ +/***********************************************************************/ + +/***********************************************************************/ +/* Include relevant section of system dependant header files. */ +/***********************************************************************/ +#include "my_global.h" +#if defined(WIN32) +#include +#include +#if defined(__BORLANDC__) +#define __MFC_COMPAT__ // To define min/max as macro +#endif +//#include +#else +#if defined(UNIX) +#include +#include +#include +#include +#include +#include "osutil.h" +#else +//#include +#endif +//#include +#endif + +/***********************************************************************/ +/* Include application header files: */ +/***********************************************************************/ +#include "table.h" // MySQL table definitions +#include "global.h" +#include "plgdbsem.h" +#include "reldef.h" +#include "filamtxt.h" +#include "tabdos.h" +#include "tabcol.h" +#include "taboccur.h" +#include "xtable.h" +#if defined(MYSQL_SUPPORT) +#include "tabmysql.h" +#endif // MYSQL_SUPPORT +#include "ha_connect.h" +#include "mycat.h" + +extern "C" int trace; + +/* -------------- Implementation of the OCCUR classes ---------------- */ + +/***********************************************************************/ +/* DefineAM: define specific AM block values from OCCUR table. */ +/***********************************************************************/ +bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) + { +//Tabname = Cat->GetStringCatInfo(g, "SrcTable", ""); + Xcol = Cat->GetStringCatInfo(g, "OccurCol", ""); + Rcol = Cat->GetStringCatInfo(g, "RankCol", ""); + Colist = Cat->GetStringCatInfo(g, "Colist", ""); + return PRXDEF::DefineAM(g, am, poff); + } // end of DefineAM + +/***********************************************************************/ +/* GetTable: makes a new TDB of the proper type. */ +/***********************************************************************/ +PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m) + { + if (Catfunc != FNC_COL) { + PTDB tdbp; + PTDBOCCUR tocp = new(g) TDBOCCUR(this); + + // Check that the source table is available + if (!tocp || !(tdbp = tocp->GetSubTable(g, Tablep))) + return NULL; + + // Set Tdbp now + tocp->SetTdbp((PTDBASE)tdbp); + + if (tocp->MakeColumnList(g) < 0) + return NULL; + + return tocp; + } else + return new(g) TDBTBC(this); + + } // end of GetTable + +/* ------------------------------------------------------------------- */ + +/***********************************************************************/ +/* Implementation of the TDBOCCUR class. */ +/***********************************************************************/ +TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp) + { +//Tdbp = NULL; // Source table + Tabname = tdp->Tablep->GetName(); // Name of source table + Colist = tdp->Colist; // List of source columns + Xcolumn = tdp->Xcol; // Occur column name + Rcolumn = tdp->Rcol; // Rank column name + Xcolp = NULL; // To the OCCURCOL column + Col = NULL; // To source column blocks array + Mult = -1; // Multiplication factor + N = 0; // The current table index + M = 0; // The occurence rank + RowFlag = 0; // 0: Ok, 1: Same, 2: Skip + } // end of TDBOCCUR constructor + +/***********************************************************************/ +/* Allocate OCCUR/SRC column description block. */ +/***********************************************************************/ +PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) + { + PCOL colp = NULL; + + if (!stricmp(cdp->GetName(), Rcolumn)) { + // Allocate a RANK column + colp = new(g) RANKCOL(cdp, this, n); + } else if (!stricmp(cdp->GetName(), Xcolumn)) { + // Allocate the OCCUR column + colp = Xcolp = new(g) OCCURCOL(cdp, this, n); + } else { + colp = new(g) PRXCOL(cdp, this, cprec, n); + + if (((PPRXCOL)colp)->Init(g)) + return NULL; + + return colp; + } //endif name + + if (cprec) { + colp->SetNext(cprec->GetNext()); + cprec->SetNext(colp); + } else { + colp->SetNext(Columns); + Columns = colp; + } // endif cprec + + return colp; + } // end of MakeCol + +/***********************************************************************/ +/* Allocate OCCUR column description block. */ +/***********************************************************************/ +int TDBOCCUR::MakeColumnList(PGLOBAL g) + { + if (Mult < 0) { + char *p, *pn; + int i; + int n = 0; + + // Count the number of columns and change separator into null char + for (pn = Colist; ; pn += (strlen(pn) + 1)) + if ((p = strchr(pn, ';'))) { + *p++ = '\0'; + n++; + } else { + if (*pn) + n++; + + break; + } // endif p + + Col = (PCOL*)PlugSubAlloc(g, NULL, n * sizeof(PCOL)); + + for (i = 0, pn = Colist; i < n; i++, pn += (strlen(pn) + 1)) { + if (!(Col[i] = Tdbp->ColDB(g, pn, 0))) { + // Column not found in table + sprintf(g->Message, MSG(COL_ISNOT_TABLE), pn, Tabname); + return -1; + } // endif Col + + if (Col[i]->InitValue(g)) { + strcpy(g->Message, "OCCUR InitValue failed"); + return -1; + } // endif InitValue + + } // endfor i + + // OCCUR column name defaults to the name of the list first column + if (!Xcolumn) + Xcolumn = Colist; + + Mult = n; + } // endif Mult + + return Mult; + } // end of MakeColumnList + +/***********************************************************************/ +/* OCCUR GetMaxSize: returns the maximum number of rows in the table. */ +/***********************************************************************/ +int TDBOCCUR::GetMaxSize(PGLOBAL g) + { + if (MaxSize < 0) { +// Mult = MakeColumnList(g); + MaxSize = Mult * Tdbp->GetMaxSize(g); + } // endif MaxSize + + return MaxSize; + } // end of GetMaxSize + +/***********************************************************************/ +/* In this sample, ROWID will be the (virtual) row number, */ +/* while ROWNUM will be the occurence rank in the multiple column. */ +/***********************************************************************/ +int TDBOCCUR::RowNumber(PGLOBAL g, bool b) + { + return (b) ? M : N; + } // end of RowNumber + +/***********************************************************************/ +/* OCCUR Access Method opening routine. */ +/***********************************************************************/ +bool TDBOCCUR::OpenDB(PGLOBAL g) + { + if (Use == USE_OPEN) { + /*******************************************************************/ + /* Table already open, just replace it at its beginning. */ + /*******************************************************************/ + N = M = 0; + RowFlag = 0; + + if (Xcolp) + Xcolp->Xreset(); + + return Tdbp->OpenDB(g); + } // endif use + + /*********************************************************************/ + /* Do it here if not done yet. */ + /*********************************************************************/ +// if (MakeColumnList(g) < 0) +// return TRUE; + + if (Mode != MODE_READ) { + /*******************************************************************/ + /* Currently OCCUR tables cannot be modified. */ + /*******************************************************************/ + strcpy(g->Message, "OCCUR tables are read only"); + return TRUE; + } // endif Mode + +#if 0 + /*********************************************************************/ + /* Be sure OCCUR column exist. */ + /*********************************************************************/ + if (!Xcolp) { + if (!(Xcolp = (POCCURCOL)ColDB(g, Xcolumn, 0))) { + sprintf(g->Message, "OCCUR column %s definition error", Xcolumn); + return TRUE; + } else if (Xcolp->InitValue(g)) { + strcpy(g->Message, "OCCUR InitValue failed"); + return TRUE; + } // endif's Xcolp + + } // endif Xcolp +#endif // 0 + + if (Xcolp) + // Lock this column so it is evaluated by its table only + Xcolp->AddStatus(BUF_READ); + + if (To_Key_Col || To_Kindex) { + /*******************************************************************/ + /* Direct access of OCCUR tables is not implemented yet. */ + /*******************************************************************/ + strcpy(g->Message, "No direct access to OCCUR tables"); + return TRUE; + } // endif To_Key_Col + + /*********************************************************************/ + /* Do open the source table. */ + /*********************************************************************/ + return Tdbp->OpenDB(g); + } // end of OpenDB + +/***********************************************************************/ +/* Data Base read routine for OCCUR access method. */ +/***********************************************************************/ +int TDBOCCUR::ReadDB(PGLOBAL g) + { + int rc = RC_OK; + + /*********************************************************************/ + /* Now start the multi reading process. */ + /*********************************************************************/ + do { + if (RowFlag != 1) + if ((rc = Tdbp->ReadDB(g)) != RC_OK) + break; + + if (Xcolp) { + RowFlag = 0; + Xcolp->ReadColumn(g); + M = Xcolp->GetI(); + } // endif Xcolp + + } while (RowFlag == 2); + + N++; + return rc; + } // end of ReadDB + +// ------------------------ OCCURCOL functions ---------------------------- + +/***********************************************************************/ +/* OCCURCOL public constructor. */ +/***********************************************************************/ +OCCURCOL::OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n) + : COLBLK(cdp, tdbp, n) + { + // Set additional OCCUR access method information for column. + I = 0; + } // end of OCCURCOL constructor + +/***********************************************************************/ +/* ReadColumn: what this routine does is to access the columns of */ +/* list, extract their value and convert it to buffer type. */ +/***********************************************************************/ +void OCCURCOL::ReadColumn(PGLOBAL g) + { + PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb; + PCOL *col = tdbp->Col; + + for (; I < tdbp->Mult; I++) { + col[I]->ReadColumn(g); + + if (Nullable || !col[I]->GetValue()->IsZero()) + break; + + } // endfor I + + if (I == tdbp->Mult) { + // No more values, go to next source row + tdbp->RowFlag = 2; + I = 0; + return; + } // endif I + + // Set the OCCUR column value from the Ith source column value + Value->SetValue_pval(col[I++]->GetValue()); + tdbp->RowFlag = 1; + } // end of ReadColumn + + +// ------------------------ RANKCOL functions --------------------------- + +/***********************************************************************/ +/* ReadColumn: what this routine does is to access the Mth columns of */ +/* list, extract its name and set to it the rank column value. */ +/***********************************************************************/ +void RANKCOL::ReadColumn(PGLOBAL g) + { + PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb; + PCOL *col = tdbp->Col; + + // Set the RANK column value from the Mth source column name + if (tdbp->M) + Value->SetValue_psz(col[tdbp->M - 1]->GetName()); + else { + Value->Reset(); + + if (Nullable) + Value->SetNull(true); + + } // endelse + + } // end of ReadColumn diff --git a/storage/connect/taboccur.h b/storage/connect/taboccur.h new file mode 100644 index 00000000000..0cfabf87793 --- /dev/null +++ b/storage/connect/taboccur.h @@ -0,0 +1,145 @@ +// TABOCCUR.H Olivier Bertrand 2013 +// Defines the OCCUR tables + +#include "tabutil.h" + +#define TYPE_AM_OCCUR (AMT)128 + +typedef class OCCURDEF *POCCURDEF; +typedef class TDBOCCUR *PTDBOCCUR; +typedef class OCCURCOL *POCCURCOL; +typedef class RANKCOL *PRANKCOL; +typedef class SRTCOL *PSRTCOL; + +/* -------------------------- OCCUR classes -------------------------- */ + +/***********************************************************************/ +/* OCCUR: OEM table that provides a view of a source table where the */ +/* contain of several columns of the source table is placed in only */ +/* one column, the OCCUR column, this resulting into several rows. */ +/***********************************************************************/ + +/***********************************************************************/ +/* OCCUR table. */ +/***********************************************************************/ +class OCCURDEF : public PRXDEF { /* Logical table description */ + friend class TDBOCCUR; + public: + // Constructor + OCCURDEF(void) {Pseudo = 3; Colist = Xcol = NULL;} + + // Implementation + virtual const char *GetType(void) {return "OCCUR";} + + // Methods + virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); + virtual PTDB GetTable(PGLOBAL g, MODE m); + + protected: + // Members +//char *Tabname; /* The source table name */ + char *Colist; /* The source column list */ + char *Xcol; /* The multiple occurence column */ + char *Rcol; /* The rank column */ + }; // end of OCCURDEF + +/***********************************************************************/ +/* This is the class declaration for the OCCUR table. */ +/***********************************************************************/ +class TDBOCCUR : public TDBPRX { + friend class OCCURCOL; + friend class RANKCOL; + friend class SRTCOL; + public: + // Constructor + TDBOCCUR(POCCURDEF tdp); + + // Implementation + virtual AMT GetAmType(void) {return TYPE_AM_OCCUR;} + void SetTdbp(PTDBASE tdbp) {Tdbp = tdbp;} + + // Methods +//virtual int GetRecpos(void) {return N;} + virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} + virtual int RowNumber(PGLOBAL g, bool b = FALSE); + PTDB GetSourceTable(PGLOBAL g); + int MakeColumnList(PGLOBAL g); + + // Database routines +//virtual PCOL ColDB(PGLOBAL g, PSZ colname, int num); + virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); + virtual int GetMaxSize(PGLOBAL g); + virtual bool OpenDB(PGLOBAL g); + virtual int ReadDB(PGLOBAL g); + + protected: + // Members +//PTDBASE Tdbp; // To the source table or view + LPCSTR Tabname; // Name of source table + char *Colist; // Source column list + char *Xcolumn; // Occurence column name + char *Rcolumn; // Rank column name + POCCURCOL Xcolp; // To the OCCURCOL column + PCOL *Col; // To source multiple columns + int Mult; // Multiplication factor + int N; // The current table index + int M; // The occurence rank + BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip + }; // end of class TDBOCCUR + +/***********************************************************************/ +/* Class OCCURCOL: for the multiple occurence column. */ +/***********************************************************************/ +class OCCURCOL : public COLBLK { + public: + // Constructors + OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n); +//OCCURCOL(OCCURCOL *colp, PTDB tdbp); // Constructor used in copy process + + // Implementation + virtual int GetAmType(void) {return TYPE_AM_OCCUR;} + int GetI(void) {return I;} + + // Methods + virtual void Reset(void) {} // Evaluated only by TDBOCCUR + virtual void ReadColumn(PGLOBAL g); + void Xreset(void) {I = 0;}; + + protected: + // Default constructor not to be used + OCCURCOL(void) {} + + // Members + int I; + }; // end of class OCCURCOL + +/***********************************************************************/ +/* Class RANKCOL: for the multiple occurence column ranking. */ +/***********************************************************************/ +class RANKCOL : public COLBLK { + public: + // Constructors + RANKCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n) : COLBLK(cdp, tdbp, n) {} +//RANKCOL(RANKCOL *colp, PTDB tdbp); // Constructor used in copy process + + // Implementation + virtual int GetAmType(void) {return TYPE_AM_OCCUR;} + + // Methods + virtual void ReadColumn(PGLOBAL g); + + protected: + // Default constructor not to be used + RANKCOL(void) {} + + // Members + }; // end of class RANKCOL + +/***********************************************************************/ +/* Definition of class XCOLDEF. */ +/* This class purpose is just to access COLDEF protected items! */ +/***********************************************************************/ +class XCOLDEF: public COLDEF { + friend class TDBOCCUR; + }; // end of class XCOLDEF + diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index b194da3fc09..c1286785d73 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -1,7 +1,7 @@ /************* TabTbl C++ Program Source Code File (.CPP) **************/ /* PROGRAM NAME: TABTBL */ /* ------------- */ -/* Version 1.4 */ +/* Version 1.5 */ /* */ /* COPYRIGHT: */ /* ---------- */ @@ -70,7 +70,7 @@ #include "filamtxt.h" #include "tabcol.h" #include "tabdos.h" // TDBDOS and DOSCOL class dcls -#include "tabtbl.h" // TDBTBL and TBLCOL classes dcls +#include "tabtbl.h" #if defined(MYSQL_SUPPORT) #include "tabmysql.h" #endif // MYSQL_SUPPORT @@ -86,7 +86,7 @@ extern "C" int trace; /**************************************************************************/ TBLDEF::TBLDEF(void) { - To_Tables = NULL; +//To_Tables = NULL; Ntables = 0; Pseudo = 3; } // end of TBLDEF constructor @@ -100,18 +100,18 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Desc = "Table list table"; tablist = Cat->GetStringCatInfo(g, "Tablist", ""); - dbname = Cat->GetStringCatInfo(g, "Database", NULL); + dbname = Cat->GetStringCatInfo(g, "Dbname", "*"); Ntables = 0; if (*tablist) { - char *p, *pn, *pdb; - PTBL *ptbl = &To_Tables, tbl; + char *p, *pn, *pdb; + PTABLE tbl; for (pdb = tablist; ;) { if ((p = strchr(pdb, ','))) *p = 0; - // Analyze the table name, it has the format: + // Analyze the table name, it may have the format: // [dbname.]tabname if ((pn = strchr(pdb, '.'))) { *pn++ = 0; @@ -121,17 +121,18 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) } // endif p // Allocate the TBLIST block for that table - tbl = (PTBL)PlugSubAlloc(g, NULL, sizeof(TBLIST)); - tbl->Next = NULL; - tbl->Name = pn; - tbl->DB = pdb; + tbl = new(g) XTAB(pn); + tbl->SetQualifier(pdb); if (trace) - htrc("TBL: Name=%s db=%s\n", tbl->Name, SVP(tbl->DB)); + htrc("TBL: Name=%s db=%s\n", tbl->GetName(), tbl->GetQualifier()); // Link the blocks - *ptbl = tbl; - ptbl = &tbl->Next; + if (Tablep) + Tablep->Link(tbl); + else + Tablep = tbl; + Ntables++; if (p) @@ -153,15 +154,11 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ PTDB TBLDEF::GetTable(PGLOBAL g, MODE m) { - PTDB tdbp; + if (Catfunc == FNC_COL) + return new(g) TDBTBC(this); + else + return new(g) TDBTBL(this); - /*********************************************************************/ - /* Allocate a TDB of the proper type. */ - /* Column blocks will be allocated only when needed. */ - /*********************************************************************/ - tdbp = new(g) TDBTBL(this); - - return tdbp; } // end of GetTable /* ------------------------- Class TDBTBL ---------------------------- */ @@ -169,11 +166,11 @@ PTDB TBLDEF::GetTable(PGLOBAL g, MODE m) /***********************************************************************/ /* TDBTBL constructors. */ /***********************************************************************/ -TDBTBL::TDBTBL(PTBLDEF tdp) : TDBASE(tdp) +TDBTBL::TDBTBL(PTBLDEF tdp) : TDBPRX(tdp) { Tablist = NULL; CurTable = NULL; - Tdbp = NULL; +//Tdbp = NULL; Accept = tdp->Accept; Maxerr = tdp->Maxerr; Nbf = 0; @@ -188,7 +185,7 @@ TDBTBL::TDBTBL(PTBLDEF tdp) : TDBASE(tdp) /***********************************************************************/ PCOL TDBTBL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) { - return new(g) TBLCOL(cdp, this, cprec, n); + return new(g) PRXCOL(cdp, this, cprec, n); } // end of MakeCol /***********************************************************************/ @@ -212,13 +209,14 @@ PCOL TDBTBL::InsertSpecialColumn(PGLOBAL g, PCOL scp) return colp; } // end of InsertSpecialColumn +#if 0 /***********************************************************************/ /* Get the PTDB of a table of the list. */ /***********************************************************************/ PTDB TDBTBL::GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp) { - char *db, key[256]; - uint k; +//char *db; + bool mysql; PTDB tdbp = NULL; TABLE_SHARE *s; PCATLG cat = To_Def->GetCat(); @@ -228,54 +226,47 @@ PTDB TDBTBL::GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp) if (!thd) return NULL; // Should not happen anymore - if (tblp->DB) - db = tblp->DB; - else - db = (char*)hc->GetDBName(NULL); +//if (tblp->DB) +// db = tblp->DB; +//else +// db = (char*)hc->GetDBName(NULL); - k = sprintf(key, "%s", db) + 1; - k += sprintf(key + k, "%s", tblp->Name); - key[++k] = 0; +//if (!(s = GetTableShare(g, thd, db, tblp->Name, mysql))) + if (!(s = GetTableShare(g, thd, tblp->DB, tblp->Name, mysql))) + return NULL; - if (!(s = alloc_table_share(db, tblp->Name, key, ++k))) { - strcpy(g->Message, "Error allocating share\n"); - return NULL; - } // endif s - - if (!open_table_def(thd, s)) { - if (plugin_data(s->db_plugin, handlerton*) != connect_hton) { + if (mysql) { #if defined(MYSQL_SUPPORT) - // Access sub-table via MySQL API - if (!(tdbp= cat->GetTable(g, tabp, MODE_READ, "MYSQL"))) { - sprintf(g->Message, "Cannot access %s.%s", db, tblp->Name); - return NULL; - } // endif Define + // Access sub-table via MySQL API + if (!(tdbp= cat->GetTable(g, tabp, MODE_READ, "MYSQL"))) { + sprintf(g->Message, "Cannot access %s.%s", tblp->DB, tblp->Name); + goto err; + } // endif Define - if (tabp->GetQualifier()) - ((PTDBMY)tdbp)->SetDatabase(tabp->GetQualifier()); + if (tabp->GetQualifier()) + ((PTDBMY)tdbp)->SetDatabase(tabp->GetQualifier()); #else // !MYSQL_SUPPORT - sprintf(g->Message, "%s.%s is not a CONNECT table", - db, tblp->Name); - return NULL; + sprintf(g->Message, "%s.%s is not a CONNECT table", + db, tblp->Name); + goto err; #endif // MYSQL_SUPPORT - } else { - // Sub-table is a CONNECT table - hc->tshp = s; - tdbp = cat->GetTable(g, tabp); - hc->tshp = NULL; - } // endif plugin - - } else - sprintf(g->Message, "Error %d opening share\n", s->error); + } else { + // Sub-table is a CONNECT table + hc->tshp = s; + tdbp = cat->GetTable(g, tabp); + hc->tshp = NULL; + } // endif plugin if (trace && tdbp) htrc("Subtable %s in %s\n", tblp->Name, SVP(((PTDBASE)tdbp)->GetDef()->GetDB())); - + + err: free_table_share(s); return tdbp; } // end of GetSubTable +#endif // 0 /***********************************************************************/ /* Initializes the table table list. */ @@ -284,28 +275,25 @@ bool TDBTBL::InitTableList(PGLOBAL g) { char *colname; int n, colpos; - PTBL tblp; - PTABLE tabp; + PTABLE tp, tabp; PTDB tdbp; PCOL colp; PTBLDEF tdp = (PTBLDEF)To_Def; // PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath()); - for (n = 0, tblp = tdp->GetTables(); tblp; tblp = tblp->Next) { - if (TestFil(g, To_Filter, tblp)) { - // Table or named view - tabp = new(g) XTAB(tblp->Name); - tabp->SetQualifier(tblp->DB); + for (n = 0, tp = tdp->Tablep; tp; tp = tp->GetNext()) { + if (TestFil(g, To_Filter, tp)) { + tabp = new(g) XTAB(tp); // Get the table description block of this table - if (!(tdbp = GetSubTable(g, tblp, tabp))) { + if (!(tdbp = GetSubTable(g, tabp))) { if (++Nbf > Maxerr) return TRUE; // Error return else continue; // Skip this table - } // endif tdbp + } // endif tdbp // We must allocate subtable columns before GetMaxSize is called // because some (PLG, ODBC?) need to have their columns attached. @@ -313,7 +301,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) for (PCOL cp = Columns; cp; cp = cp->GetNext()) if (!cp->IsSpecial()) { colname = cp->GetName(); - colpos = ((PTBLCOL)cp)->Colnum; + colpos = ((PPRXCOL)cp)->Colnum; // We try first to get the column by name if (!(colp = tdbp->ColDB(g, colname, 0)) && colpos) @@ -328,7 +316,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) return TRUE; // Error return } // endif !Accept - } else // this is needed in particular by PLG tables + } else // this is needed by some tables (which?) colp->SetColUse(cp->GetColUse()); } // endif !special @@ -351,7 +339,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) /***********************************************************************/ /* Test the tablename against the pseudo "local" filter. */ /***********************************************************************/ -bool TDBTBL::TestFil(PGLOBAL g, PFIL filp, PTBL tblp) +bool TDBTBL::TestFil(PGLOBAL g, PFIL filp, PTABLE tabp) { char *fil, op[8], tn[NAME_LEN]; bool neg; @@ -374,7 +362,7 @@ bool TDBTBL::TestFil(PGLOBAL g, PFIL filp, PTBL tblp) if (sscanf(fil, "TABID = '%[^']'", tn) != 1) return TRUE; // ignore invalid filter - return !stricmp(tn, tblp->Name); + return !stricmp(tn, tabp->GetName()); } else if (!strcmp(op, "IN")) { char *p, *tnl = (char*)PlugSubAlloc(g, NULL, strlen(fil) - 10); int n; @@ -393,7 +381,7 @@ bool TDBTBL::TestFil(PGLOBAL g, PFIL filp, PTBL tblp) if (sscanf(tnl, "'%[^']'", tn) != 1) return TRUE; // ignore invalid filter - else if (!stricmp(tn, tblp->Name)) + else if (!stricmp(tn, tabp->GetName())) return !neg; // Found tnl = p; @@ -405,19 +393,19 @@ bool TDBTBL::TestFil(PGLOBAL g, PFIL filp, PTBL tblp) return TRUE; // invalid operator } // end of TestFil +#if 0 /***********************************************************************/ /* TBL GetProgMax: get the max value for progress information. */ /***********************************************************************/ int TDBTBL::GetProgMax(PGLOBAL g) { - PTABLE tblp; - int n, pmx = 0; + int n, pmx = 0; if (!Tablist && InitTableList(g)) return -1; - for (tblp = Tablist; tblp; tblp = tblp->GetNext()) - if ((n = tblp->GetTo_Tdb()->GetProgMax(g)) > 0) + for (PTABLE tabp = Tablist; tabp; tblp = tabp->GetNext()) + if ((n = tabp->GetTo_Tdb()->GetProgMax(g)) > 0) pmx += n; return pmx; @@ -431,7 +419,6 @@ int TDBTBL::GetProgCur(void) return Crp + Tdbp->GetProgCur(); } // end of GetProgCur -#if 0 /***********************************************************************/ /* TBL Cardinality: returns table cardinality in number of rows. */ /* This function can be called with a null argument to test the */ @@ -470,7 +457,6 @@ int TDBTBL::Cardinality(PGLOBAL g) int TDBTBL::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { - PTABLE tblp; int mxsz; if (!Tablist && InitTableList(g)) @@ -482,8 +468,8 @@ int TDBTBL::GetMaxSize(PGLOBAL g) // } else MaxSize = 0; - for (tblp = Tablist; tblp; tblp = tblp->GetNext()) { - if ((mxsz = tblp->GetTo_Tdb()->GetMaxSize(g)) < 0) { + for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) { + if ((mxsz = tabp->GetTo_Tdb()->GetMaxSize(g)) < 0) { MaxSize = -1; return mxsz; } // endif mxsz @@ -505,8 +491,8 @@ void TDBTBL::ResetDB(void) if (colp->GetAmType() == TYPE_AM_TABID) colp->COLBLK::Reset(); - for (PTABLE tblp = Tablist; tblp; tblp = tblp->GetNext()) - ((PTDBASE)tblp->GetTo_Tdb())->ResetDB(); + for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) + ((PTDBASE)tabp->GetTo_Tdb())->ResetDB(); Tdbp = (PTDBASE)Tablist->GetTo_Tdb(); Crp = 0; @@ -573,7 +559,7 @@ bool TDBTBL::OpenDB(PGLOBAL g) for (PCOL cp = Columns; cp; cp = cp->GetNext()) if (cp->GetAmType() == TYPE_AM_TABID) cp->COLBLK::Reset(); - else if (((PTBLCOL)cp)->Init(g)) + else if (((PPRXCOL)cp)->Init(g)) return TRUE; if (trace) @@ -627,7 +613,7 @@ int TDBTBL::ReadDB(PGLOBAL g) for (PCOL cp = Columns; cp; cp = cp->GetNext()) if (cp->GetAmType() == TYPE_AM_TABID) cp->COLBLK::Reset(); - else if (((PTBLCOL)cp)->Init(g)) + else if (((PPRXCOL)cp)->Init(g)) return RC_FX; if (trace) @@ -648,6 +634,7 @@ int TDBTBL::ReadDB(PGLOBAL g) return rc; } // end of ReadDB +#if 0 /***********************************************************************/ /* Data Base write routine for MUL access method. */ /***********************************************************************/ @@ -675,9 +662,11 @@ void TDBTBL::CloseDB(PGLOBAL g) Tdbp->CloseDB(g); } // end of CloseDB +#endif // 0 /* ---------------------------- TBLCOL ------------------------------- */ +#if 0 /***********************************************************************/ /* TBLCOL public constructor. */ /***********************************************************************/ @@ -705,7 +694,6 @@ TBLCOL::TBLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) } // end of TBLCOL constructor -#if 0 /***********************************************************************/ /* TBLCOL public constructor. */ /***********************************************************************/ @@ -733,7 +721,6 @@ TBLCOL::TBLCOL(TBLCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp) To_Val = col1->To_Val; Pseudo = col1->Pseudo; } // end of TBLCOL copy constructor -#endif /***********************************************************************/ /* TBLCOL initialization routine. */ @@ -783,6 +770,7 @@ void TBLCOL::ReadColumn(PGLOBAL g) } // endif Colp } // end of ReadColumn +#endif // 0 /* ---------------------------- TBTBLK ------------------------------- */ diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index 07a20bb2867..d241b00743e 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -1,41 +1,30 @@ /*************** TabTbl H Declares Source Code File (.H) ***************/ /* Name: TABTBL.H Version 1.2 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2008-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 2008-2013 */ /* */ /* This file contains the TDBTBL classes declares. */ /***********************************************************************/ -//#include "osutil.h" #include "block.h" #include "colblk.h" +#include "tabutil.h" typedef class TBLDEF *PTBLDEF; typedef class TDBTBL *PTDBTBL; -typedef class TBLCOL *PTBLCOL; - -/***********************************************************************/ -/* Defines the structure used for multiple tables. */ -/***********************************************************************/ -typedef struct _tablist *PTBL; - -typedef struct _tablist { - PTBL Next; - char *Name; - char *DB; - } TBLIST; /***********************************************************************/ /* TBL table. */ /***********************************************************************/ -class DllExport TBLDEF : public TABDEF { /* Logical table description */ +class DllExport TBLDEF : public PRXDEF { /* Logical table description */ friend class TDBTBL; + friend class TDBTBC; public: // Constructor TBLDEF(void); // Implementation virtual const char *GetType(void) {return "TBL";} - PTBL GetTables(void) {return To_Tables;} +//PTABLE GetTables(void) {return Tablep;} //int GetNtables(void) {return Ntables;} // Methods @@ -44,7 +33,7 @@ class DllExport TBLDEF : public TABDEF { /* Logical table description */ protected: // Members - PTBL To_Tables; /* To the list of tables */ +//PTABLE To_Tables; /* To the list of tables */ bool Accept; /* TRUE if bad tables are accepted */ int Maxerr; /* Maximum number of bad tables */ int Ntables; /* Number of tables */ @@ -53,50 +42,46 @@ class DllExport TBLDEF : public TABDEF { /* Logical table description */ /***********************************************************************/ /* This is the TBL Access Method class declaration. */ /***********************************************************************/ -class DllExport TDBTBL : public TDBASE { - friend class TBLCOL; +class DllExport TDBTBL : public TDBPRX { +//friend class TBLCOL; friend class TBTBLK; friend class TDBPLG; public: // Constructor TDBTBL(PTBLDEF tdp = NULL); -//TDBTBL(PTDBTBL tdbp); // Implementation virtual AMT GetAmType(void) {return TYPE_AM_TBL;} -//virtual PTDB Duplicate(PGLOBAL g) -// {return (PTDB)new(g) TDBTBL(this);} // Methods virtual void ResetDB(void); //virtual PTABLE GetTablist(void) {return (PSZ)Tablist;} -//virtual PTDB CopyOne(PTABS t); virtual int GetRecpos(void) {return Rows;} virtual int GetBadLines(void) {return (int)Nbf;} // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int GetMaxSize(PGLOBAL g); - virtual int GetProgMax(PGLOBAL g); - virtual int GetProgCur(void); +//virtual int GetProgMax(PGLOBAL g); +//virtual int GetProgCur(void); virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g); - virtual int WriteDB(PGLOBAL g); - virtual int DeleteDB(PGLOBAL g, int irc); - virtual void CloseDB(PGLOBAL g); +//virtual int WriteDB(PGLOBAL g); +//virtual int DeleteDB(PGLOBAL g, int irc); +//virtual void CloseDB(PGLOBAL g); protected: // Internal functions - PTDB GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp); +//PTDB GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp); bool InitTableList(PGLOBAL g); - bool TestFil(PGLOBAL g, PFIL filp, PTBL tblp); + bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp); // Members PTABLE Tablist; // Points to the table list PTABLE CurTable; // Points to the current table - PTDBASE Tdbp; // Current table PTDB +//PTDBASE Tdbp; // Current table PTDB bool Accept; // TRUE if bad tables are accepted int Maxerr; // Maximum number of bad tables int Nbf; // Number of bad connections @@ -104,6 +89,7 @@ class DllExport TDBTBL : public TDBASE { int Crp; // Used for CurPos }; // end of class TDBTBL +#if 0 /***********************************************************************/ /* Class TBLCOL: TBL access method column descriptor. */ /* This A.M. is used for TBL tables. */ @@ -136,6 +122,7 @@ class DllExport TBLCOL : public COLBLK { bool Pseudo; // TRUE for special columns int Colnum; // Used when retrieving columns by number }; // end of class TBLCOL +#endif // 0 /***********************************************************************/ /* Class TBTBLK: TDBPLG TABID special column descriptor. */ diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp new file mode 100644 index 00000000000..5706ca7aeba --- /dev/null +++ b/storage/connect/tabutil.cpp @@ -0,0 +1,596 @@ +/************* Tabutil cpp Declares Source Code File (.H) **************/ +/* Name: TABUTIL.CPP Version 1.0 */ +/* */ +/* (C) Copyright to the author Olivier BERTRAND 2013 */ +/* */ +/* Utility function used by TBL and PRX tables. */ +/***********************************************************************/ + +/***********************************************************************/ +/* Include relevant section of system dependant header files. */ +/***********************************************************************/ +#include "my_global.h" +#include "sql_class.h" +#include "table.h" +#include "field.h" +#if defined(WIN32) +#include +#include +#if defined(__BORLANDC__) +#define __MFC_COMPAT__ // To define min/max as macro +#endif +//#include +#else +#if defined(UNIX) +#include +#include +#include +#include +#include +#include "osutil.h" +#else +//#include +#endif +//#include +#endif + +/***********************************************************************/ +/* Include application header files: */ +/***********************************************************************/ +#include "table.h" // MySQL table definitions +#include "global.h" +#include "plgdbsem.h" +#include "plgcnx.h" // For DB types +#include "myutil.h" +#include "mycat.h" +#include "valblk.h" +#include "resource.h" +#include "reldef.h" +#include "xtable.h" +#if defined(MYSQL_SUPPORT) +#include "tabmysql.h" +#endif // MYSQL_SUPPORT +#include "tabcol.h" +#include "tabutil.h" +#include "ha_connect.h" + +extern "C" int trace; + +/************************************************************************/ +/* GetTableShare: allocates and open a table share. */ +/************************************************************************/ +TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, + const char *name, bool& mysql) +{ + char key[256]; + uint k; +//TABLE_LIST table_list; + TABLE_SHARE *s; + +//table_list.init_one_table(db, strlen(db), name, strlen(name), +// NULL, TL_IGNORE); + k = sprintf(key, "%s", db); + k += sprintf(key + ++k, "%s", name); + key[++k] = 0; + + if (!(s = alloc_table_share(db, name, key, ++k))) { + strcpy(g->Message, "Error allocating share\n"); + return NULL; + } // endif s + +// 1 2 4 8 +//flags = GTS_TABLE | GTS_VIEW | GTS_NOLOCK | GTS_FORCE_DISCOVERY; + + if (!open_table_def(thd, s, GTS_TABLE)) { +#ifdef DBUG_OFF + if (stricmp(s->db_plugin->name.str, "connect")) { +#else + if (stricmp((*s->db_plugin)->name.str, "connect")) { +#endif +#if defined(MYSQL_SUPPORT) + mysql = true; +#else // !MYSQL_SUPPORT + sprintf(g->Message, "%s.%s is not a CONNECT table", db, name); + return NULL; +#endif // MYSQL_SUPPORT + } else + mysql = false; + + } else { + sprintf(g->Message, "Error %d opening share\n", s->error); + free_table_share(s); + return NULL; + } // endif open_table_def + + return s; +} // end of GetTableShare + +/************************************************************************/ +/* TabColumns: constructs the result blocks containing all the columns */ +/* of the object table that will be retrieved by GetData commands. */ +/* key = TRUE when called from Create Table to get key informations. */ +/************************************************************************/ +PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, + const char *name, bool info) + { + static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR, DB_INT, + DB_INT, DB_SHORT, DB_SHORT, DB_SHORT, + DB_CHAR, DB_CHAR, DB_CHAR}; + static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, + TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, + TYPE_STRING, TYPE_STRING, TYPE_STRING}; + static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, + FLD_LENGTH, FLD_SCALE, FLD_RADIX, FLD_NULL, + FLD_REM, FLD_NO, FLD_CHARSET}; + static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 256, 32, 32}; + char *fld, *fmt; + int i, n, ncol = sizeof(dbtype) / sizeof(int); + int len, type, prec; + bool mysql; + TABLE_SHARE *s; + Field* *field; + Field *fp; + PQRYRES qrp; + PCOLRES crp; + + if (!info) { + if (!(s = GetTableShare(g, thd, db, name, mysql))) + return NULL; + else + n = s->fieldnames.count; + + } else { + n = 0; + length[0] = 128; + } // endif info + + /**********************************************************************/ + /* Allocate the structures used to refer to the result set. */ + /**********************************************************************/ + qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3, + dbtype, buftyp, fldtyp, length, true, true); + + // Some columns must be renamed + for (i = 0, crp = qrp->Colresp; crp; crp = crp->Next) + switch (++i) { + case 10: crp->Name = "Date_fmt"; break; + case 11: crp->Name = "Collation"; break; + } // endswitch i + + if (info) + return qrp; + + /**********************************************************************/ + /* Now get the results into blocks. */ + /**********************************************************************/ + for (i = 0, field= s->field; *field; i++, field++) { + fp= *field; + + // Get column name + crp = qrp->Colresp; // Column_Name + fld = (char *)fp->field_name; + crp->Kdata->SetValue(fld, i); + + if ((type = MYSQLtoPLG(fp->type())) == TYPE_ERROR) { + sprintf(g->Message, "Unsupported column type %s", GetTypeName(type)); + qrp = NULL; + break; + } // endif type + + crp = crp->Next; // Data_Type + crp->Kdata->SetValue(type, i); + crp = crp->Next; // Type_Name + crp->Kdata->SetValue(GetTypeName(type), i); + + if (type == TYPE_DATE) { + // When creating tables we do need info about date columns + if (mysql) { + fmt = MyDateFmt(fp->type()); + len = strlen(fmt); + } else { + fmt = (char*)fp->option_struct->dateformat; + len = fp->field_length; + } // endif mysql + + } else { + fmt = NULL; + len = fp->char_length(); + } // endif type + + crp = crp->Next; // Precision + crp->Kdata->SetValue(len, i); + + crp = crp->Next; // Length + len = fp->field_length; + crp->Kdata->SetValue(len, i); + + prec = (type == TYPE_FLOAT) ? fp->decimals() : 0; + crp = crp->Next; // Scale + crp->Kdata->SetValue(prec, i); + + crp = crp->Next; // Radix + crp->Kdata->SetValue(0, i); + + crp = crp->Next; // Nullable + crp->Kdata->SetValue((fp->null_ptr != 0) ? 1 : 0, i); + + crp = crp->Next; // Remark + fld = fp->comment.str; + crp->Kdata->SetValue(fld, fp->comment.length, i); + + crp = crp->Next; // New + crp->Kdata->SetValue((fmt) ? fmt : (char*) "", i); + + crp = crp->Next; // New (charset) + fld = (char *)fp->charset()->name; + crp->Kdata->SetValue(fld, i); + + // Add this item + qrp->Nblin++; + } // endfor field + + /**********************************************************************/ + /* Return the result pointer for use by GetData routines. */ + /**********************************************************************/ + free_table_share(s); + return qrp; + } // end of TabColumns + +/* -------------- Implementation of the XCOL classes ---------------- */ + +/***********************************************************************/ +/* PRXDEF constructor. */ +/***********************************************************************/ +PRXDEF::PRXDEF(void) + { + Tablep = NULL; + Pseudo = 3; +} // end of PRXDEF constructor + +/***********************************************************************/ +/* DefineAM: define specific AM block values from XCOL file. */ +/***********************************************************************/ +bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) + { + char *pn, *db, *tab; + + db = Cat->GetStringCatInfo(g, "Dbname", "*"); + tab = Cat->GetStringCatInfo(g, "Tabname", NULL); + + // Analyze the table name, it may have the format: [dbname.]tabname + if ((pn = strchr(tab, '.'))) { + *pn++ = 0; + db = tab; + tab = pn; + } // endif pn + + Tablep = new(g) XTAB(tab); + Tablep->SetQualifier(db); + return FALSE; + } // end of DefineAM + +/***********************************************************************/ +/* GetTable: makes a new TDB of the proper type. */ +/***********************************************************************/ +PTDB PRXDEF::GetTable(PGLOBAL g, MODE mode) + { + if (Catfunc == FNC_COL) + return new(g) TDBTBC(this); + else + return new(g) TDBPRX(this); + + } // end of GetTable + +/* ------------------------------------------------------------------- */ + +/***********************************************************************/ +/* Implementation of the TDBPRX class. */ +/***********************************************************************/ +TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp) + { + Tdbp = NULL; // The object table + } // end of TDBPRX constructor + +/***********************************************************************/ +/* Get the PTDB of the sub-table. */ +/***********************************************************************/ +PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) + { + char *db, *name; + bool mysql; + PTDB tdbp = NULL; + TABLE_SHARE *s; + PCATLG cat = To_Def->GetCat(); + PHC hc = ((MYCAT*)cat)->GetHandler(); + THD *thd = (hc->GetTable())->in_use; + + db = (char*)tabp->GetQualifier(); + name = (char*)tabp->GetName(); + + if (!(s = GetTableShare(g, thd, db, name, mysql))) + return NULL; + + hc->tshp = s; + + if (mysql) { +#if defined(MYSQL_SUPPORT) + // Access sub-table via MySQL API + if (!(tdbp= cat->GetTable(g, tabp, MODE_READ, "MYSQL"))) { + sprintf(g->Message, "Cannot access %s.%s", db, name); + goto err; + } // endif Define + + if (db) + ((PTDBMY)tdbp)->SetDatabase(tabp->GetQualifier()); + +#else // !MYSQL_SUPPORT + sprintf(g->Message, "%s.%s is not a CONNECT table", + db, tblp->Name); + goto err; +#endif // MYSQL_SUPPORT + } else + // Sub-table is a CONNECT table + tdbp = cat->GetTable(g, tabp); + + hc->tshp = NULL; + + if (trace && tdbp) + htrc("Subtable %s in %s\n", + name, SVP(((PTDBASE)tdbp)->GetDef()->GetDB())); + + err: + free_table_share(s); + return tdbp; + } // end of GetSubTable + +/***********************************************************************/ +/* Initializes the table. */ +/***********************************************************************/ +bool TDBPRX::InitTable(PGLOBAL g) + { + if (!Tdbp) { + // Get the table description block of this table + if (!(Tdbp = (PTDBASE)GetSubTable(g, ((PPRXDEF)To_Def)->Tablep))) + return TRUE; + + } // endif Tdbp + + return FALSE; + } // end of InitTable + +/***********************************************************************/ +/* Allocate PRX column description block. */ +/***********************************************************************/ +PCOL TDBPRX::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) + { + return new(g) PRXCOL(cdp, this, cprec, n); + } // end of MakeCol + +/***********************************************************************/ +/* PRX GetMaxSize: returns the maximum number of rows in the table. */ +/***********************************************************************/ +int TDBPRX::GetMaxSize(PGLOBAL g) + { + if (MaxSize < 0) { + if (InitTable(g)) + return NULL; + + MaxSize = Tdbp->GetMaxSize(g); + } // endif MaxSize + + return MaxSize; + } // end of GetMaxSize + +/***********************************************************************/ +/* In this sample, ROWID will be the (virtual) row number, */ +/* while ROWNUM will be the occurence rank in the multiple column. */ +/***********************************************************************/ +int TDBPRX::RowNumber(PGLOBAL g, bool b) + { + return Tdbp->RowNumber(g, b); + } // end of RowNumber + +/***********************************************************************/ +/* XCV Access Method opening routine. */ +/***********************************************************************/ +bool TDBPRX::OpenDB(PGLOBAL g) + { + if (Use == USE_OPEN) { + /*******************************************************************/ + /* Table already open, just replace it at its beginning. */ + /*******************************************************************/ + return Tdbp->OpenDB(g); + } // endif use + + if (Mode != MODE_READ) { + /*******************************************************************/ + /* Currently XCOL tables cannot be modified. */ + /*******************************************************************/ + strcpy(g->Message, "PROXY tables are read only"); + return TRUE; + } // endif Mode + + if (InitTable(g)) + return NULL; + + /*********************************************************************/ + /* Check and initialize the subtable columns. */ + /*********************************************************************/ + for (PCOL cp = Columns; cp; cp = cp->GetNext()) + if (((PPRXCOL)cp)->Init(g)) + return TRUE; + + /*********************************************************************/ + /* Physically open the object table. */ + /*********************************************************************/ + if (Tdbp->OpenDB(g)) + return TRUE; + + return FALSE; + } // end of OpenDB + +/***********************************************************************/ +/* Data Base read routine for XCV access method. */ +/***********************************************************************/ +int TDBPRX::ReadDB(PGLOBAL g) + { + /*********************************************************************/ + /* Now start the reading process. */ + /*********************************************************************/ + return Tdbp->ReadDB(g); + } // end of ReadDB + +/***********************************************************************/ +/* WriteDB: Data Base write routine for XCV access methods. */ +/***********************************************************************/ +int TDBPRX::WriteDB(PGLOBAL g) + { + sprintf(g->Message, "%s tables are read only", To_Def->GetType()); + return RC_FX; + } // end of WriteDB + +/***********************************************************************/ +/* Data Base delete line routine for XCV access methods. */ +/***********************************************************************/ +int TDBPRX::DeleteDB(PGLOBAL g, int irc) + { + sprintf(g->Message, "Delete not enabled for %s tables", + To_Def->GetType()); + return RC_FX; + } // end of DeleteDB + +/* ---------------------------- PRXCOL ------------------------------- */ + +/***********************************************************************/ +/* PRXCOL public constructor. */ +/***********************************************************************/ +PRXCOL::PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) + : COLBLK(cdp, tdbp, i) + { + if (cprec) { + Next = cprec->GetNext(); + cprec->SetNext(this); + } else { + Next = tdbp->GetColumns(); + tdbp->SetColumns(this); + } // endif cprec + + // Set additional Dos access method information for column. + Long = cdp->GetLong(); // Useful ??? +//strcpy(F_Date, cdp->F_Date); + Colp = NULL; + To_Val = NULL; + Pseudo = FALSE; + Colnum = cdp->GetOffset(); // If columns are retrieved by number + + if (trace) + htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); + + } // end of PRXCOL constructor + +/***********************************************************************/ +/* PRXCOL initialization routine. */ +/* Look for the matching column in the object table. */ +/***********************************************************************/ +bool PRXCOL::Init(PGLOBAL g) + { + PTDBPRX tdbp = (PTDBPRX)To_Tdb; + + if (!(Colp = tdbp->Tdbp->ColDB(g, Name, 0)) && Colnum) + Colp = tdbp->Tdbp->ColDB(g, NULL, Colnum); + + if (Colp) { + Colp->InitValue(g); // May not have been done elsewhere + To_Val = Colp->GetValue(); + } else { + sprintf(g->Message, MSG(NO_MATCHING_COL), Name, tdbp->Tdbp->GetName()); + return TRUE; + } // endif Colp + + return FALSE; + } // end of Init + +/***********************************************************************/ +/* ReadColumn: */ +/***********************************************************************/ +void PRXCOL::ReadColumn(PGLOBAL g) + { + if (trace) + htrc("PRX ReadColumn: name=%s\n", Name); + + if (Colp) { + Colp->ReadColumn(g); + Value->SetValue_pval(To_Val); + + // Set null when applicable + if (Nullable) + Value->SetNull(Value->IsNull()); + + } // endif Colp + + } // end of ReadColumn + +#if 0 +/* ---------------------------TBCDEF class --------------------------- */ + +/***********************************************************************/ +/* DefineAM: define specific AM block values from CATLG table. */ +/***********************************************************************/ +bool TBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) + { + Desc = "Catalog Table"; + Database = Cat->GetStringCatInfo(g, "Database", "*"); + Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); + return FALSE; + } // end of DefineAM + +/***********************************************************************/ +/* GetTable: makes a new TDB of the proper type. */ +/***********************************************************************/ +PTDB TBCDEF::GetTable(PGLOBAL g, MODE m) + { + return new(g) TDBTBC(this); + } // end of GetTable +#endif // 0 + +/* ---------------------------TDBTBC class --------------------------- */ + +/***********************************************************************/ +/* TDBTBC class constructor. */ +/***********************************************************************/ +TDBTBC::TDBTBC(PPRXDEF tdp) : TDBCAT(tdp) + { +// Db = tdp->Database; +// Tab = tdp->Tabname; + Db = (PSZ)tdp->Tablep->GetQualifier(); + Tab = (PSZ)tdp->Tablep->GetName(); + } // end of TDBTBC constructor + +#if 0 +/***********************************************************************/ +/* TDBTBC class constructor from TBL table. */ +/***********************************************************************/ +TDBTBC::TDBTBC(PTBLDEF tdp) : TDBCAT(tdp) + { + Db = tdp->To_Tables->DB; + Tab = tdp->To_Tables->Name; + } // end of TDBTBC constructor + +/***********************************************************************/ +/* TDBTBC class constructor from PRX table. */ +/***********************************************************************/ +TDBTBC::TDBTBC(PXCLDEF tdp) : TDBCAT(tdp) + { + Db = (PSZ)tdp->Tablep->GetQualifier(); + Tab = (PSZ)tdp->Tablep->GetName(); + } // end of TDBTBC constructor +#endif // 0 + +/***********************************************************************/ +/* GetResult: Get the list the MYSQL table columns. */ +/***********************************************************************/ +PQRYRES TDBTBC::GetResult(PGLOBAL g) + { + return TabColumns(g, current_thd, Db, Tab, false); + } // end of GetResult + diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h new file mode 100644 index 00000000000..48e97bd49ec --- /dev/null +++ b/storage/connect/tabutil.h @@ -0,0 +1,181 @@ +// TABUTIL.H Olivier Bertrand 2013 +// Defines the TAB catalog tables + +#ifndef TABUTIL +#define TABUTIL 1 + +//#include "tabtbl.h" + +#define TYPE_AM_PRX (AMT)129 + +typedef class PRXDEF *PPRXDEF; +typedef class TDBPRX *PTDBPRX; +typedef class XXLCOL *PXXLCOL; +typedef class PRXCOL *PPRXCOL; +typedef class TBCDEF *PTBCDEF; +typedef class TDBTBC *PTDBTBC; +typedef class XTDBASE *PTDBX; +typedef class XCOLBLK *PCOLX; + +TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, + const char *name, bool& mysql); +PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, + const char *name, bool info); + +/***********************************************************************/ +/* This class is used to access protected members of TDBASE. */ +/***********************************************************************/ +class XTDBASE : public TDBASE { + friend class TDBXCL; + }; // end of class XCOLBLK + +/***********************************************************************/ +/* This class is used to access protected members of COLBLK. */ +/***********************************************************************/ +class XCOLBLK : public COLBLK { + friend class TDBXCL; + }; // end of class XCOLBLK + +/* -------------------------- PROXY classes -------------------------- */ + +/***********************************************************************/ +/* PROXY: table based on another table. Can be used to have a */ +/* different view on an existing table. */ +/* However, its real use is to be the base of TBL and PRX tables. */ +/***********************************************************************/ + +/***********************************************************************/ +/* PRX table. */ +/***********************************************************************/ +class DllExport PRXDEF : public TABDEF { /* Logical table description */ + friend class TDBPRX; + friend class TDBTBC; + public: + // Constructor + PRXDEF(void); + + // Implementation + virtual const char *GetType(void) {return "PRX";} + + // Methods + virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); + virtual PTDB GetTable(PGLOBAL g, MODE mode); + + protected: + // Members + PTABLE Tablep; /* The object table */ + }; // end of PRXDEF + +/***********************************************************************/ +/* This is the class declaration for the XCSV table. */ +/***********************************************************************/ +class DllExport TDBPRX : public TDBASE { +//friend class MULINDX; + friend class PRXDEF; + friend class PRXCOL; + public: + // Constructor + TDBPRX(PPRXDEF tdp); + + // Implementation + virtual AMT GetAmType(void) {return TYPE_AM_PRX;} + + // Methods + virtual int GetRecpos(void) {return Tdbp->GetRecpos();} + virtual void ResetDB(void) {Tdbp->ResetDB();} + virtual int RowNumber(PGLOBAL g, bool b = FALSE); + + // Database routines + virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); + virtual bool InitTable(PGLOBAL g); + virtual int GetMaxSize(PGLOBAL g); + virtual bool OpenDB(PGLOBAL g); + virtual int ReadDB(PGLOBAL g); + virtual int WriteDB(PGLOBAL g); + virtual int DeleteDB(PGLOBAL g, int irc); + virtual void CloseDB(PGLOBAL g) {if (Tdbp) Tdbp->CloseDB(g);} + PTDB GetSubTable(PGLOBAL g, PTABLE tabp); + + protected: + // Members + PTDBASE Tdbp; // The object table + }; // end of class TDBPRX + +/***********************************************************************/ +/* Class PRXCOL: PRX access method column descriptor. */ +/* This A.M. is used for PRX tables. */ +/***********************************************************************/ +class DllExport PRXCOL : public COLBLK { + friend class TDBPRX; + friend class TDBTBL; + public: + // Constructors + PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "PRX"); + + // Implementation + virtual int GetAmType(void) {return TYPE_AM_PRX;} + + // Methods + virtual bool IsSpecial(void) {return Pseudo;} + virtual void ReadColumn(PGLOBAL g); + bool Init(PGLOBAL g); + + protected: + // Default constructor not to be used + PRXCOL(void) {} + + // Members + PCOL Colp; // Points to matching table column + PVAL To_Val; // To the matching column value + bool Pseudo; // TRUE for special columns + int Colnum; // Used when retrieving columns by number + }; // end of class PRXCOL + +#if 0 +/***********************************************************************/ +/* TBC table. */ +/***********************************************************************/ +class TBCDEF : public TABDEF {/* Logical table description */ + friend class TDBTBC; + friend class ha_connect; + public: + // Constructor + TBCDEF(void) {Database = NULL; Tabname = NULL;} + + + // Implementation + virtual const char *GetType(void) {return "TBC";} + inline PSZ GetDatabase(void) {return Database;}; + inline PSZ GetTabname(void) {return Tabname;} + + // Methods + virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); + virtual PTDB GetTable(PGLOBAL g, MODE m); + + protected: + // Members + PSZ Database; /* Database to be used by server */ + PSZ Tabname; /* External table name */ + }; // end of TBCDEF +#endif // 0 + +/***********************************************************************/ +/* This is the class declaration for the TBC column catalog table. */ +/***********************************************************************/ +class TDBTBC : public TDBCAT { + public: + // Constructors + TDBTBC(PPRXDEF tdp); +//TDBTBC(PTBLDEF tdp); +//TDBTBC(PXCLDEF tdp); + + protected: + // Specific routines + virtual PQRYRES GetResult(PGLOBAL g); + + // Members + PSZ Db; // Database of the table + PSZ Tab; // Table name + }; // end of class TDBMCL + +#endif // TABUTIL diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp new file mode 100644 index 00000000000..337a6cefd1d --- /dev/null +++ b/storage/connect/tabxcl.cpp @@ -0,0 +1,376 @@ +/************* TabXcl CPP Declares Source Code File (.CPP) *************/ +/* Name: TABXCL.CPP Version 1.0 */ +/* */ +/* (C) Copyright to the author Olivier BERTRAND 2013 */ +/* */ +/* XCOL: Table having one column containing several values */ +/* comma separated. When creating the table, the name of the X */ +/* column is given by the Name option. */ +/* This first version has one limitation: */ +/* - The X column has the same length than in the physical file. */ +/* This tables produces as many rows for a physical row than the */ +/* number of items in the X column (eventually 0). */ +/***********************************************************************/ + +/***********************************************************************/ +/* Include relevant section of system dependant header files. */ +/***********************************************************************/ +#include "my_global.h" +#if defined(WIN32) +#include +#include +#if defined(__BORLANDC__) +#define __MFC_COMPAT__ // To define min/max as macro +#endif +//#include +#else +#if defined(UNIX) +#include +#include +#include +#include +#include +#include "osutil.h" +#else +//#include +#endif +//#include +#endif + +/***********************************************************************/ +/* Include application header files: */ +/***********************************************************************/ +#include "table.h" // MySQL table definitions +#include "global.h" +#include "plgdbsem.h" +#include "plgcnx.h" // For DB types +#include "resource.h" +#include "reldef.h" +#include "filamtxt.h" +#include "tabdos.h" +#include "tabcol.h" +#include "tabxcl.h" +#include "xtable.h" +#if defined(MYSQL_SUPPORT) +#include "tabmysql.h" +#endif // MYSQL_SUPPORT +#include "ha_connect.h" +#include "mycat.h" + +extern "C" int trace; + +/* -------------- Implementation of the XCOL classes ---------------- */ + +/***********************************************************************/ +/* XCLDEF constructor. */ +/***********************************************************************/ +XCLDEF::XCLDEF(void) + { + Pseudo = 3; + Xcol = NULL; + Sep = ','; + Mult = 10; +} // end of XCLDEF constructor + +/***********************************************************************/ +/* DefineAM: define specific AM block values from XCOL file. */ +/***********************************************************************/ +bool XCLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) + { + char buf[8]; + + Xcol = Cat->GetStringCatInfo(g, "Colname", ""); + Cat->GetCharCatInfo("Separator", ",", buf, sizeof(buf)); + Sep = (strlen(buf) == 2 && buf[0] == '\\' && buf[1] == 't') ? '\t' : *buf; + Mult = Cat->GetIntCatInfo("Mult", 10); + return PRXDEF::DefineAM(g, am, poff); + } // end of DefineAM + +/***********************************************************************/ +/* GetTable: makes a new TDB of the proper type. */ +/***********************************************************************/ +PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode) + { + if (Catfunc == FNC_COL) + return new(g) TDBTBC(this); + else + return new(g) TDBXCL(this); + + } // end of GetTable + +/* ------------------------------------------------------------------- */ + +/***********************************************************************/ +/* Implementation of the TDBXCL class. */ +/***********************************************************************/ +TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp) + { +//Tdbp = NULL; // The physical table + Xcolumn = tdp->Xcol; // CSV column name + Xcolp = NULL; // To the XCVCOL column + Mult = tdp->Mult; // Multiplication factor + N = 0; // The current table index + M = 0; // The occurence rank + RowFlag = 0; // 0: Ok, 1: Same, 2: Skip + New = TRUE; // TRUE for new line + Sep = tdp->Sep; // The Xcol separator + } // end of TDBXCL constructor + +/***********************************************************************/ +/* Initializes the table. */ +/***********************************************************************/ +bool TDBXCL::InitTable(PGLOBAL g) + { + if (!Tdbp) { + PCOLDEF cdp; + + // Get the table description block of this table + if (!(Tdbp = (PTDBASE)GetSubTable(g, ((PXCLDEF)To_Def)->Tablep))) + return TRUE; + + for (cdp = Tdbp->GetDef()->GetCols(); cdp; cdp = cdp->GetNext()) + if (!stricmp(cdp->GetName(), Xcolumn)) + break; + + if (!cdp) { + sprintf(g->Message, "%s is not a %s column", + Xcolumn, Tdbp->GetName()); + return TRUE; + } // endif cdp + + } // endif Tdbp + + return FALSE; + } // end of InitTable + +/***********************************************************************/ +/* Allocate XCL column description block. */ +/***********************************************************************/ +PCOL TDBXCL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) + { + PCOL colp; + + if (!stricmp(cdp->GetName(), Xcolumn)) { + Xcolp = new(g) XCLCOL(g, cdp, this, cprec, n); + colp = Xcolp; + } else + colp = new(g) PRXCOL(cdp, this, cprec, n); + + return colp; + } // end of MakeCol + +/***********************************************************************/ +/* XCL GetMaxSize: returns the maximum number of rows in the table. */ +/***********************************************************************/ +int TDBXCL::GetMaxSize(PGLOBAL g) + { + if (MaxSize < 0) { + if (InitTable(g)) + return NULL; + + MaxSize = Mult * Tdbp->GetMaxSize(g); + } // endif MaxSize + + return MaxSize; + } // end of GetMaxSize + +/***********************************************************************/ +/* In this sample, ROWID will be the (virtual) row number, */ +/* while ROWNUM will be the occurence rank in the multiple column. */ +/***********************************************************************/ +int TDBXCL::RowNumber(PGLOBAL g, bool b) + { + return (b) ? M : N; + } // end of RowNumber + +/***********************************************************************/ +/* XCV Access Method opening routine. */ +/***********************************************************************/ +bool TDBXCL::OpenDB(PGLOBAL g) + { + if (Use == USE_OPEN) { + /*******************************************************************/ + /* Table already open, just replace it at its beginning. */ + /*******************************************************************/ + M = N = 0; + RowFlag = 0; + New = TRUE; + return Tdbp->OpenDB(g); + } // endif use + + if (Mode != MODE_READ) { + /*******************************************************************/ + /* Currently XCOL tables cannot be modified. */ + /*******************************************************************/ + strcpy(g->Message, "XCOL tables are read only"); + return TRUE; + } // endif Mode + + if (InitTable(g)) + return NULL; + + /*********************************************************************/ + /* Check and initialize the subtable columns. */ + /*********************************************************************/ + for (PCOL cp = Columns; cp; cp = cp->GetNext()) + if (((PXCLCOL)cp)->Init(g)) + return TRUE; + + /*********************************************************************/ + /* Physically open the object table. */ + /*********************************************************************/ + if (Tdbp->OpenDB(g)) + return TRUE; + +#if 0 + /*********************************************************************/ + /* Check for direct access. */ + /*********************************************************************/ + if (To_Key_Col) + if (!Tdbp->GetDef()->Indexable()) { + strcpy(g->Message, "Object table is not indexable"); + return TRUE; + } else { + ((PTDBX)Tdbp)->To_Key_Col = To_Key_Col; + ((PTDBX)Tdbp)->To_Link = To_Link; + ((PTDBX)Tdbp)->Knum = Knum; + To_Kindex = (PKXBASE)new(g) KINDEX(Tdbp); + + if (To_Kindex->Init(g)) + return TRUE; + + ((PKINDEX)To_Kindex)->SetMult(Mult); + Tdbp->SetKindex(To_Kindex); + } // endif Indexable +#endif // 0 + + return FALSE; + } // end of OpenDB + +/***********************************************************************/ +/* Data Base read routine for XCV access method. */ +/***********************************************************************/ +int TDBXCL::ReadDB(PGLOBAL g) + { + int rc = RC_OK; + + /*********************************************************************/ + /* Now start the multi reading process. */ + /*********************************************************************/ + do { + if (RowFlag != 1) { + if ((rc = Tdbp->ReadDB(g)) != RC_OK) + break; + + New = TRUE; + M = 1; + } else { + New = FALSE; + M++; + } // endif RowFlag + + if (Xcolp) { + RowFlag = 0; + Xcolp->ReadColumn(g); + } // endif Xcolp + + N++; + } while (RowFlag == 2); + + return rc; + } // end of ReadDB + + +// ------------------------ XCLCOL functions ---------------------------- + +/***********************************************************************/ +/* XCLCOL public constructor. */ +/***********************************************************************/ +XCLCOL::XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i) + : PRXCOL(cdp, tdbp, cprec, i, "XCL") + { + // Set additional XXL access method information for column. + Cbuf = (char*)PlugSubAlloc(g, NULL, Long + 1); + Cp = NULL; // Pointer to current position in Cbuf + Sep = ((PTDBXCL)tdbp)->Sep; + AddStatus(BUF_READ); // Only evaluated from TDBXCL::ReadDB + } // end of XCLCOL constructor + +/***********************************************************************/ +/* What this routine does is to get the comma-separated string */ +/* from the source table column, extract the single values and */ +/* set the flag for the table ReadDB function. */ +/***********************************************************************/ +void XCLCOL::ReadColumn(PGLOBAL g) + { + if (((PTDBXCL)To_Tdb)->New) { + Colp->ReadColumn(g); + strcpy(Cbuf, To_Val->GetCharValue()); + Cp = Cbuf; + } // endif New + + if (*Cp) { + PSZ p; + + // Trim left + for (p = Cp; *p == ' '; p++) ; + + if ((Cp = strchr(Cp, Sep))) + // Separator is found + *Cp++ = '\0'; + + Value->SetValue_psz(p); + } else if (Nullable) { + Value->Reset(); + Value->SetNull(true); + } else + // Skip that row + ((PTDBXCL)To_Tdb)->RowFlag = 2; + + if (Cp && *Cp) + // More to come from the same row + ((PTDBXCL)To_Tdb)->RowFlag = 1; + + } // end of ReadColumn + +#if 0 +/* -------------- Implementation of the MULINDX class ---------------- */ + +/***********************************************************************/ +/* Returns FALSE if Ok, TRUE if there are no more equal values. */ +/***********************************************************************/ +bool MULINDX::HaveSame(void) + { + return (Op == OP_SAME || Txlp->RowFlag == 1); + } // end of HaveSame + +/***********************************************************************/ +/* Returns FALSE if Ok, TRUE if there are no more equal values. */ +/***********************************************************************/ +bool MULINDX::NextVal(bool eq) + { + return (Pof) ? KINDEX::NextVal(eq) : TRUE; + } // end of NextVal + +/***********************************************************************/ +/* Returns TRUE if there are more same values. */ +/***********************************************************************/ +bool MULINDX::MoreVal(void) + { + Op = OP_SAME; // There may be more equal values + return (Pof) ? Pof[Val_K] : Val_K; + } // end of MoreVal + +/***********************************************************************/ +/* Change the index multiple status. */ +/***********************************************************************/ +bool MULINDX::Init(PGLOBAL g) + { + if (KINDEX::Init(g)) + return TRUE; + + Mul = TRUE; + MaxSame *= Txlp->Mult; + return FALSE; + } // end of Init +#endif // 0 diff --git a/storage/connect/tabxcl.h b/storage/connect/tabxcl.h new file mode 100644 index 00000000000..6db653d5709 --- /dev/null +++ b/storage/connect/tabxcl.h @@ -0,0 +1,133 @@ +// TABXCL.H Olivier Bertrand 2013 +// Defines the XCOL tables + +#include "tabutil.h" + +#define TYPE_AM_XCOL (AMT)124 + +typedef class XCLDEF *PXCLDEF; +typedef class TDBXCL *PTDBXCL; +typedef class XCLCOL *PXCLCOL; +//pedef class MULINDX *PMINDX; + +/* -------------------------- XCOL classes --------------------------- */ + +/***********************************************************************/ +/* XCOL: table having one column containing several values comma */ +/* (or any other character) separated. When creating the table, the */ +/* name of the X column is given by the NAME option. */ +/* This sample has a limitation: */ +/* - The X column has the same length than in the physical file. */ +/* This tables produces as many rows for a physical row than the */ +/* number of items in the X column (eventually 0). */ +/***********************************************************************/ + +/***********************************************************************/ +/* XCL table. */ +/***********************************************************************/ +class XCLDEF : public PRXDEF { /* Logical table description */ + friend class TDBXCL; + public: + // Constructor + XCLDEF(void); + + // Implementation + virtual const char *GetType(void) {return "XCL";} + + // Methods + virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); + virtual PTDB GetTable(PGLOBAL g, MODE mode); + + protected: + // Members + char *Xcol; /* The column containing separated fields */ + char Sep; /* The field separator, defaults to comma */ + int Mult; /* Multiplication factor */ + }; // end of XCLDEF + +/***********************************************************************/ +/* This is the class declaration for the XCSV table. */ +/***********************************************************************/ +class TDBXCL : public TDBPRX { +//friend class MULINDX; + friend class XCLDEF; + friend class PRXCOL; + friend class XCLCOL; + public: + // Constructor + TDBXCL(PXCLDEF tdp); + + // Implementation + virtual AMT GetAmType(void) {return TYPE_AM_XCOL;} + + // Methods + virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} + virtual int RowNumber(PGLOBAL g, bool b = FALSE); +//virtual bool HaveSame(void) {return RowFlag == 1;} + + // Database routines + virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); + virtual bool InitTable(PGLOBAL g); + virtual int GetMaxSize(PGLOBAL g); + virtual bool OpenDB(PGLOBAL g); + virtual int ReadDB(PGLOBAL g); + + protected: + // Members + char *Xcolumn; // Multiple column name + PXCLCOL Xcolp; // To the XCVCOL column + int Mult; // Multiplication factor + int N; // The current table index + int M; // The occurence rank + BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip + BOOL New; // TRUE for new line + char Sep; // The Xcol separator + }; // end of class TDBXCL + +/***********************************************************************/ +/* Class XCLCOL: for the multiple CSV column. */ +/***********************************************************************/ +class XCLCOL : public PRXCOL { + friend class TDBXCL; + public: + // Constructors + XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); + + // Methods + virtual void Reset(void) {} // Evaluated only by TDBXCL + virtual void ReadColumn(PGLOBAL g); + + protected: + // Default constructor not to be used + XCLCOL(void) {} + + // Members + char *Cbuf; // The column buffer + char *Cp; // Pointer to current position + char Sep; // The separator + }; // end of class XCLCOL + +#if 0 +/* ------------------------- MULINDX classes ------------------------- */ + +/***********************************************************************/ +/* This represents a KINDEX class for an XCOL table. */ +/***********************************************************************/ +class MULINDX : public KINDEX { + public: + // Constructor + MULINDX(PTDBXCL txlp) : KINDEX(txlp->Tdbp) {Txlp = txlp;} + + // Implementation + virtual BOOL HaveSame(void); + + // Methods + virtual BOOL Init(PGLOBAL g); + virtual BOOL NextVal(BOOL eq); + virtual int MoreVal(void); + + protected: + //Member + PTDBXCL Txlp; +}; // end of class MULINDX +#endif // 0 diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index a56841d8980..a96dec2565c 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -266,7 +266,7 @@ char TYPBLK::GetTypedValue(PVAL valp) {return valp->GetTinyValue();} /***********************************************************************/ -/* Set one value in a block. */ +/* Set one value in a block from a zero terminated string. */ /***********************************************************************/ template void TYPBLK::SetValue(PSZ p, int n) @@ -294,6 +294,22 @@ double TYPBLK::GetTypedValue(PSZ p) {return atof(p);} template <> char TYPBLK::GetTypedValue(PSZ p) {return (char)atoi(p);} +/***********************************************************************/ +/* Set one value in a block from an array of characters. */ +/***********************************************************************/ +template +void TYPBLK::SetValue(char *sp, uint len, int n) + { + PGLOBAL& g = Global; + PSZ spz = (PSZ)PlugSubAlloc(g, NULL, 0); // Temporary + + if (sp) + memcpy(spz, sp, len); + + spz[len] = 0; + SetValue(spz, n); + } // end of SetValue + /***********************************************************************/ /* Set one value in a block from a value in another block. */ /***********************************************************************/ @@ -552,11 +568,19 @@ void CHRBLK::SetValue(PVAL valp, int n) } // end of SetValue /***********************************************************************/ -/* Set one value in a block. */ +/* Set one value in a block from a zero terminated string. */ /***********************************************************************/ void CHRBLK::SetValue(PSZ sp, int n) { - size_t len = (sp) ? strlen(sp) : 0; + uint len = (sp) ? strlen(sp) : 0; + SetValue(sp, len, n); + } // end of SetValue + +/***********************************************************************/ +/* Set one value in a block from an array of characters. */ +/***********************************************************************/ +void CHRBLK::SetValue(char *sp, uint len, int n) + { char *p = Chrp + n * Long; #if defined(_DEBUG) || defined(DEBTRACE) @@ -568,15 +592,16 @@ void CHRBLK::SetValue(PSZ sp, int n) #endif if (sp) - strncpy(p, sp, Long); - else - *p = '\0'; + memcpy(p, sp, len); - if (Blanks) + if (Blanks) { // Suppress eventual ending zero and right fill with blanks for (register int i = len; i < Long; i++) p[i] = ' '; + } else if ((signed)len < Long) + p[len] = 0; + SetNull(n, false); } // end of SetValue @@ -801,12 +826,33 @@ void STRBLK::SetValue(PVAL valp, int n) } // end of SetValue /***********************************************************************/ -/* Set one value in a block. */ +/* Set one value in a block from a zero terminated string. */ /***********************************************************************/ void STRBLK::SetValue(PSZ p, int n) { - Strp[n] = (PSZ)PlugSubAlloc(Global, NULL, strlen(p) + 1); - strcpy(Strp[n], p); + if (p) { + Strp[n] = (PSZ)PlugSubAlloc(Global, NULL, strlen(p) + 1); + strcpy(Strp[n], p); + } else + Strp[n] = NULL; + + } // end of SetValue + +/***********************************************************************/ +/* Set one value in a block from an array of characters. */ +/***********************************************************************/ +void STRBLK::SetValue(char *sp, uint len, int n) + { + PSZ p; + + if (sp) { + p = (PSZ)PlugSubAlloc(Global, NULL, len + 1); + memcpy(p, sp, len); + p[len] = 0; + } else + p = NULL; + + Strp[n] = p; } // end of SetValue /***********************************************************************/ diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h index 9a85577a104..a7b1b5046d7 100644 --- a/storage/connect/valblk.h +++ b/storage/connect/valblk.h @@ -64,6 +64,7 @@ class VALBLK : public BLOCK { virtual void SetValue(double fval, int n) {assert(false);} virtual void SetValue(char cval, int n) {assert(false);} virtual void SetValue(PSZ sp, int n) {assert(false);} + virtual void SetValue(char *sp, uint len, int n) {assert(false);} virtual void SetValue(PVAL valp, int n) = 0; virtual void SetValue(PVBLK pv, int n1, int n2) = 0; #if 0 @@ -120,6 +121,7 @@ class TYPBLK : public VALBLK { // Methods virtual void SetValue(PSZ sp, int n); + virtual void SetValue(char *sp, uint len, int n); virtual void SetValue(short sval, int n) {Typp[n] = (TYPE)sval; SetNull(n, false);} virtual void SetValue(int lval, int n) @@ -175,6 +177,7 @@ class CHRBLK : public VALBLK { // Methods virtual void SetValue(PSZ sp, int n); + virtual void SetValue(char *sp, uint len, int n); virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVBLK pv, int n1, int n2); //virtual void SetValues(PVBLK pv, int k, int n); @@ -221,6 +224,7 @@ class STRBLK : public VALBLK { // Methods virtual void SetValue(PSZ sp, int n); + virtual void SetValue(char *sp, uint len, int n); virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVBLK pv, int n1, int n2); //virtual void SetValues(PVBLK pv, int k, int n); From 2a37f3e0308062f393decee9ab6935fb45f8be52 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 29 Apr 2013 17:47:23 +0200 Subject: [PATCH 119/273] - Fix a bug causing a crash when using OEM tables based on BIN tables. modified: storage/connect/reldef.cpp --- storage/connect/reldef.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 77f2f43ec31..6d16dcde04a 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -304,7 +304,7 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode) else txfp = new(g) DOSFAM(defp); - } else if (rfm == RECFM_FIX || rfm == RECFM_FIX) { + } else if (rfm == RECFM_FIX || rfm == RECFM_BIN) { if (map) txfp = new(g) MPXFAM(defp); else From 8d75f11a67d620727b87ef3a00d61a6f92418817 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 30 Apr 2013 00:29:47 +0200 Subject: [PATCH 120/273] MDEV-4458 - Windows installer does not launch upgrade wizard anymore, even if there are upgradable instances (i.e windows service of lower MariaDB/MySQL version) The main reason for he error is misplaced ADD_DIRECTORY in top-level CMakeLists.txt. ADD_DIRECTORY(win/packaging) was places before win/upgrade_wizard, and MSI was not able to detect that upgrade wizard was built, and thus excluded upgrade wizard entirely. --- CMakeLists.txt | 2 +- win/packaging/ca/CustomAction.cpp | 2 +- win/packaging/extra.wxs.in | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b8d52feedb..1bae7e81f5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -329,8 +329,8 @@ INCLUDE(cmake/abi_check.cmake) INCLUDE(cmake/tags.cmake) IF(WIN32) - ADD_SUBDIRECTORY(win/packaging) ADD_SUBDIRECTORY(win/upgrade_wizard) + ADD_SUBDIRECTORY(win/packaging) ENDIF() CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/my_config.h) diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp index 50b39adc0b1..67a17c2cc19 100644 --- a/win/packaging/ca/CustomAction.cpp +++ b/win/packaging/ca/CustomAction.cpp @@ -895,7 +895,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall) Only look for services that have mysqld.exe outside of the current installation directory. */ - if(strstr(props.mysqld_exe,installDir) == 0) + if(installDir[0] == 0 || strstr(props.mysqld_exe,installDir) == 0) { WcaLog(LOGMSG_STANDARD, "found service %S, major=%d, minor=%d", info[i].lpServiceName, props.version_major, props.version_minor); diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in index ff1a529a2ee..e0a36ef2e41 100644 --- a/win/packaging/extra.wxs.in +++ b/win/packaging/extra.wxs.in @@ -151,6 +151,9 @@ CreateOrUpgradeChoice = "Upgrade" CreateOrUpgradeChoice = "Create" + CreateOrUpgradeChoice = "Create" + CreateOrUpgradeChoice = "Create" + CreateOrUpgradeChoice = "Upgrade" 1 @@ -823,7 +826,7 @@ - + - $C.bin.mysql_upgrade_wizard.exe = 3 AND NOT Installed + $C.bin.mysql_upgrade_wizard.exe = 3 AND NOT Installed AND NOT OLDERVERSIONBEINGUPGRADED - 3) AND NOT Installed]]> + 3) AND NOT Installed OR OLDERVERSIONBEINGUPGRADED]]> - 3) AND NOT Installed]]> + 3) AND NOT Installed OR OLDERVERSIONBEINGUPGRADED]]> From 86f43c30771cdfbb38f1a958de0e7f131451a988 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 29 Apr 2013 20:31:40 -0700 Subject: [PATCH 121/273] Fixed bug mdev-4274. This bug was the result of incompleteness of the patch for bug mdev-4177. When an OR condition is simplified to a single conjunct it is merged into the embedding AND condition. Multiple equalities are also merged, and any field item involved in those equality should acquire a pointer to a the multiple equality formed by this merge. --- mysql-test/r/select.result | 35 +++++++++++++++++++++++++ mysql-test/r/select_jcl6.result | 35 +++++++++++++++++++++++++ mysql-test/r/select_pkeycache.result | 35 +++++++++++++++++++++++++ mysql-test/r/subselect_sj2_mat.result | 2 +- mysql-test/t/select.test | 37 +++++++++++++++++++++++++++ sql/sql_select.cc | 19 +++++++++++++- 6 files changed, 161 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 3d1dc5ec170..953b1409827 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -5049,6 +5049,7 @@ SELECT 1 FROM t1 GROUP BY 1; 1 1 drop table t1; +set sql_buffer_result= 0; End of 5.1 tests # # BUG#776274: substitution of a single row table @@ -5132,4 +5133,38 @@ AND Time_zone_id = Time_zone_id OR Time_zone_id <> Time_zone_id ) AND Use_leap_seconds <> 'N'; Time_zone_id Use_leap_seconds +# +# Bug mdev-4274: result of simplification of OR badly merged +# into embedding AND +# +CREATE TABLE t1 (a int, b int, INDEX idx(b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (8,8); +CREATE TABLE t2 (c int, INDEX idx(c)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); +EXPLAIN EXTENDED +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) +WHERE 1 IS NULL OR b < 33 AND b = c; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 +1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index +Warnings: +Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) +WHERE 1 IS NULL OR b < 33 AND b = c; +a b c +8 8 8 +DROP TABLE t1,t2; +# +# Bug mdev-4413: another manifestations of bug mdev-2474 +# (valgrind complains) +# +CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,1); +CREATE TABLE t2 (c int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0), (8); +SELECT * FROM t1, t2 +WHERE c = a AND +( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c ); +a b c +DROP TABLE t1, t2; End of 5.3 tests diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index e2e0db128b3..d2faa9e85e1 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -5060,6 +5060,7 @@ SELECT 1 FROM t1 GROUP BY 1; 1 1 drop table t1; +set sql_buffer_result= 0; End of 5.1 tests # # BUG#776274: substitution of a single row table @@ -5143,6 +5144,40 @@ AND Time_zone_id = Time_zone_id OR Time_zone_id <> Time_zone_id ) AND Use_leap_seconds <> 'N'; Time_zone_id Use_leap_seconds +# +# Bug mdev-4274: result of simplification of OR badly merged +# into embedding AND +# +CREATE TABLE t1 (a int, b int, INDEX idx(b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (8,8); +CREATE TABLE t2 (c int, INDEX idx(c)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); +EXPLAIN EXTENDED +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) +WHERE 1 IS NULL OR b < 33 AND b = c; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 +1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index +Warnings: +Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) +WHERE 1 IS NULL OR b < 33 AND b = c; +a b c +8 8 8 +DROP TABLE t1,t2; +# +# Bug mdev-4413: another manifestations of bug mdev-2474 +# (valgrind complains) +# +CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,1); +CREATE TABLE t2 (c int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0), (8); +SELECT * FROM t1, t2 +WHERE c = a AND +( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c ); +a b c +DROP TABLE t1, t2; End of 5.3 tests set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index 3d1dc5ec170..953b1409827 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -5049,6 +5049,7 @@ SELECT 1 FROM t1 GROUP BY 1; 1 1 drop table t1; +set sql_buffer_result= 0; End of 5.1 tests # # BUG#776274: substitution of a single row table @@ -5132,4 +5133,38 @@ AND Time_zone_id = Time_zone_id OR Time_zone_id <> Time_zone_id ) AND Use_leap_seconds <> 'N'; Time_zone_id Use_leap_seconds +# +# Bug mdev-4274: result of simplification of OR badly merged +# into embedding AND +# +CREATE TABLE t1 (a int, b int, INDEX idx(b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (8,8); +CREATE TABLE t2 (c int, INDEX idx(c)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); +EXPLAIN EXTENDED +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) +WHERE 1 IS NULL OR b < 33 AND b = c; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 +1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index +Warnings: +Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) +WHERE 1 IS NULL OR b < 33 AND b = c; +a b c +8 8 8 +DROP TABLE t1,t2; +# +# Bug mdev-4413: another manifestations of bug mdev-2474 +# (valgrind complains) +# +CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,1); +CREATE TABLE t2 (c int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0), (8); +SELECT * FROM t1, t2 +WHERE c = a AND +( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c ); +a b c +DROP TABLE t1, t2; End of 5.3 tests diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result index bf5b95d2d8f..18e3f6ddd34 100644 --- a/mysql-test/r/subselect_sj2_mat.result +++ b/mysql-test/r/subselect_sj2_mat.result @@ -1380,7 +1380,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join) Warnings: -Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t3`.`i3` > 0)) +Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t2`.`i2` > 0)) SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2); i1 diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index e202e013377..54168332664 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4241,6 +4241,7 @@ SELECT f1 FROM t1 GROUP BY 1; SELECT f1 FROM t1 GROUP BY '123' = 'abc'; SELECT 1 FROM t1 GROUP BY 1; drop table t1; +set sql_buffer_result= 0; --echo End of 5.1 tests @@ -4305,4 +4306,40 @@ WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1) OR Time_zone_id <> Time_zone_id ) AND Use_leap_seconds <> 'N'; +--echo # +--echo # Bug mdev-4274: result of simplification of OR badly merged +--echo # into embedding AND +--echo # + +CREATE TABLE t1 (a int, b int, INDEX idx(b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (8,8); + +CREATE TABLE t2 (c int, INDEX idx(c)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); + +EXPLAIN EXTENDED +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) + WHERE 1 IS NULL OR b < 33 AND b = c; +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) + WHERE 1 IS NULL OR b < 33 AND b = c; + +DROP TABLE t1,t2; + +--echo # +--echo # Bug mdev-4413: another manifestations of bug mdev-2474 +--echo # (valgrind complains) +--echo # + +CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,1); + +CREATE TABLE t2 (c int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0), (8); + +SELECT * FROM t1, t2 + WHERE c = a AND + ( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c ); + +DROP TABLE t1, t2; + --echo End of 5.3 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6432142597f..410244b88f0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13195,7 +13195,24 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) if (new_item_and_list->is_empty()) li.remove(); else - li.replace(*new_item_and_list); + { + Item *list_item; + Item *new_list_item; + List_iterator it(*new_item_and_list); + while ((list_item= it++)) + { + uchar* is_subst_valid= (uchar *) Item::ANY_SUBST; + new_list_item= + list_item->compile(&Item::subst_argument_checker, + &is_subst_valid, + &Item::equal_fields_propagator, + (uchar *) &cond_and->cond_equal); + if (new_list_item != list_item) + it.replace(new_list_item); + new_list_item->update_used_tables(); + } + li.replace(*new_item_and_list); + } cond_and_list->concat((List*) cond_equal_items); } else if (new_item->type() == Item::FUNC_ITEM && From 7461d8e30c085ec4936959ebd21c7ff07ba268e5 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 30 Apr 2013 16:16:32 +0200 Subject: [PATCH 122/273] - Allow PROXY based tables to specify MySQL access parameters when the object table is not a CONNECT table. This was the case in previous versions but was no more possible with recent changes. modified: storage/connect/mycat.cc storage/connect/tabmysql.cpp storage/connect/tabutil.cpp --- storage/connect/mycat.cc | 1 + storage/connect/tabmysql.cpp | 8 ++++++++ storage/connect/tabutil.cpp | 11 ++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 5a7f53977c7..b46c014fba6 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -120,6 +120,7 @@ TABTYPE GetTypeID(const char *type) #endif #ifdef MYSQL_SUPPORT : (!stricmp(type, "MYSQL")) ? TAB_MYSQL + : (!stricmp(type, "MYPRX")) ? TAB_MYSQL #endif : (!stricmp(type, "DIR")) ? TAB_DIR #ifdef WIN32 diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 495324b74f7..2af1055e8e1 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -65,6 +65,9 @@ void PrintResult(PGLOBAL, PSEM, PQRYRES); extern "C" int trace; extern MYSQL_PLUGIN_IMPORT uint mysqld_port; +// This function is located in tabutil.cpp +void Remove_tshp(PCATLG cat); + /* -------------- Implementation of the MYSQLDEF class --------------- */ /***********************************************************************/ @@ -280,6 +283,11 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Desc = "MySQL Table"; + if (!stricmp(am, "MYPRX")) + // MYSQL access from a PROXY table, + // we must get parms from the calling table + Remove_tshp(Cat); + if (!url || !*url) { // Not using the connection URL Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 5706ca7aeba..76885aeedce 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -56,6 +56,15 @@ extern "C" int trace; +/************************************************************************/ +/* Used by MYSQL tables to get MySQL parameters from the calling proxy */ +/* table (PROXY, TBL, XCL, or OCCUR) when used by one of these. */ +/************************************************************************/ +void Remove_tshp(PCATLG cat) +{ + ((MYCAT*)cat)->GetHandler()->tshp = NULL; +} // end of Remove_thsp + /************************************************************************/ /* GetTableShare: allocates and open a table share. */ /************************************************************************/ @@ -315,7 +324,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) if (mysql) { #if defined(MYSQL_SUPPORT) // Access sub-table via MySQL API - if (!(tdbp= cat->GetTable(g, tabp, MODE_READ, "MYSQL"))) { + if (!(tdbp= cat->GetTable(g, tabp, MODE_READ, "MYPRX"))) { sprintf(g->Message, "Cannot access %s.%s", db, name); goto err; } // endif Define From 3d4adc3fdfa1238efb9cd1b6335a397527c24da2 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 30 Apr 2013 17:48:18 +0200 Subject: [PATCH 123/273] - Change in connect_assisted_discovery the default value for port from MYSQL_PORT to 0. So it can be later set to mysqld_port if necessary. Doing so, it is no more required to specify port when using the current port and the current port is not equal to MYSQL_PORT (3306) modified: storage/connect/ha_connect.cc --- storage/connect/ha_connect.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 99f81905f0c..b2303b07de8 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3333,7 +3333,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, db= GetListOption(g,"database", topt->oplist, db); pwd= GetListOption(g,"password", topt->oplist); prt= GetListOption(g,"port", topt->oplist); - port= (prt) ? atoi(prt) : MYSQL_PORT; + port= (prt) ? atoi(prt) : 0; #if defined(WIN32) nsp= GetListOption(g,"namespace", topt->oplist); cls= GetListOption(g,"class", topt->oplist); From f3e944099e1d7369bbf84e0b1087b45506279034 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 2 May 2013 16:33:15 +0200 Subject: [PATCH 124/273] - Adding a loop test to prevent PROXY based table to loop when repointing on itself. - Fix bug causing PROXY on non CONNECT tables to sometimes use the wrong DB. - Making some more tests in create that were in pre_create not called anymore when columns are defined. - Updating some test results to reflect new warnings. modified: storage/connect/ha_connect.cc storage/connect/mysql-test/connect/r/tbl.result storage/connect/mysql-test/connect/r/upd.result storage/connect/tabcol.h storage/connect/tabmysql.cpp storage/connect/taboccur.cpp storage/connect/taboccur.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabxcl.cpp storage/connect/tabxcl.h --- storage/connect/ha_connect.cc | 60 ++-- .../connect/mysql-test/connect/r/tbl.result | 3 + .../connect/mysql-test/connect/r/upd.result | 6 + storage/connect/tabcol.h | 3 +- storage/connect/tabmysql.cpp | 33 ++- storage/connect/taboccur.cpp | 65 ++-- storage/connect/taboccur.h | 6 +- storage/connect/tabtbl.cpp | 277 +----------------- storage/connect/tabtbl.h | 47 --- storage/connect/tabutil.cpp | 28 +- storage/connect/tabutil.h | 1 + storage/connect/tabxcl.cpp | 65 ---- storage/connect/tabxcl.h | 28 -- 13 files changed, 132 insertions(+), 490 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index b2303b07de8..7422815223f 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3392,21 +3392,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, } // endif tab - // Check whether a table is defined on itself - switch (ttp) { - case TAB_PRX: - case TAB_XCL: - case TAB_TBL: - case TAB_OCCUR: - if (!stricmp(tab, create_info->alias) && - !stricmp(db, thd->db)) { - sprintf(g->Message, "A %s table cannot refer to itself", topt->type); - my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); - return HA_ERR_INTERNAL_ERROR; - } // endif tab - - } // endswitch ttp - switch (ttp) { #if defined(ODBC_SUPPORT) case TAB_ODBC: @@ -3758,7 +3743,8 @@ int ha_connect::create(const char *name, TABLE *table_arg, Field *fp; TABTYPE type; TABLE *st= table; // Probably unuseful - xp= GetUser(ha_thd(), xp); + THD *thd= ha_thd(); + xp= GetUser(thd, xp); PGLOBAL g= xp->g; DBUG_ENTER("ha_connect::create"); @@ -3768,7 +3754,27 @@ int ha_connect::create(const char *name, TABLE *table_arg, DBUG_ASSERT(options); type= GetTypeID(options->type); - if (check_privileges(ha_thd(), options)) + // Check table type + if (type == TAB_UNDEF) { + if (!options->tabname) { + strcpy(g->Message, "No table_type. Will be set to DOS"); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + type= TAB_DOS; + options->type= "DOS"; + } else { + strcpy(g->Message, "No table_type. Will be set to PROXY"); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + type= TAB_PRX; + options->type= "PROXY"; + } // endif fnc + + } else if (type == TAB_NIY) { + sprintf(g->Message, "Unsupported table type %s", options->type); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + DBUG_RETURN(HA_ERR_INTERNAL_ERROR); + } // endif ttp + + if (check_privileges(thd, options)) DBUG_RETURN(HA_ERR_INTERNAL_ERROR); if (options->data_charset) { @@ -3795,6 +3801,21 @@ int ha_connect::create(const char *name, TABLE *table_arg, } else dbf= (GetTypeID(options->type) == TAB_DBF && !options->catfunc); + // Check whether a table is defined on itself + switch (type) { + case TAB_PRX: + case TAB_XCL: + case TAB_OCCUR: + if (!stricmp(options->tabname, create_info->alias) && + (!options->dbname || !stricmp(options->dbname, thd->db))) { + sprintf(g->Message, "A %s table cannot refer to itself", + options->type); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + return HA_ERR_INTERNAL_ERROR; + } // endif tab + + } // endswitch ttp + if (type == TAB_XML) { bool dom; // True: MS-DOM, False libxml2 char *xsup= GetListOption(g, "Xmlsup", options->oplist, "*"); @@ -3964,8 +3985,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, strcat(strcat(buf, "."), lwt); sprintf(g->Message, "No file name. Table will use %s", buf); - push_warning(table->in_use, - MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/"); PlugSetPath(fn, buf, dbpath); @@ -3994,7 +4014,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, // We should be in CREATE TABLE if (table->in_use->lex->sql_command != SQLCOM_CREATE_TABLE) - push_warning(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, "Wrong command in create, please contact CONNECT team"); // Get the index definitions diff --git a/storage/connect/mysql-test/connect/r/tbl.result b/storage/connect/mysql-test/connect/r/tbl.result index 01a6afcebe8..bc77516c22d 100644 --- a/storage/connect/mysql-test/connect/r/tbl.result +++ b/storage/connect/mysql-test/connect/r/tbl.result @@ -4,6 +4,9 @@ CREATE TABLE t1 ( a INT NOT NULL, message CHAR(10)) ENGINE=connect; +Warnings: +Warning 1105 No table_type. Will be set to DOS +Warning 1105 No file name. Table will use t1.dos INSERT INTO t1 VALUES (1,'Testing'),(2,'dos table'),(3,'t1'); SELECT * FROM t1; a message diff --git a/storage/connect/mysql-test/connect/r/upd.result b/storage/connect/mysql-test/connect/r/upd.result index 24cfdafaa9a..fa519c4b688 100644 --- a/storage/connect/mysql-test/connect/r/upd.result +++ b/storage/connect/mysql-test/connect/r/upd.result @@ -59,6 +59,9 @@ END// # Testing DOS table changes # CREATE TABLE t1 ENGINE=connect AS SELECT * FROM employee; +Warnings: +Warning 1105 No table_type. Will be set to DOS +Warning 1105 No file name. Table will use t1.dos CALL test.tst_up(); serialno name sex title manager department secretary salary 74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00 @@ -154,6 +157,9 @@ serialno name sex title manager department secretary salary # Testing DOS table changes # CREATE TABLE t1 ENGINE=connect mapped=yes AS SELECT * FROM employee; +Warnings: +Warning 1105 No table_type. Will be set to DOS +Warning 1105 No file name. Table will use t1.dos CALL test.tst_up(); serialno name sex title manager department secretary salary 74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00 diff --git a/storage/connect/tabcol.h b/storage/connect/tabcol.h index 5cc2050f872..8c21fe6d1b2 100644 --- a/storage/connect/tabcol.h +++ b/storage/connect/tabcol.h @@ -15,7 +15,8 @@ /***********************************************************************/ /* Definition of class XTAB with all its method functions. */ /***********************************************************************/ - class DllExport XTAB: public BLOCK { // Table Name-Owner-Correl block. +class DllExport XTAB: public BLOCK { // Table Name-Owner-Correl block. + friend class TDBPRX; public: // Constructors XTAB(LPCSTR name, LPCSTR correl = NULL); diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 2af1055e8e1..b3401530c1b 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -283,25 +283,36 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Desc = "MySQL Table"; - if (!stricmp(am, "MYPRX")) - // MYSQL access from a PROXY table, - // we must get parms from the calling table - Remove_tshp(Cat); + if (!stricmp(am, "MYPRX")) { + // Normal case of specific MYSQL table + if (!url || !*url) { + // Not using the connection URL + Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); + Database = Cat->GetStringCatInfo(g, "Database", "*"); + Tabname = Cat->GetStringCatInfo(g, "Name", Name); // Deprecated + Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); + Username = Cat->GetStringCatInfo(g, "User", "*"); + Password = Cat->GetStringCatInfo(g, "Password", NULL); + Portnumber = Cat->GetIntCatInfo("Port", mysqld_port); + } else if (ParseURL(g, url)) + return TRUE; - if (!url || !*url) { - // Not using the connection URL - Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); + Bind = !!Cat->GetIntCatInfo("Bind", 0); + Delayed = !!Cat->GetIntCatInfo("Delayed", 0); + } else { + // MYSQL access from a PROXY table, not using URL Database = Cat->GetStringCatInfo(g, "Database", "*"); Tabname = Cat->GetStringCatInfo(g, "Name", Name); // Deprecated Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); + + // We must get connection parms from the calling table + Remove_tshp(Cat); + Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); Username = Cat->GetStringCatInfo(g, "User", "*"); Password = Cat->GetStringCatInfo(g, "Password", NULL); Portnumber = Cat->GetIntCatInfo("Port", mysqld_port); - } else if (ParseURL(g, url)) - return TRUE; + } // endif am - Bind = !!Cat->GetIntCatInfo("Bind", 0); - Delayed = !!Cat->GetIntCatInfo("Delayed", 0); return FALSE; } // end of DefineAM diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index e1b83c06422..8b7e10f2e34 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -60,7 +60,6 @@ extern "C" int trace; /***********************************************************************/ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { -//Tabname = Cat->GetStringCatInfo(g, "SrcTable", ""); Xcol = Cat->GetStringCatInfo(g, "OccurCol", ""); Rcol = Cat->GetStringCatInfo(g, "RankCol", ""); Colist = Cat->GetStringCatInfo(g, "Colist", ""); @@ -72,22 +71,9 @@ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m) { - if (Catfunc != FNC_COL) { - PTDB tdbp; - PTDBOCCUR tocp = new(g) TDBOCCUR(this); - - // Check that the source table is available - if (!tocp || !(tdbp = tocp->GetSubTable(g, Tablep))) - return NULL; - - // Set Tdbp now - tocp->SetTdbp((PTDBASE)tdbp); - - if (tocp->MakeColumnList(g) < 0) - return NULL; - - return tocp; - } else + if (Catfunc != FNC_COL) + return new(g) TDBOCCUR(this); + else return new(g) TDBTBC(this); } // end of GetTable @@ -145,6 +131,24 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) return colp; } // end of MakeCol +/***********************************************************************/ +/* Initializes the table. */ +/***********************************************************************/ +bool TDBOCCUR::InitTable(PGLOBAL g) + { + if (!Tdbp) { + // Get the table description block of this table + if (!(Tdbp = (PTDBASE)GetSubTable(g, ((POCCURDEF)To_Def)->Tablep))) + return TRUE; + + if (MakeColumnList(g) < 0) + return TRUE; + + } // endif Tdbp + + return FALSE; + } // end of InitTable + /***********************************************************************/ /* Allocate OCCUR column description block. */ /***********************************************************************/ @@ -199,7 +203,9 @@ int TDBOCCUR::MakeColumnList(PGLOBAL g) int TDBOCCUR::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { -// Mult = MakeColumnList(g); + if (InitTable(g)) + return NULL; + MaxSize = Mult * Tdbp->GetMaxSize(g); } // endif MaxSize @@ -233,12 +239,7 @@ bool TDBOCCUR::OpenDB(PGLOBAL g) return Tdbp->OpenDB(g); } // endif use - /*********************************************************************/ - /* Do it here if not done yet. */ - /*********************************************************************/ -// if (MakeColumnList(g) < 0) -// return TRUE; - + if (Mode != MODE_READ) { /*******************************************************************/ /* Currently OCCUR tables cannot be modified. */ @@ -247,21 +248,11 @@ bool TDBOCCUR::OpenDB(PGLOBAL g) return TRUE; } // endif Mode -#if 0 /*********************************************************************/ - /* Be sure OCCUR column exist. */ + /* Do it here if not done yet. */ /*********************************************************************/ - if (!Xcolp) { - if (!(Xcolp = (POCCURCOL)ColDB(g, Xcolumn, 0))) { - sprintf(g->Message, "OCCUR column %s definition error", Xcolumn); - return TRUE; - } else if (Xcolp->InitValue(g)) { - strcpy(g->Message, "OCCUR InitValue failed"); - return TRUE; - } // endif's Xcolp - - } // endif Xcolp -#endif // 0 + if (InitTable(g)) + return NULL; if (Xcolp) // Lock this column so it is evaluated by its table only diff --git a/storage/connect/taboccur.h b/storage/connect/taboccur.h index 0cfabf87793..c0077a0b33e 100644 --- a/storage/connect/taboccur.h +++ b/storage/connect/taboccur.h @@ -37,7 +37,6 @@ class OCCURDEF : public PRXDEF { /* Logical table description */ protected: // Members -//char *Tabname; /* The source table name */ char *Colist; /* The source column list */ char *Xcol; /* The multiple occurence column */ char *Rcol; /* The rank column */ @@ -59,15 +58,14 @@ class TDBOCCUR : public TDBPRX { void SetTdbp(PTDBASE tdbp) {Tdbp = tdbp;} // Methods -//virtual int GetRecpos(void) {return N;} virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} virtual int RowNumber(PGLOBAL g, bool b = FALSE); PTDB GetSourceTable(PGLOBAL g); int MakeColumnList(PGLOBAL g); // Database routines -//virtual PCOL ColDB(PGLOBAL g, PSZ colname, int num); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); + virtual bool InitTable(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g); virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g); @@ -94,7 +92,6 @@ class OCCURCOL : public COLBLK { public: // Constructors OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n); -//OCCURCOL(OCCURCOL *colp, PTDB tdbp); // Constructor used in copy process // Implementation virtual int GetAmType(void) {return TYPE_AM_OCCUR;} @@ -120,7 +117,6 @@ class RANKCOL : public COLBLK { public: // Constructors RANKCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n) : COLBLK(cdp, tdbp, n) {} -//RANKCOL(RANKCOL *colp, PTDB tdbp); // Constructor used in copy process // Implementation virtual int GetAmType(void) {return TYPE_AM_OCCUR;} diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index c1286785d73..5a2089d04d6 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -209,65 +209,6 @@ PCOL TDBTBL::InsertSpecialColumn(PGLOBAL g, PCOL scp) return colp; } // end of InsertSpecialColumn -#if 0 -/***********************************************************************/ -/* Get the PTDB of a table of the list. */ -/***********************************************************************/ -PTDB TDBTBL::GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp) - { -//char *db; - bool mysql; - PTDB tdbp = NULL; - TABLE_SHARE *s; - PCATLG cat = To_Def->GetCat(); - PHC hc = ((MYCAT*)cat)->GetHandler(); - THD *thd = (hc->GetTable())->in_use; - - if (!thd) - return NULL; // Should not happen anymore - -//if (tblp->DB) -// db = tblp->DB; -//else -// db = (char*)hc->GetDBName(NULL); - -//if (!(s = GetTableShare(g, thd, db, tblp->Name, mysql))) - if (!(s = GetTableShare(g, thd, tblp->DB, tblp->Name, mysql))) - return NULL; - - if (mysql) { -#if defined(MYSQL_SUPPORT) - // Access sub-table via MySQL API - if (!(tdbp= cat->GetTable(g, tabp, MODE_READ, "MYSQL"))) { - sprintf(g->Message, "Cannot access %s.%s", tblp->DB, tblp->Name); - goto err; - } // endif Define - - if (tabp->GetQualifier()) - ((PTDBMY)tdbp)->SetDatabase(tabp->GetQualifier()); - -#else // !MYSQL_SUPPORT - sprintf(g->Message, "%s.%s is not a CONNECT table", - db, tblp->Name); - goto err; -#endif // MYSQL_SUPPORT - } else { - // Sub-table is a CONNECT table - hc->tshp = s; - tdbp = cat->GetTable(g, tabp); - hc->tshp = NULL; - } // endif plugin - - if (trace && tdbp) - htrc("Subtable %s in %s\n", - tblp->Name, SVP(((PTDBASE)tdbp)->GetDef()->GetDB())); - - err: - free_table_share(s); - return tdbp; - } // end of GetSubTable -#endif // 0 - /***********************************************************************/ /* Initializes the table table list. */ /***********************************************************************/ @@ -293,7 +234,8 @@ bool TDBTBL::InitTableList(PGLOBAL g) else continue; // Skip this table - } // endif tdbp + } else + RemoveNext(tabp); // To avoid looping // We must allocate subtable columns before GetMaxSize is called // because some (PLG, ODBC?) need to have their columns attached. @@ -393,80 +335,18 @@ bool TDBTBL::TestFil(PGLOBAL g, PFIL filp, PTABLE tabp) return TRUE; // invalid operator } // end of TestFil -#if 0 -/***********************************************************************/ -/* TBL GetProgMax: get the max value for progress information. */ -/***********************************************************************/ -int TDBTBL::GetProgMax(PGLOBAL g) - { - int n, pmx = 0; - - if (!Tablist && InitTableList(g)) - return -1; - - for (PTABLE tabp = Tablist; tabp; tblp = tabp->GetNext()) - if ((n = tabp->GetTo_Tdb()->GetProgMax(g)) > 0) - pmx += n; - - return pmx; - } // end of GetProgMax - -/***********************************************************************/ -/* TBL GetProgCur: get the current value for progress information. */ -/***********************************************************************/ -int TDBTBL::GetProgCur(void) - { - return Crp + Tdbp->GetProgCur(); - } // end of GetProgCur - -/***********************************************************************/ -/* TBL Cardinality: returns table cardinality in number of rows. */ -/* This function can be called with a null argument to test the */ -/* availability of Cardinality implementation (1 yes, 0 no). */ -/* Can be used on Multiple FIX table only. */ -/***********************************************************************/ -int TDBTBL::Cardinality(PGLOBAL g) - { - if (!g) - return Tdbp->Cardinality(g); - - if (!Tablist && InitTableList(g)) - return -1; - - int n, card = 0; - - for (int i = 0; i < NumFiles; i++) { - Tdbp->SetFile(g, Filenames[i]); - Tdbp->ResetSize(); - - if ((n = Tdbp->Cardinality(g)) < 0) { -// strcpy(g->Message, MSG(BAD_CARDINALITY)); - return -1; - } // endif n - - card += n; - } // endfor i - - return card; - } // end of Cardinality -#endif // 0 - /***********************************************************************/ /* Sum up the sizes of all sub-tables. */ /***********************************************************************/ int TDBTBL::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { - int mxsz; + int mxsz; if (!Tablist && InitTableList(g)) return 0; // Cannot be calculated at this stage -// if (Use == USE_OPEN) { -// strcpy(g->Message, MSG(MAXSIZE_ERROR)); -// return -1; -// } else - MaxSize = 0; + MaxSize = 0; for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) { if ((mxsz = tabp->GetTo_Tdb()->GetMaxSize(g)) < 0) { @@ -524,17 +404,6 @@ bool TDBTBL::OpenDB(PGLOBAL g) return Tdbp->OpenDB(g); // Re-open fist table } // endif use -#if 0 - /*********************************************************************/ - /* Direct access needed for join or sorting. */ - /*********************************************************************/ - if (NeedIndexing(g)) { - // Direct access of TBL tables is not implemented yet - strcpy(g->Message, MSG(NO_MUL_DIR_ACC)); - return TRUE; - } // endif NeedIndexing -#endif // 0 - /*********************************************************************/ /* When GetMaxsize was called, To_Filter was not set yet. */ /*********************************************************************/ @@ -634,144 +503,6 @@ int TDBTBL::ReadDB(PGLOBAL g) return rc; } // end of ReadDB -#if 0 -/***********************************************************************/ -/* Data Base write routine for MUL access method. */ -/***********************************************************************/ -int TDBTBL::WriteDB(PGLOBAL g) - { - strcpy(g->Message, MSG(TABMUL_READONLY)); - return RC_FX; // NIY - } // end of WriteDB - -/***********************************************************************/ -/* Data Base delete line routine for MUL access method. */ -/***********************************************************************/ -int TDBTBL::DeleteDB(PGLOBAL g, int irc) - { - strcpy(g->Message, MSG(TABMUL_READONLY)); - return RC_FX; // NIY - } // end of DeleteDB - -/***********************************************************************/ -/* Data Base close routine for MUL access method. */ -/***********************************************************************/ -void TDBTBL::CloseDB(PGLOBAL g) - { - if (Tdbp) - Tdbp->CloseDB(g); - - } // end of CloseDB -#endif // 0 - -/* ---------------------------- TBLCOL ------------------------------- */ - -#if 0 -/***********************************************************************/ -/* TBLCOL public constructor. */ -/***********************************************************************/ -TBLCOL::TBLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) - : COLBLK(cdp, tdbp, i) - { - if (cprec) { - Next = cprec->GetNext(); - cprec->SetNext(this); - } else { - Next = tdbp->GetColumns(); - tdbp->SetColumns(this); - } // endif cprec - - // Set additional Dos access method information for column. - Long = cdp->GetLong(); // ??? -//strcpy(F_Date, cdp->F_Date); - Colp = NULL; - To_Val = NULL; - Pseudo = FALSE; - Colnum = cdp->GetOffset(); // If columns are retrieved by number - - if (trace) - htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); - - } // end of TBLCOL constructor - -/***********************************************************************/ -/* TBLCOL public constructor. */ -/***********************************************************************/ -TBLCOL::TBLCOL(SPCBLK *scp, PTDB tdbp) : COLBLK(scp->GetName(), tdbp, 0) - { - // Set additional TBL access method information for pseudo column. - Is_Key = Was_Key = scp->IsKey(); - Long = scp->GetLength(); - Buf_Type = scp->GetResultType(); - *Format.Type = (Buf_Type == TYPE_INT) ? 'N' : 'C'; - Format.Length = Long; - Colp = NULL; - To_Val = NULL; - Pseudo = TRUE; - } // end of TBLCOL constructor - -/***********************************************************************/ -/* TBLCOL constructor used for copying columns. */ -/* tdbp is the pointer to the new table descriptor. */ -/***********************************************************************/ -TBLCOL::TBLCOL(TBLCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp) - { - Long = col1->Long; - Colp = col1->Colp; - To_Val = col1->To_Val; - Pseudo = col1->Pseudo; - } // end of TBLCOL copy constructor - -/***********************************************************************/ -/* TBLCOL initialization routine. */ -/* Look for the matching column in the current table. */ -/***********************************************************************/ -bool TBLCOL::Init(PGLOBAL g) - { - PTDBTBL tdbp = (PTDBTBL)To_Tdb; - - To_Val = NULL; - - if (!(Colp = tdbp->Tdbp->ColDB(g, Name, 0)) && Colnum) - Colp = tdbp->Tdbp->ColDB(g, NULL, Colnum); - - if (Colp) { - Colp->InitValue(g); // May not have been done elsewhere - To_Val = Colp->GetValue(); - } else if (!tdbp->Accept) { - sprintf(g->Message, MSG(NO_MATCHING_COL), Name, tdbp->Tdbp->GetName()); - return TRUE; - } else { - if (Nullable) - Value->SetNull(true); - - Value->Reset(); - } // endif's - - return FALSE; - } // end of Init - -/***********************************************************************/ -/* ReadColumn: */ -/***********************************************************************/ -void TBLCOL::ReadColumn(PGLOBAL g) - { - if (trace) - htrc("TBL ReadColumn: name=%s\n", Name); - - if (Colp) { - Colp->ReadColumn(g); - Value->SetValue_pval(To_Val); - - // Set null when applicable - if (Nullable) - Value->SetNull(Value->IsNull()); - - } // endif Colp - - } // end of ReadColumn -#endif // 0 - /* ---------------------------- TBTBLK ------------------------------- */ /***********************************************************************/ diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index d241b00743e..69b862ebe4e 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -24,8 +24,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */ // Implementation virtual const char *GetType(void) {return "TBL";} -//PTABLE GetTables(void) {return Tablep;} -//int GetNtables(void) {return Ntables;} // Methods virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); @@ -33,7 +31,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */ protected: // Members -//PTABLE To_Tables; /* To the list of tables */ bool Accept; /* TRUE if bad tables are accepted */ int Maxerr; /* Maximum number of bad tables */ int Ntables; /* Number of tables */ @@ -43,7 +40,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */ /* This is the TBL Access Method class declaration. */ /***********************************************************************/ class DllExport TDBTBL : public TDBPRX { -//friend class TBLCOL; friend class TBTBLK; friend class TDBPLG; public: @@ -55,33 +51,25 @@ class DllExport TDBTBL : public TDBPRX { // Methods virtual void ResetDB(void); -//virtual PTABLE GetTablist(void) {return (PSZ)Tablist;} virtual int GetRecpos(void) {return Rows;} virtual int GetBadLines(void) {return (int)Nbf;} // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int GetMaxSize(PGLOBAL g); -//virtual int GetProgMax(PGLOBAL g); -//virtual int GetProgCur(void); virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g); -//virtual int WriteDB(PGLOBAL g); -//virtual int DeleteDB(PGLOBAL g, int irc); -//virtual void CloseDB(PGLOBAL g); protected: // Internal functions -//PTDB GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp); bool InitTableList(PGLOBAL g); bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp); // Members PTABLE Tablist; // Points to the table list PTABLE CurTable; // Points to the current table -//PTDBASE Tdbp; // Current table PTDB bool Accept; // TRUE if bad tables are accepted int Maxerr; // Maximum number of bad tables int Nbf; // Number of bad connections @@ -89,41 +77,6 @@ class DllExport TDBTBL : public TDBPRX { int Crp; // Used for CurPos }; // end of class TDBTBL -#if 0 -/***********************************************************************/ -/* Class TBLCOL: TBL access method column descriptor. */ -/* This A.M. is used for TBL tables. */ -/***********************************************************************/ -class DllExport TBLCOL : public COLBLK { - friend class TDBTBL; - public: - // Constructors - TBLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "TBL"); - TBLCOL(TBLCOL *colp, PTDB tdbp); // Constructor used in copy process -//TBLCOL(SPCBLK *colp, PTDB tdbp); // Constructor used for pseudo columns - - // Implementation - virtual int GetAmType(void) {return TYPE_AM_TBL;} - - // Methods - virtual bool IsSpecial(void) {return Pseudo;} - virtual void ReadColumn(PGLOBAL g); -//virtual void WriteColumn(PGLOBAL g); -// void Print(PGLOBAL g, FILE *, UINT); - bool Init(PGLOBAL g); - - protected: - // Default constructor not to be used - TBLCOL(void) {} - - // Members - PCOL Colp; // Points to matching table column - PVAL To_Val; // To the matching column value - bool Pseudo; // TRUE for special columns - int Colnum; // Used when retrieving columns by number - }; // end of class TBLCOL -#endif // 0 - /***********************************************************************/ /* Class TBTBLK: TDBPLG TABID special column descriptor. */ /***********************************************************************/ diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 76885aeedce..3829e16b00b 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -245,7 +245,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, return qrp; } // end of TabColumns -/* -------------- Implementation of the XCOL classes ---------------- */ +/* -------------- Implementation of the PROXY classes ---------------- */ /***********************************************************************/ /* PRXDEF constructor. */ @@ -311,11 +311,23 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) TABLE_SHARE *s; PCATLG cat = To_Def->GetCat(); PHC hc = ((MYCAT*)cat)->GetHandler(); + LPCSTR cdb, curdb = hc->GetDBName(NULL); THD *thd = (hc->GetTable())->in_use; db = (char*)tabp->GetQualifier(); name = (char*)tabp->GetName(); + // Check for eventual loop + for (PTABLE tp = To_Table; tp; tp = tp->Next) { + cdb = (tp->Qualifier) ? tp->Qualifier : curdb; + + if (!stricmp(name, tp->Name) && !stricmp(db, cdb)) { + sprintf(g->Message, "Table %s.%s pointing on itself", db, name); + return NULL; + } // endif + + } // endfor tp + if (!(s = GetTableShare(g, thd, db, name, mysql))) return NULL; @@ -337,9 +349,11 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) db, tblp->Name); goto err; #endif // MYSQL_SUPPORT - } else + } else { // Sub-table is a CONNECT table + tabp->Next = To_Table; // For loop checking tdbp = cat->GetTable(g, tabp); + } // endif mysql hc->tshp = NULL; @@ -420,7 +434,7 @@ bool TDBPRX::OpenDB(PGLOBAL g) } // endif Mode if (InitTable(g)) - return NULL; + return TRUE; /*********************************************************************/ /* Check and initialize the subtable columns. */ @@ -468,6 +482,14 @@ int TDBPRX::DeleteDB(PGLOBAL g, int irc) return RC_FX; } // end of DeleteDB +/***********************************************************************/ +/* Used by the TBL tables. */ +/***********************************************************************/ +void TDBPRX::RemoveNext(PTABLE tp) + { + tp->Next = NULL; + } // end of RemoveNext + /* ---------------------------- PRXCOL ------------------------------- */ /***********************************************************************/ diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index 48e97bd49ec..3a5946bae8f 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -95,6 +95,7 @@ class DllExport TDBPRX : public TDBASE { virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g) {if (Tdbp) Tdbp->CloseDB(g);} PTDB GetSubTable(PGLOBAL g, PTABLE tabp); + void RemoveNext(PTABLE tp); protected: // Members diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index 337a6cefd1d..78998435aa6 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -105,7 +105,6 @@ PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode) /***********************************************************************/ TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp) { -//Tdbp = NULL; // The physical table Xcolumn = tdp->Xcol; // CSV column name Xcolp = NULL; // To the XCVCOL column Mult = tdp->Mult; // Multiplication factor @@ -222,28 +221,6 @@ bool TDBXCL::OpenDB(PGLOBAL g) if (Tdbp->OpenDB(g)) return TRUE; -#if 0 - /*********************************************************************/ - /* Check for direct access. */ - /*********************************************************************/ - if (To_Key_Col) - if (!Tdbp->GetDef()->Indexable()) { - strcpy(g->Message, "Object table is not indexable"); - return TRUE; - } else { - ((PTDBX)Tdbp)->To_Key_Col = To_Key_Col; - ((PTDBX)Tdbp)->To_Link = To_Link; - ((PTDBX)Tdbp)->Knum = Knum; - To_Kindex = (PKXBASE)new(g) KINDEX(Tdbp); - - if (To_Kindex->Init(g)) - return TRUE; - - ((PKINDEX)To_Kindex)->SetMult(Mult); - Tdbp->SetKindex(To_Kindex); - } // endif Indexable -#endif // 0 - return FALSE; } // end of OpenDB @@ -332,45 +309,3 @@ void XCLCOL::ReadColumn(PGLOBAL g) ((PTDBXCL)To_Tdb)->RowFlag = 1; } // end of ReadColumn - -#if 0 -/* -------------- Implementation of the MULINDX class ---------------- */ - -/***********************************************************************/ -/* Returns FALSE if Ok, TRUE if there are no more equal values. */ -/***********************************************************************/ -bool MULINDX::HaveSame(void) - { - return (Op == OP_SAME || Txlp->RowFlag == 1); - } // end of HaveSame - -/***********************************************************************/ -/* Returns FALSE if Ok, TRUE if there are no more equal values. */ -/***********************************************************************/ -bool MULINDX::NextVal(bool eq) - { - return (Pof) ? KINDEX::NextVal(eq) : TRUE; - } // end of NextVal - -/***********************************************************************/ -/* Returns TRUE if there are more same values. */ -/***********************************************************************/ -bool MULINDX::MoreVal(void) - { - Op = OP_SAME; // There may be more equal values - return (Pof) ? Pof[Val_K] : Val_K; - } // end of MoreVal - -/***********************************************************************/ -/* Change the index multiple status. */ -/***********************************************************************/ -bool MULINDX::Init(PGLOBAL g) - { - if (KINDEX::Init(g)) - return TRUE; - - Mul = TRUE; - MaxSame *= Txlp->Mult; - return FALSE; - } // end of Init -#endif // 0 diff --git a/storage/connect/tabxcl.h b/storage/connect/tabxcl.h index 6db653d5709..79b890c9f55 100644 --- a/storage/connect/tabxcl.h +++ b/storage/connect/tabxcl.h @@ -8,7 +8,6 @@ typedef class XCLDEF *PXCLDEF; typedef class TDBXCL *PTDBXCL; typedef class XCLCOL *PXCLCOL; -//pedef class MULINDX *PMINDX; /* -------------------------- XCOL classes --------------------------- */ @@ -49,7 +48,6 @@ class XCLDEF : public PRXDEF { /* Logical table description */ /* This is the class declaration for the XCSV table. */ /***********************************************************************/ class TDBXCL : public TDBPRX { -//friend class MULINDX; friend class XCLDEF; friend class PRXCOL; friend class XCLCOL; @@ -63,7 +61,6 @@ class TDBXCL : public TDBPRX { // Methods virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} virtual int RowNumber(PGLOBAL g, bool b = FALSE); -//virtual bool HaveSame(void) {return RowFlag == 1;} // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); @@ -106,28 +103,3 @@ class XCLCOL : public PRXCOL { char *Cp; // Pointer to current position char Sep; // The separator }; // end of class XCLCOL - -#if 0 -/* ------------------------- MULINDX classes ------------------------- */ - -/***********************************************************************/ -/* This represents a KINDEX class for an XCOL table. */ -/***********************************************************************/ -class MULINDX : public KINDEX { - public: - // Constructor - MULINDX(PTDBXCL txlp) : KINDEX(txlp->Tdbp) {Txlp = txlp;} - - // Implementation - virtual BOOL HaveSame(void); - - // Methods - virtual BOOL Init(PGLOBAL g); - virtual BOOL NextVal(BOOL eq); - virtual int MoreVal(void); - - protected: - //Member - PTDBXCL Txlp; -}; // end of class MULINDX -#endif // 0 From 6ed00c4d8a90129e7098bcb5fad5b01332e9882c Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Fri, 3 May 2013 00:10:43 +0400 Subject: [PATCH 125/273] MDEV-4465: Reproducible crash (mysqld got signal 11) in multi_delete::initialize_tables... - make multi_delete::initialize_tables() take into account that the JOIN structure may have semi-join nests (which are not fully initialized when this function is called, they have tab->table=NULL which caused the crash) - Also checked multi_update::initialize_tables(): it has a different logic and needed no fixing. --- mysql-test/r/subselect_mat.result | 14 ++++++++++++++ mysql-test/r/subselect_sj_mat.result | 14 ++++++++++++++ mysql-test/t/subselect_sj_mat.test | 19 +++++++++++++++++++ sql/sql_delete.cc | 2 +- 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result index 53334dbc32b..0a98efb5c0e 100644 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@ -1999,6 +1999,20 @@ b b v v b b s s b b y y DROP TABLE t1,t2; +# +# MDEV-4465: Reproducible crash (mysqld got signal 11) in multi_delete::initialize_tables with semijoin+materialization +# +CREATE TABLE t1 ( +id int(11) NOT NULL +); +CREATE TABLE t2 ( +id int(11) NOT NULL, +a_id int(11) DEFAULT NULL +); +insert into t1 values (1), (2), (3); +insert into t2 values (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3), (7, 3); +delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as x); +drop table t1,t2; # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result index 549282c9dbe..4e8d1697b83 100644 --- a/mysql-test/r/subselect_sj_mat.result +++ b/mysql-test/r/subselect_sj_mat.result @@ -2039,6 +2039,20 @@ b b v v b b s s b b y y DROP TABLE t1,t2; +# +# MDEV-4465: Reproducible crash (mysqld got signal 11) in multi_delete::initialize_tables with semijoin+materialization +# +CREATE TABLE t1 ( +id int(11) NOT NULL +); +CREATE TABLE t2 ( +id int(11) NOT NULL, +a_id int(11) DEFAULT NULL +); +insert into t1 values (1), (2), (3); +insert into t2 values (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3), (7, 3); +delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as x); +drop table t1,t2; # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index 4c40b2b5487..711f2f4f9b6 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -1677,6 +1677,25 @@ SELECT * FROM t1, t2 WHERE b1 IN ( SELECT b2 FROM t2 WHERE b1 > 'o' ) AND ( b1 < DROP TABLE t1,t2; +--echo # +--echo # MDEV-4465: Reproducible crash (mysqld got signal 11) in multi_delete::initialize_tables with semijoin+materialization +--echo # +CREATE TABLE t1 ( + id int(11) NOT NULL +); + +CREATE TABLE t2 ( + id int(11) NOT NULL, + a_id int(11) DEFAULT NULL +); + +insert into t1 values (1), (2), (3); +insert into t2 values (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3), (7, 3); + +delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as x); + +drop table t1,t2; + --echo # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 3c245807b47..64fd33bbc2c 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -677,7 +677,7 @@ multi_delete::initialize_tables(JOIN *join) tab; tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { - if (tab->table->map & tables_to_delete_from) + if (!tab->bush_children && tab->table->map & tables_to_delete_from) { /* We are going to delete from this table */ TABLE *tbl=walk->table=tab->table; From 682c8a36ca503f53db50628463424f205b609ab0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 May 2013 16:07:13 +0300 Subject: [PATCH 126/273] MDEV-4290: Fix agregate function resolution in derived tables (no name resolution over a derived table border) --- mysql-test/r/func_group.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/func_group.test | 24 ++++++++++++++++++++++++ sql/item.h | 6 ++++++ sql/item_sum.cc | 21 ++++++++++++++++----- sql/sql_lex.cc | 1 + sql/sql_lex.h | 3 +++ 6 files changed, 78 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index bd77f800f67..5fa37f577e9 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -2097,3 +2097,31 @@ avg(export_set( 3, 'y', sha(i))) group_concat(d) 0 2008-10-02 0 2010-12-12 drop table t1; +# +# MDEV-4290: crash in st_select_lex::mark_as_dependent +# +create table `t1`(`a` int); +select 1 from t1 v1 right join t1 on count(*); +ERROR HY000: Invalid use of group function +select 1 from t1 order by +( +select 1 from +( +select 1 from t1 v1 right join t1 on count(*) +) v +); +ERROR HY000: Invalid use of group function +insert into t1 values (1),(1),(2),(2); +select count(*) from t1; +count(*) +4 +select z from (select count(*) as z from t1) v; +z +4 +# next is how it implemented now (may be changed in case of dependent +# derived tables) +select z from (select count(*) as z from t1) v group by 1; +z +4 +drop table t1; +# end of 5.3 tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index fef4d3b1de2..9f0d7e102da 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1380,3 +1380,27 @@ insert into t1 values (1, '2008-10-02'), (2, '2010-12-12'); select avg(export_set( 3, 'y', sha(i))), group_concat(d) from t1 group by d order by i; drop table t1; +--echo # +--echo # MDEV-4290: crash in st_select_lex::mark_as_dependent +--echo # +create table `t1`(`a` int); + +--error ER_INVALID_GROUP_FUNC_USE +select 1 from t1 v1 right join t1 on count(*); +--error ER_INVALID_GROUP_FUNC_USE +select 1 from t1 order by +( + select 1 from + ( + select 1 from t1 v1 right join t1 on count(*) + ) v +); +insert into t1 values (1),(1),(2),(2); +select count(*) from t1; +select z from (select count(*) as z from t1) v; +--echo # next is how it implemented now (may be changed in case of dependent +--echo # derived tables) +select z from (select count(*) as z from t1) v group by 1; +drop table t1; + +--echo # end of 5.3 tests diff --git a/sql/item.h b/sql/item.h index 1e35c7839de..1938273c261 100644 --- a/sql/item.h +++ b/sql/item.h @@ -353,6 +353,12 @@ struct Name_resolution_context: Sql_alloc { (*error_processor)(thd, error_processor_data); } + st_select_lex *outer_select() + { + return (outer_context ? + outer_context->select_lex : + NULL); + } }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 3f2020efeb5..489c0f1c23e 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -53,7 +53,15 @@ bool Item_sum::init_sum_func_check(THD *thd) { - if (!thd->lex->allow_sum_func) + SELECT_LEX *curr_sel= thd->lex->current_select; + if (!curr_sel->name_visibility_map) + { + for (SELECT_LEX *sl= curr_sel; sl; sl= sl->context.outer_select()) + { + curr_sel->name_visibility_map|= (1 << sl-> nest_level); + } + } + if (!(thd->lex->allow_sum_func & curr_sel->name_visibility_map)) { my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE), MYF(0)); @@ -124,8 +132,11 @@ bool Item_sum::init_sum_func_check(THD *thd) bool Item_sum::check_sum_func(THD *thd, Item **ref) { + SELECT_LEX *curr_sel= thd->lex->current_select; + nesting_map allow_sum_func= (thd->lex->allow_sum_func & + curr_sel->name_visibility_map); bool invalid= FALSE; - nesting_map allow_sum_func= thd->lex->allow_sum_func; + DBUG_ASSERT(curr_sel->name_visibility_map); // should be set already /* The value of max_arg_level is updated if an argument of the set function contains a column reference resolved against a subquery whose level is @@ -158,7 +169,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) if (!invalid && aggr_level < 0) { aggr_level= nest_level; - aggr_sel= thd->lex->current_select; + aggr_sel= curr_sel; } /* By this moment we either found a subquery where the set function is @@ -295,9 +306,9 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref) { SELECT_LEX *sl; nesting_map allow_sum_func= thd->lex->allow_sum_func; - for (sl= thd->lex->current_select->master_unit()->outer_select() ; + for (sl= thd->lex->current_select->context.outer_select() ; sl && sl->nest_level > max_arg_level; - sl= sl->master_unit()->outer_select() ) + sl= sl->context.outer_select()) { if (aggr_level < 0 && (allow_sum_func & (1 << sl->nest_level))) { diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5bacb675644..ab50ad99c28 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1690,6 +1690,7 @@ void st_select_lex::init_select() merged_into= 0; m_non_agg_field_used= false; m_agg_func_used= false; + name_visibility_map= 0; } /* diff --git a/sql/sql_lex.h b/sql/sql_lex.h index a3240d3bcab..4b4496a7df8 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -783,6 +783,9 @@ public: */ List *prev_join_using; + /* namp of nesting SELECT visibility (for aggregate functions check) */ + nesting_map name_visibility_map; + void init_query(); void init_select(); st_select_lex_unit* master_unit(); From b3720ff7553ced6208737482d3410183cab4a545 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 4 May 2013 00:56:50 +0400 Subject: [PATCH 127/273] MDEV-621: LP:693329 - Assertion `!is_interleave_error' failed on low optimizer_search_depth - When restore_prev_nj_state() is called for the table that is the last remaining child of a nested join, do not leave that nested join's bit in join->cur_embedding_map. --- mysql-test/r/join_nested.result | 24 ++++++++++++++++++++++++ mysql-test/t/join_nested.test | 24 ++++++++++++++++++++++++ sql/sql_select.cc | 4 ++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result index 255714a7236..84b6ff640e9 100644 --- a/mysql-test/r/join_nested.result +++ b/mysql-test/r/join_nested.result @@ -1847,3 +1847,27 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` A DROP TABLE t1,t2,t3,t4; SET optimizer_switch=@save_optimizer_switch; End of 5.0 tests +# +# MDEV-621: LP:693329 - Assertion `!is_interleave_error' failed on low optimizer_search_depth +# +set @tmp_mdev621= @@optimizer_search_depth; +SET SESSION optimizer_search_depth = 4; +CREATE TABLE t1 (f1 int,f2 int,f3 int,f4 int) ; +INSERT IGNORE INTO t1 VALUES (0,0,2,0),(NULL,0,2,0); +CREATE TABLE t2 (f1 int) ; +CREATE TABLE t3 (f3 int,PRIMARY KEY (f3)) ; +CREATE TABLE t4 (f5 int) ; +CREATE TABLE t5 (f2 int) ; +SELECT alias2.f4 FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +LEFT JOIN t2 AS alias3 +LEFT JOIN t3 AS alias4 ON alias3.f1 = alias4.f3 +ON alias2.f1 +LEFT JOIN t4 AS alias5 +JOIN t5 ON alias5.f5 +ON alias2.f3 ON alias1.f2; +f4 +NULL +NULL +DROP TABLE t1,t2,t3,t4,t5; +set optimizer_search_depth= @tmp_mdev621; diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test index 3168e95f620..7b7d9236835 100644 --- a/mysql-test/t/join_nested.test +++ b/mysql-test/t/join_nested.test @@ -1287,3 +1287,27 @@ SET optimizer_switch=@save_optimizer_switch; --echo End of 5.0 tests +--echo # +--echo # MDEV-621: LP:693329 - Assertion `!is_interleave_error' failed on low optimizer_search_depth +--echo # +set @tmp_mdev621= @@optimizer_search_depth; +SET SESSION optimizer_search_depth = 4; + +CREATE TABLE t1 (f1 int,f2 int,f3 int,f4 int) ; +INSERT IGNORE INTO t1 VALUES (0,0,2,0),(NULL,0,2,0); +CREATE TABLE t2 (f1 int) ; +CREATE TABLE t3 (f3 int,PRIMARY KEY (f3)) ; +CREATE TABLE t4 (f5 int) ; +CREATE TABLE t5 (f2 int) ; + +SELECT alias2.f4 FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 + LEFT JOIN t2 AS alias3 + LEFT JOIN t3 AS alias4 ON alias3.f1 = alias4.f3 + ON alias2.f1 +LEFT JOIN t4 AS alias5 + JOIN t5 ON alias5.f5 +ON alias2.f3 ON alias1.f2; +DROP TABLE t1,t2,t3,t4,t5; +set optimizer_search_depth= @tmp_mdev621; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6d80ea8d212..4843d7be400 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13262,13 +13262,13 @@ static void restore_prev_nj_state(JOIN_TAB *last) bool was_fully_covered= nest->is_fully_covered(); + join->cur_embedding_map|= nest->nj_map; + if (--nest->counter == 0) join->cur_embedding_map&= ~nest->nj_map; if (!was_fully_covered) break; - - join->cur_embedding_map|= nest->nj_map; } } } From c0ca15ab9c4c1838dfe89568391cdf40ed5fb1b6 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 4 May 2013 01:08:20 +0400 Subject: [PATCH 128/273] MDEV-4270: crash in fix_semijoin_strategies_for_picked_join_order - Added testcase --- mysql-test/r/join_outer_innodb.result | 22 ++++++++++++++++++++++ mysql-test/t/join_outer_innodb.test | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/mysql-test/r/join_outer_innodb.result b/mysql-test/r/join_outer_innodb.result index 0184e236d14..1081fc0eed3 100644 --- a/mysql-test/r/join_outer_innodb.result +++ b/mysql-test/r/join_outer_innodb.result @@ -476,3 +476,25 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t10 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) drop view v1; drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16; +# +# MDEV-4270: crash in fix_semijoin_strategies_for_picked_join_order +# +drop table if exists t1,t2,t3; +Warnings: +Note 1051 Unknown table 't1' +Note 1051 Unknown table 't2' +Note 1051 Unknown table 't3' +create table t2(a int,unique key (a)) engine=innodb; +create table t3(b int) engine=innodb; +create table t1(a int,b int)engine=innodb; +set @mdev4270_opl= @@optimizer_prune_level; +set @mdev4270_osd= @@optimizer_search_depth; +set optimizer_prune_level=0; +set optimizer_search_depth=2; +select 1 from t1 join t2 a +natural left join t2 b +natural right outer join t3; +1 +drop table t1,t2,t3; +set optimizer_prune_level=@mdev4270_opl; +set optimizer_search_depth=@mdev4270_osd; diff --git a/mysql-test/t/join_outer_innodb.test b/mysql-test/t/join_outer_innodb.test index adb555d5f85..539d85a8b11 100644 --- a/mysql-test/t/join_outer_innodb.test +++ b/mysql-test/t/join_outer_innodb.test @@ -350,3 +350,26 @@ explain select * from v1; drop view v1; drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16; + + +--echo # +--echo # MDEV-4270: crash in fix_semijoin_strategies_for_picked_join_order +--echo # +drop table if exists t1,t2,t3; +create table t2(a int,unique key (a)) engine=innodb; +create table t3(b int) engine=innodb; +create table t1(a int,b int)engine=innodb; + +set @mdev4270_opl= @@optimizer_prune_level; +set @mdev4270_osd= @@optimizer_search_depth; +set optimizer_prune_level=0; +set optimizer_search_depth=2; + +select 1 from t1 join t2 a +natural left join t2 b +natural right outer join t3; + +drop table t1,t2,t3; +set optimizer_prune_level=@mdev4270_opl; +set optimizer_search_depth=@mdev4270_osd; + From 5fc19f8db85af67efac58c3710933aa6c8925e29 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 4 May 2013 00:47:55 +0200 Subject: [PATCH 129/273] - Add test for XCOL and OCCUR tables - Fix a bug causing a crash when doing an ALTER TABLE (because create_info->alias is NULL) added: storage/connect/mysql-test/connect/r/occur.result storage/connect/mysql-test/connect/r/xcol.result storage/connect/mysql-test/connect/t/occur.test storage/connect/mysql-test/connect/t/xcol.test modified: storage/connect/ha_connect.cc --- storage/connect/ha_connect.cc | 28 +- .../connect/mysql-test/connect/r/occur.result | 255 ++++++++++++++++++ .../connect/mysql-test/connect/r/xcol.result | 85 ++++++ .../connect/mysql-test/connect/t/occur.test | 59 ++++ .../connect/mysql-test/connect/t/xcol.test | 28 ++ 5 files changed, 442 insertions(+), 13 deletions(-) create mode 100644 storage/connect/mysql-test/connect/r/occur.result create mode 100644 storage/connect/mysql-test/connect/r/xcol.result create mode 100644 storage/connect/mysql-test/connect/t/occur.test create mode 100644 storage/connect/mysql-test/connect/t/xcol.test diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 7422815223f..2eefd1e20d2 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3801,20 +3801,22 @@ int ha_connect::create(const char *name, TABLE *table_arg, } else dbf= (GetTypeID(options->type) == TAB_DBF && !options->catfunc); - // Check whether a table is defined on itself - switch (type) { - case TAB_PRX: - case TAB_XCL: - case TAB_OCCUR: - if (!stricmp(options->tabname, create_info->alias) && - (!options->dbname || !stricmp(options->dbname, thd->db))) { - sprintf(g->Message, "A %s table cannot refer to itself", - options->type); - my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); - return HA_ERR_INTERNAL_ERROR; - } // endif tab + // Can be null in ALTER TABLE + if (create_info->alias) + // Check whether a table is defined on itself + switch (type) { + case TAB_PRX: + case TAB_XCL: + case TAB_OCCUR: + if (!stricmp(options->tabname, create_info->alias) && + (!options->dbname || !stricmp(options->dbname, thd->db))) { + sprintf(g->Message, "A %s table cannot refer to itself", + options->type); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + return HA_ERR_INTERNAL_ERROR; + } // endif tab - } // endswitch ttp + } // endswitch ttp if (type == TAB_XML) { bool dom; // True: MS-DOM, False libxml2 diff --git a/storage/connect/mysql-test/connect/r/occur.result b/storage/connect/mysql-test/connect/r/occur.result new file mode 100644 index 00000000000..a497dfc9942 --- /dev/null +++ b/storage/connect/mysql-test/connect/r/occur.result @@ -0,0 +1,255 @@ +CREATE TABLE employee ( +serialno CHAR(5) NOT NULL, +name VARCHAR(12) NOT NULL FLAG=6, +sex TINYINT(1) NOT NULL, +title VARCHAR(15) NOT NULL FLAG=20, +manager CHAR(5) DEFAULT NULL, +department CHAR(4) NOT NULL FLAG=41, +secretary CHAR(5) DEFAULT NULL FLAG=46, +salary DOUBLE(8,2) NOT NULL FLAG=52 +) ENGINE=connect TABLE_TYPE=fix FILE_NAME='employee.dat' ENDING=1; +SELECT * FROM employee; +serialno name sex title manager department secretary salary +74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00 +02345 SMITH 1 ENGINEER 31416 2452 11111 9000.00 +78943 MERCHANT 1 SALESMAN 70012 0318 24888 8700.00 +07654 FUNNIGUY 1 ADMINISTRATOR 40567 0319 33333 8500.00 +45678 BUGHAPPY 1 PROGRAMMER 40567 0319 12345 8500.00 +34567 BIGHEAD 1 SCIENTIST 31416 2452 11111 8000.00 +77777 SHRINKY 2 ADMINISTRATOR 70012 0318 27845 7500.00 +74234 WALTER 1 ENGINEER 70012 0318 24888 7400.00 +56789 FODDERMAN 1 SALESMAN 40567 0319 12345 7000.00 +73452 TONGHO 1 ENGINEER 70012 0318 24888 6800.00 +22222 SHORTSIGHT 2 SECRETARY 87777 0021 NULL 5500.00 +55555 MESSIFUL 2 SECRETARY 40567 0319 12345 5000.50 +27845 HONEY 2 SECRETARY 70012 0318 24888 4900.00 +98765 GOOSEPEN 1 ADMINISTRATOR 07654 0319 33333 4700.00 +11111 CHERRY 2 SECRETARY 31416 2452 NULL 4500.00 +33333 MONAPENNY 2 SECRETARY 07654 0319 NULL 3800.00 +12345 KITTY 2 TYPIST 40567 0319 NULL 3000.45 +24888 PLUMHEAD 2 TYPIST 27845 0318 NULL 2800.00 +87777 STRONG 1 DIRECTOR NULL 0021 22222 23000.00 +76543 BULLOZER 1 SALESMAN 40567 0319 12345 14800.00 +70012 WERTHER 1 DIRECTOR 87777 0318 27845 14500.00 +40567 QUINN 1 DIRECTOR 87777 0319 55555 14000.00 +31416 ORELLY 1 ENGINEER 87777 2452 11111 13400.00 +36666 BIGHORN 1 SCIENTIST 31416 2452 11111 11000.00 +00137 BROWNY 1 ENGINEER 40567 0319 12345 10500.00 +73111 WHEELFOR 1 SALESMAN 70012 0318 24888 10030.00 +00023 MARTIN 1 ENGINEER 40567 0319 12345 10000.00 +CREATE TABLE occurs (name CHAR(12), sex CHAR(1), title CHAR(15), department CHAR(4), salary DOUBLE(8,2), id_of CHAR(12), id CHAR(5) NOT NULL) ENGINE=CONNECT TABLE_TYPE=OCCUR TABNAME=employee OPTION_LIST='OccurCol=ID,RankCol=ID_OF,Colist=serialno;manager;secretary,port=PORT';; +SELECT * FROM occurs; +name sex title department salary id_of id +BANCROFT 2 SALESMAN 0318 9600.00 serialno 74200 +BANCROFT 2 SALESMAN 0318 9600.00 manager 70012 +BANCROFT 2 SALESMAN 0318 9600.00 secretary 24888 +SMITH 1 ENGINEER 2452 9000.00 serialno 02345 +SMITH 1 ENGINEER 2452 9000.00 manager 31416 +SMITH 1 ENGINEER 2452 9000.00 secretary 11111 +MERCHANT 1 SALESMAN 0318 8700.00 serialno 78943 +MERCHANT 1 SALESMAN 0318 8700.00 manager 70012 +MERCHANT 1 SALESMAN 0318 8700.00 secretary 24888 +FUNNIGUY 1 ADMINISTRATOR 0319 8500.00 serialno 07654 +FUNNIGUY 1 ADMINISTRATOR 0319 8500.00 manager 40567 +FUNNIGUY 1 ADMINISTRATOR 0319 8500.00 secretary 33333 +BUGHAPPY 1 PROGRAMMER 0319 8500.00 serialno 45678 +BUGHAPPY 1 PROGRAMMER 0319 8500.00 manager 40567 +BUGHAPPY 1 PROGRAMMER 0319 8500.00 secretary 12345 +BIGHEAD 1 SCIENTIST 2452 8000.00 serialno 34567 +BIGHEAD 1 SCIENTIST 2452 8000.00 manager 31416 +BIGHEAD 1 SCIENTIST 2452 8000.00 secretary 11111 +SHRINKY 2 ADMINISTRATOR 0318 7500.00 serialno 77777 +SHRINKY 2 ADMINISTRATOR 0318 7500.00 manager 70012 +SHRINKY 2 ADMINISTRATOR 0318 7500.00 secretary 27845 +WALTER 1 ENGINEER 0318 7400.00 serialno 74234 +WALTER 1 ENGINEER 0318 7400.00 manager 70012 +WALTER 1 ENGINEER 0318 7400.00 secretary 24888 +FODDERMAN 1 SALESMAN 0319 7000.00 serialno 56789 +FODDERMAN 1 SALESMAN 0319 7000.00 manager 40567 +FODDERMAN 1 SALESMAN 0319 7000.00 secretary 12345 +TONGHO 1 ENGINEER 0318 6800.00 serialno 73452 +TONGHO 1 ENGINEER 0318 6800.00 manager 70012 +TONGHO 1 ENGINEER 0318 6800.00 secretary 24888 +SHORTSIGHT 2 SECRETARY 0021 5500.00 serialno 22222 +SHORTSIGHT 2 SECRETARY 0021 5500.00 manager 87777 +MESSIFUL 2 SECRETARY 0319 5000.50 serialno 55555 +MESSIFUL 2 SECRETARY 0319 5000.50 manager 40567 +MESSIFUL 2 SECRETARY 0319 5000.50 secretary 12345 +HONEY 2 SECRETARY 0318 4900.00 serialno 27845 +HONEY 2 SECRETARY 0318 4900.00 manager 70012 +HONEY 2 SECRETARY 0318 4900.00 secretary 24888 +GOOSEPEN 1 ADMINISTRATOR 0319 4700.00 serialno 98765 +GOOSEPEN 1 ADMINISTRATOR 0319 4700.00 manager 07654 +GOOSEPEN 1 ADMINISTRATOR 0319 4700.00 secretary 33333 +CHERRY 2 SECRETARY 2452 4500.00 serialno 11111 +CHERRY 2 SECRETARY 2452 4500.00 manager 31416 +MONAPENNY 2 SECRETARY 0319 3800.00 serialno 33333 +MONAPENNY 2 SECRETARY 0319 3800.00 manager 07654 +KITTY 2 TYPIST 0319 3000.45 serialno 12345 +KITTY 2 TYPIST 0319 3000.45 manager 40567 +PLUMHEAD 2 TYPIST 0318 2800.00 serialno 24888 +PLUMHEAD 2 TYPIST 0318 2800.00 manager 27845 +STRONG 1 DIRECTOR 0021 23000.00 serialno 87777 +STRONG 1 DIRECTOR 0021 23000.00 secretary 22222 +BULLOZER 1 SALESMAN 0319 14800.00 serialno 76543 +BULLOZER 1 SALESMAN 0319 14800.00 manager 40567 +BULLOZER 1 SALESMAN 0319 14800.00 secretary 12345 +WERTHER 1 DIRECTOR 0318 14500.00 serialno 70012 +WERTHER 1 DIRECTOR 0318 14500.00 manager 87777 +WERTHER 1 DIRECTOR 0318 14500.00 secretary 27845 +QUINN 1 DIRECTOR 0319 14000.00 serialno 40567 +QUINN 1 DIRECTOR 0319 14000.00 manager 87777 +QUINN 1 DIRECTOR 0319 14000.00 secretary 55555 +ORELLY 1 ENGINEER 2452 13400.00 serialno 31416 +ORELLY 1 ENGINEER 2452 13400.00 manager 87777 +ORELLY 1 ENGINEER 2452 13400.00 secretary 11111 +BIGHORN 1 SCIENTIST 2452 11000.00 serialno 36666 +BIGHORN 1 SCIENTIST 2452 11000.00 manager 31416 +BIGHORN 1 SCIENTIST 2452 11000.00 secretary 11111 +BROWNY 1 ENGINEER 0319 10500.00 serialno 00137 +BROWNY 1 ENGINEER 0319 10500.00 manager 40567 +BROWNY 1 ENGINEER 0319 10500.00 secretary 12345 +WHEELFOR 1 SALESMAN 0318 10030.00 serialno 73111 +WHEELFOR 1 SALESMAN 0318 10030.00 manager 70012 +WHEELFOR 1 SALESMAN 0318 10030.00 secretary 24888 +MARTIN 1 ENGINEER 0319 10000.00 serialno 00023 +MARTIN 1 ENGINEER 0319 10000.00 manager 40567 +MARTIN 1 ENGINEER 0319 10000.00 secretary 12345 +DROP TABLE occurs; +DROP TABLE employee; +CREATE TABLE pets ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0, +cat INT NOT NULL DEFAULT 0, +rabbit INT NOT NULL DEFAULT 0, +bird INT NOT NULL DEFAULT 0, +fish INT NOT NULL DEFAULT 0) ENGINE=MYISAM; +INSERT INTO pets(name,dog) VALUES('John',2); +INSERT INTO pets(name,cat) VALUES('Bill',1); +INSERT INTO pets(name,dog,cat) VALUES('Mary',1,1); +INSERT INTO pets(name,rabbit) VALUES('Lisbeth',2); +INSERT INTO pets(name,cat,bird) VALUES('Kevin',2,6); +INSERT INTO pets(name,dog,fish) VALUES('Donald',1,3); +SELECT * FROM pets; +name dog cat rabbit bird fish +John 2 0 0 0 0 +Bill 0 1 0 0 0 +Mary 1 1 0 0 0 +Lisbeth 0 0 2 0 0 +Kevin 0 2 0 6 0 +Donald 1 0 0 0 3 +CREATE TABLE xpet (name VARCHAR(12) NOT NULL, race CHAR(6) NOT NULL, number INT) ENGINE=CONNECT TABLE_TYPE=OCCUR TABNAME=pets OPTION_LIST='OccurCol=number,RankCol=race,Colist=dog;cat;rabbit;bird;fish,port=PORT'; +SELECT * FROM xpet; +name race number +John dog 2 +John cat 0 +John rabbit 0 +John bird 0 +John fish 0 +Bill dog 0 +Bill cat 1 +Bill rabbit 0 +Bill bird 0 +Bill fish 0 +Mary dog 1 +Mary cat 1 +Mary rabbit 0 +Mary bird 0 +Mary fish 0 +Lisbeth dog 0 +Lisbeth cat 0 +Lisbeth rabbit 2 +Lisbeth bird 0 +Lisbeth fish 0 +Kevin dog 0 +Kevin cat 2 +Kevin rabbit 0 +Kevin bird 6 +Kevin fish 0 +Donald dog 1 +Donald cat 0 +Donald rabbit 0 +Donald bird 0 +Donald fish 3 +SELECT name FROM xpet; +name +John +Bill +Mary +Lisbeth +Kevin +Donald +SELECT name FROM xpet WHERE race = 'cat' AND number = 0; +name +John +Lisbeth +Donald +SELECT name, SUM(number) pets FROM xpet GROUP BY name; +name pets +Bill 1 +Donald 4 +John 2 +Kevin 8 +Lisbeth 2 +Mary 2 +ALTER TABLE xpet MODIFY number INT NOT NULL; +SELECT * FROM xpet; +name race number +John dog 2 +Bill cat 1 +Mary dog 1 +Mary cat 1 +Lisbeth rabbit 2 +Kevin cat 2 +Kevin bird 6 +Donald dog 1 +Donald fish 3 +SELECT * FROM xpet WHERE number > 1; +name race number +John dog 2 +Lisbeth rabbit 2 +Kevin cat 2 +Kevin bird 6 +Donald fish 3 +SELECT DISTINCT name FROM xpet WHERE number > 1; +name +John +Lisbeth +Kevin +Donald +SELECT name FROM xpet; +name +John +Bill +Mary +Lisbeth +Kevin +Donald +SELECT name, race FROM xpet; +name race +John +Bill +Mary +Lisbeth +Kevin +Donald +SELECT name, count(*) FROM xpet GROUP BY name, LEAST(number,1); +name count(*) +Bill 1 +Donald 2 +John 1 +Kevin 2 +Lisbeth 1 +Mary 2 +SELECT name, number, count(*) FROM xpet GROUP BY name, number; +name number count(*) +Bill 1 1 +Donald 1 1 +Donald 3 1 +John 2 1 +Kevin 2 1 +Kevin 6 1 +Lisbeth 2 1 +Mary 1 2 +DROP TABLE xpet; +DROP TABLE pets; diff --git a/storage/connect/mysql-test/connect/r/xcol.result b/storage/connect/mysql-test/connect/r/xcol.result new file mode 100644 index 00000000000..f6899b47504 --- /dev/null +++ b/storage/connect/mysql-test/connect/r/xcol.result @@ -0,0 +1,85 @@ +# +# Checking XCOL tables +# +CREATE TABLE chlist ( +mother char(12) NOT NULL COMMENT 'The mother of the listed children', +children varchar(30) DEFAULT NULL COMMENT 'The comma separated list of children' +) ENGINE=CONNECT; +Warnings: +Warning 1105 No table_type. Will be set to DOS +Warning 1105 No file name. Table will use chlist.dos +INSERT INTO chlist VALUES('Sophia','Vivian, Antony'); +INSERT INTO chlist VALUES('Lisbeth','Lucy,Charles,Diana'); +INSERT INTO chlist VALUES('Corinne',NULL); +INSERT INTO chlist VALUES('Claude','Marc'); +INSERT INTO chlist VALUES('Janet','Arthur,Sandra,Peter,John'); +SELECT * FROM chlist; +mother children +Sophia Vivian, Antony +Lisbeth Lucy,Charles,Diana +Corinne NULL +Claude Marc +Janet Arthur,Sandra,Peter,John +CREATE TABLE child ENGINE=CONNECT TABLE_TYPE=XCOL TABNAME=chlist OPTION_LIST='colname=children,port=PORT'; +SELECT * FROM child; +mother children +Sophia Vivian +Sophia Antony +Lisbeth Lucy +Lisbeth Charles +Lisbeth Diana +Corinne NULL +Claude Marc +Janet Arthur +Janet Sandra +Janet Peter +Janet John +SELECT * FROM child ORDER BY mother; +mother children +Claude Marc +Corinne NULL +Janet Peter +Janet Sandra +Janet Arthur +Janet John +Lisbeth Diana +Lisbeth Charles +Lisbeth Lucy +Sophia Antony +Sophia Vivian +SELECT * FROM child ORDER BY children; +mother children +Corinne NULL +Sophia Antony +Janet Arthur +Lisbeth Charles +Lisbeth Diana +Janet John +Lisbeth Lucy +Claude Marc +Janet Peter +Janet Sandra +Sophia Vivian +SELECT mother FROM child; +mother +Sophia +Lisbeth +Corinne +Claude +Janet +SELECT mother, COUNT(*) FROM child GROUP BY mother; +mother COUNT(*) +Claude 1 +Corinne 1 +Janet 1 +Lisbeth 1 +Sophia 1 +SELECT mother, COUNT(children) FROM child GROUP BY mother; +mother COUNT(children) +Claude 1 +Corinne 0 +Janet 4 +Lisbeth 3 +Sophia 2 +DROP TABLE child; +DROP TABLE chlist; diff --git a/storage/connect/mysql-test/connect/t/occur.test b/storage/connect/mysql-test/connect/t/occur.test new file mode 100644 index 00000000000..5b237742fd8 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/occur.test @@ -0,0 +1,59 @@ +let $MYSQLD_DATADIR= `select @@datadir`; +let $PORT= `select @@port`; +--copy_file $MTR_SUITE_DIR/std_data/employee.dat $MYSQLD_DATADIR/test/employee.dat + +CREATE TABLE employee ( +serialno CHAR(5) NOT NULL, +name VARCHAR(12) NOT NULL FLAG=6, +sex TINYINT(1) NOT NULL, +title VARCHAR(15) NOT NULL FLAG=20, +manager CHAR(5) DEFAULT NULL, +department CHAR(4) NOT NULL FLAG=41, +secretary CHAR(5) DEFAULT NULL FLAG=46, +salary DOUBLE(8,2) NOT NULL FLAG=52 +) ENGINE=connect TABLE_TYPE=fix FILE_NAME='employee.dat' ENDING=1; +SELECT * FROM employee; + +--replace_result $PORT PORT +--eval CREATE TABLE occurs (name CHAR(12), sex CHAR(1), title CHAR(15), department CHAR(4), salary DOUBLE(8,2), id_of CHAR(12), id CHAR(5) NOT NULL) ENGINE=CONNECT TABLE_TYPE=OCCUR TABNAME=employee OPTION_LIST='OccurCol=ID,RankCol=ID_OF,Colist=serialno;manager;secretary,port=$PORT'; +SELECT * FROM occurs; + +DROP TABLE occurs; +DROP TABLE employee; + +CREATE TABLE pets ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0, +cat INT NOT NULL DEFAULT 0, +rabbit INT NOT NULL DEFAULT 0, +bird INT NOT NULL DEFAULT 0, +fish INT NOT NULL DEFAULT 0) ENGINE=MYISAM; +INSERT INTO pets(name,dog) VALUES('John',2); +INSERT INTO pets(name,cat) VALUES('Bill',1); +INSERT INTO pets(name,dog,cat) VALUES('Mary',1,1); +INSERT INTO pets(name,rabbit) VALUES('Lisbeth',2); +INSERT INTO pets(name,cat,bird) VALUES('Kevin',2,6); +INSERT INTO pets(name,dog,fish) VALUES('Donald',1,3); +SELECT * FROM pets; + +--replace_result $PORT PORT +--eval CREATE TABLE xpet (name VARCHAR(12) NOT NULL, race CHAR(6) NOT NULL, number INT) ENGINE=CONNECT TABLE_TYPE=OCCUR TABNAME=pets OPTION_LIST='OccurCol=number,RankCol=race,Colist=dog;cat;rabbit;bird;fish,port=$PORT' + +SELECT * FROM xpet; +SELECT name FROM xpet; +SELECT name FROM xpet WHERE race = 'cat' AND number = 0; +SELECT name, SUM(number) pets FROM xpet GROUP BY name; + +ALTER TABLE xpet MODIFY number INT NOT NULL; + +SELECT * FROM xpet; +SELECT * FROM xpet WHERE number > 1; +SELECT DISTINCT name FROM xpet WHERE number > 1; +SELECT name FROM xpet; +SELECT name, race FROM xpet; +SELECT name, count(*) FROM xpet GROUP BY name, LEAST(number,1); +SELECT name, number, count(*) FROM xpet GROUP BY name, number; + +DROP TABLE xpet; +DROP TABLE pets; +--remove_file $MYSQLD_DATADIR/test/employee.dat diff --git a/storage/connect/mysql-test/connect/t/xcol.test b/storage/connect/mysql-test/connect/t/xcol.test new file mode 100644 index 00000000000..b6998ee77e0 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/xcol.test @@ -0,0 +1,28 @@ +let $MYSQLD_DATADIR= `select @@datadir`; +let $PORT= `select @@port`; + +--echo # +--echo # Checking XCOL tables +--echo # +CREATE TABLE chlist ( +mother char(12) NOT NULL COMMENT 'The mother of the listed children', +children varchar(30) DEFAULT NULL COMMENT 'The comma separated list of children' +) ENGINE=CONNECT; +INSERT INTO chlist VALUES('Sophia','Vivian, Antony'); +INSERT INTO chlist VALUES('Lisbeth','Lucy,Charles,Diana'); +INSERT INTO chlist VALUES('Corinne',NULL); +INSERT INTO chlist VALUES('Claude','Marc'); +INSERT INTO chlist VALUES('Janet','Arthur,Sandra,Peter,John'); +SELECT * FROM chlist; + +--replace_result $PORT PORT +--eval CREATE TABLE child ENGINE=CONNECT TABLE_TYPE=XCOL TABNAME=chlist OPTION_LIST='colname=children,port=$PORT' +SELECT * FROM child; +SELECT * FROM child ORDER BY mother; +SELECT * FROM child ORDER BY children; +SELECT mother FROM child; +SELECT mother, COUNT(*) FROM child GROUP BY mother; +SELECT mother, COUNT(children) FROM child GROUP BY mother; + +DROP TABLE child; +DROP TABLE chlist; From b249680fd11f5c9102f7a22cf638f3872d5c2e61 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 3 May 2013 18:45:20 -0700 Subject: [PATCH 130/273] Made consistent handling of the predicates of the form IS NULL in outer joins with that in inner joins. Previously such condition was transformed into the condition = 0 unless the field belonged to an inner table of an outer join. In this case the predicate was interpreted as for any other field. Now if the field in the predicate IS NULL belongs to an inner table of an outer join the predicate is transformed into the disjunction = 0 OR IS NULL. This is fully compatible with the semantics of such predicates in 5.5. --- mysql-test/r/type_datetime.result | 16 +++++++++++++++ mysql-test/t/type_datetime.test | 15 ++++++++++++++ sql/sql_select.cc | 33 +++++++++++++++++++------------ 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 1019462cdb5..e32ee96cc82 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -665,4 +665,20 @@ Warning 1292 Incorrect datetime value: '10:19:31' Warning 1292 Incorrect datetime value: '22:55:23' Warning 1292 Incorrect datetime value: '10:19:31' drop table t1; +# +# Semantics of the condition IS NULL +# when the field belongs to an inner table of an outer join +# +create table t1 (a int, b date not null); +insert t1 values (1, 0), (2, '1999-01-02'); +create table t2 (c int); +insert t2 values (1),(3); +select * from t2 left join t1 on t1.a=t2.c where t1.a is null; +c a b +3 NULL NULL +select * from t2 left join t1 on t1.a=t2.c where t1.b is null; +c a b +1 1 0000-00-00 +3 NULL NULL +drop table t1,t2; End of 5.3 tests diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index eeba0ca69e3..77ce606697b 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -471,5 +471,20 @@ insert into t1 values ('2000-12-03','22:55:23'),('2008-05-03','10:19:31'); select case when d = '2012-12-12' then d else t end as cond, group_concat( d ) from t1 group by cond; drop table t1; +--echo # +--echo # Semantics of the condition IS NULL +--echo # when the field belongs to an inner table of an outer join +--echo # + +create table t1 (a int, b date not null); +insert t1 values (1, 0), (2, '1999-01-02'); +create table t2 (c int); +insert t2 values (1),(3); + +select * from t2 left join t1 on t1.a=t2.c where t1.a is null; +select * from t2 left join t1 on t1.a=t2.c where t1.b is null; + +drop table t1,t2; + --echo End of 5.3 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 410244b88f0..b5f76608672 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13325,20 +13325,27 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) /* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */ else if (((field->type() == MYSQL_TYPE_DATE) || (field->type() == MYSQL_TYPE_DATETIME)) && - (field->flags & NOT_NULL_FLAG) && - !field->table->maybe_null) + (field->flags & NOT_NULL_FLAG)) { - COND *new_cond; - if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2)))) - { - cond=new_cond; - /* - Item_func_eq can't be fixed after creation so we do not check - cond->fixed, also it do not need tables so we use 0 as second - argument. - */ - cond->fix_fields(thd, &cond); - } + COND *eq_cond; + if (!(eq_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2)))) + return cond; + + if (field->table->pos_in_table_list->outer_join) + { + // outer join: transform "col IS NULL" to "col IS NULL or col=0" + Item *or_cond= new Item_cond_or(eq_cond, cond); + if (!or_cond) + return cond; + cond= or_cond; + } + else + { + // not outer join: transform "col IS NULL" to "col=0" + cond= eq_cond; + } + + cond->fix_fields(thd, &cond); } } if (cond->const_item() && !cond->is_expensive()) From 920c479c6ebd2236dbe5510e5ed8b748bf0ee158 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 3 May 2013 22:46:45 -0700 Subject: [PATCH 131/273] Fixed bug mdev-4336. When iterating over a list of conditions using List_iterator the function remove_eq_conds should skip all predicates that replace a condition from the list. Otherwise it can come to an infinite recursion. --- mysql-test/r/join_outer.result | 14 ++++++++++++++ mysql-test/r/join_outer_jcl6.result | 14 ++++++++++++++ mysql-test/t/join_outer.test | 17 +++++++++++++++++ sql/sql_select.cc | 15 ++++++++++++--- 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 7bc95e78041..723b2a88382 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1822,4 +1822,18 @@ b c d 5 8 88 5 8 81 DROP TABLE t1,t2; +# +# Bug mdev-4336: LEFT JOIN with disjunctive +# IS NULL in WHERE +# causes a hang and eventual crash +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +modified datetime NOT NULL, +PRIMARY KEY (id) +); +SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id +WHERE a.modified > b.modified or b.modified IS NULL; +id modified +DROP TABLE t1; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 554e0027a9e..d063720836d 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1833,6 +1833,20 @@ b c d 5 8 88 5 8 81 DROP TABLE t1,t2; +# +# Bug mdev-4336: LEFT JOIN with disjunctive +# IS NULL in WHERE +# causes a hang and eventual crash +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +modified datetime NOT NULL, +PRIMARY KEY (id) +); +SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id +WHERE a.modified > b.modified or b.modified IS NULL; +id modified +DROP TABLE t1; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 69c08cd54bd..8c0ee82e1fa 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1359,4 +1359,21 @@ ORDER BY t1.b; DROP TABLE t1,t2; +--echo # +--echo # Bug mdev-4336: LEFT JOIN with disjunctive +--echo # IS NULL in WHERE +--echo # causes a hang and eventual crash +--echo # + +CREATE TABLE t1 ( + id int(11) NOT NULL, + modified datetime NOT NULL, + PRIMARY KEY (id) +); + +SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id + WHERE a.modified > b.modified or b.modified IS NULL; + +DROP TABLE t1; + SET optimizer_switch=@save_optimizer_switch; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b5f76608672..3ccebf688e2 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13197,7 +13197,8 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) else { Item *list_item; - Item *new_list_item; + Item *new_list_item; + uint cnt= new_item_and_list->elements; List_iterator it(*new_item_and_list); while ((list_item= it++)) { @@ -13211,7 +13212,9 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) it.replace(new_list_item); new_list_item->update_used_tables(); } - li.replace(*new_item_and_list); + li.replace(*new_item_and_list); + for (cnt--; cnt; cnt--) + item= li++; } cond_and_list->concat((List*) cond_equal_items); } @@ -13232,7 +13235,13 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) if (new_item->type() == Item::COND_ITEM && ((Item_cond*) new_item)->functype() == ((Item_cond*) cond)->functype()) - li.replace(*((Item_cond*) new_item)->argument_list()); + { + List *arg_list= ((Item_cond*) new_item)->argument_list(); + uint cnt= arg_list->elements; + li.replace(*arg_list); + for ( cnt--; cnt; cnt--) + item= li++; + } else li.replace(new_item); } From 2a8db1ca59456e8cea3077dc6d1735c10a0b0027 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 4 May 2013 13:05:24 +0400 Subject: [PATCH 132/273] Update testcase result --- mysql-test/r/join_nested_jcl6.result | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mysql-test/r/join_nested_jcl6.result b/mysql-test/r/join_nested_jcl6.result index c744df9e2fe..6b5a50ba978 100644 --- a/mysql-test/r/join_nested_jcl6.result +++ b/mysql-test/r/join_nested_jcl6.result @@ -1858,6 +1858,30 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` A DROP TABLE t1,t2,t3,t4; SET optimizer_switch=@save_optimizer_switch; End of 5.0 tests +# +# MDEV-621: LP:693329 - Assertion `!is_interleave_error' failed on low optimizer_search_depth +# +set @tmp_mdev621= @@optimizer_search_depth; +SET SESSION optimizer_search_depth = 4; +CREATE TABLE t1 (f1 int,f2 int,f3 int,f4 int) ; +INSERT IGNORE INTO t1 VALUES (0,0,2,0),(NULL,0,2,0); +CREATE TABLE t2 (f1 int) ; +CREATE TABLE t3 (f3 int,PRIMARY KEY (f3)) ; +CREATE TABLE t4 (f5 int) ; +CREATE TABLE t5 (f2 int) ; +SELECT alias2.f4 FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +LEFT JOIN t2 AS alias3 +LEFT JOIN t3 AS alias4 ON alias3.f1 = alias4.f3 +ON alias2.f1 +LEFT JOIN t4 AS alias5 +JOIN t5 ON alias5.f5 +ON alias2.f3 ON alias1.f2; +f4 +NULL +NULL +DROP TABLE t1,t2,t3,t4,t5; +set optimizer_search_depth= @tmp_mdev621; CREATE TABLE t5 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); CREATE TABLE t6 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); CREATE TABLE t7 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); From 71422d7b143ae92a1a5802f0669d2d3d9483c2e4 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 4 May 2013 21:02:07 +0400 Subject: [PATCH 133/273] MDEV-389: Wrong result (missing row) with semijoin, join_cache_level>4 ... - Added testcase --- mysql-test/r/subselect_sj.result | 18 ++++++++++++++++++ mysql-test/r/subselect_sj_jcl6.result | 18 ++++++++++++++++++ mysql-test/t/subselect_sj.test | 27 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index 92c626eca61..35c499fa8d4 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -2852,4 +2852,22 @@ field1 o o DROP TABLE t1, t2; +# +# MDEV-389: Wrong result (missing row) with semijoin, join_cache_level>4, LEFT JOIN... +# (testcase only) +# +SET join_cache_level = 5; +SET optimizer_switch = 'semijoin=on'; +CREATE TABLE t1 (a INT NOT NULL, b CHAR(1), KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4,'p'),(1,'q'),(8,'e'); +CREATE TABLE t2 (c INT, d CHAR(1), KEY(c), KEY(d)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (4,'f'),(2,'i'),(5,'h'),(3,'q'),(1,'g'); +SELECT a, COUNT(*) AS cnt +FROM t1 LEFT JOIN t2 ON (d = b) +WHERE a IN ( SELECT c FROM t2 WHERE b > 'k' ) +GROUP BY a ORDER BY a, cnt LIMIT 2; +a cnt +1 1 +4 1 +drop table t1, t2; set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index 04a54c9a371..5148c8e1577 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -2866,6 +2866,24 @@ field1 o o DROP TABLE t1, t2; +# +# MDEV-389: Wrong result (missing row) with semijoin, join_cache_level>4, LEFT JOIN... +# (testcase only) +# +SET join_cache_level = 5; +SET optimizer_switch = 'semijoin=on'; +CREATE TABLE t1 (a INT NOT NULL, b CHAR(1), KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4,'p'),(1,'q'),(8,'e'); +CREATE TABLE t2 (c INT, d CHAR(1), KEY(c), KEY(d)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (4,'f'),(2,'i'),(5,'h'),(3,'q'),(1,'g'); +SELECT a, COUNT(*) AS cnt +FROM t1 LEFT JOIN t2 ON (d = b) +WHERE a IN ( SELECT c FROM t2 WHERE b > 'k' ) +GROUP BY a ORDER BY a, cnt LIMIT 2; +a cnt +1 1 +4 1 +drop table t1, t2; set optimizer_switch=@subselect_sj_tmp; # # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index e2abb8040b3..15ca4ce884e 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -2540,5 +2540,32 @@ WHERE (field1) IN ($query); DROP TABLE t1, t2; +--echo # +--echo # MDEV-389: Wrong result (missing row) with semijoin, join_cache_level>4, LEFT JOIN... +--echo # (testcase only) +--echo # + +# Use another connection to get rid of this test's settings +connect (con1,localhost,root,,); +connection con1; + +SET join_cache_level = 5; +SET optimizer_switch = 'semijoin=on'; + +CREATE TABLE t1 (a INT NOT NULL, b CHAR(1), KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4,'p'),(1,'q'),(8,'e'); + +CREATE TABLE t2 (c INT, d CHAR(1), KEY(c), KEY(d)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (4,'f'),(2,'i'),(5,'h'),(3,'q'),(1,'g'); + +SELECT a, COUNT(*) AS cnt +FROM t1 LEFT JOIN t2 ON (d = b) +WHERE a IN ( SELECT c FROM t2 WHERE b > 'k' ) +GROUP BY a ORDER BY a, cnt LIMIT 2; + +drop table t1, t2; +connection default; +disconnect con1; + # The following command must be the last one the file set optimizer_switch=@subselect_sj_tmp; From ddd341b71ae6b9c2dd206df64c662c0a29730ae9 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 4 May 2013 20:42:43 +0400 Subject: [PATCH 134/273] MDEV-4071: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with ... - Call tmp_having->update_used_tables() *before* we have call JOIN::cleanup(). Making the call after join::cleanup() is not allowed, because subquery predicate items walk parent join's JOIN_TAB structures. Which can be invalidated by JOIN::cleanup(). --- mysql-test/r/subselect_sj.result | 14 ++++++++++++++ mysql-test/r/subselect_sj_jcl6.result | 14 ++++++++++++++ mysql-test/t/subselect_sj.test | 17 +++++++++++++++++ sql/sql_select.cc | 20 ++++++-------------- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index 35c499fa8d4..56c3044c4e4 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -2870,4 +2870,18 @@ a cnt 1 1 4 1 drop table t1, t2; +# +# MDEV-4071: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with ... +# +CREATE TABLE t1 (b INT, c VARCHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,'v'),(0,'s'); +CREATE TABLE t2 (a INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0),(8); +SELECT c, SUM( DISTINCT b ) AS sm FROM t1 +WHERE ( 5, 108 ) IN ( SELECT MIN(a), MAX(a) FROM t2 ) +GROUP BY b +HAVING c <> ( SELECT MAX( c ) FROM t1 ) +ORDER BY sm; +c sm +DROP TABLE t1,t2; set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index 5148c8e1577..7be29201c63 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -2884,6 +2884,20 @@ a cnt 1 1 4 1 drop table t1, t2; +# +# MDEV-4071: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with ... +# +CREATE TABLE t1 (b INT, c VARCHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,'v'),(0,'s'); +CREATE TABLE t2 (a INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0),(8); +SELECT c, SUM( DISTINCT b ) AS sm FROM t1 +WHERE ( 5, 108 ) IN ( SELECT MIN(a), MAX(a) FROM t2 ) +GROUP BY b +HAVING c <> ( SELECT MAX( c ) FROM t1 ) +ORDER BY sm; +c sm +DROP TABLE t1,t2; set optimizer_switch=@subselect_sj_tmp; # # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index 15ca4ce884e..bfdc6335f1d 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -2567,5 +2567,22 @@ drop table t1, t2; connection default; disconnect con1; +--echo # +--echo # MDEV-4071: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with ... +--echo # +CREATE TABLE t1 (b INT, c VARCHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,'v'),(0,'s'); + +CREATE TABLE t2 (a INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0),(8); + +SELECT c, SUM( DISTINCT b ) AS sm FROM t1 +WHERE ( 5, 108 ) IN ( SELECT MIN(a), MAX(a) FROM t2 ) +GROUP BY b +HAVING c <> ( SELECT MAX( c ) FROM t1 ) +ORDER BY sm; + +DROP TABLE t1,t2; + # The following command must be the last one the file set optimizer_switch=@subselect_sj_tmp; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4843d7be400..24f480bbfb9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2367,7 +2367,12 @@ JOIN::exec() List *curr_all_fields= &all_fields; List *curr_fields_list= &fields_list; TABLE *curr_tmp_table= 0; - bool tmp_having_used_tables_updated= FALSE; + /* + curr_join->join_free() will call JOIN::cleanup(full=TRUE). It will not + be safe to call update_used_tables() after that. + */ + if (curr_join->tmp_having) + curr_join->tmp_having->update_used_tables(); /* Initialize examined rows here because the values from all join parts @@ -2618,16 +2623,6 @@ JOIN::exec() curr_join->select_distinct=0; /* Each row is unique */ - /* - curr_join->join_free() will call JOIN::cleanup(full=TRUE). It will not - be safe to call update_used_tables() after that. - */ - if (curr_join->tmp_having) - { - curr_join->tmp_having->update_used_tables(); - tmp_having_used_tables_updated= TRUE; - } - curr_join->join_free(); /* Free quick selects */ if (curr_join->select_distinct && ! curr_join->group_list) @@ -2708,9 +2703,6 @@ JOIN::exec() if (curr_join->tmp_having && ! curr_join->group_list && ! curr_join->sort_and_group) { - // Some tables may have been const - if (!tmp_having_used_tables_updated) - curr_join->tmp_having->update_used_tables(); JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables]; table_map used_tables= (curr_join->const_table_map | curr_table->table->map); From 445fc7ba5d471c99a0fa8d2f5a7b4e755c6575b4 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sun, 5 May 2013 05:27:02 +0400 Subject: [PATCH 135/273] MDEV-4482: main.windows test fails in buildbot with result mismatch - Rollback an earlier patch (was pushed into 5.3 instead of 5.5) --- mysql-test/r/windows.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index d0cdd858d4a..dc624a07f4f 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -16,7 +16,7 @@ CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (1,1); EXPLAIN SELECT * FROM t1 WHERE b = (SELECT max(2)); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 PRIMARY t1 system NULL NULL NULL NULL 1 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used DROP TABLE t1; CREATE DATABASE `TESTDB`; From 495981141118e7b88b75526c494af12888ffcf12 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 5 May 2013 12:45:26 +0200 Subject: [PATCH 136/273] - General code cleaning, eliminating a few potential bugs modified: storage/connect/catalog.h storage/connect/mycat.cc storage/connect/taboccur.cpp storage/connect/taboccur.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabxcl.cpp storage/connect/tabxcl.h --- storage/connect/catalog.h | 4 +-- storage/connect/mycat.cc | 16 ++++----- storage/connect/taboccur.cpp | 2 +- storage/connect/taboccur.h | 6 ++-- storage/connect/tabutil.cpp | 66 +++++++----------------------------- storage/connect/tabutil.h | 28 --------------- storage/connect/tabxcl.cpp | 43 +++++------------------ storage/connect/tabxcl.h | 5 ++- 8 files changed, 34 insertions(+), 136 deletions(-) diff --git a/storage/connect/catalog.h b/storage/connect/catalog.h index 4f0584ef7bc..365169100d9 100644 --- a/storage/connect/catalog.h +++ b/storage/connect/catalog.h @@ -63,7 +63,7 @@ class DllExport CATALOG { // Implementation void *GetDescp(void) {return Descp;} - PRELDEF GetTo_Desc(void) {return To_Desc;} +//PRELDEF GetTo_Desc(void) {return To_Desc;} //PSZ GetDescFile(void) {return DescFile;} int GetCblen(void) {return Cblen;} bool GetDefHuge(void) {return DefHuge;} @@ -115,7 +115,7 @@ class DllExport CATALOG { virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} // Members - PRELDEF To_Desc; /* To chain of relation desc. */ +//PRELDEF To_Desc; /* To chain of relation desc. */ void *Descp; /* To DB description area */ //AREADEF DescArea; /* Table desc. area size */ char *Cbuf; /* Buffer used for col section */ diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index b46c014fba6..badcdcb9514 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -253,7 +253,7 @@ uint GetFuncID(const char *func) /***********************************************************************/ CATALOG::CATALOG(void) { - To_Desc= NULL; +//To_Desc= NULL; //*DescFile= '\0'; #if defined(WIN32) DataPath= ".\\"; @@ -276,7 +276,7 @@ CATALOG::CATALOG(void) MYCAT::MYCAT(PHC hc) : CATALOG() { Hc= hc; - To_Desc= NULL; +//To_Desc= NULL; DefHuge= false; //SepIndex= true; // Temporay until we can store offet and size } // end of MYCAT constructor @@ -286,7 +286,7 @@ MYCAT::MYCAT(PHC hc) : CATALOG() /***********************************************************************/ void MYCAT::Reset(void) { - To_Desc= NULL; +//To_Desc= NULL; } // end of Reset /***********************************************************************/ @@ -586,9 +586,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp) /***********************************************************************/ /* GetTableDesc: retrieve a table descriptor. */ -/* Look for a table descriptor matching the name and type. If found */ -/* in storage, return a pointer to it, else look in the XDB file. If */ -/* found, make and add the descriptor and return a pointer to it. */ +/* Look for a table descriptor matching the name and type. */ /***********************************************************************/ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, PRELDEF *prp) @@ -597,8 +595,8 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, printf("GetTableDesc: name=%s am=%s\n", name, SVP(type)); // Firstly check whether this table descriptor is in memory - if (To_Desc) - return To_Desc; +//if (To_Desc) +// return To_Desc; // If not specified get the type of this table if (!type && !(type= Hc->GetStringOption("Type"))) @@ -707,7 +705,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) /***********************************************************************/ void MYCAT::ClearDB(PGLOBAL g) { - To_Desc= NULL; +//To_Desc= NULL; } // end of ClearDB /* ------------------------ End of MYCAT --------------------------- */ diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 8b7e10f2e34..2f721c6a7cf 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -161,7 +161,7 @@ int TDBOCCUR::MakeColumnList(PGLOBAL g) // Count the number of columns and change separator into null char for (pn = Colist; ; pn += (strlen(pn) + 1)) - if ((p = strchr(pn, ';'))) { + if ((p = strchr(pn, ',')) || (p = strchr(pn, ';'))) { *p++ = '\0'; n++; } else { diff --git a/storage/connect/taboccur.h b/storage/connect/taboccur.h index c0077a0b33e..076202be477 100644 --- a/storage/connect/taboccur.h +++ b/storage/connect/taboccur.h @@ -9,12 +9,11 @@ typedef class OCCURDEF *POCCURDEF; typedef class TDBOCCUR *PTDBOCCUR; typedef class OCCURCOL *POCCURCOL; typedef class RANKCOL *PRANKCOL; -typedef class SRTCOL *PSRTCOL; /* -------------------------- OCCUR classes -------------------------- */ /***********************************************************************/ -/* OCCUR: OEM table that provides a view of a source table where the */ +/* OCCUR: Table that provides a view of a source table where the */ /* contain of several columns of the source table is placed in only */ /* one column, the OCCUR column, this resulting into several rows. */ /***********************************************************************/ @@ -48,7 +47,6 @@ class OCCURDEF : public PRXDEF { /* Logical table description */ class TDBOCCUR : public TDBPRX { friend class OCCURCOL; friend class RANKCOL; - friend class SRTCOL; public: // Constructor TDBOCCUR(POCCURDEF tdp); @@ -116,7 +114,7 @@ class OCCURCOL : public COLBLK { class RANKCOL : public COLBLK { public: // Constructors - RANKCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n) : COLBLK(cdp, tdbp, n) {} + RANKCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n) : COLBLK(cdp, tdbp, n) {} // Implementation virtual int GetAmType(void) {return TYPE_AM_OCCUR;} diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 3829e16b00b..2bd92ff9607 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -1,9 +1,9 @@ -/************* Tabutil cpp Declares Source Code File (.H) **************/ +/************* Tabutil cpp Declares Source Code File (.CPP) ************/ /* Name: TABUTIL.CPP Version 1.0 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2013 */ /* */ -/* Utility function used by TBL and PRX tables. */ +/* Utility function used by the PROXY, XCOL, OCCUR, and TBL tables. */ /***********************************************************************/ /***********************************************************************/ @@ -117,7 +117,6 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, /************************************************************************/ /* TabColumns: constructs the result blocks containing all the columns */ /* of the object table that will be retrieved by GetData commands. */ -/* key = TRUE when called from Create Table to get key informations. */ /************************************************************************/ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, const char *name, bool info) @@ -264,7 +263,11 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) char *pn, *db, *tab; db = Cat->GetStringCatInfo(g, "Dbname", "*"); - tab = Cat->GetStringCatInfo(g, "Tabname", NULL); + + if (!(tab = Cat->GetStringCatInfo(g, "Tabname", NULL))) { + strcpy(g->Message, "Missing object table name"); + return TRUE; + } // endif tab // Analyze the table name, it may have the format: [dbname.]tabname if ((pn = strchr(tab, '.'))) { @@ -414,7 +417,7 @@ int TDBPRX::RowNumber(PGLOBAL g, bool b) } // end of RowNumber /***********************************************************************/ -/* XCV Access Method opening routine. */ +/* PROXY Access Method opening routine. */ /***********************************************************************/ bool TDBPRX::OpenDB(PGLOBAL g) { @@ -453,7 +456,7 @@ bool TDBPRX::OpenDB(PGLOBAL g) } // end of OpenDB /***********************************************************************/ -/* Data Base read routine for XCV access method. */ +/* Data Base read routine for PROY access method. */ /***********************************************************************/ int TDBPRX::ReadDB(PGLOBAL g) { @@ -464,7 +467,7 @@ int TDBPRX::ReadDB(PGLOBAL g) } // end of ReadDB /***********************************************************************/ -/* WriteDB: Data Base write routine for XCV access methods. */ +/* WriteDB: Data Base write routine for PROXY access methods. */ /***********************************************************************/ int TDBPRX::WriteDB(PGLOBAL g) { @@ -473,7 +476,7 @@ int TDBPRX::WriteDB(PGLOBAL g) } // end of WriteDB /***********************************************************************/ -/* Data Base delete line routine for XCV access methods. */ +/* Data Base delete line routine for PROXY access methods. */ /***********************************************************************/ int TDBPRX::DeleteDB(PGLOBAL g, int irc) { @@ -496,7 +499,7 @@ void TDBPRX::RemoveNext(PTABLE tp) /* PRXCOL public constructor. */ /***********************************************************************/ PRXCOL::PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) - : COLBLK(cdp, tdbp, i) + : COLBLK(cdp, tdbp, i) { if (cprec) { Next = cprec->GetNext(); @@ -561,29 +564,6 @@ void PRXCOL::ReadColumn(PGLOBAL g) } // end of ReadColumn -#if 0 -/* ---------------------------TBCDEF class --------------------------- */ - -/***********************************************************************/ -/* DefineAM: define specific AM block values from CATLG table. */ -/***********************************************************************/ -bool TBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) - { - Desc = "Catalog Table"; - Database = Cat->GetStringCatInfo(g, "Database", "*"); - Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); - return FALSE; - } // end of DefineAM - -/***********************************************************************/ -/* GetTable: makes a new TDB of the proper type. */ -/***********************************************************************/ -PTDB TBCDEF::GetTable(PGLOBAL g, MODE m) - { - return new(g) TDBTBC(this); - } // end of GetTable -#endif // 0 - /* ---------------------------TDBTBC class --------------------------- */ /***********************************************************************/ @@ -591,32 +571,10 @@ PTDB TBCDEF::GetTable(PGLOBAL g, MODE m) /***********************************************************************/ TDBTBC::TDBTBC(PPRXDEF tdp) : TDBCAT(tdp) { -// Db = tdp->Database; -// Tab = tdp->Tabname; Db = (PSZ)tdp->Tablep->GetQualifier(); Tab = (PSZ)tdp->Tablep->GetName(); } // end of TDBTBC constructor -#if 0 -/***********************************************************************/ -/* TDBTBC class constructor from TBL table. */ -/***********************************************************************/ -TDBTBC::TDBTBC(PTBLDEF tdp) : TDBCAT(tdp) - { - Db = tdp->To_Tables->DB; - Tab = tdp->To_Tables->Name; - } // end of TDBTBC constructor - -/***********************************************************************/ -/* TDBTBC class constructor from PRX table. */ -/***********************************************************************/ -TDBTBC::TDBTBC(PXCLDEF tdp) : TDBCAT(tdp) - { - Db = (PSZ)tdp->Tablep->GetQualifier(); - Tab = (PSZ)tdp->Tablep->GetName(); - } // end of TDBTBC constructor -#endif // 0 - /***********************************************************************/ /* GetResult: Get the list the MYSQL table columns. */ /***********************************************************************/ diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index 3a5946bae8f..b99cf959bca 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -132,34 +132,6 @@ class DllExport PRXCOL : public COLBLK { int Colnum; // Used when retrieving columns by number }; // end of class PRXCOL -#if 0 -/***********************************************************************/ -/* TBC table. */ -/***********************************************************************/ -class TBCDEF : public TABDEF {/* Logical table description */ - friend class TDBTBC; - friend class ha_connect; - public: - // Constructor - TBCDEF(void) {Database = NULL; Tabname = NULL;} - - - // Implementation - virtual const char *GetType(void) {return "TBC";} - inline PSZ GetDatabase(void) {return Database;}; - inline PSZ GetTabname(void) {return Tabname;} - - // Methods - virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); - virtual PTDB GetTable(PGLOBAL g, MODE m); - - protected: - // Members - PSZ Database; /* Database to be used by server */ - PSZ Tabname; /* External table name */ - }; // end of TBCDEF -#endif // 0 - /***********************************************************************/ /* This is the class declaration for the TBC column catalog table. */ /***********************************************************************/ diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index 78998435aa6..d64a730beb0 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -73,7 +73,7 @@ XCLDEF::XCLDEF(void) } // end of XCLDEF constructor /***********************************************************************/ -/* DefineAM: define specific AM block values from XCOL file. */ +/* DefineAM: define specific AM block values from XCOL table. */ /***********************************************************************/ bool XCLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { @@ -106,7 +106,7 @@ PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode) TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp) { Xcolumn = tdp->Xcol; // CSV column name - Xcolp = NULL; // To the XCVCOL column + Xcolp = NULL; // To the XCLCOL column Mult = tdp->Mult; // Multiplication factor N = 0; // The current table index M = 0; // The occurence rank @@ -115,33 +115,6 @@ TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp) Sep = tdp->Sep; // The Xcol separator } // end of TDBXCL constructor -/***********************************************************************/ -/* Initializes the table. */ -/***********************************************************************/ -bool TDBXCL::InitTable(PGLOBAL g) - { - if (!Tdbp) { - PCOLDEF cdp; - - // Get the table description block of this table - if (!(Tdbp = (PTDBASE)GetSubTable(g, ((PXCLDEF)To_Def)->Tablep))) - return TRUE; - - for (cdp = Tdbp->GetDef()->GetCols(); cdp; cdp = cdp->GetNext()) - if (!stricmp(cdp->GetName(), Xcolumn)) - break; - - if (!cdp) { - sprintf(g->Message, "%s is not a %s column", - Xcolumn, Tdbp->GetName()); - return TRUE; - } // endif cdp - - } // endif Tdbp - - return FALSE; - } // end of InitTable - /***********************************************************************/ /* Allocate XCL column description block. */ /***********************************************************************/ @@ -165,7 +138,7 @@ int TDBXCL::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { if (InitTable(g)) - return NULL; + return 0; MaxSize = Mult * Tdbp->GetMaxSize(g); } // endif MaxSize @@ -174,8 +147,8 @@ int TDBXCL::GetMaxSize(PGLOBAL g) } // end of GetMaxSize /***********************************************************************/ -/* In this sample, ROWID will be the (virtual) row number, */ -/* while ROWNUM will be the occurence rank in the multiple column. */ +/* For this table type, ROWID is the (virtual) row number, */ +/* while ROWNUM is be the occurence rank in the multiple column. */ /***********************************************************************/ int TDBXCL::RowNumber(PGLOBAL g, bool b) { @@ -183,7 +156,7 @@ int TDBXCL::RowNumber(PGLOBAL g, bool b) } // end of RowNumber /***********************************************************************/ -/* XCV Access Method opening routine. */ +/* XCL Access Method opening routine. */ /***********************************************************************/ bool TDBXCL::OpenDB(PGLOBAL g) { @@ -206,7 +179,7 @@ bool TDBXCL::OpenDB(PGLOBAL g) } // endif Mode if (InitTable(g)) - return NULL; + return TRUE; /*********************************************************************/ /* Check and initialize the subtable columns. */ @@ -225,7 +198,7 @@ bool TDBXCL::OpenDB(PGLOBAL g) } // end of OpenDB /***********************************************************************/ -/* Data Base read routine for XCV access method. */ +/* Data Base read routine for XCL access method. */ /***********************************************************************/ int TDBXCL::ReadDB(PGLOBAL g) { diff --git a/storage/connect/tabxcl.h b/storage/connect/tabxcl.h index 79b890c9f55..28fbf85d509 100644 --- a/storage/connect/tabxcl.h +++ b/storage/connect/tabxcl.h @@ -45,7 +45,7 @@ class XCLDEF : public PRXDEF { /* Logical table description */ }; // end of XCLDEF /***********************************************************************/ -/* This is the class declaration for the XCSV table. */ +/* This is the class declaration for the XCOL table. */ /***********************************************************************/ class TDBXCL : public TDBPRX { friend class XCLDEF; @@ -64,7 +64,6 @@ class TDBXCL : public TDBPRX { // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual bool InitTable(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g); virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g); @@ -77,7 +76,7 @@ class TDBXCL : public TDBPRX { int N; // The current table index int M; // The occurence rank BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip - BOOL New; // TRUE for new line + bool New; // TRUE for new line char Sep; // The Xcol separator }; // end of class TDBXCL From d4be9e7bc0cfd5ddd444ecc64daa4166597ca2eb Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 6 May 2013 16:51:41 +0300 Subject: [PATCH 137/273] If one declared several continue handler for the same condition on different level of stored procedures, all of them where executed. Now we only execute the innermost of them (the most relevant). The solution was to add a 'handled' marker to MYSQL_ERROR and mark all elements for which we have executed a condition handler. When searching for new conditions, we will ignore any marked element. .bzrignore: Ignore error message file mysql-test/r/sp.result: Added testcase for continue handlers. mysql-test/t/sp.test: Added testcase for continue handlers. sql/sp_head.cc: Mark errors for which we will excute a handler as 'handled' Ignore already handled warnings/errors sql/sql_error.cc: Add 'handled' argument to MYSQL_ERROR, so that we can mark the errors/warnings we have handled. sql/sql_error.h: Add 'handled' argument to MYSQL_ERROR, so that we can mark the errors/warnings we have handled. --- .bzrignore | 1 + mysql-test/r/sp.result | 61 ++++++++++++++++++++++++++++++++++++++++ mysql-test/t/sp.test | 63 +++++++++++++++++++++++++++++++++++++++++- sql/sp_head.cc | 6 ++-- sql/sql_error.cc | 4 +++ sql/sql_error.h | 14 ++++++++++ 6 files changed, 146 insertions(+), 3 deletions(-) diff --git a/.bzrignore b/.bzrignore index 57209c72b87..37ae77824f8 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1068,6 +1068,7 @@ vio/viotest.cpp ylwrap zlib/*.ds? sql-bench/test-table-elimination +sql/share/bulgarian sql/share/czech sql/share/danish sql/share/dutch diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index defd3955f6c..a0f21b434d1 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -7916,4 +7916,65 @@ DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP FUNCTION f4; + +Stored procedures and a condition handler in a nested procedure call +doesn't suppress the condition from being passed on to the calling +procedure + +drop procedure if exists p1; +drop procedure if exists p0; +create table t1 (id int); +create procedure p1 () begin +declare i int default 0; +declare continue handler for not found begin +select "You should see this message and the warning that generated this" as "message"; +show warnings; +end; +select id into i from t1; +end$$ +create procedure p0 () begin +declare continue handler for not found begin +select "You should NOT see this message" as "message"; +end; +call p1(); +end$$ +call p0(); +message +You should see this message and the warning that generated this +Level Code Message +Warning 1329 No data - zero rows fetched, selected, or processed +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +drop procedure p1; +drop procedure p0; +drop table t1; + +Test if stored procedures propagates errors + +create table t1 (id int primary key); +create procedure p1 () begin +insert into t1 values(1); +insert into t1 values(2); +insert into t1 values(2); +insert into t1 values(3); +end$$ +create procedure p2 () begin +declare x int; +select id into x from t1 where id=5; +end$$ +call p1(); +ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +show warnings; +Level Code Message +Error 1062 Duplicate entry '2' for key 'PRIMARY' +select * from t1; +id +1 +2 +call p2(); +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +drop procedure p1; +drop procedure p2; +drop table t1; # End of 5.5 test diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 0a368826ee7..3590dc66187 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -9209,5 +9209,66 @@ DROP FUNCTION f2; DROP FUNCTION f3; DROP FUNCTION f4; ---echo # End of 5.5 test +--echo +--echo Stored procedures and a condition handler in a nested procedure call +--echo doesn't suppress the condition from being passed on to the calling +--echo procedure +--echo +--disable_warnings +drop procedure if exists p1; +drop procedure if exists p0; +--enable_warnings + +create table t1 (id int); +delimiter $$; +create procedure p1 () begin +declare i int default 0; +declare continue handler for not found begin +select "You should see this message and the warning that generated this" as "message"; +show warnings; +end; +select id into i from t1; +end$$ +create procedure p0 () begin +declare continue handler for not found begin +select "You should NOT see this message" as "message"; +end; +call p1(); +end$$ +delimiter ;$$ +call p0(); + +drop procedure p1; +drop procedure p0; +drop table t1; + +--echo +--echo Test if stored procedures propagates errors +--echo + +create table t1 (id int primary key); +delimiter $$; +create procedure p1 () begin +insert into t1 values(1); +insert into t1 values(2); +insert into t1 values(2); +insert into t1 values(3); +end$$ +create procedure p2 () begin + declare x int; + select id into x from t1 where id=5; +end$$ +delimiter ;$$ +--error ER_DUP_ENTRY +call p1(); +show warnings; +select * from t1; +call p2(); + +drop procedure p1; +drop procedure p2; + +drop table t1; + +--echo # End of 5.5 test diff --git a/sql/sp_head.cc b/sql/sp_head.cc index be6dc935dcc..847a4f214ab 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1160,8 +1160,9 @@ find_handler_after_execution(THD *thd, sp_rcontext *ctx) MYSQL_ERROR *err; while ((err= it++)) { - if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_WARN && - err->get_level() != MYSQL_ERROR::WARN_LEVEL_NOTE) + if ((err->get_level() != MYSQL_ERROR::WARN_LEVEL_WARN && + err->get_level() != MYSQL_ERROR::WARN_LEVEL_NOTE) || + err->handled()) continue; if (ctx->find_handler(thd, @@ -1170,6 +1171,7 @@ find_handler_after_execution(THD *thd, sp_rcontext *ctx) err->get_level(), err->get_message_text())) { + err->mark_handled(); break; } } diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 61281af1d0a..a4f5b210285 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -185,6 +185,7 @@ MYSQL_ERROR::MYSQL_ERROR() m_cursor_name((const char*) NULL, 0, & my_charset_utf8_bin), m_message_text(), m_sql_errno(0), + m_handled(0), m_level(MYSQL_ERROR::WARN_LEVEL_ERROR), m_mem_root(NULL) { @@ -212,6 +213,7 @@ void MYSQL_ERROR::clear() m_cursor_name.length(0); m_message_text.length(0); m_sql_errno= 0; + m_handled= 0; m_level= MYSQL_ERROR::WARN_LEVEL_ERROR; } @@ -229,6 +231,7 @@ MYSQL_ERROR::MYSQL_ERROR(MEM_ROOT *mem_root) m_cursor_name((const char*) NULL, 0, & my_charset_utf8_bin), m_message_text(), m_sql_errno(0), + m_handled(0), m_level(MYSQL_ERROR::WARN_LEVEL_ERROR), m_mem_root(mem_root) { @@ -267,6 +270,7 @@ MYSQL_ERROR::copy_opt_attributes(const MYSQL_ERROR *cond) copy_string(m_mem_root, & m_table_name, & cond->m_table_name); copy_string(m_mem_root, & m_column_name, & cond->m_column_name); copy_string(m_mem_root, & m_cursor_name, & cond->m_cursor_name); + m_handled= cond->m_handled; } void diff --git a/sql/sql_error.h b/sql/sql_error.h index 00ade934226..0483e7c65d1 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -191,6 +191,17 @@ public: MYSQL_ERROR::enum_warning_level get_level() const { return m_level; } + /** check if condition was handled by a condition handler */ + bool handled() const + { + return m_handled; + } + /** mark that condition was handled */ + void mark_handled() + { + m_handled= 1; + } + private: /* The interface of MYSQL_ERROR is mostly private, by design, @@ -306,6 +317,9 @@ private: /** MySQL extension, MYSQL_ERRNO condition item. */ uint m_sql_errno; + /** Marker if error/warning was handled by a continue handler */ + bool m_handled; + /** SQL RETURNED_SQLSTATE condition item. This member is always NUL terminated. From e0a08c567a028db406ebf69ece8b3210cba2af0c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 7 May 2013 18:26:22 +0200 Subject: [PATCH 138/273] Compilation warnings. openssl compilation problem. --- storage/maria/ma_loghandler.c | 3 +-- storage/maria/ma_search.c | 10 +++------- storage/xtradb/os/os0file.c | 3 +-- vio/viossl.c | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 341bbc6088f..54f67eb1ab3 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -7472,9 +7472,8 @@ static void translog_force_current_buffer_to_finish() struct st_translog_buffer *old_buffer= log_descriptor.bc.buffer; uchar *data= log_descriptor.bc.ptr - log_descriptor.bc.current_page_fill; uint16 left= TRANSLOG_PAGE_SIZE - log_descriptor.bc.current_page_fill; - uint16 current_page_fill, write_counter, previous_offset; + uint16 UNINIT_VAR(current_page_fill), write_counter, previous_offset; DBUG_ENTER("translog_force_current_buffer_to_finish"); - LINT_INIT(current_page_fill); DBUG_PRINT("enter", ("Buffer #%u 0x%lx " "Buffer addr: (%lu,0x%lx) " diff --git a/storage/maria/ma_search.c b/storage/maria/ma_search.c index ccb4bf77717..d38bc7af26c 100644 --- a/storage/maria/ma_search.c +++ b/storage/maria/ma_search.c @@ -424,9 +424,9 @@ int _ma_prefix_search(const MARIA_KEY *key, const MARIA_PAGE *ma_page, flag is the value returned by ha_key_cmp and as treated as final */ int flag=0, my_flag=-1; - uint nod_flag, length, len, matched, cmplen, kseg_len; - uint page_flag, prefix_len,suffix_len; - int key_len_skip, seg_len_pack, key_len_left; + uint nod_flag, UNINIT_VAR(length), len, matched, cmplen, kseg_len; + uint page_flag, UNINIT_VAR(prefix_len),suffix_len; + int key_len_skip, UNINIT_VAR(seg_len_pack), key_len_left; uchar *end, *vseg, *UNINIT_VAR(saved_vseg), *UNINIT_VAR(saved_from); uchar *page; uchar tt_buff[MARIA_MAX_KEY_BUFF+2], *t_buff=tt_buff+2; @@ -439,10 +439,6 @@ int _ma_prefix_search(const MARIA_KEY *key, const MARIA_PAGE *ma_page, const uchar *sort_order= keyinfo->seg->charset->sort_order; DBUG_ENTER("_ma_prefix_search"); - LINT_INIT(seg_len_pack); - LINT_INIT(prefix_len); - LINT_INIT(length); - t_buff[0]=0; /* Avoid bugs */ page_flag= ma_page->flag; nod_flag= ma_page->node; diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c index 8f1b3e46bb2..8f7f8216782 100644 --- a/storage/xtradb/os/os0file.c +++ b/storage/xtradb/os/os0file.c @@ -1462,7 +1462,6 @@ os_file_set_nocache( #endif static int os_file_set_atomic_writes(os_file_t file, const char *name) { - static int first_time = 1; int atomic_option = 1; int ret = ioctl (file, DFS_IOCTL_ATOMIC_WRITE_SET, &atomic_option); @@ -2138,7 +2137,7 @@ os_file_set_size( "InnoDB: Error: preallocating data for" " file %s failed at\n" "InnoDB: offset 0 size %lld %lld. Operating system" - " error number %llu.\n" + " error number %d.\n" "InnoDB: Check that the disk is not full" " or a disk quota exceeded.\n" "InnoDB: Some operating system error numbers" diff --git a/vio/viossl.c b/vio/viossl.c index 88f23df6842..ad20a6ab5c3 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -183,7 +183,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout, SSL_clear(ssl); SSL_SESSION_set_timeout(SSL_get_session(ssl), timeout); SSL_set_fd(ssl, vio->sd); -#ifndef HAVE_YASSL +#if !defined(HAVE_YASSL) && defined(SSL_OP_NO_COMPRESSION) SSL_set_options(ssl, SSL_OP_NO_COMPRESSION); #endif From 009dee833c94ebcf7199514f32baf3f4530d92f0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 7 May 2013 18:28:36 +0200 Subject: [PATCH 139/273] centos5 gcc 4.1 asm bug include/atomic/x86-gcc.h: force %esi register, don't give gcc a choice. (otherwise it could choose %ebx, and 4.1 did) --- cmake/os/Linux.cmake | 6 ------ include/atomic/x86-gcc.h | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/cmake/os/Linux.cmake b/cmake/os/Linux.cmake index 108e06cf7b0..36d7ade66a7 100644 --- a/cmake/os/Linux.cmake +++ b/cmake/os/Linux.cmake @@ -47,9 +47,3 @@ IF(HAVE_DECL_SHM_HUGETLB) SET(HAVE_LARGE_PAGE_OPTION 1) ENDIF() -IF(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR MATCHES "86") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686") - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=i686") -ENDIF() - diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index 2238347d419..173e32e790c 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -124,10 +124,10 @@ asm volatile ("push %%ebx;" \ "movl (%%ecx), %%ebx;" \ "movl 4(%%ecx), %%ecx;" \ - LOCK_prefix "; cmpxchg8b %0;" \ + LOCK_prefix "; cmpxchg8b (%%esi);" \ "setz %2; pop %%ebx" \ - : "=m" (*a), "+A" (*cmp), "=c" (ret) \ - : "c" (&set), "m" (*a) \ + : "+S" (a), "+A" (*cmp), "=c" (ret) \ + : "c" (&set) \ : "memory", "esp") #endif From bcfa90b471b4a04ba9eb9dccd88a41c8f72cd38a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 8 May 2013 09:52:54 +0200 Subject: [PATCH 140/273] Percona-Server-5.5.30-rel30.2.tar.gz --- btr/btr0btr.c | 38 +++---- btr/btr0cur.c | 111 +++++++++----------- btr/btr0pcur.c | 13 ++- btr/btr0sea.c | 5 +- buf/buf0buf.c | 121 ++++++--------------- buf/buf0flu.c | 9 +- buf/buf0lru.c | 40 ------- buf/buf0rea.c | 8 +- dict/dict0dict.c | 6 +- fil/fil0fil.c | 109 ++++++------------- fsp/fsp0fsp.c | 45 +++----- handler/ha_innodb.cc | 38 ++++--- include/btr0btr.ic | 2 +- include/buf0buf.h | 1 - include/buf0buf.ic | 9 +- include/buf0flu.ic | 2 +- include/buf0lru.h | 7 -- include/fut0fut.ic | 5 +- include/log0log.h | 18 +++- include/log0log.ic | 23 +++- include/mtr0mtr.h | 2 + include/mtr0mtr.ic | 21 ++++ include/read0read.h | 33 ++++-- include/read0read.ic | 41 +++----- include/srv0srv.h | 17 ++- include/trx0purge.h | 1 + include/trx0sys.h | 38 +++++++ include/trx0sys.ic | 46 ++++---- include/trx0trx.h | 43 ++++++-- include/trx0trx.ic | 8 +- lock/lock0lock.c | 22 ++-- log/log0log.c | 19 ++-- mtr/mtr0mtr.c | 39 ++++++- read/read0read.c | 198 +++++++++++++++++------------------ row/row0ins.c | 9 +- row/row0merge.c | 6 +- row/row0sel.c | 23 ++-- row/row0vers.c | 6 +- srv/srv0srv.c | 4 +- trx/trx0purge.c | 16 ++- trx/trx0roll.c | 8 +- trx/trx0sys.c | 11 +- trx/trx0trx.c | 243 +++++++++++++++++++++++++++++++++++-------- 43 files changed, 808 insertions(+), 656 deletions(-) diff --git a/btr/btr0btr.c b/btr/btr0btr.c index b0ae888e676..3efd9bc76e0 100644 --- a/btr/btr0btr.c +++ b/btr/btr0btr.c @@ -688,7 +688,7 @@ btr_root_fseg_validate( { ulint offset = mach_read_from_2(seg_header + FSEG_HDR_OFFSET); - if (UNIV_UNLIKELY(srv_pass_corrupt_table)) { + if (UNIV_UNLIKELY(srv_pass_corrupt_table != 0)) { return (mach_read_from_4(seg_header + FSEG_HDR_SPACE) == space) && (offset >= FIL_PAGE_DATA) && (offset <= UNIV_PAGE_SIZE - FIL_PAGE_DATA_END); @@ -723,17 +723,14 @@ btr_root_block_get( block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, index, mtr); - if (srv_pass_corrupt_table && !block) { - return(0); - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return(0);); btr_assert_not_corrupted(block, index); #ifdef UNIV_BTR_DEBUG if (!dict_index_is_ibuf(index)) { const page_t* root = buf_block_get_frame(block); - if (UNIV_UNLIKELY(srv_pass_corrupt_table)) { + if (UNIV_UNLIKELY(srv_pass_corrupt_table != 0)) { if (!btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF + root, space)) @@ -1063,11 +1060,11 @@ btr_get_size( root = btr_root_get(index, mtr); - if (srv_pass_corrupt_table && !root) { + SRV_CORRUPT_TABLE_CHECK(root, + { mtr_commit(mtr); return(0); - } - ut_a(root); + }); if (flag == BTR_N_LEAF_PAGES) { seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; @@ -1525,11 +1522,11 @@ leaf_loop: root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, NULL, &mtr); - if (srv_pass_corrupt_table && !root) { + SRV_CORRUPT_TABLE_CHECK(root, + { mtr_commit(&mtr); return; - } - ut_a(root); + }); #ifdef UNIV_BTR_DEBUG ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF @@ -1555,11 +1552,12 @@ top_loop: root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, NULL, &mtr); - if (srv_pass_corrupt_table && !root) { + SRV_CORRUPT_TABLE_CHECK(root, + { mtr_commit(&mtr); return; - } - ut_a(root); + }); + #ifdef UNIV_BTR_DEBUG ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP + root, space)); @@ -1593,10 +1591,7 @@ btr_free_root( block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, NULL, mtr); - if (srv_pass_corrupt_table && !block) { - return; - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return;); btr_search_drop_page_hash_index(block); @@ -4565,10 +4560,11 @@ btr_validate_index( root = btr_root_get(index, &mtr); - if (UNIV_UNLIKELY(srv_pass_corrupt_table && !root)) { + SRV_CORRUPT_TABLE_CHECK(root, + { mtr_commit(&mtr); return(FALSE); - } + }); n = btr_page_get_level(root, &mtr); diff --git a/btr/btr0cur.c b/btr/btr0cur.c index d089fb5ad22..488212f087c 100644 --- a/btr/btr0cur.c +++ b/btr/btr0cur.c @@ -258,10 +258,8 @@ btr_cur_latch_leaves( get_block = btr_block_get( space, zip_size, page_no, mode, cursor->index, mtr); - if (srv_pass_corrupt_table && !get_block) { - return; - } - ut_a(get_block); + SRV_CORRUPT_TABLE_CHECK(get_block, return;); + #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); #endif /* UNIV_BTR_DEBUG */ @@ -283,10 +281,8 @@ btr_cur_latch_leaves( space, zip_size, left_page_no, sibling_mode, cursor->index, mtr); - if (srv_pass_corrupt_table && !get_block) { - return; - } - ut_a(get_block); + SRV_CORRUPT_TABLE_CHECK(get_block, return;); + #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); @@ -309,10 +305,8 @@ btr_cur_latch_leaves( space, zip_size, page_no, mode, cursor->index, mtr); - if (srv_pass_corrupt_table && !get_block) { - return; - } - ut_a(get_block); + SRV_CORRUPT_TABLE_CHECK(get_block, return;); + #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); #endif /* UNIV_BTR_DEBUG */ @@ -325,10 +319,8 @@ btr_cur_latch_leaves( space, zip_size, right_page_no, sibling_mode, cursor->index, mtr); - if (srv_pass_corrupt_table && !get_block) { - return; - } - ut_a(get_block); + SRV_CORRUPT_TABLE_CHECK(get_block, return;); + #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); @@ -357,10 +349,8 @@ btr_cur_latch_leaves( left_page_no, mode, cursor->index, mtr); cursor->left_block = get_block; - if (srv_pass_corrupt_table && !get_block) { - return; - } - ut_a(get_block); + SRV_CORRUPT_TABLE_CHECK(get_block, return;); + #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); @@ -373,10 +363,8 @@ btr_cur_latch_leaves( get_block = btr_block_get( space, zip_size, page_no, mode, cursor->index, mtr); - if (srv_pass_corrupt_table && !get_block) { - return; - } - ut_a(get_block); + SRV_CORRUPT_TABLE_CHECK(get_block, return;); + #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); #endif /* UNIV_BTR_DEBUG */ @@ -652,18 +640,19 @@ retry_page_get: file, line, mtr); if (block == NULL) { - if (srv_pass_corrupt_table - && buf_mode != BUF_GET_IF_IN_POOL - && buf_mode != BUF_GET_IF_IN_POOL_OR_WATCH) { - page_cursor->block = 0; - page_cursor->rec = 0; - if (estimate) { - cursor->path_arr->nth_rec = ULINT_UNDEFINED; - } - goto func_exit; - } - ut_a(buf_mode == BUF_GET_IF_IN_POOL - || buf_mode == BUF_GET_IF_IN_POOL_OR_WATCH); + SRV_CORRUPT_TABLE_CHECK(buf_mode == BUF_GET_IF_IN_POOL || + buf_mode == BUF_GET_IF_IN_POOL_OR_WATCH, + { + page_cursor->block = 0; + page_cursor->rec = 0; + if (estimate) { + + cursor->path_arr->nth_rec = + ULINT_UNDEFINED; + } + + goto func_exit; + }); /* This must be a search to perform an insert/delete mark/ delete; try using the insert/delete buffer */ @@ -739,15 +728,18 @@ retry_page_get: block->check_index_page_at_flush = TRUE; page = buf_block_get_frame(block); - if (srv_pass_corrupt_table && !page) { + SRV_CORRUPT_TABLE_CHECK(page, + { page_cursor->block = 0; page_cursor->rec = 0; + if (estimate) { + cursor->path_arr->nth_rec = ULINT_UNDEFINED; } + goto func_exit; - } - ut_a(page); + }); if (rw_latch != RW_NO_LATCH) { #ifdef UNIV_ZIP_DEBUG @@ -943,15 +935,19 @@ btr_cur_open_at_index_side_func( file, line, mtr); page = buf_block_get_frame(block); - if (srv_pass_corrupt_table && !page) { + SRV_CORRUPT_TABLE_CHECK(page, + { page_cursor->block = 0; page_cursor->rec = 0; + if (estimate) { - cursor->path_arr->nth_rec = ULINT_UNDEFINED; + + cursor->path_arr->nth_rec = + ULINT_UNDEFINED; } - break; - } - ut_a(page); + /* Can't use break with the macro */ + goto exit_loop; + }); ut_ad(index->id == btr_page_get_index_id(page)); @@ -1021,6 +1017,7 @@ btr_cur_open_at_index_side_func( page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); } +exit_loop: if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1074,12 +1071,13 @@ btr_cur_open_at_rnd_pos_func( file, line, mtr); page = buf_block_get_frame(block); - if (srv_pass_corrupt_table && !page) { + SRV_CORRUPT_TABLE_CHECK(page, + { page_cursor->block = 0; page_cursor->rec = 0; - break; - } - ut_a(page); + + goto exit_loop; + }); ut_ad(index->id == btr_page_get_index_id(page)); @@ -1112,6 +1110,7 @@ btr_cur_open_at_rnd_pos_func( page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); } +exit_loop: if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1300,10 +1299,7 @@ btr_cur_optimistic_insert( block = btr_cur_get_block(cursor); - if (srv_pass_corrupt_table && !block) { - return(DB_CORRUPTION); - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return(DB_CORRUPTION);); page = buf_block_get_frame(block); index = cursor->index; @@ -3149,10 +3145,7 @@ btr_cur_optimistic_delete( block = btr_cur_get_block(cursor); - if (srv_pass_corrupt_table && !block) { - return(DB_CORRUPTION); - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return(DB_CORRUPTION);); ut_ad(page_is_leaf(buf_block_get_frame(block))); @@ -3868,10 +3861,7 @@ btr_estimate_number_of_different_key_vals( page = btr_cur_get_page(&cursor); - if (srv_pass_corrupt_table && !page) { - break; - } - ut_a(page); + SRV_CORRUPT_TABLE_CHECK(page, goto exit_loop;); rec = page_rec_get_next(page_get_infimum_rec(page)); @@ -3957,6 +3947,7 @@ btr_estimate_number_of_different_key_vals( mtr_commit(&mtr); } +exit_loop: /* If we saw k borders between different key values on n_sample_pages leaf pages, we can estimate how many there will be in index->stat_n_leaf_pages */ diff --git a/btr/btr0pcur.c b/btr/btr0pcur.c index a1b7affdeb7..7c4ec2dd1ac 100644 --- a/btr/btr0pcur.c +++ b/btr/btr0pcur.c @@ -116,10 +116,7 @@ btr_pcur_store_position( block = btr_pcur_get_block(cursor); - if (srv_pass_corrupt_table && !block) { - return; - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return;); index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor)); @@ -439,14 +436,16 @@ btr_pcur_move_to_next_page( btr_pcur_get_btr_cur(cursor)->index, mtr); next_page = buf_block_get_frame(next_block); - if (srv_pass_corrupt_table && !next_page) { + SRV_CORRUPT_TABLE_CHECK(next_page, + { btr_leaf_page_release(btr_pcur_get_block(cursor), cursor->latch_mode, mtr); btr_pcur_get_page_cur(cursor)->block = 0; btr_pcur_get_page_cur(cursor)->rec = 0; + return; - } - ut_a(next_page); + }); + #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(next_page) == page_is_comp(page)); ut_a(btr_page_get_prev(next_page, mtr) diff --git a/btr/btr0sea.c b/btr/btr0sea.c index 7e9449a6474..d53452bb959 100644 --- a/btr/btr0sea.c +++ b/btr/btr0sea.c @@ -649,10 +649,7 @@ btr_search_info_update_slow( block = btr_cur_get_block(cursor); - if (srv_pass_corrupt_table && !block) { - return; - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return;); /* NOTE that the following two function calls do NOT protect info or block->n_fields etc. with any semaphore, to save CPU time! diff --git a/buf/buf0buf.c b/buf/buf0buf.c index 5bcfb0f51b9..ae4b2fba98d 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -2002,27 +2002,6 @@ lookup: #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ } - if (UNIV_UNLIKELY(bpage->space_was_being_deleted)) { - /* This page is obsoleted, should discard and retry */ - rw_lock_s_unlock(&buf_pool->page_hash_latch); - - mutex_enter(&buf_pool->LRU_list_mutex); - block_mutex = buf_page_get_mutex_enter(bpage); - - if (UNIV_UNLIKELY(!block_mutex)) { - mutex_exit(&buf_pool->LRU_list_mutex); - goto lookup; - } - - buf_LRU_free_block(bpage, TRUE, TRUE); - - mutex_exit(&buf_pool->LRU_list_mutex); - mutex_exit(block_mutex); - block_mutex = NULL; - - goto lookup; - } - if (UNIV_UNLIKELY(!bpage->zip.data)) { /* There is no compressed page. */ err_exit: @@ -2031,11 +2010,11 @@ err_exit: return(NULL); } - if (srv_pass_corrupt_table <= 1) { - if (bpage->is_corrupt) { - rw_lock_s_unlock(&buf_pool->page_hash_latch); - return(NULL); - } + if (UNIV_UNLIKELY(bpage->is_corrupt && srv_pass_corrupt_table <= 1)) { + + rw_lock_s_unlock(&buf_pool->page_hash_latch); + + return(NULL); } block_mutex = buf_page_get_mutex_enter(bpage); @@ -2533,26 +2512,6 @@ loop: block = (buf_block_t*) buf_page_hash_get_low( buf_pool, space, offset, fold); if (block) { - if (UNIV_UNLIKELY(block->page.space_was_being_deleted)) { - /* This page is obsoleted, should discard and retry */ - rw_lock_s_unlock(&buf_pool->page_hash_latch); - - mutex_enter(&buf_pool->LRU_list_mutex); - block_mutex = buf_page_get_mutex_enter((buf_page_t*)block); - - if (UNIV_UNLIKELY(!block_mutex)) { - mutex_exit(&buf_pool->LRU_list_mutex); - goto loop; - } - - buf_LRU_free_block((buf_page_t*)block, TRUE, TRUE); - - mutex_exit(&buf_pool->LRU_list_mutex); - mutex_exit(block_mutex); - block_mutex = NULL; - - goto loop; - } block_mutex = buf_page_get_mutex_enter((buf_page_t*)block); ut_a(block_mutex); @@ -2640,11 +2599,12 @@ got_block: return(NULL); } - if (srv_pass_corrupt_table <= 1) { - if (block->page.is_corrupt) { - mutex_exit(block_mutex); - return(NULL); - } + if (UNIV_UNLIKELY(block->page.is_corrupt && + srv_pass_corrupt_table <= 1)) { + + mutex_exit(block_mutex); + + return(NULL); } switch (buf_block_get_state(block)) { @@ -3487,28 +3447,12 @@ buf_page_init_for_read( fold = buf_page_address_fold(space, offset); -retry: //buf_pool_mutex_enter(buf_pool); mutex_enter(&buf_pool->LRU_list_mutex); rw_lock_x_lock(&buf_pool->page_hash_latch); watch_page = buf_page_hash_get_low(buf_pool, space, offset, fold); - if (UNIV_UNLIKELY(watch_page && watch_page->space_was_being_deleted)) { - mutex_t* block_mutex = buf_page_get_mutex_enter(watch_page); - - /* This page is obsoleted, should discard and retry */ - rw_lock_x_unlock(&buf_pool->page_hash_latch); - ut_a(block_mutex); - - buf_LRU_free_block(watch_page, TRUE, TRUE); - - mutex_exit(&buf_pool->LRU_list_mutex); - mutex_exit(block_mutex); - - goto retry; - } - if (watch_page && !buf_pool_watch_is_sentinel(buf_pool, watch_page)) { /* The page is already in the buffer pool. */ watch_page = NULL; @@ -3637,7 +3581,6 @@ err_exit: bpage->state = BUF_BLOCK_ZIP_PAGE; bpage->space = space; bpage->offset = offset; - bpage->space_was_being_deleted = FALSE; #ifdef UNIV_DEBUG bpage->in_page_hash = FALSE; @@ -3722,7 +3665,6 @@ buf_page_create( fold = buf_page_address_fold(space, offset); -retry: //buf_pool_mutex_enter(buf_pool); mutex_enter(&buf_pool->LRU_list_mutex); rw_lock_x_lock(&buf_pool->page_hash_latch); @@ -3730,21 +3672,6 @@ retry: block = (buf_block_t*) buf_page_hash_get_low( buf_pool, space, offset, fold); - if (UNIV_UNLIKELY(block && block->page.space_was_being_deleted)) { - mutex_t* block_mutex = buf_page_get_mutex_enter((buf_page_t*)block); - - /* This page is obsoleted, should discard and retry */ - rw_lock_x_unlock(&buf_pool->page_hash_latch); - ut_a(block_mutex); - - buf_LRU_free_block((buf_page_t*)block, TRUE, TRUE); - - mutex_exit(&buf_pool->LRU_list_mutex); - mutex_exit(block_mutex); - - goto retry; - } - if (block && buf_page_in_file(&block->page) && !buf_pool_watch_is_sentinel(buf_pool, &block->page)) { @@ -4001,7 +3928,8 @@ buf_page_io_complete( (ulong) bpage->offset); } - if (!srv_pass_corrupt_table || !bpage->is_corrupt) { + if (UNIV_LIKELY(!bpage->is_corrupt || + !srv_pass_corrupt_table)) { /* From version 3.23.38 up we store the page checksum to the 4 first bytes of the page end lsn field */ @@ -4086,13 +4014,26 @@ corrupt: } if (uncompressed && !recv_no_ibuf_operations) { + + buf_block_t* block; + ibool update_ibuf_bitmap; + + if (UNIV_UNLIKELY(bpage->is_corrupt && + srv_pass_corrupt_table)) { + + block = NULL; + update_ibuf_bitmap = FALSE; + + } else { + + block = (buf_block_t *) bpage; + update_ibuf_bitmap = TRUE; + } + ibuf_merge_or_delete_for_page( - /* Delete possible entries, if bpage is_corrupt */ - (srv_pass_corrupt_table && bpage->is_corrupt) ? NULL : - (buf_block_t*) bpage, bpage->space, + block, bpage->space, bpage->offset, buf_page_get_zip_size(bpage), - (srv_pass_corrupt_table && bpage->is_corrupt) ? FALSE : - TRUE); + update_ibuf_bitmap); } } diff --git a/buf/buf0flu.c b/buf/buf0flu.c index 663e2d8f537..9452b53df38 100644 --- a/buf/buf0flu.c +++ b/buf/buf0flu.c @@ -459,7 +459,7 @@ buf_flush_ready_for_replace( if (UNIV_LIKELY(bpage->in_LRU_list && buf_page_in_file(bpage))) { - return((bpage->oldest_modification == 0 || bpage->space_was_being_deleted) + return(bpage->oldest_modification == 0 && buf_page_get_io_fix(bpage) == BUF_IO_NONE && bpage->buf_fix_count == 0); } @@ -501,13 +501,6 @@ buf_flush_ready_for_flush( && buf_page_get_io_fix(bpage) == BUF_IO_NONE) { ut_ad(bpage->in_flush_list); - if (bpage->space_was_being_deleted) { - /* should be removed from flush_list here */ - /* because buf_flush_try_neighbors() cannot flush without fil_space_get_size(space) */ - buf_flush_remove(bpage); - return(FALSE); - } - if (flush_type != BUF_FLUSH_LRU) { return(TRUE); diff --git a/buf/buf0lru.c b/buf/buf0lru.c index bbf483c708a..ef747ce470d 100644 --- a/buf/buf0lru.c +++ b/buf/buf0lru.c @@ -884,42 +884,6 @@ buf_LRU_flush_or_remove_pages( } } -/******************************************************************//** -*/ -UNIV_INTERN -void -buf_LRU_mark_space_was_deleted( -/*===========================*/ - ulint id) /*!< in: space id */ -{ - ulint i; - - for (i = 0; i < srv_buf_pool_instances; i++) { - buf_pool_t* buf_pool; - buf_page_t* bpage; - - buf_pool = buf_pool_from_array(i); - - mutex_enter(&buf_pool->LRU_list_mutex); - - bpage = UT_LIST_GET_FIRST(buf_pool->LRU); - - while (bpage != NULL) { - if (buf_page_get_space(bpage) == id) { - bpage->space_was_being_deleted = TRUE; - } - bpage = UT_LIST_GET_NEXT(LRU, bpage); - } - - mutex_exit(&buf_pool->LRU_list_mutex); - - /* The AHI entries for the tablespace being deleted should be - removed by now. */ - ut_ad(buf_LRU_drop_page_hash_for_tablespace(buf_pool, id) - == 0); - } -} - #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /********************************************************************//** Insert a compressed block into buf_pool->zip_clean in the LRU order. */ @@ -1891,10 +1855,6 @@ buf_LRU_free_block( return(FALSE); } - if (bpage->space_was_being_deleted && bpage->oldest_modification != 0) { - buf_flush_remove(bpage); - } - #ifdef UNIV_IBUF_COUNT_DEBUG ut_a(ibuf_count_get(bpage->space, bpage->offset) == 0); #endif /* UNIV_IBUF_COUNT_DEBUG */ diff --git a/buf/buf0rea.c b/buf/buf0rea.c index cf0a029df92..5edbeadb64e 100644 --- a/buf/buf0rea.c +++ b/buf/buf0rea.c @@ -245,13 +245,7 @@ not_to_recover: return(0); } - if (srv_pass_corrupt_table) { - if (*err != DB_SUCCESS) { - bpage->is_corrupt = TRUE; - } - } else { - ut_a(*err == DB_SUCCESS); - } + SRV_CORRUPT_TABLE_CHECK(*err == DB_SUCCESS, bpage->is_corrupt = TRUE;); if (sync) { /* The i/o is already completed when we arrive from diff --git a/dict/dict0dict.c b/dict/dict0dict.c index 461bdd55ad3..6e883e5048b 100644 --- a/dict/dict0dict.c +++ b/dict/dict0dict.c @@ -4419,7 +4419,7 @@ dict_reload_statistics( while (index) { mtr_t mtr; - if (table->is_corrupt) { + if (UNIV_UNLIKELY(table->is_corrupt)) { ut_a(srv_pass_corrupt_table); mem_heap_free(heap); return(FALSE); @@ -4577,7 +4577,7 @@ dict_store_statistics( heap = mem_heap_create(1000); while (index) { - if (table->is_corrupt) { + if (UNIV_UNLIKELY(table->is_corrupt)) { ut_a(srv_pass_corrupt_table); mem_heap_free(heap); return; @@ -4771,7 +4771,7 @@ dict_update_statistics( mtr_t mtr; ulint size; - if (table->is_corrupt) { + if (UNIV_UNLIKELY(table->is_corrupt)) { ut_a(srv_pass_corrupt_table); dict_table_stats_unlock(table, RW_X_LATCH); return; diff --git a/fil/fil0fil.c b/fil/fil0fil.c index a90f47bda91..1c53c02efb4 100644 --- a/fil/fil0fil.c +++ b/fil/fil0fil.c @@ -2426,15 +2426,11 @@ try_again: To deal with potential read requests by checking the ::stop_new_ops flag in fil_io() */ - if (srv_lazy_drop_table) { - buf_LRU_mark_space_was_deleted(id); - } else { buf_LRU_flush_or_remove_pages( id, evict_all ? BUF_REMOVE_ALL_NO_WRITE : BUF_REMOVE_FLUSH_NO_WRITE); - } #endif /* printf("Deleting tablespace %s id %lu\n", space->name, id); */ @@ -5304,22 +5300,6 @@ _fil_io( srv_data_written+= len; } - /* if the table space was already deleted, space might not exist already. */ - if (message - && space_id < SRV_LOG_SPACE_FIRST_ID - && ((buf_page_t*)message)->space_was_being_deleted) { - - if (mode == OS_AIO_NORMAL) { - buf_page_io_complete(message); - return(DB_SUCCESS); /*fake*/ - } - if (type == OS_FILE_READ) { - return(DB_TABLESPACE_DELETED); - } else { - return(DB_SUCCESS); /*fake*/ - } - } - /* Reserve the fil_system mutex and make sure that we can open at least one file while holding it, if the file is not already open */ @@ -5423,35 +5403,38 @@ _fil_io( ut_a(byte_offset % OS_MIN_LOG_BLOCK_SIZE == 0); ut_a((len % OS_MIN_LOG_BLOCK_SIZE) == 0); - if (srv_pass_corrupt_table == 1 && space->is_corrupt) { +#ifndef UNIV_HOTBACKUP + if (UNIV_UNLIKELY(space->is_corrupt && srv_pass_corrupt_table)) { + /* should ignore i/o for the crashed space */ - mutex_enter(&fil_system->mutex); - fil_node_complete_io(node, fil_system, type); - mutex_exit(&fil_system->mutex); - if (mode == OS_AIO_NORMAL) { - ut_a(space->purpose == FIL_TABLESPACE); - buf_page_io_complete(message); - } - if (type == OS_FILE_READ) { - return(DB_TABLESPACE_DELETED); - } else { - return(DB_SUCCESS); - } - } else { - if (srv_pass_corrupt_table > 1 && space->is_corrupt) { - /* should ignore write i/o for the crashed space */ - if (type == OS_FILE_WRITE) { - mutex_enter(&fil_system->mutex); - fil_node_complete_io(node, fil_system, type); - mutex_exit(&fil_system->mutex); - if (mode == OS_AIO_NORMAL) { - ut_a(space->purpose == FIL_TABLESPACE); - buf_page_io_complete(message); - } - return(DB_SUCCESS); + if (srv_pass_corrupt_table == 1 || + type == OS_FILE_WRITE) { + + mutex_enter(&fil_system->mutex); + fil_node_complete_io(node, fil_system, type); + mutex_exit(&fil_system->mutex); + if (mode == OS_AIO_NORMAL) { + ut_a(space->purpose == FIL_TABLESPACE); + buf_page_io_complete(message); } } -#ifdef UNIV_HOTBACKUP + + if (srv_pass_corrupt_table == 1 && type == OS_FILE_READ) { + + return(DB_TABLESPACE_DELETED); + + } else if (type == OS_FILE_WRITE) { + + return(DB_SUCCESS); + } + } /**/ + + /* Queue the aio request */ + ret = os_aio(type, mode | wake_later, node->name, node->handle, buf, + offset_low, offset_high, len, node, message, space_id, + trx); + +#else /* In ibbackup do normal i/o, not aio */ if (type == OS_FILE_READ) { ret = os_file_read(node->handle, buf, offset_low, offset_high, @@ -5460,26 +5443,7 @@ _fil_io( ret = os_file_write(node->name, node->handle, buf, offset_low, offset_high, len); } -#else - /* Queue the aio request */ - ret = os_aio(type, mode | wake_later, node->name, node->handle, buf, - offset_low, offset_high, len, node, message, space_id, trx); #endif - } /**/ - - /* if the table space was already deleted, space might not exist already. */ - if (message - && space_id < SRV_LOG_SPACE_FIRST_ID - && ((buf_page_t*)message)->space_was_being_deleted) { - - if (mode == OS_AIO_SYNC) { - if (type == OS_FILE_READ) { - return(DB_TABLESPACE_DELETED); - } else { - return(DB_SUCCESS); /*fake*/ - } - } - } ut_a(ret); @@ -5603,21 +5567,6 @@ fil_aio_wait( &message, &type, &space_id); } - /* if the table space was already deleted, fil_node might not exist already. */ - if (message - && space_id < SRV_LOG_SPACE_FIRST_ID - && ((buf_page_t*)message)->space_was_being_deleted) { - - /* intended not to be uncompress read page */ - ut_a(buf_page_get_io_fix_unlocked(message) == BUF_IO_WRITE - || !buf_page_get_zip_size(message) - || buf_page_get_state(message) != BUF_BLOCK_FILE_PAGE); - - srv_set_io_thread_op_info(segment, "complete io for buf page"); - buf_page_io_complete(message); - return; - } - ut_a(ret); if (UNIV_UNLIKELY(fil_node == NULL)) { ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS); diff --git a/fsp/fsp0fsp.c b/fsp/fsp0fsp.c index cf066404555..24d5183f880 100644 --- a/fsp/fsp0fsp.c +++ b/fsp/fsp0fsp.c @@ -317,10 +317,7 @@ fsp_get_space_header( block = buf_page_get(id, zip_size, 0, RW_X_LATCH, mtr); - if (srv_pass_corrupt_table && !block) { - return(0); - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return(0);); header = FSP_HEADER_OFFSET + buf_block_get_frame(block); buf_block_dbg_add_level(block, SYNC_FSP_PAGE); @@ -731,10 +728,7 @@ xdes_get_descriptor( block = buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr); - if (srv_pass_corrupt_table && !block) { - return(0); - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return(0);); buf_block_dbg_add_level(block, SYNC_FSP_PAGE); @@ -1882,10 +1876,7 @@ fsp_seg_inode_page_find_free( { fseg_inode_t* inode; - if (srv_pass_corrupt_table && !page) { - return(ULINT_UNDEFINED); - } - ut_a(page); + SRV_CORRUPT_TABLE_CHECK(page, return(ULINT_UNDEFINED);); for (; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) { @@ -1999,10 +1990,7 @@ fsp_alloc_seg_inode( page = buf_block_get_frame(block); - if (srv_pass_corrupt_table && !page) { - return(0); - } - ut_a(page); + SRV_CORRUPT_TABLE_CHECK(page, return(0);); n = fsp_seg_inode_page_find_free(page, 0, zip_size, mtr); @@ -2097,10 +2085,7 @@ fseg_inode_try_get( inode = fut_get_ptr(space, zip_size, inode_addr, RW_X_LATCH, mtr); - if (srv_pass_corrupt_table && !inode) { - return(0); - } - ut_a(inode); + SRV_CORRUPT_TABLE_CHECK(inode, return(0);); if (UNIV_UNLIKELY(!mach_read_from_8(inode + FSEG_ID))) { @@ -2128,7 +2113,7 @@ fseg_inode_get( { fseg_inode_t* inode = fseg_inode_try_get(header, space, zip_size, mtr); - ut_a(srv_pass_corrupt_table || inode); + SRV_CORRUPT_TABLE_CHECK(inode, ; /* do nothing */); return(inode); } @@ -3320,12 +3305,12 @@ fseg_free_page_low( descr = xdes_get_descriptor(space, zip_size, page, mtr); - if (srv_pass_corrupt_table && !descr) { + SRV_CORRUPT_TABLE_CHECK(descr, + { /* The page may be corrupt. pass it. */ return; - } + }); - ut_a(descr); if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) { fputs("InnoDB: Dump of the tablespace extent descriptor: ", stderr); @@ -3574,15 +3559,15 @@ fseg_free_step( descr = xdes_get_descriptor(space, zip_size, header_page, mtr); - if (srv_pass_corrupt_table && !descr) { + SRV_CORRUPT_TABLE_CHECK(descr, + { /* The page may be corrupt. pass it. */ return(TRUE); - } + }); /* Check that the header resides on a page which has not been freed yet */ - ut_a(descr); ut_a(xdes_get_bit(descr, XDES_FREE_BIT, header_page % FSP_EXTENT_SIZE, mtr) == FALSE); inode = fseg_inode_try_get(header, space, zip_size, mtr); @@ -3663,11 +3648,11 @@ fseg_free_step_not_header( inode = fseg_inode_get(header, space, zip_size, mtr); - if (srv_pass_corrupt_table && !inode) { + SRV_CORRUPT_TABLE_CHECK(inode, + { /* ignore the corruption */ return(TRUE); - } - ut_a(inode); + }); descr = fseg_get_first_extent(inode, space, zip_size, mtr); diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index ff18ffbecdf..569770602d0 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -202,6 +202,8 @@ static ulong innobase_sys_stats_root_page = 0; #endif static my_bool innobase_buffer_pool_shm_checksum = TRUE; static uint innobase_buffer_pool_shm_key = 0; +static ulong srv_lazy_drop_table = 0; + static char* internal_innobase_data_file_path = NULL; @@ -1910,7 +1912,7 @@ trx_is_started( /*===========*/ trx_t* trx) /* in: transaction */ { - return(trx->conc_state != TRX_NOT_STARTED); + return(trx->state != TRX_NOT_STARTED); } /*********************************************************************//** @@ -3009,6 +3011,12 @@ innobase_change_buffering_inited_ok: "InnoDB: innodb_buffer_pool_shm_key was ignored.\n"); } + if (srv_lazy_drop_table) { + fprintf(stderr, + "InnoDB: Warning: " + "innodb_lazy_drop_table is deprecated and ignored.\n"); + } + srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size; srv_n_file_io_threads = (ulint) innobase_file_io_threads; @@ -4599,7 +4607,8 @@ ha_innobase::open( DBUG_RETURN(1); } - if (srv_pass_corrupt_table <= 1 && share->ib_table && share->ib_table->is_corrupt) { + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt && + srv_pass_corrupt_table <= 1)) { free_share(share); DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); @@ -4624,7 +4633,8 @@ retry: /* Get pointer to a table object in InnoDB dictionary cache */ ib_table = dict_table_get(norm_name, TRUE); - if (srv_pass_corrupt_table <= 1 && ib_table && ib_table->is_corrupt) { + if (UNIV_UNLIKELY(ib_table && ib_table->is_corrupt && + srv_pass_corrupt_table <= 1)) { free_share(share); my_free(upd_buf); upd_buf = NULL; @@ -6692,7 +6702,8 @@ ha_innobase::index_read( ha_statistic_increment(&SSV::ha_read_key_count); - if (srv_pass_corrupt_table <= 1 && share->ib_table->is_corrupt) { + if (UNIV_UNLIKELY(share->ib_table->is_corrupt && + srv_pass_corrupt_table <= 1)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -6763,7 +6774,8 @@ ha_innobase::index_read( ret = DB_UNSUPPORTED; } - if (srv_pass_corrupt_table <= 1 && share->ib_table->is_corrupt) { + if (UNIV_UNLIKELY(share->ib_table->is_corrupt && + srv_pass_corrupt_table <= 1)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -6881,7 +6893,8 @@ ha_innobase::change_active_index( { DBUG_ENTER("change_active_index"); - if (srv_pass_corrupt_table <= 1 && share->ib_table->is_corrupt) { + if (UNIV_UNLIKELY(share->ib_table->is_corrupt && + srv_pass_corrupt_table <= 1)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -6998,7 +7011,8 @@ ha_innobase::general_fetch( DBUG_ENTER("general_fetch"); - if (srv_pass_corrupt_table <= 1 && share->ib_table->is_corrupt) { + if (UNIV_UNLIKELY(share->ib_table->is_corrupt && + srv_pass_corrupt_table <= 1)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -7011,7 +7025,8 @@ ha_innobase::general_fetch( innodb_srv_conc_exit_innodb(prebuilt->trx); - if (srv_pass_corrupt_table <= 1 && share->ib_table->is_corrupt) { + if (UNIV_UNLIKELY(share->ib_table->is_corrupt && + srv_pass_corrupt_table <= 1)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -9039,7 +9054,7 @@ ha_innobase::info_low( prebuilt->trx->op_info = "confirming rows of SYS_STATS to store statistics"; - ut_a(prebuilt->trx->conc_state == TRX_NOT_STARTED); + ut_a(!trx_is_started(prebuilt->trx)); for (index = dict_table_get_first_index(ib_table); index != NULL; @@ -9052,7 +9067,7 @@ ha_innobase::info_low( innobase_commit_low(prebuilt->trx); } - ut_a(prebuilt->trx->conc_state == TRX_NOT_STARTED); + ut_a(!trx_is_started(prebuilt->trx)); } prebuilt->trx->op_info = "updating table statistics"; @@ -13020,8 +13035,7 @@ static MYSQL_SYSVAR_ENUM(corrupt_table_action, srv_pass_corrupt_table, static MYSQL_SYSVAR_ULONG(lazy_drop_table, srv_lazy_drop_table, PLUGIN_VAR_RQCMDARG, - "At deleting tablespace, only miminum needed processes at the time are done. " - "e.g. for http://bugs.mysql.com/51325", + "[Deprecated option] no effect", NULL, NULL, 0, 0, 1, 0); static MYSQL_SYSVAR_BOOL(locking_fake_changes, srv_fake_changes_locks, diff --git a/include/btr0btr.ic b/include/btr0btr.ic index 53c8159c448..798107628d7 100644 --- a/include/btr0btr.ic +++ b/include/btr0btr.ic @@ -59,7 +59,7 @@ btr_block_get_func( block = buf_page_get_gen(space, zip_size, page_no, mode, NULL, BUF_GET, file, line, mtr); - ut_a(srv_pass_corrupt_table || block); + SRV_CORRUPT_TABLE_CHECK(block, ; /* do nothing */); if (block && mode != RW_NO_LATCH) { diff --git a/include/buf0buf.h b/include/buf0buf.h index f4f9cc47ff4..991fdb7ca88 100644 --- a/include/buf0buf.h +++ b/include/buf0buf.h @@ -1587,7 +1587,6 @@ struct buf_page_struct{ 0 if the block was never accessed in the buffer pool. Protected by block mutex */ - ibool space_was_being_deleted; ibool is_corrupt; # if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG ibool file_page_was_freed; diff --git a/include/buf0buf.ic b/include/buf0buf.ic index 8d5c3edeef8..18c46b6412e 100644 --- a/include/buf0buf.ic +++ b/include/buf0buf.ic @@ -430,7 +430,6 @@ buf_block_set_file_page( buf_block_set_state(block, BUF_BLOCK_FILE_PAGE); block->page.space = space; block->page.offset = page_no; - block->page.space_was_being_deleted = FALSE; } /*********************************************************************//** @@ -712,13 +711,7 @@ buf_block_get_frame( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ { - ut_a(srv_pass_corrupt_table || block); - - if (srv_pass_corrupt_table && !block) { - return(0); - } - - ut_ad(block); + SRV_CORRUPT_TABLE_CHECK(block, return(0);); switch (buf_block_get_state(block)) { case BUF_BLOCK_ZIP_FREE: diff --git a/include/buf0flu.ic b/include/buf0flu.ic index 30e2cc8efe8..8228c025d23 100644 --- a/include/buf0flu.ic +++ b/include/buf0flu.ic @@ -70,7 +70,7 @@ buf_flush_note_modification( ut_ad(!buf_pool_mutex_own(buf_pool)); ut_ad(!buf_flush_list_mutex_own(buf_pool)); - ut_ad(log_flush_order_mutex_own()); + ut_ad(!mtr->made_dirty || log_flush_order_mutex_own()); ut_ad(mtr->start_lsn != 0); ut_ad(mtr->modifications); diff --git a/include/buf0lru.h b/include/buf0lru.h index 2ea4f9b1ecf..8bb3aed4059 100644 --- a/include/buf0lru.h +++ b/include/buf0lru.h @@ -73,13 +73,6 @@ buf_LRU_flush_or_remove_pages( enum buf_remove_t buf_remove);/*!< in: remove or flush strategy */ -/******************************************************************//** -*/ -UNIV_INTERN -void -buf_LRU_mark_space_was_deleted( -/*===========================*/ - ulint id); /*!< in: space id */ #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /********************************************************************//** Insert a compressed block into buf_pool->zip_clean in the LRU order. */ diff --git a/include/fut0fut.ic b/include/fut0fut.ic index 529f2a516d3..63e5736d99e 100644 --- a/include/fut0fut.ic +++ b/include/fut0fut.ic @@ -50,10 +50,7 @@ fut_get_ptr( block = buf_page_get(space, zip_size, addr.page, rw_latch, mtr); - if (srv_pass_corrupt_table && !block) { - return(0); - } - ut_a(block); + SRV_CORRUPT_TABLE_CHECK(block, return(0);); ptr = buf_block_get_frame(block) + addr.boffset; diff --git a/include/log0log.h b/include/log0log.h index ee20f429a2b..e4c19c41137 100644 --- a/include/log0log.h +++ b/include/log0log.h @@ -122,16 +122,24 @@ UNIV_INLINE void log_free_check(void); /*================*/ -/************************************************************//** -Opens the log for log_write_low. The log must be closed with log_close and -released with log_release. -@return start lsn of the log record */ -UNIV_INTERN +/**************************************************************************//** +Locks the log mutex and opens the log for log_write_low. The log must be closed +with log_close and released with log_release. +@return start lsn of the log record */ +UNIV_INLINE ib_uint64_t log_reserve_and_open( /*=================*/ ulint len); /*!< in: length of data to be catenated */ /************************************************************//** +Opens the log for log_write_low. The log must be closed with log_close. +@return start lsn of the log record */ +UNIV_INTERN +ib_uint64_t +log_open( +/*=====*/ + ulint len); /*!< in: length of data to be catenated */ +/************************************************************//** Writes to the log the string given. It is assumed that the caller holds the log mutex. */ UNIV_INTERN diff --git a/include/log0log.ic b/include/log0log.ic index 67db6695cab..c39586dbcf9 100644 --- a/include/log0log.ic +++ b/include/log0log.ic @@ -332,10 +332,10 @@ log_reserve_and_write_fast( if (data_len >= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE) { - /* The string does not fit within the current log block - or the log block would become full */ - - mutex_exit(&log_sys->mutex); + /* The string does not fit within the current log block or the + log block would become full. Do not release the log mutex, + because it has to be reacquired immediately for the "slow" write + procedure via log_write_low(). */ return(0); } @@ -382,6 +382,21 @@ log_reserve_and_write_fast( return(log_sys->lsn); } +/**************************************************************************//** +Locks the log mutex and opens the log for log_write_low. The log must be closed +with log_close and released with log_release. +@return start lsn of the log record */ +UNIV_INLINE +ib_uint64_t +log_reserve_and_open( +/*=================*/ + ulint len) /*!< in: length of data to be catenated */ +{ + mutex_enter(&(log_sys->mutex)); + + return log_open(len); +} + /***********************************************************************//** Releases the log mutex. */ UNIV_INLINE diff --git a/include/mtr0mtr.h b/include/mtr0mtr.h index 46f1ff9310c..c51632e0ed5 100644 --- a/include/mtr0mtr.h +++ b/include/mtr0mtr.h @@ -375,6 +375,8 @@ struct mtr_struct{ ibool modifications; /* TRUE if the mtr made modifications to buffer pool pages */ + ibool made_dirty;/*!< TRUE if mtr has made at least + one buffer pool page dirty */ ulint n_log_recs; /* count of how many page initial log records have been written to the mtr log */ diff --git a/include/mtr0mtr.ic b/include/mtr0mtr.ic index a03a0271535..7b5d268b70f 100644 --- a/include/mtr0mtr.ic +++ b/include/mtr0mtr.ic @@ -29,6 +29,17 @@ Created 11/26/1995 Heikki Tuuri #endif /* !UNIV_HOTBACKUP */ #include "mach0data.h" +/***************************************************//** +Checks if a mini-transaction is dirtying a clean page. +@return TRUE if the mtr is dirtying a clean page. */ +UNIV_INTERN +ibool +mtr_block_dirtied( +/*==============*/ + const buf_block_t* block) /*!< in: block being x-fixed */ + __attribute__((nonnull,warn_unused_result)); + + /***************************************************************//** Starts a mini-transaction. */ UNIV_INLINE @@ -47,6 +58,7 @@ mtr_start( mtr->inside_ibuf = FALSE; mtr->n_log_recs = 0; mtr->n_freed_pages = 0; + mtr->made_dirty = FALSE; ut_d(mtr->state = MTR_ACTIVE); ut_d(mtr->magic_n = MTR_MAGIC_N); @@ -65,6 +77,15 @@ mtr_memo_push( dyn_array_t* memo; mtr_memo_slot_t* slot; + /* If this mtr has x-fixed a clean page then we set + the made_dirty flag. This tells us if we need to + grab log_flush_order_mutex at mtr_commit so that we + can insert the dirtied page to the flush list. */ + if (type == MTR_MEMO_PAGE_X_FIX && !mtr->made_dirty) { + mtr->made_dirty = + mtr_block_dirtied((const buf_block_t *)object); + } + ut_ad(object); ut_ad(type >= MTR_MEMO_PAGE_S_FIX); ut_ad(type <= MTR_MEMO_X_LOCK); diff --git a/include/read0read.h b/include/read0read.h index 0c9468d985e..dd378ecc997 100644 --- a/include/read0read.h +++ b/include/read0read.h @@ -32,6 +32,7 @@ Created 2/16/1997 Heikki Tuuri #include "ut0byte.h" #include "ut0lst.h" #include "trx0trx.h" +#include "trx0sys.h" #include "read0types.h" /*********************************************************************//** @@ -44,8 +45,11 @@ read_view_open_now( /*===============*/ trx_id_t cr_trx_id, /*!< in: trx_id of creating transaction, or 0 used in purge */ - mem_heap_t* heap); /*!< in: memory heap from which - allocated */ + read_view_t* view, /*!< in: current read view or NULL if it + doesn't exist yet */ + ibool exclude_self); /*!< in: TRUE, if cr_trx_id should be + excluded from the resulting view */ + /*********************************************************************//** Makes a copy of the oldest existing read view, or opens a new. The view must be closed with ..._close. @@ -56,8 +60,8 @@ read_view_oldest_copy_or_open_new( /*==============================*/ trx_id_t cr_trx_id, /*!< in: trx_id of creating transaction, or 0 used in purge */ - mem_heap_t* heap); /*!< in: memory heap from which - allocated */ + read_view_t* view); /*!< in: pre-allocated view array or + NULL if a new one needs to be created */ /*********************************************************************//** Closes a read view. */ UNIV_INTERN @@ -66,6 +70,13 @@ read_view_close( /*============*/ read_view_t* view); /*!< in: read view */ /*********************************************************************//** +Frees memory allocated by a read view. */ +UNIV_INTERN +void +read_view_free( +/*===========*/ + read_view_t* view); /*< in: read view */ +/*********************************************************************//** Closes a consistent read view for MySQL. This function is called at an SQL statement end if the trx isolation level is <= TRX_ISO_READ_COMMITTED. */ UNIV_INTERN @@ -143,16 +154,20 @@ struct read_view_struct{ are strictly smaller (<) than this value. In other words, this is the "low water mark". */ - ulint n_trx_ids; + ulint n_descr; /*!< Number of cells in the trx_ids array */ - trx_id_t* trx_ids;/*!< Additional trx ids which the read should - not see: typically, these are the active + ulint max_descr; + /*!< Maximum number of cells in the trx_ids + array */ + trx_id_t* descriptors; + /*!< Array of trx descriptors which the read + should not see: typically, these are the active transactions at the time when the read is serialized, except the reading transaction itself; the trx ids in this array are in a descending order. These trx_ids should be - between the "low" and "high" water marks, - that is, up_limit_id and low_limit_id. */ + between the "low" and "high" water marks, that + is, up_limit_id and low_limit_id. */ trx_id_t creator_trx_id; /*!< trx id of creating transaction, or 0 used in purge */ diff --git a/include/read0read.ic b/include/read0read.ic index 5bb5249b591..ebcdb767406 100644 --- a/include/read0read.ic +++ b/include/read0read.ic @@ -25,6 +25,11 @@ Created 2/16/1997 Heikki Tuuri /*********************************************************************//** Gets the nth trx id in a read view. + +Upstream code stores array of trx_ids in the descending order. Percona Server +keeps it in the ascending order for performance reasons. Let us keep the +semantics. + @return trx id */ UNIV_INLINE trx_id_t @@ -33,13 +38,17 @@ read_view_get_nth_trx_id( const read_view_t* view, /*!< in: read view */ ulint n) /*!< in: position */ { - ut_ad(n < view->n_trx_ids); + ut_ad(n < view->n_descr); - return(*(view->trx_ids + n)); + return(view->descriptors[view->n_descr - 1 - n]); } /*********************************************************************//** -Sets the nth trx id in a read view. */ +Sets the nth trx id in a read view. + +Upstream code stores array of trx_ids in the descending order. Percona Server +keeps it in the ascending order for performance reasons. Let us keep the +semantics. */ UNIV_INLINE void read_view_set_nth_trx_id( @@ -48,9 +57,9 @@ read_view_set_nth_trx_id( ulint n, /*!< in: position */ trx_id_t trx_id) /*!< in: trx id to set */ { - ut_ad(n < view->n_trx_ids); + ut_ad(n < view->n_descr); - *(view->trx_ids + n) = trx_id; + view->descriptors[view->n_descr - 1 - n] = trx_id; } /*********************************************************************//** @@ -63,9 +72,6 @@ read_view_sees_trx_id( const read_view_t* view, /*!< in: read view */ trx_id_t trx_id) /*!< in: trx id */ { - ulint n_ids; - ulint i; - if (trx_id < view->up_limit_id) { return(TRUE); @@ -76,21 +82,8 @@ read_view_sees_trx_id( return(FALSE); } - /* We go through the trx ids in the array smallest first: this order - may save CPU time, because if there was a very long running - transaction in the trx id array, its trx id is looked at first, and - the first two comparisons may well decide the visibility of trx_id. */ + /* Do a binary search over this view's descriptors array */ - n_ids = view->n_trx_ids; - - for (i = 0; i < n_ids; i++) { - trx_id_t view_trx_id - = read_view_get_nth_trx_id(view, n_ids - i - 1); - - if (trx_id <= view_trx_id) { - return(trx_id != view_trx_id); - } - } - - return(TRUE); + return(trx_find_descriptor(view->descriptors, view->n_descr, + trx_id) == NULL); } diff --git a/include/srv0srv.h b/include/srv0srv.h index 53dbdf8bd8f..c4fb9712b51 100644 --- a/include/srv0srv.h +++ b/include/srv0srv.h @@ -266,9 +266,22 @@ extern ulint srv_adaptive_flushing_method; extern ulint srv_expand_import; extern ulint srv_pass_corrupt_table; -extern ulint srv_dict_size_limit; +/* Helper macro to support srv_pass_corrupt_table checks. If 'cond' is FALSE, +execute 'code' if srv_pass_corrupt_table is non-zero, or trigger a fatal error +otherwise. The break statement in 'code' will obviously not work as expected. */ -extern ulint srv_lazy_drop_table; +#define SRV_CORRUPT_TABLE_CHECK(cond,code) \ + do { \ + if (UNIV_UNLIKELY(!(cond))) { \ + if (srv_pass_corrupt_table) { \ + code \ + } else { \ + ut_error; \ + } \ + } \ + } while(0) + +extern ulint srv_dict_size_limit; /*-------------------------------------------*/ extern ulint srv_n_rows_inserted; diff --git a/include/trx0purge.h b/include/trx0purge.h index 1e8acd65e01..1ddc9068b8e 100644 --- a/include/trx0purge.h +++ b/include/trx0purge.h @@ -143,6 +143,7 @@ struct trx_purge_struct{ obtaining an s-latch here. */ read_view_t* view; /*!< The purge will not remove undo logs which are >= this view (purge view) */ + read_view_t* prebuilt_view; /*!< Pre-built view array */ ulonglong n_pages_handled;/*!< Approximate number of undo log pages processed in purge */ ulonglong handle_limit; /*!< Target of how many pages to get diff --git a/include/trx0sys.h b/include/trx0sys.h index cba21ae97a9..75a3b0fb4fd 100644 --- a/include/trx0sys.h +++ b/include/trx0sys.h @@ -249,6 +249,17 @@ trx_id_t trx_sys_get_new_trx_id(void); /*========================*/ +/*************************************************************//** +Find a slot for a given trx ID in a descriptors array. +@return: slot pointer */ +UNIV_INLINE +trx_id_t* +trx_find_descriptor( +/*================*/ + const trx_id_t* descriptors, /*!< in: descriptors array */ + ulint n_descr, /*!< in: array size */ + trx_id_t trx_id); /*!< in: trx pointer */ + #ifdef UNIV_DEBUG /* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ extern uint trx_rseg_n_slots_debug; @@ -633,6 +644,8 @@ identifier is added to this 64-bit constant. */ | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW) /* @} */ +#define TRX_DESCR_ARRAY_INITIAL_SIZE 1000 + #ifndef UNIV_HOTBACKUP /** Doublewrite control struct */ struct trx_doublewrite_struct{ @@ -660,16 +673,41 @@ struct trx_sys_struct{ trx_id_t max_trx_id; /*!< The smallest number not yet assigned as a transaction id or transaction number */ + char pad1[64]; /*!< Ensure max_trx_id does not share + cache line with other fields. */ + trx_id_t* descriptors; /*!< Array of trx descriptors */ + ulint descr_n_max; /*!< The current size of the descriptors + array. */ + char pad2[64]; /*!< Ensure static descriptor fields + do not share cache lines with + descr_n_used */ + ulint descr_n_used; /*!< Number of used elements in the + descriptors array. */ + char pad3[64]; /*!< Ensure descriptors do not share + cache line with other fields */ UT_LIST_BASE_NODE_T(trx_t) trx_list; /*!< List of active and committed in memory transactions, sorted on trx id, biggest first */ + char pad4[64]; /*!< Ensure list base nodes do not + share cache line with other fields */ UT_LIST_BASE_NODE_T(trx_t) mysql_trx_list; /*!< List of transactions created for MySQL */ + char pad5[64]; /*!< Ensure list base nodes do not + share cache line with other fields */ + UT_LIST_BASE_NODE_T(trx_t) trx_serial_list; + /*!< trx->no ordered List of + transactions in either TRX_PREPARED or + TRX_ACTIVE which have already been + assigned a serialization number */ + char pad6[64]; /*!< Ensure trx_serial_list does not + share cache line with other fields */ UT_LIST_BASE_NODE_T(trx_rseg_t) rseg_list; /*!< List of rollback segment objects */ + char pad7[64]; /*!< Ensure list base nodes do not + share cache line with other fields */ trx_rseg_t* latest_rseg; /*!< Latest rollback segment in the round-robin assignment of rollback segments to transactions */ diff --git a/include/trx0sys.ic b/include/trx0sys.ic index af05ab2f5ed..3af98cdf98b 100644 --- a/include/trx0sys.ic +++ b/include/trx0sys.ic @@ -367,28 +367,11 @@ trx_is_active( /*==========*/ trx_id_t trx_id) /*!< in: trx id of the transaction */ { - trx_t* trx; - ut_ad(mutex_own(&(kernel_mutex))); - if (trx_id < trx_list_get_min_trx_id()) { - - return(FALSE); - } - - if (UNIV_UNLIKELY(trx_id >= trx_sys->max_trx_id)) { - - /* There must be corruption: we return TRUE because this - function is only called by lock_clust_rec_some_has_impl() - and row_vers_impl_x_locked_off_kernel() and they have - diagnostic prints in this case */ - - return(TRUE); - } - - trx = trx_get_on_id(trx_id); - if (trx && (trx->conc_state == TRX_ACTIVE - || trx->conc_state == TRX_PREPARED)) { + if (trx_find_descriptor(trx_sys->descriptors, + trx_sys->descr_n_used, + trx_id)) { return(TRUE); } @@ -425,4 +408,27 @@ trx_sys_get_new_trx_id(void) return(id); } + +/*************************************************************//** +Find a slot for a given trx ID in a descriptors array. +@return: slot pointer */ +UNIV_INLINE +trx_id_t* +trx_find_descriptor( +/*================*/ + const trx_id_t* descriptors, /*!< in: descriptors array */ + ulint n_descr, /*!< in: array size */ + trx_id_t trx_id) /*!< in: trx pointer */ +{ + ut_ad(descriptors != trx_sys->descriptors || + mutex_own(&kernel_mutex)); + + if (UNIV_UNLIKELY(n_descr == 0)) { + + return(NULL); + } + + return((trx_id_t *) bsearch(&trx_id, descriptors, n_descr, + sizeof(trx_id_t), trx_descr_cmp)); +} #endif /* !UNIV_HOTBACKUP */ diff --git a/include/trx0trx.h b/include/trx0trx.h index 39b8ccf26ec..fec1d746297 100644 --- a/include/trx0trx.h +++ b/include/trx0trx.h @@ -447,6 +447,23 @@ trx_get_que_state_str( /*==================*/ const trx_t* trx); /*!< in: transaction */ +/*************************************************************//** +Callback function for trx_find_descriptor() to compare trx IDs. */ +UNIV_INTERN +int +trx_descr_cmp( +/*==========*/ + const void *a, /*!< in: pointer to first comparison argument */ + const void *b); /*!< in: pointer to second comparison argument */ + +/*************************************************************//** +Release a slot for a given trx in the global descriptors array. */ +UNIV_INTERN +void +trx_release_descriptor( +/*===================*/ + trx_t* trx); /*!< in: trx pointer */ + /* Signal to a transaction */ struct trx_sig_struct{ unsigned type:3; /*!< signal type */ @@ -477,10 +494,18 @@ struct trx_struct{ const char* op_info; /*!< English text describing the current operation, or an empty string */ - ulint conc_state; /*!< state of the trx from the point - of view of concurrency control: - TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY, - ... */ + ulint state; /*!< state of the trx from the point of + view of concurrency control: TRX_ACTIVE, + TRX_COMMITTED_IN_MEMORY, ... This was + called 'conc_state' in the upstream and + has been renamed in Percona Server, + because changing it's value to/from + either TRX_ACTIVE or TRX_PREPARED + requires calling + trx_reserve_descriptor() / + trx_release_descriptor(). Different name + ensures we notice any new code changing + the state. */ /*------------------------------*/ /* MySQL has a transaction coordinator to coordinate two phase commit between multiple storage engines and the binary log. When @@ -495,6 +520,9 @@ struct trx_struct{ also be set to 1. This is used in the XA code */ unsigned called_commit_ordered:1;/* 1 if innobase_commit_ordered has run. */ + unsigned is_in_trx_serial_list:1; + /* Set when transaction is in the + trx_serial_list */ /*------------------------------*/ ulint isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */ ulint check_foreigns; /* normally TRUE, but if the user @@ -628,6 +656,9 @@ struct trx_struct{ UT_LIST_NODE_T(trx_t) mysql_trx_list; /*!< list of transactions created for MySQL */ + UT_LIST_NODE_T(trx_t) + trx_serial_list;/*!< list node for + trx_sys->trx_serial_list */ /*------------------------------*/ ulint error_state; /*!< 0 if no error, otherwise error number; NOTE That ONLY the thread @@ -686,9 +717,6 @@ struct trx_struct{ UT_LIST_BASE_NODE_T(lock_t) trx_locks; /*!< locks reserved by the transaction */ /*------------------------------*/ - mem_heap_t* global_read_view_heap; - /* memory heap for the global read - view */ read_view_t* global_read_view; /* consistent read view associated to a transaction or NULL */ @@ -698,6 +726,7 @@ struct trx_struct{ associated to a transaction (i.e. same as global_read_view) or read view associated to a cursor */ + read_view_t* prebuilt_view; /* pre-built view array */ /*------------------------------*/ UT_LIST_BASE_NODE_T(trx_named_savept_t) trx_savepoints; /*!< savepoints set with SAVEPOINT ..., diff --git a/include/trx0trx.ic b/include/trx0trx.ic index 4a1d3bcde0b..1a1fc91eac5 100644 --- a/include/trx0trx.ic +++ b/include/trx0trx.ic @@ -31,9 +31,9 @@ trx_start_if_not_started( /*=====================*/ trx_t* trx) /*!< in: transaction */ { - ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY); + ut_ad(trx->state != TRX_COMMITTED_IN_MEMORY); - if (trx->conc_state == TRX_NOT_STARTED) { + if (trx->state == TRX_NOT_STARTED) { trx_start(trx, ULINT_UNDEFINED); } @@ -48,9 +48,9 @@ trx_start_if_not_started_low( /*=========================*/ trx_t* trx) /*!< in: transaction */ { - ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY); + ut_ad(trx->state != TRX_COMMITTED_IN_MEMORY); - if (trx->conc_state == TRX_NOT_STARTED) { + if (trx->state == TRX_NOT_STARTED) { trx_start_low(trx, ULINT_UNDEFINED); } diff --git a/lock/lock0lock.c b/lock/lock0lock.c index 47d082ed49f..f4c991d4fe9 100644 --- a/lock/lock0lock.c +++ b/lock/lock0lock.c @@ -4652,7 +4652,7 @@ lock_print_info_all_transactions( trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list); while (trx) { - if (trx->conc_state == TRX_NOT_STARTED) { + if (trx->state == TRX_NOT_STARTED) { fputs("---", file); trx_print(file, trx, 600); } @@ -4820,9 +4820,9 @@ lock_table_queue_validate( lock = UT_LIST_GET_FIRST(table->locks); while (lock) { - ut_a(((lock->trx)->conc_state == TRX_ACTIVE) - || ((lock->trx)->conc_state == TRX_PREPARED) - || ((lock->trx)->conc_state == TRX_COMMITTED_IN_MEMORY)); + ut_a(((lock->trx)->state == TRX_ACTIVE) + || ((lock->trx)->state == TRX_PREPARED) + || ((lock->trx)->state == TRX_COMMITTED_IN_MEMORY)); if (!lock_get_wait(lock)) { @@ -4870,7 +4870,7 @@ lock_rec_queue_validate( lock = lock_rec_get_first(block, heap_no); while (lock) { - switch(lock->trx->conc_state) { + switch(lock->trx->state) { case TRX_ACTIVE: case TRX_PREPARED: case TRX_COMMITTED_IN_MEMORY: @@ -4957,9 +4957,9 @@ lock_rec_queue_validate( lock = lock_rec_get_first(block, heap_no); while (lock) { - ut_a(lock->trx->conc_state == TRX_ACTIVE - || lock->trx->conc_state == TRX_PREPARED - || lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); + ut_a(lock->trx->state == TRX_ACTIVE + || lock->trx->state == TRX_PREPARED + || lock->trx->state == TRX_COMMITTED_IN_MEMORY); ut_a(trx_in_trx_list(lock->trx)); if (index) { @@ -5036,9 +5036,9 @@ loop: } ut_a(trx_in_trx_list(lock->trx)); - ut_a(lock->trx->conc_state == TRX_ACTIVE - || lock->trx->conc_state == TRX_PREPARED - || lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); + ut_a(lock->trx->state == TRX_ACTIVE + || lock->trx->state == TRX_PREPARED + || lock->trx->state == TRX_COMMITTED_IN_MEMORY); # ifdef UNIV_SYNC_DEBUG /* Only validate the record queues when this thread is not diff --git a/log/log0log.c b/log/log0log.c index 8fbf4b80df4..298234050e8 100644 --- a/log/log0log.c +++ b/log/log0log.c @@ -263,13 +263,12 @@ log_check_tracking_margin( } /************************************************************//** -Opens the log for log_write_low. The log must be closed with log_close and -released with log_release. +Opens the log for log_write_low. The log must be closed with log_close. @return start lsn of the log record */ UNIV_INTERN ib_uint64_t -log_reserve_and_open( -/*=================*/ +log_open( +/*=====*/ ulint len) /*!< in: length of data to be catenated */ { log_t* log = log_sys; @@ -282,7 +281,6 @@ log_reserve_and_open( ut_a(len < log->buf_size / 2); loop: - mutex_enter(&(log->mutex)); ut_ad(!recv_no_log_write); /* Calculate an upper limit for the space the string may take in the @@ -303,6 +301,8 @@ loop: ut_ad(++count < 50); + mutex_enter(&(log->mutex)); + goto loop; } @@ -316,6 +316,8 @@ loop: os_thread_sleep(10000); + mutex_enter(&(log->mutex)); + goto loop; } @@ -336,6 +338,8 @@ loop: ut_ad(++count < 50); + mutex_enter(&(log->mutex)); + goto loop; } } @@ -492,9 +496,12 @@ log_close(void) if (tracked_lsn_age >= log->log_group_capacity) { - fprintf(stderr, " InnoDB: Error: the age of the " + fprintf(stderr, "InnoDB: Error: the age of the " "oldest untracked record exceeds the log " "group capacity!\n"); + fprintf(stderr, "InnoDB: Error: stopping the log " + "tracking thread at LSN %llu\n", tracked_lsn); + srv_track_changed_pages = FALSE; } } diff --git a/mtr/mtr0mtr.c b/mtr/mtr0mtr.c index d852ed6f496..f0cd3fb77de 100644 --- a/mtr/mtr0mtr.c +++ b/mtr/mtr0mtr.c @@ -37,6 +37,25 @@ Created 11/26/1995 Heikki Tuuri #ifndef UNIV_HOTBACKUP # include "log0recv.h" + +/***************************************************//** +Checks if a mini-transaction is dirtying a clean page. +@return TRUE if the mtr is dirtying a clean page. */ +UNIV_INTERN +ibool +mtr_block_dirtied( +/*==============*/ + const buf_block_t* block) /*!< in: block being x-fixed */ +{ + ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); + ut_ad(block->page.buf_fix_count > 0); + + /* It is OK to read oldest_modification because no + other thread can be performing a write of it and it + is only during write that the value is reset to 0. */ + return(block->page.oldest_modification == 0); +} + /*****************************************************************//** Releases the item in the slot given. */ static @@ -125,7 +144,7 @@ mtr_memo_slot_note_modification( buf_block_t* block = (buf_block_t*) slot->object; #ifdef UNIV_DEBUG - ut_ad(log_flush_order_mutex_own()); + ut_ad(!mtr->made_dirty || log_flush_order_mutex_own()); #endif /* UNIV_DEBUG */ buf_flush_note_modification(block, mtr); } @@ -201,12 +220,14 @@ mtr_log_reserve_and_write( Add pages to flush list and exit */ goto func_exit; } + } else { + mutex_enter(&log_sys->mutex); } data_size = dyn_array_get_data_size(mlog); /* Open the database log for log_write_low */ - mtr->start_lsn = log_reserve_and_open(data_size); + mtr->start_lsn = log_open(data_size); if (mtr->log_mode == MTR_LOG_ALL) { @@ -225,7 +246,15 @@ mtr_log_reserve_and_write( mtr->end_lsn = log_close(); func_exit: - log_flush_order_mutex_enter(); + + /* No need to acquire log_flush_order_mutex if this mtr has + not dirtied a clean page. log_flush_order_mutex is used to + ensure ordered insertions in the flush_list. We need to + insert in the flush_list iff the page in question was clean + before modifications. */ + if (mtr->made_dirty) { + log_flush_order_mutex_enter(); + } /* It is now safe to release the log mutex because the flush_order mutex will ensure that we are the first one @@ -236,7 +265,9 @@ func_exit: mtr_memo_note_modifications(mtr); } - log_flush_order_mutex_exit(); + if (mtr->made_dirty) { + log_flush_order_mutex_exit(); + } } #endif /* !UNIV_HOTBACKUP */ diff --git a/read/read0read.c b/read/read0read.c index f049dd21e8d..c04dae51ff5 100644 --- a/read/read0read.c +++ b/read/read0read.c @@ -145,14 +145,27 @@ read_view_t* read_view_create_low( /*=================*/ ulint n, /*!< in: number of cells in the trx_ids array */ - mem_heap_t* heap) /*!< in: memory heap from which allocated */ + read_view_t* view) /*!< in: pre-allocated view array or NULL if a + new one needs to be created */ { - read_view_t* view; + if (view == NULL) { + view = ut_malloc(sizeof(read_view_t)); + view->max_descr = 0; + view->descriptors = NULL; + } - view = mem_heap_alloc(heap, sizeof(read_view_t)); + if (UNIV_UNLIKELY(view->max_descr < n)) { - view->n_trx_ids = n; - view->trx_ids = mem_heap_alloc(heap, n * sizeof *view->trx_ids); + /* avoid frequent re-allocations by extending the array to the + desired size + 10% */ + + view->max_descr = n + n / 10; + view->descriptors = ut_realloc(view->descriptors, + view->max_descr * + sizeof(trx_id_t)); + } + + view->n_descr = n; return(view); } @@ -169,8 +182,8 @@ read_view_oldest_copy_or_open_new( /*==============================*/ trx_id_t cr_trx_id, /*!< in: trx_id of creating transaction, or 0 used in purge */ - mem_heap_t* heap) /*!< in: memory heap from which - allocated */ + read_view_t* view) /*!< in: pre-allocated view array or + NULL if a new one needs to be created */ { read_view_t* old_view; read_view_t* view_copy; @@ -185,10 +198,10 @@ read_view_oldest_copy_or_open_new( if (old_view == NULL) { - return(read_view_open_now(cr_trx_id, heap)); + return(read_view_open_now(cr_trx_id, view, TRUE)); } - n = old_view->n_trx_ids; + n = old_view->n_descr; if (old_view->creator_trx_id) { n++; @@ -196,7 +209,7 @@ read_view_oldest_copy_or_open_new( needs_insert = FALSE; } - view_copy = read_view_create_low(n, heap); + view_copy = read_view_create_low(n, view); /* Insert the id of the creator in the right place of the descending array of ids, if needs_insert is TRUE: */ @@ -204,7 +217,7 @@ read_view_oldest_copy_or_open_new( i = 0; while (i < n) { if (needs_insert - && (i >= old_view->n_trx_ids + && (i >= old_view->n_descr || old_view->creator_trx_id > read_view_get_nth_trx_id(old_view, i))) { @@ -251,16 +264,17 @@ read_view_open_now( /*===============*/ trx_id_t cr_trx_id, /*!< in: trx_id of creating transaction, or 0 used in purge */ - mem_heap_t* heap) /*!< in: memory heap from which - allocated */ + read_view_t* view, /*!< in: current read view or NULL if it + doesn't exist yet */ + ibool exclude_self) /*!< in: TRUE, if cr_trx_id should be + excluded from the resulting view */ { - read_view_t* view; - trx_t* trx; - ulint n; + trx_id_t* descr; + ulint i; ut_ad(mutex_own(&kernel_mutex)); - view = read_view_create_low(UT_LIST_GET_LEN(trx_sys->trx_list), heap); + view = read_view_create_low(trx_sys->descr_n_used, view); view->creator_trx_id = cr_trx_id; view->type = VIEW_NORMAL; @@ -271,40 +285,58 @@ read_view_open_now( view->low_limit_no = trx_sys->max_trx_id; view->low_limit_id = view->low_limit_no; - n = 0; - trx = UT_LIST_GET_FIRST(trx_sys->trx_list); + /* No active transaction should be visible */ - /* No active transaction should be visible, except cr_trx */ + descr = trx_find_descriptor(trx_sys->descriptors, + trx_sys->descr_n_used, + cr_trx_id); - while (trx) { - if (trx->id != cr_trx_id - && (trx->conc_state == TRX_ACTIVE - || trx->conc_state == TRX_PREPARED)) { + if (UNIV_LIKELY(exclude_self && descr != NULL)) { - read_view_set_nth_trx_id(view, n, trx->id); + ut_ad(trx_sys->descr_n_used > 0); + ut_ad(view->n_descr > 0); - n++; + view->n_descr--; - /* NOTE that a transaction whose trx number is < - trx_sys->max_trx_id can still be active, if it is - in the middle of its commit! Note that when a - transaction starts, we initialize trx->no to - IB_ULONGLONG_MAX. */ - - if (view->low_limit_no > trx->no) { - - view->low_limit_no = trx->no; - } - } - - trx = UT_LIST_GET_NEXT(trx_list, trx); + i = descr - trx_sys->descriptors; + } else { + i = trx_sys->descr_n_used; } - view->n_trx_ids = n; + if (UNIV_LIKELY(i > 0)) { - if (n > 0) { + /* Copy the [0; i-1] range */ + memcpy(view->descriptors, trx_sys->descriptors, + i * sizeof(trx_id_t)); + } + + if (UNIV_UNLIKELY(i + 1 < trx_sys->descr_n_used)) { + + /* Copy the [i+1; descr_n_used-1] range */ + memcpy(view->descriptors + i, + trx_sys->descriptors + i + 1, + (trx_sys->descr_n_used - i - 1) * + sizeof(trx_id_t)); + } + + /* NOTE that a transaction whose trx number is < trx_sys->max_trx_id can + still be active, if it is in the middle of its commit! Note that when a + transaction starts, we initialize trx->no to IB_ULONGLONG_MAX. */ + + if (UT_LIST_GET_LEN(trx_sys->trx_serial_list) > 0) { + + trx_id_t trx_no; + + trx_no = UT_LIST_GET_FIRST(trx_sys->trx_serial_list)->no; + + if (trx_no < view->low_limit_no) { + view->low_limit_no = trx_no; + } + } + + if (UNIV_LIKELY(view->n_descr > 0)) { /* The last active transaction has the smallest id: */ - view->up_limit_id = read_view_get_nth_trx_id(view, n - 1); + view->up_limit_id = view->descriptors[0]; } else { view->up_limit_id = view->low_limit_id; } @@ -328,6 +360,23 @@ read_view_close( UT_LIST_REMOVE(view_list, trx_sys->view_list, view); } +/*********************************************************************//** +Frees resource allocated by a read view. */ +UNIV_INTERN +void +read_view_free( +/*===========*/ + read_view_t* view) /*< in: read view */ +{ + ut_ad(mutex_own(&kernel_mutex)); + + if (view->descriptors != NULL) { + ut_free(view->descriptors); + } + + ut_free(view); +} + /*********************************************************************//** Closes a consistent read view for MySQL. This function is called at an SQL statement end if the trx isolation level is <= TRX_ISO_READ_COMMITTED. */ @@ -343,8 +392,6 @@ read_view_close_for_mysql( read_view_close(trx->global_read_view); - mem_heap_empty(trx->global_read_view_heap); - trx->read_view = NULL; trx->global_read_view = NULL; @@ -382,7 +429,7 @@ read_view_print( fprintf(file, "Read view individually stored trx ids:\n"); - n_ids = view->n_trx_ids; + n_ids = view->n_descr; for (i = 0; i < n_ids; i++) { fprintf(file, "Read view trx id " TRX_ID_FMT "\n", @@ -404,8 +451,6 @@ read_cursor_view_create_for_mysql( cursor_view_t* curview; read_view_t* view; mem_heap_t* heap; - trx_t* trx; - ulint n; ut_a(cr_trx); @@ -424,61 +469,14 @@ read_cursor_view_create_for_mysql( mutex_enter(&kernel_mutex); - curview->read_view = read_view_create_low( - UT_LIST_GET_LEN(trx_sys->trx_list), curview->heap); - - view = curview->read_view; - view->creator_trx_id = cr_trx->id; - view->type = VIEW_HIGH_GRANULARITY; - view->undo_no = cr_trx->undo_no; - - /* No future transactions should be visible in the view */ - - view->low_limit_no = trx_sys->max_trx_id; - view->low_limit_id = view->low_limit_no; - - n = 0; - trx = UT_LIST_GET_FIRST(trx_sys->trx_list); - - /* No active transaction should be visible */ - - while (trx) { - - if (trx->conc_state == TRX_ACTIVE - || trx->conc_state == TRX_PREPARED) { - - read_view_set_nth_trx_id(view, n, trx->id); - - n++; - - /* NOTE that a transaction whose trx number is < - trx_sys->max_trx_id can still be active, if it is - in the middle of its commit! Note that when a - transaction starts, we initialize trx->no to - IB_ULONGLONG_MAX. */ - - if (view->low_limit_no > trx->no) { - - view->low_limit_no = trx->no; - } - } - - trx = UT_LIST_GET_NEXT(trx_list, trx); - } - - view->n_trx_ids = n; - - if (n > 0) { - /* The last active transaction has the smallest id: */ - view->up_limit_id = read_view_get_nth_trx_id(view, n - 1); - } else { - view->up_limit_id = view->low_limit_id; - } - - UT_LIST_ADD_FIRST(view_list, trx_sys->view_list, view); + curview->read_view = read_view_open_now(cr_trx->id, NULL, FALSE); mutex_exit(&kernel_mutex); + view = curview->read_view; + view->type = VIEW_HIGH_GRANULARITY; + view->undo_no = cr_trx->undo_no; + return(curview); } @@ -503,6 +501,8 @@ read_cursor_view_close_for_mysql( mutex_enter(&kernel_mutex); read_view_close(curview->read_view); + read_view_free(curview->read_view); + trx->read_view = trx->global_read_view; mutex_exit(&kernel_mutex); diff --git a/row/row0ins.c b/row/row0ins.c index fda0c55b5c7..0002f4410d6 100644 --- a/row/row0ins.c +++ b/row/row0ins.c @@ -1346,11 +1346,11 @@ run_again: const rec_t* rec = btr_pcur_get_rec(&pcur); const buf_block_t* block = btr_pcur_get_block(&pcur); - if (srv_pass_corrupt_table && !block) { + SRV_CORRUPT_TABLE_CHECK(block, + { err = DB_CORRUPTION; - break; - } - ut_a(block); + goto exit_loop; + }); if (page_rec_is_infimum(rec)) { @@ -1474,6 +1474,7 @@ run_again: } } while (btr_pcur_move_to_next(&pcur, &mtr)); +exit_loop: if (check_ref) { row_ins_foreign_report_add_err( trx, foreign, btr_pcur_get_rec(&pcur), entry); diff --git a/row/row0merge.c b/row/row0merge.c index 460a44e34b2..ade708f93e7 100644 --- a/row/row0merge.c +++ b/row/row0merge.c @@ -1298,11 +1298,11 @@ row_merge_read_clustered_index( if (UNIV_LIKELY(has_next)) { rec = btr_pcur_get_rec(&pcur); - if (srv_pass_corrupt_table && !rec) { + SRV_CORRUPT_TABLE_CHECK(rec, + { err = DB_CORRUPTION; goto err_exit; - } - ut_a(rec); + }); offsets = rec_get_offsets(rec, clust_index, NULL, ULINT_UNDEFINED, &row_heap); diff --git a/row/row0sel.c b/row/row0sel.c index eb60aaa2314..f5b2c0fd014 100644 --- a/row/row0sel.c +++ b/row/row0sel.c @@ -3813,9 +3813,9 @@ release_search_latch_if_needed: trx->has_search_latch = FALSE; } - ut_ad(prebuilt->sql_stat_start || trx->conc_state == TRX_ACTIVE); - ut_ad(trx->conc_state == TRX_NOT_STARTED - || trx->conc_state == TRX_ACTIVE); + ut_ad(prebuilt->sql_stat_start || trx->state == TRX_ACTIVE); + ut_ad(trx->state == TRX_NOT_STARTED + || trx->state == TRX_ACTIVE); ut_ad(prebuilt->sql_stat_start || prebuilt->select_lock_type != LOCK_NONE || trx->read_view); @@ -3997,11 +3997,11 @@ rec_loop: rec = btr_pcur_get_rec(pcur); - if (srv_pass_corrupt_table && !rec) { + SRV_CORRUPT_TABLE_CHECK(rec, + { err = DB_CORRUPTION; goto lock_wait_or_error; - } - ut_a(rec); + }); ut_ad(!!page_rec_is_comp(rec) == comp); #ifdef UNIV_SEARCH_DEBUG @@ -4138,8 +4138,9 @@ wrong_offs: offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); - if (UNIV_UNLIKELY(srv_force_recovery > 0) - || (srv_pass_corrupt_table == 2 && index->table->is_corrupt)) { + if (UNIV_UNLIKELY(srv_force_recovery > 0 + || (index->table->is_corrupt && + srv_pass_corrupt_table == 2))) { if (!rec_validate(rec, offsets) || !btr_index_rec_validate(rec, index, FALSE)) { fprintf(stderr, @@ -4896,8 +4897,10 @@ row_search_check_if_query_cache_permitted( if (trx->isolation_level >= TRX_ISO_REPEATABLE_READ && !trx->read_view) { - trx->read_view = read_view_open_now( - trx->id, trx->global_read_view_heap); + trx->read_view = + read_view_open_now(trx->id, + NULL, TRUE); + trx->global_read_view = trx->read_view; } } diff --git a/row/row0vers.c b/row/row0vers.c index 6d83dbaf8ee..3fd13b829a2 100644 --- a/row/row0vers.c +++ b/row/row0vers.c @@ -667,9 +667,9 @@ row_vers_build_for_semi_consistent_read( mutex_enter(&kernel_mutex); version_trx = trx_get_on_id(version_trx_id); - if (version_trx - && (version_trx->conc_state == TRX_COMMITTED_IN_MEMORY - || version_trx->conc_state == TRX_NOT_STARTED)) { + if (version_trx && + (version_trx->state == TRX_COMMITTED_IN_MEMORY + || version_trx->state == TRX_NOT_STARTED)) { version_trx = NULL; } diff --git a/srv/srv0srv.c b/srv/srv0srv.c index adcc0aa1cc2..9c8abc5dac1 100644 --- a/srv/srv0srv.c +++ b/srv/srv0srv.c @@ -430,8 +430,6 @@ UNIV_INTERN ulint srv_expand_import = 0; /* 0:disable 1:enable */ UNIV_INTERN ulint srv_pass_corrupt_table = 0; /* 0:disable 1:enable */ UNIV_INTERN ulint srv_dict_size_limit = 0; - -UNIV_INTERN ulint srv_lazy_drop_table = 0; /*-------------------------------------------*/ UNIV_INTERN ulong srv_n_spin_wait_rounds = 30; UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500; @@ -2925,7 +2923,7 @@ rescan_idle: mutex_enter(&kernel_mutex); trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list); while (trx) { - if (trx->conc_state == TRX_ACTIVE + if (trx->state == TRX_ACTIVE && trx->mysql_thd && innobase_thd_is_idle(trx->mysql_thd)) { ib_int64_t start_time = innobase_thd_get_start_time(trx->mysql_thd); diff --git a/trx/trx0purge.c b/trx/trx0purge.c index b048dc66efe..1e119c6828b 100644 --- a/trx/trx0purge.c +++ b/trx/trx0purge.c @@ -263,8 +263,9 @@ trx_purge_sys_create( purge_sys->query = trx_purge_graph_build(); - purge_sys->view = read_view_oldest_copy_or_open_new(0, - purge_sys->heap); + purge_sys->prebuilt_view = + read_view_oldest_copy_or_open_new(0, NULL); + purge_sys->view = purge_sys->prebuilt_view; } /************************************************************************ @@ -279,7 +280,12 @@ trx_purge_sys_close(void) que_graph_free(purge_sys->query); ut_a(purge_sys->sess->trx->is_purge); - purge_sys->sess->trx->conc_state = TRX_NOT_STARTED; + purge_sys->sess->trx->state = TRX_NOT_STARTED; + + mutex_enter(&kernel_mutex); + trx_release_descriptor(purge_sys->sess->trx); + mutex_exit(&kernel_mutex); + sess_close(purge_sys->sess); purge_sys->sess = NULL; @@ -289,6 +295,8 @@ trx_purge_sys_close(void) mutex_enter(&kernel_mutex); read_view_close(purge_sys->view); + read_view_free(purge_sys->prebuilt_view); + purge_sys->prebuilt_view = NULL; purge_sys->view = NULL; mutex_exit(&kernel_mutex); @@ -1177,7 +1185,7 @@ trx_purge( } purge_sys->view = read_view_oldest_copy_or_open_new( - 0, purge_sys->heap); + 0, purge_sys->prebuilt_view); mutex_exit(&kernel_mutex); diff --git a/trx/trx0roll.c b/trx/trx0roll.c index b55471959ce..ae42623a1d9 100644 --- a/trx/trx0roll.c +++ b/trx/trx0roll.c @@ -132,7 +132,7 @@ trx_rollback_for_mysql( { int err; - if (trx->conc_state == TRX_NOT_STARTED) { + if (trx->state == TRX_NOT_STARTED) { return(DB_SUCCESS); } @@ -161,7 +161,7 @@ trx_rollback_last_sql_stat_for_mysql( { int err; - if (trx->conc_state == TRX_NOT_STARTED) { + if (trx->state == TRX_NOT_STARTED) { return(DB_SUCCESS); } @@ -263,7 +263,7 @@ trx_rollback_to_savepoint_for_mysql( return(DB_NO_SAVEPOINT); } - if (trx->conc_state == TRX_NOT_STARTED) { + if (trx->state == TRX_NOT_STARTED) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: transaction has a savepoint ", stderr); ut_print_name(stderr, trx, FALSE, savep->name); @@ -560,7 +560,7 @@ loop: continue; } - switch (trx->conc_state) { + switch (trx->state) { case TRX_NOT_STARTED: case TRX_PREPARED: continue; diff --git a/trx/trx0sys.c b/trx/trx0sys.c index 978748642bf..5f589b70343 100644 --- a/trx/trx0sys.c +++ b/trx/trx0sys.c @@ -1319,6 +1319,12 @@ trx_sys_init_at_db_start(void) trx_sys = mem_zalloc(sizeof(*trx_sys)); + /* Allocate the trx descriptors array */ + trx_sys->descriptors = ut_malloc(sizeof(trx_id_t) * + TRX_DESCR_ARRAY_INITIAL_SIZE); + trx_sys->descr_n_max = TRX_DESCR_ARRAY_INITIAL_SIZE; + trx_sys->descr_n_used = 0; + sys_header = trx_sysf_get(&mtr); trx_rseg_list_and_array_init(sys_header, ib_bh, &mtr); @@ -1346,7 +1352,7 @@ trx_sys_init_at_db_start(void) for (;;) { - if (trx->conc_state != TRX_PREPARED) { + if (trx->state != TRX_PREPARED) { rows_to_undo += trx->undo_no; } @@ -2028,6 +2034,9 @@ trx_sys_close(void) ut_a(UT_LIST_GET_LEN(trx_sys->view_list) == 0); ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0); + ut_ad(trx_sys->descr_n_used == 0); + ut_free(trx_sys->descriptors); + mem_free(trx_sys); trx_sys = NULL; diff --git a/trx/trx0trx.c b/trx/trx0trx.c index c5e26f8d7d1..f061bb4c0b6 100644 --- a/trx/trx0trx.c +++ b/trx/trx0trx.c @@ -85,6 +85,126 @@ trx_set_detailed_error_from_file( sizeof(trx->detailed_error)); } +/*************************************************************//** +Callback function for trx_find_descriptor() to compare trx IDs. */ +UNIV_INTERN +int +trx_descr_cmp( +/*==========*/ + const void *a, /*!< in: pointer to first comparison argument */ + const void *b) /*!< in: pointer to second comparison argument */ +{ + const trx_id_t* da = (const trx_id_t*) a; + const trx_id_t* db = (const trx_id_t*) b; + + if (*da < *db) { + return -1; + } else if (*da > *db) { + return 1; + } + + return 0; +} + +/*************************************************************//** +Reserve a slot for a given trx in the global descriptors array. */ +UNIV_INLINE +void +trx_reserve_descriptor( +/*===================*/ + const trx_t* trx) /*!< in: trx pointer */ +{ + ulint n_used; + ulint n_max; + trx_id_t* descr; + + ut_ad(mutex_own(&kernel_mutex)); + ut_ad(!trx_find_descriptor(trx_sys->descriptors, + trx_sys->descr_n_used, + trx->id)); + + n_used = trx_sys->descr_n_used + 1; + n_max = trx_sys->descr_n_max; + + if (UNIV_UNLIKELY(n_used > n_max)) { + + n_max = n_max * 2; + + trx_sys->descriptors = + ut_realloc(trx_sys->descriptors, + n_max * sizeof(trx_id_t)); + + trx_sys->descr_n_max = n_max; + } + + descr = trx_sys->descriptors + n_used - 1; + + if (UNIV_UNLIKELY(n_used > 1 && trx->id < descr[-1])) { + + /* Find the slot where it should be inserted. We could use a + binary search, but in reality linear search should be faster, + because the slot we are looking for is near the array end. */ + + trx_id_t* tdescr; + + for (tdescr = descr - 1; + tdescr >= trx_sys->descriptors && *tdescr > trx->id; + tdescr--) { + } + + tdescr++; + + ut_memmove(tdescr + 1, tdescr, (descr - tdescr) * + sizeof(trx_id_t)); + + descr = tdescr; + } + + *descr = trx->id; + + trx_sys->descr_n_used = n_used; +} + +/*************************************************************//** +Release a slot for a given trx in the global descriptors array. */ +UNIV_INTERN +void +trx_release_descriptor( +/*===================*/ + trx_t* trx) /*!< in: trx pointer */ +{ + ulint size; + trx_id_t* descr; + + ut_ad(mutex_own(&kernel_mutex)); + + if (UNIV_LIKELY(trx->is_in_trx_serial_list)) { + + UT_LIST_REMOVE(trx_serial_list, trx_sys->trx_serial_list, + trx); + trx->is_in_trx_serial_list = 0; + } + + descr = trx_find_descriptor(trx_sys->descriptors, + trx_sys->descr_n_used, + trx->id); + + if (UNIV_UNLIKELY(descr == NULL)) { + + return; + } + + size = (trx_sys->descriptors + trx_sys->descr_n_used - 1 - descr) * + sizeof(trx_id_t); + + if (UNIV_LIKELY(size > 0)) { + + ut_memmove(descr, descr + 1, size); + } + + trx_sys->descr_n_used--; +} + /****************************************************************//** Creates and initializes a transaction object. @return own: the transaction */ @@ -107,7 +227,7 @@ trx_create( trx->is_purge = 0; trx->is_recovered = 0; - trx->conc_state = TRX_NOT_STARTED; + trx->state = TRX_NOT_STARTED; trx->is_registered = 0; trx->owns_prepare_mutex = 0; @@ -119,6 +239,7 @@ trx_create( trx->id = 0; trx->no = IB_ULONGLONG_MAX; + trx->is_in_trx_serial_list = 0; trx->support_xa = TRUE; @@ -190,9 +311,9 @@ trx_create( trx->declared_to_be_inside_innodb = FALSE; trx->n_tickets_to_enter_innodb = 0; - trx->global_read_view_heap = mem_heap_create(256); trx->global_read_view = NULL; trx->read_view = NULL; + trx->prebuilt_view = NULL; trx->io_reads = 0; trx->io_read = 0; @@ -328,7 +449,7 @@ trx_free( trx->magic_n = 11112222; - ut_a(trx->conc_state == TRX_NOT_STARTED); + ut_a(trx->state == TRX_NOT_STARTED); mutex_free(&(trx->undo_mutex)); @@ -355,18 +476,18 @@ trx_free( ut_a(UT_LIST_GET_LEN(trx->trx_locks) == 0); - if (trx->global_read_view_heap) { - mem_heap_free(trx->global_read_view_heap); + if (trx->prebuilt_view != NULL) { + read_view_free(trx->prebuilt_view); } - trx->global_read_view = NULL; - ut_a(trx->read_view == NULL); ut_a(ib_vector_is_empty(trx->autoinc_locks)); /* We allocated a dedicated heap for the vector. */ ib_vector_free(trx->autoinc_locks); + trx_release_descriptor(trx); + mem_free(trx); } @@ -379,7 +500,7 @@ trx_free_prepared( trx_t* trx) /*!< in, own: trx object */ { ut_ad(mutex_own(&kernel_mutex)); - ut_a(trx->conc_state == TRX_PREPARED); + ut_a(trx->state == TRX_PREPARED); ut_a(trx->magic_n == TRX_MAGIC_N); /* Prepared transactions are sort of active; they allow @@ -412,15 +533,19 @@ trx_free_prepared( mem_heap_free(trx->lock_heap); } - if (trx->global_read_view_heap) { - mem_heap_free(trx->global_read_view_heap); - } - ut_a(ib_vector_is_empty(trx->autoinc_locks)); ib_vector_free(trx->autoinc_locks); + trx_release_descriptor(trx); + + if (trx->prebuilt_view != NULL) { + read_view_free(trx->prebuilt_view); + } + UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx); + ut_ad(trx_sys->descr_n_used <= UT_LIST_GET_LEN(trx_sys->trx_list)); + mem_free(trx); } @@ -529,6 +654,7 @@ trx_lists_init_at_db_start(void) ut_ad(mutex_own(&kernel_mutex)); UT_LIST_INIT(trx_sys->trx_list); + UT_LIST_INIT(trx_sys->trx_serial_list); /* Look from the rollback segments if there exist undo logs for transactions */ @@ -565,7 +691,7 @@ trx_lists_init_at_db_start(void) if (srv_force_recovery == 0) { - trx->conc_state = TRX_PREPARED; + trx->state = TRX_PREPARED; trx_n_prepared++; } else { fprintf(stderr, @@ -575,11 +701,12 @@ trx_lists_init_at_db_start(void) " rollback it" " anyway.\n"); - trx->conc_state = TRX_ACTIVE; + trx->state = TRX_ACTIVE; } + + trx_reserve_descriptor(trx); } else { - trx->conc_state - = TRX_COMMITTED_IN_MEMORY; + trx->state = TRX_COMMITTED_IN_MEMORY; } /* We give a dummy value for the trx no; @@ -591,12 +718,15 @@ trx_lists_init_at_db_start(void) trx->no = trx->id; } else { - trx->conc_state = TRX_ACTIVE; + trx->state = TRX_ACTIVE; /* A running transaction always has the number field inited to IB_ULONGLONG_MAX */ trx->no = IB_ULONGLONG_MAX; + + trx_reserve_descriptor(trx); + } if (undo->dict_operation) { @@ -641,7 +771,7 @@ trx_lists_init_at_db_start(void) if (srv_force_recovery == 0) { - trx->conc_state + trx->state = TRX_PREPARED; trx_n_prepared++; } else { @@ -652,11 +782,12 @@ trx_lists_init_at_db_start(void) " rollback it" " anyway.\n"); - trx->conc_state - = TRX_ACTIVE; + trx->state = TRX_ACTIVE; + trx_reserve_descriptor( + trx); } } else { - trx->conc_state + trx->state = TRX_COMMITTED_IN_MEMORY; } @@ -665,13 +796,14 @@ trx_lists_init_at_db_start(void) trx->no = trx->id; } else { - trx->conc_state = TRX_ACTIVE; - + trx->state = TRX_ACTIVE; /* A running transaction always has the number field inited to IB_ULONGLONG_MAX */ trx->no = IB_ULONGLONG_MAX; + + trx_reserve_descriptor(trx); } trx->rseg = rseg; @@ -742,13 +874,15 @@ trx_start_low( if (trx->is_purge) { trx->id = 0; - trx->conc_state = TRX_ACTIVE; + /* Don't reserve a descriptor, since this trx is not added to + trx_list. */ + trx->state = TRX_ACTIVE; trx->start_time = time(NULL); return(TRUE); } - ut_ad(trx->conc_state != TRX_ACTIVE); + ut_ad(trx->state != TRX_ACTIVE); ut_a(rseg_id == ULINT_UNDEFINED); @@ -763,7 +897,10 @@ trx_start_low( trx->rseg = rseg; - trx->conc_state = TRX_ACTIVE; + trx->state = TRX_ACTIVE; + + trx_reserve_descriptor(trx); + trx->start_time = time(NULL); UT_LIST_ADD_FIRST(trx_list, trx_sys->trx_list, trx); @@ -820,6 +957,14 @@ trx_serialisation_number_get( trx->no = trx_sys_get_new_trx_id(); + if (UNIV_LIKELY(trx->is_in_trx_serial_list == 0)) { + + UT_LIST_ADD_LAST(trx_serial_list, trx_sys->trx_serial_list, + trx); + + trx->is_in_trx_serial_list = 1; + } + /* If the rollack segment is not empty then the new trx_t::no can't be less than any trx_t::no already in the rollback segment. User threads only @@ -1001,10 +1146,10 @@ trx_commit_off_kernel( lsn = 0; } - ut_ad(trx->conc_state == TRX_ACTIVE || trx->conc_state == TRX_PREPARED); + ut_ad(trx->state == TRX_ACTIVE || trx->state == TRX_PREPARED); ut_ad(mutex_own(&kernel_mutex)); - if (UNIV_UNLIKELY(trx->conc_state == TRX_PREPARED)) { + if (UNIV_UNLIKELY(trx->state == TRX_PREPARED)) { ut_a(trx_n_prepared > 0); trx_n_prepared--; } @@ -1024,7 +1169,9 @@ trx_commit_off_kernel( committed. */ /*--------------------------------------*/ - trx->conc_state = TRX_COMMITTED_IN_MEMORY; + trx->state = TRX_COMMITTED_IN_MEMORY; + /* The following also removes trx from trx_serial_list */ + trx_release_descriptor(trx); /*--------------------------------------*/ /* If we release kernel_mutex below and we are still doing @@ -1045,7 +1192,6 @@ trx_commit_off_kernel( if (trx->global_read_view) { read_view_close(trx->global_read_view); - mem_heap_empty(trx->global_read_view_heap); trx->global_read_view = NULL; } @@ -1131,7 +1277,7 @@ trx_commit_off_kernel( /* Free all savepoints */ trx_roll_free_all_savepoints(trx); - trx->conc_state = TRX_NOT_STARTED; + trx->state = TRX_NOT_STARTED; trx->rseg = NULL; trx->undo_no = 0; trx->last_sql_stat_start.least_undo_no = 0; @@ -1141,6 +1287,8 @@ trx_commit_off_kernel( UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx); + ut_ad(trx_sys->descr_n_used <= UT_LIST_GET_LEN(trx_sys->trx_list)); + trx->error_state = DB_SUCCESS; } @@ -1159,12 +1307,15 @@ trx_cleanup_at_db_startup( trx_undo_insert_cleanup(trx); } - trx->conc_state = TRX_NOT_STARTED; + trx->state = TRX_NOT_STARTED; + trx_release_descriptor(trx); trx->rseg = NULL; trx->undo_no = 0; trx->last_sql_stat_start.least_undo_no = 0; UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx); + + ut_ad(trx_sys->descr_n_used <= UT_LIST_GET_LEN(trx_sys->trx_list)); } /********************************************************************//** @@ -1178,7 +1329,7 @@ trx_assign_read_view( /*=================*/ trx_t* trx) /*!< in: active transaction */ { - ut_ad(trx->conc_state == TRX_ACTIVE); + ut_ad(trx->state == TRX_ACTIVE); if (trx->read_view) { return(trx->read_view); @@ -1186,11 +1337,9 @@ trx_assign_read_view( mutex_enter(&kernel_mutex); - if (!trx->read_view) { - trx->read_view = read_view_open_now( - trx->id, trx->global_read_view_heap); - trx->global_read_view = trx->read_view; - } + trx->read_view = read_view_open_now(trx->id, trx->prebuilt_view, TRUE); + trx->prebuilt_view = trx->read_view; + trx->global_read_view = trx->read_view; mutex_exit(&kernel_mutex); @@ -1555,7 +1704,7 @@ loop: return; } - if (trx->conc_state == TRX_NOT_STARTED) { + if (trx->state == TRX_NOT_STARTED) { trx_start_low(trx, ULINT_UNDEFINED); } @@ -1847,7 +1996,7 @@ trx_mark_sql_stat_end( { ut_a(trx); - if (trx->conc_state == TRX_NOT_STARTED) { + if (trx->state == TRX_NOT_STARTED) { trx->undo_no = 0; } @@ -1870,7 +2019,7 @@ trx_print( fprintf(f, "TRANSACTION " TRX_ID_FMT, (ullint) trx->id); - switch (trx->conc_state) { + switch (trx->state) { case TRX_NOT_STARTED: fputs(", not started", f); break; @@ -1886,7 +2035,7 @@ trx_print( fputs(", COMMITTED IN MEMORY", f); break; default: - fprintf(f, " state %lu", (ulong) trx->conc_state); + fprintf(f, " state %lu", (ulong) trx->state); } if (*trx->op_info) { @@ -2081,7 +2230,11 @@ trx_prepare_off_kernel( ut_ad(mutex_own(&kernel_mutex)); /*--------------------------------------*/ - trx->conc_state = TRX_PREPARED; + if (UNIV_UNLIKELY(trx->state != TRX_ACTIVE)) { + + trx_reserve_descriptor(trx); + } + trx->state = TRX_PREPARED; trx_n_prepared++; /*--------------------------------------*/ @@ -2195,7 +2348,7 @@ trx_recover_for_mysql( trx = UT_LIST_GET_FIRST(trx_sys->trx_list); while (trx) { - if (trx->conc_state == TRX_PREPARED) { + if (trx->state == TRX_PREPARED) { xid_list[count] = trx->xid; if (count == 0) { @@ -2268,7 +2421,7 @@ trx_get_trx_by_xid( the same */ if (trx->is_recovered - && trx->conc_state == TRX_PREPARED + && trx->state == TRX_PREPARED && xid->gtrid_length == trx->xid.gtrid_length && xid->bqual_length == trx->xid.bqual_length && memcmp(xid->data, trx->xid.data, From e013bf9f0e2ffd05de5bfe95c4102e61b08ac06a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 8 May 2013 13:36:17 +0400 Subject: [PATCH 141/273] The bug MDEV-4489 "Replication of big5, cp932, gbk, sjis strings makes wrong values on slave" has been fixed. Problem: String constants of some Asian charsets (big5,cp932,gbk,sjis) can have backslash '\' (0x5C) in the second byte of multi-byte characters. Replicating of such constants using the standard '\'-escaping is dangerous. Therefore, constants of these charsets are replicated using hex notation: INSERT INTO t1 (a) VALUES (0x815C); However, 0xHHHH constants do not work well in some cases, because they can behave as strings and as numbers, depending on context (for example, depending on the data type of the column in an INSERT statement). This SQL script was not replicated correctly with statement-based replication: SET NAMES gbk; PREPARE STMT FROM 'INSERT INTO t1 (a) VALUES (?)'; SET @a = '1'; EXECUTE STMT USING @a; The INSERT statement was replicated as: INSERT INTO t1 (a) VALUES (0x31); '1' was correctly converted to the number 1 on master. But the 0x31 constant was treated as number 49 on slave. Fix: 1. Binary log now uses X'HHHH' instead of 0xHHHH constants. 2. The X'HHHH' constants now work always as strings, in all contexts. This is the SQL standard compliant behaviour. After the fix, the above statement is replicated as: INSERT INTO t1 (a) VALUES (X'31'); X'31' is treated as string '1' on slave, and is correctly converted to 1. modified: @ mysql-test/r/ctype_cp932_binlog_stm.result @ mysql-test/r/select.result @ mysql-test/r/select_jcl6.result @ mysql-test/r/select_pkeycache.result @ mysql-test/r/user_var-binlog.result @ mysql-test/r/varbinary.result @ mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result @ mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result @ mysql-test/suite/rpl/r/rpl_charset_sjis.result @ mysql-test/suite/rpl/r/rpl_mdev382.result @ mysql-test/suite/rpl/t/rpl_charset_sjis.test @ mysql-test/t/ctype_cp932_binlog_stm.test @ mysql-test/t/select.test @ mysql-test/t/varbinary.test Adding and updating tests @ sql/item.cc @ sql/item.h @ sql/sql_yacc.yy @ sql/sql_lex.cc Splitting the implementations of X'HH' and 0xHH constants into two separate classes. Fixing the parser to distinguish the two syntaxes. @ sql/log_event.cc Using X'HH' instead of 0xHH for binary logging for string constants of the "dangerous" charsets. @ sql/sql_string.h Adding a helped method String::append_hex(). --- mysql-test/r/ctype_cp932_binlog_stm.result | 37 +++++- mysql-test/r/select.result | 4 +- mysql-test/r/select_jcl6.result | 4 +- mysql-test/r/select_pkeycache.result | 4 +- mysql-test/r/user_var-binlog.result | 12 +- mysql-test/r/varbinary.result | 61 +++++++++- .../binlog/r/binlog_stm_ctype_ucs.result | 4 +- .../r/binlog_stm_mix_innodb_myisam.result | 4 +- .../suite/rpl/r/rpl_charset_sjis.result | 32 +++++ mysql-test/suite/rpl/r/rpl_mdev382.result | 4 +- mysql-test/suite/rpl/t/rpl_charset_sjis.test | 33 +++++ mysql-test/t/ctype_cp932_binlog_stm.test | 17 +++ mysql-test/t/select.test | 2 +- mysql-test/t/varbinary.test | 27 ++++- sql/item.cc | 52 +++----- sql/item.h | 114 +++++++++++++++--- sql/log_event.cc | 15 ++- sql/sql_lex.cc | 2 +- sql/sql_string.h | 10 ++ sql/sql_yacc.yy | 27 ++++- 20 files changed, 376 insertions(+), 89 deletions(-) diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result index 1e62787835f..deca926a69c 100644 --- a/mysql-test/r/ctype_cp932_binlog_stm.result +++ b/mysql-test/r/ctype_cp932_binlog_stm.result @@ -10,7 +10,7 @@ show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; CREATE TABLE t1(f1 blob) master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(0x8300) +master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(X'8300') master-bin.000001 # Query # # COMMIT SELECT HEX(f1) FROM t1; HEX(f1) @@ -44,7 +44,7 @@ BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172 COLLATE 'latin1_swedish_ci'), NAME_CONST('ins2',_cp932 0xED40ED41ED42 COLLATE 'cp932_japanese_ci'), NAME_CONST('ind',47.93)) +master-bin.000001 # Query # # use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 X'466F6F2773206120426172' COLLATE 'latin1_swedish_ci'), NAME_CONST('ins2',_cp932 X'ED40ED41ED42' COLLATE 'cp932_japanese_ci'), NAME_CONST('ind',47.93)) master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP PROCEDURE bug18293 master-bin.000001 # Query # # use `test`; DROP TABLE `t4` /* generated by server */ @@ -19491,5 +19491,38 @@ EFBFA4 FA55 EFBFA5 818F DROP TABLE t1; # +# Bug#MDEV-4489 Replication of big5, cp932, gbk, sjis strings makes wrong values on slave +# +SET NAMES cp932; +CREATE TABLE t1 (a INT); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (0x31); +INSERT INTO t1 VALUES (X'31'); +PREPARE stmt FROM 'INSERT INTO t1 (a) VALUES (?)'; +SET @a='1'; +SELECT charset(@a); +charset(@a) +cp932 +EXECUTE stmt USING @a; +DROP PREPARE stmt; +DROP TABLE t1; +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT) +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (0x31) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (X'31') +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t1 (a) VALUES (X'31') +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +# # End of 5.5 tests # diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 38a991990be..c086a62275a 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2921,8 +2921,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) DROP TABLE t1,t2; -select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; -x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +select x'3136' + 0, X'3136' + 0, b'10' + 0, B'10' + 0; +x'3136' + 0 X'3136' + 0 b'10' + 0 B'10' + 0 16 16 2 2 create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index 8fa4f27b4b8..00b356fc1c0 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -2932,8 +2932,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t2.a 5 Using where; Using join buffer (flat, BNLH join) DROP TABLE t1,t2; -select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; -x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +select x'3136' + 0, X'3136' + 0, b'10' + 0, B'10' + 0; +x'3136' + 0 X'3136' + 0 b'10' + 0 B'10' + 0 16 16 2 2 create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index 38a991990be..c086a62275a 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -2921,8 +2921,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) DROP TABLE t1,t2; -select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; -x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +select x'3136' + 0, X'3136' + 0, b'10' + 0, B'10' + 0; +x'3136' + 0 X'3136' + 0 b'10' + 0 B'10' + 0 16 16 2 2 create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); diff --git a/mysql-test/r/user_var-binlog.result b/mysql-test/r/user_var-binlog.result index ae4bd68a435..8aae1bca4f6 100644 --- a/mysql-test/r/user_var-binlog.result +++ b/mysql-test/r/user_var-binlog.result @@ -9,12 +9,12 @@ insert into t1 values (@var1),(@var2); show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # User var # # @`a b`=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci +master-bin.000001 # User var # # @`a b`=_latin1 X'68656C6C6F' COLLATE latin1_swedish_ci master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(@`a b`) master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # BEGIN -master-bin.000001 # User var # # @`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci -master-bin.000001 # User var # # @`var2`=_binary 0x61 COLLATE binary +master-bin.000001 # User var # # @`var1`=_latin1 X'273B616161' COLLATE latin1_swedish_ci +master-bin.000001 # User var # # @`var2`=_binary X'61' COLLATE binary master-bin.000001 # Query # # use `test`; insert into t1 values (@var1),(@var2) master-bin.000001 # Query # # COMMIT flush logs; @@ -34,7 +34,7 @@ SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/; +SET @`a b`:=_latin1 X'68656C6C6F' COLLATE `latin1_swedish_ci`/*!*/; use `test`/*!*/; SET TIMESTAMP=10000/*!*/; INSERT INTO t1 VALUES(@`a b`) @@ -45,8 +45,8 @@ COMMIT SET TIMESTAMP=10000/*!*/; BEGIN /*!*/; -SET @`var1`:=_latin1 0x273B616161 COLLATE `latin1_swedish_ci`/*!*/; -SET @`var2`:=_binary 0x61 COLLATE `binary`/*!*/; +SET @`var1`:=_latin1 X'273B616161' COLLATE `latin1_swedish_ci`/*!*/; +SET @`var2`:=_binary X'61' COLLATE `binary`/*!*/; SET TIMESTAMP=10000/*!*/; insert into t1 values (@var1),(@var2) /*!*/; diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result index 065abbb9c00..689db16b5d4 100644 --- a/mysql-test/r/varbinary.result +++ b/mysql-test/r/varbinary.result @@ -5,9 +5,62 @@ A 65 9223372036854775807 18446744073709551615 select 0x31+1,concat(0x31)+1,-0xf; 0x31+1 concat(0x31)+1 -0xf 50 2 -15 -select x'31',X'ffff'+0; -x'31' X'ffff'+0 +select x'31',0xffff+0; +x'31' 0xffff+0 1 65535 +select X'FFFF'+0; +X'FFFF'+0 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\xFF\xFF' +SELECT x'31'+0, 0x31+0; +x'31'+0 0x31+0 +1 49 +SELECT x'31'+0.1e0, 0x31+0.1e0; +x'31'+0.1e0 0x31+0.1e0 +1.1 49.1 +SELECT x'312E39'+0e0, 0x312E39+0e0; +x'312E39'+0e0 0x312E39+0e0 +1.9 3223097 +SELECT CAST(x'31' AS SIGNED), CAST(0x31 AS SIGNED); +CAST(x'31' AS SIGNED) CAST(0x31 AS SIGNED) +1 49 +SELECT CAST(x'31' AS DECIMAL(10,1)), CAST(0x31 AS DECIMAL(10,1)); +CAST(x'31' AS DECIMAL(10,1)) CAST(0x31 AS DECIMAL(10,1)) +1.0 49.0 +SELECT CAST(x'312E39' AS SIGNED), CAST(0x312E39 AS SIGNED); +CAST(x'312E39' AS SIGNED) CAST(0x312E39 AS SIGNED) +1 3223097 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '1.9' +SELECT CAST(x'312E39' AS DECIMAL(10,1)), CAST(0x312E39 AS DECIMAL(10,1)); +CAST(x'312E39' AS DECIMAL(10,1)) CAST(0x312E39 AS DECIMAL(10,1)) +1.9 3223097.0 +EXPLAIN EXTENDED SELECT X'FFFF', 0xFFFF; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select X'ffff' AS `X'FFFF'`,0xffff AS `0xFFFF` +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (X'31'),(0x31); +INSERT INTO t1 VALUES (X'312E39'),(0x312E39); +SELECT * FROM t1; +a +1 +49 +2 +3223097 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(10,1)); +INSERT INTO t1 VALUES (X'31'),(0x31); +INSERT INTO t1 VALUES (X'312E39'),(0x312E39); +SELECT * FROM t1; +a +1.0 +49.0 +1.9 +3223097.0 +DROP TABLE t1; create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) ); insert into t1 set UNIQ=0x38afba1d73e6a18a; insert into t1 set UNIQ=123; @@ -104,8 +157,8 @@ A select b'01000001'; b'01000001' A -select x'41', 0+x'41'; -x'41' 0+x'41' +select x'41', 0+x'3635'; +x'41' 0+x'3635' A 65 select N'abc', length(N'abc'); abc length(N'abc') diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result index 3a5c3ac4b02..fba725bb80e 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result @@ -6,7 +6,7 @@ insert into t2 values (@v); show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # User var # # @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci +master-bin.000001 # User var # # @`v`=_ucs2 X'006100620063' COLLATE ucs2_general_ci master-bin.000001 # Query # # use `test`; insert into t2 values (@v) master-bin.000001 # Query # # COMMIT flush logs; @@ -26,7 +26,7 @@ SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/; +SET @`v`:=_ucs2 X'006100620063' COLLATE `ucs2_general_ci`/*!*/; use `test`/*!*/; SET TIMESTAMP=10000/*!*/; insert into t2 values (@v) diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result index 978b045d599..c10aa7abd05 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result @@ -946,10 +946,10 @@ show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=10 -master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci +master-bin.000001 # User var # # @`b`=_latin1 X'3135' COLLATE latin1_swedish_ci master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# master-bin.000001 # Intvar # # INSERT_ID=10 -master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci +master-bin.000001 # User var # # @`b`=_latin1 X'3135' COLLATE latin1_swedish_ci master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= @b + bug27417(2) ;file_id=# master-bin.000001 # Query # # ROLLBACK drop trigger trg_del_t2; diff --git a/mysql-test/suite/rpl/r/rpl_charset_sjis.result b/mysql-test/suite/rpl/r/rpl_charset_sjis.result index b31bad28a59..ff6296987f8 100644 --- a/mysql-test/suite/rpl/r/rpl_charset_sjis.result +++ b/mysql-test/suite/rpl/r/rpl_charset_sjis.result @@ -20,4 +20,36 @@ hex(a) 965C drop table t1; drop procedure p1; +# +# Start of 5.5 tests +# +# +# Bug#MDEV-4489 Replication of big5, cp932, gbk, sjis strings makes wrong values on slave +# +--- on master --- +SET NAMES sjis; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0x31),(X'31'),('1'); +PREPARE stmt FROM 'INSERT INTO t1 (a) VALUES (?)'; +SET @a='1'; +EXECUTE stmt USING @a; +DROP PREPARE stmt; +SELECT * FROM t1; +a +49 +1 +1 +1 +--- on slave --- +SELECT * FROM t1; +a +49 +1 +1 +1 +--- on master --- +DROP TABLE t1; +# +# End of 5.5 tests +# include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_mdev382.result b/mysql-test/suite/rpl/r/rpl_mdev382.result index f904561b722..e2b7d084a3f 100644 --- a/mysql-test/suite/rpl/r/rpl_mdev382.result +++ b/mysql-test/suite/rpl/r/rpl_mdev382.result @@ -245,7 +245,7 @@ master-bin.000001 # User var # # @`a``3`=9223372036854775807 master-bin.000001 # User var # # @`a``4`=18446744073709551615 master-bin.000001 # User var # # @`b```=-1.234560123456789e125 master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789 -master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci +master-bin.000001 # User var # # @```d```=_latin1 X'78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878' COLLATE latin1_swedish_ci master-bin.000001 # Query # # use `db1``; select 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98)) master-bin.000001 # Query # # COMMIT /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; @@ -283,7 +283,7 @@ SET @`a``3`:=9223372036854775807/*!*/; SET @`a``4`:=18446744073709551615/*!*/; SET @`b```:=-1.2345601234568e+125/*!*/; SET @```c`:=-1234501234567890123456789012345678901234567890123456789.0123456789/*!*/; -SET @```d```:=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE `latin1_swedish_ci`/*!*/; +SET @```d```:=_latin1 X'78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878' COLLATE `latin1_swedish_ci`/*!*/; SET TIMESTAMP=1000000000/*!*/; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98)) /*!*/; diff --git a/mysql-test/suite/rpl/t/rpl_charset_sjis.test b/mysql-test/suite/rpl/t/rpl_charset_sjis.test index a3a3de8c1d0..7d3d21cf9a0 100644 --- a/mysql-test/suite/rpl/t/rpl_charset_sjis.test +++ b/mysql-test/suite/rpl/t/rpl_charset_sjis.test @@ -23,4 +23,37 @@ sync_slave_with_master; connection master; # End of 5.0 tests + +--echo # +--echo # Start of 5.5 tests +--echo # + +--echo # +--echo # Bug#MDEV-4489 Replication of big5, cp932, gbk, sjis strings makes wrong values on slave +--echo # + +connection master; +--echo --- on master --- +SET NAMES sjis; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0x31),(X'31'),('1'); +PREPARE stmt FROM 'INSERT INTO t1 (a) VALUES (?)'; +SET @a='1'; +EXECUTE stmt USING @a; +DROP PREPARE stmt; +SELECT * FROM t1; +sync_slave_with_master; +connection slave; +--echo --- on slave --- +SELECT * FROM t1; +connection master; +--echo --- on master --- +DROP TABLE t1; +sync_slave_with_master; +connection master; + +--echo # +--echo # End of 5.5 tests +--echo # + --source include/rpl_end.inc diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test index 6140178c0f4..e7b6fe1a014 100644 --- a/mysql-test/t/ctype_cp932_binlog_stm.test +++ b/mysql-test/t/ctype_cp932_binlog_stm.test @@ -141,6 +141,23 @@ SELECT HEX(a), HEX(CONVERT(a using cp932)) as b FROM t1 HAVING b<>'3F' ORDER BY DROP TABLE t1; +--echo # +--echo # Bug#MDEV-4489 Replication of big5, cp932, gbk, sjis strings makes wrong values on slave +--echo # +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); +SET NAMES cp932; +CREATE TABLE t1 (a INT); +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (0x31); +INSERT INTO t1 VALUES (X'31'); +PREPARE stmt FROM 'INSERT INTO t1 (a) VALUES (?)'; +SET @a='1'; +SELECT charset(@a); +EXECUTE stmt USING @a; +DROP PREPARE stmt; +DROP TABLE t1; +--source include/show_binlog_events.inc + --echo # --echo # End of 5.5 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index b036cc6bc01..6a82a2901c5 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2493,7 +2493,7 @@ DROP TABLE t1,t2; # Bug #10650 # -select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +select x'3136' + 0, X'3136' + 0, b'10' + 0, B'10' + 0; # # Bug #11398 Bug in field_conv() results in wrong result of join with index diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test index 1f9f7b5412d..f03f3fcf703 100644 --- a/mysql-test/t/varbinary.test +++ b/mysql-test/t/varbinary.test @@ -13,7 +13,30 @@ drop table if exists t1; select 0x41,0x41+0,0x41 | 0x7fffffffffffffff | 0,0xffffffffffffffff | 0 ; select 0x31+1,concat(0x31)+1,-0xf; -select x'31',X'ffff'+0; +select x'31',0xffff+0; +select X'FFFF'+0; + +# +# Hex string vs hex hybrid +# +SELECT x'31'+0, 0x31+0; +SELECT x'31'+0.1e0, 0x31+0.1e0; +SELECT x'312E39'+0e0, 0x312E39+0e0; +SELECT CAST(x'31' AS SIGNED), CAST(0x31 AS SIGNED); +SELECT CAST(x'31' AS DECIMAL(10,1)), CAST(0x31 AS DECIMAL(10,1)); +SELECT CAST(x'312E39' AS SIGNED), CAST(0x312E39 AS SIGNED); +SELECT CAST(x'312E39' AS DECIMAL(10,1)), CAST(0x312E39 AS DECIMAL(10,1)); +EXPLAIN EXTENDED SELECT X'FFFF', 0xFFFF; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (X'31'),(0x31); +INSERT INTO t1 VALUES (X'312E39'),(0x312E39); +SELECT * FROM t1; +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(10,1)); +INSERT INTO t1 VALUES (X'31'),(0x31); +INSERT INTO t1 VALUES (X'312E39'),(0x312E39); +SELECT * FROM t1; +DROP TABLE t1; # # Test of hex constants in WHERE: @@ -115,7 +138,7 @@ select 0x41; select b'01000001'; -select x'41', 0+x'41'; +select x'41', 0+x'3635'; select N'abc', length(N'abc'); diff --git a/sql/item.cc b/sql/item.cc index 14a505256b8..c251e3d6df3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6125,17 +6125,8 @@ inline uint char_val(char X) X-'a'+10); } -Item_hex_string::Item_hex_string() -{ - hex_string_init("", 0); -} -Item_hex_string::Item_hex_string(const char *str, uint str_length) -{ - hex_string_init(str, str_length); -} - -void Item_hex_string::hex_string_init(const char *str, uint str_length) +void Item_hex_constant::hex_string_init(const char *str, uint str_length) { max_length=(str_length+1)/2; char *ptr=(char*) sql_alloc(max_length+1); @@ -6159,7 +6150,7 @@ void Item_hex_string::hex_string_init(const char *str, uint str_length) unsigned_flag= 1; } -longlong Item_hex_string::val_int() +longlong Item_hex_hybrid::val_int() { // following assert is redundant, because fixed=1 assigned in constructor DBUG_ASSERT(fixed == 1); @@ -6173,17 +6164,7 @@ longlong Item_hex_string::val_int() } -my_decimal *Item_hex_string::val_decimal(my_decimal *decimal_value) -{ - // following assert is redundant, because fixed=1 assigned in constructor - DBUG_ASSERT(fixed == 1); - ulonglong value= (ulonglong)val_int(); - int2my_decimal(E_DEC_FATAL_ERROR, value, TRUE, decimal_value); - return (decimal_value); -} - - -int Item_hex_string::save_in_field(Field *field, bool no_conversions) +int Item_hex_hybrid::save_in_field(Field *field, bool no_conversions) { field->set_notnull(); if (field->result_type() == STRING_RESULT) @@ -6216,22 +6197,27 @@ warn: } -void Item_hex_string::print(String *str, enum_query_type query_type) +void Item_hex_hybrid::print(String *str, enum_query_type query_type) { - char *end= (char*) str_value.ptr() + str_value.length(), - *ptr= end - min(str_value.length(), sizeof(longlong)); + uint32 len= min(str_value.length(), sizeof(longlong)); + const char *ptr= str_value.ptr() + str_value.length() - len; str->append("0x"); - for (; ptr != end ; ptr++) - { - str->append(_dig_vec_lower[((uchar) *ptr) >> 4]); - str->append(_dig_vec_lower[((uchar) *ptr) & 0x0F]); - } + str->append_hex(ptr, len); } -bool Item_hex_string::eq(const Item *arg, bool binary_cmp) const +void Item_hex_string::print(String *str, enum_query_type query_type) { - if (arg->basic_const_item() && arg->type() == type()) + str->append("X'"); + str->append_hex(str_value.ptr(), str_value.length()); + str->append("'"); +} + + +bool Item_hex_constant::eq(const Item *arg, bool binary_cmp) const +{ + if (arg->basic_const_item() && arg->type() == type() && + arg->cast_to_int_type() == cast_to_int_type()) { if (binary_cmp) return !stringcmp(&str_value, &arg->str_value); @@ -6241,7 +6227,7 @@ bool Item_hex_string::eq(const Item *arg, bool binary_cmp) const } -Item *Item_hex_string::safe_charset_converter(CHARSET_INFO *tocs) +Item *Item_hex_constant::safe_charset_converter(CHARSET_INFO *tocs) { Item_string *conv; String tmp, *str= val_str(&tmp); diff --git a/sql/item.h b/sql/item.h index 66e3afa1de9..891a1500eb1 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2730,36 +2730,112 @@ public: }; -class Item_hex_string: public Item_basic_constant +/** + Item_hex_constant -- a common class for hex literals: X'HHHH' and 0xHHHH +*/ +class Item_hex_constant: public Item_basic_constant { +private: + void hex_string_init(const char *str, uint str_length); public: - Item_hex_string(); - Item_hex_string(const char *str,uint str_length); - enum Type type() const { return VARBIN_ITEM; } - double val_real() - { - DBUG_ASSERT(fixed == 1); - return (double) (ulonglong) Item_hex_string::val_int(); + Item_hex_constant() + { + hex_string_init("", 0); } - longlong val_int(); - bool basic_const_item() const { return 1; } - String *val_str(String*) { DBUG_ASSERT(fixed == 1); return &str_value; } - my_decimal *val_decimal(my_decimal *); - int save_in_field(Field *field, bool no_conversions); + Item_hex_constant(const char *str, uint str_length) + { + hex_string_init(str, str_length); + } + enum Type type() const { return VARBIN_ITEM; } enum Item_result result_type () const { return STRING_RESULT; } - enum Item_result cast_to_int_type() const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } - virtual void print(String *str, enum_query_type query_type); - bool eq(const Item *item, bool binary_cmp) const; virtual Item *safe_charset_converter(CHARSET_INFO *tocs); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_vcol_func_processor(uchar *arg) { return FALSE;} -private: - void hex_string_init(const char *str, uint str_length); + bool basic_const_item() const { return 1; } + bool eq(const Item *item, bool binary_cmp) const; + String *val_str(String*) { DBUG_ASSERT(fixed == 1); return &str_value; } }; -class Item_bin_string: public Item_hex_string +/** + Item_hex_hybrid -- is a class implementing 0xHHHH literals, e.g.: + SELECT 0x3132; + They can behave as numbers and as strings depending on context. +*/ +class Item_hex_hybrid: public Item_hex_constant +{ +public: + Item_hex_hybrid(): Item_hex_constant() {} + Item_hex_hybrid(const char *str, uint str_length): + Item_hex_constant(str, str_length) {} + double val_real() + { + DBUG_ASSERT(fixed == 1); + return (double) (ulonglong) Item_hex_hybrid::val_int(); + } + longlong val_int(); + my_decimal *val_decimal(my_decimal *decimal_value) + { + // following assert is redundant, because fixed=1 assigned in constructor + DBUG_ASSERT(fixed == 1); + ulonglong value= (ulonglong) Item_hex_hybrid::val_int(); + int2my_decimal(E_DEC_FATAL_ERROR, value, TRUE, decimal_value); + return decimal_value; + } + int save_in_field(Field *field, bool no_conversions); + enum Item_result cast_to_int_type() const { return INT_RESULT; } + void print(String *str, enum_query_type query_type); +}; + + +/** + Item_hex_string -- is a class implementing X'HHHH' literals, e.g.: + SELECT X'3132'; + Unlike Item_hex_hybrid, X'HHHH' literals behave as strings in all contexts. + X'HHHH' are also used in replication of string constants in case of + "dangerous" charsets (sjis, cp932, big5, gbk) who can have backslash (0x5C) + as the second byte of a multi-byte character, so using '\' escaping for + these charsets is not desirable. +*/ +class Item_hex_string: public Item_hex_constant +{ +public: + Item_hex_string(): Item_hex_constant() {} + Item_hex_string(const char *str, uint str_length): + Item_hex_constant(str, str_length) {} + longlong val_int() + { + DBUG_ASSERT(fixed == 1); + return longlong_from_string_with_check(str_value.charset(), + str_value.ptr(), + str_value.ptr()+ + str_value.length()); + } + double val_real() + { + DBUG_ASSERT(fixed == 1); + return double_from_string_with_check(str_value.charset(), + str_value.ptr(), + str_value.ptr() + + str_value.length()); + } + my_decimal *val_decimal(my_decimal *decimal_value) + { + return val_decimal_from_string(decimal_value); + } + int save_in_field(Field *field, bool no_conversions) + { + field->set_notnull(); + return field->store(str_value.ptr(), str_value.length(), + collation.collation); + } + enum Item_result cast_to_int_type() const { return STRING_RESULT; } + void print(String *str, enum_query_type query_type); +}; + + +class Item_bin_string: public Item_hex_hybrid { public: Item_bin_string(const char *str,uint str_length); diff --git a/sql/log_event.cc b/sql/log_event.cc index f3cf3623d47..1c326863cc5 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -622,16 +622,18 @@ static inline int read_str(const char **buf, const char *buf_end, /** - Transforms a string into "" or its expression in 0x... form. + Transforms a string into "" or its expression in X'HHHH' form. */ char *str_to_hex(char *to, const char *from, uint len) { if (len) { - *to++= '0'; - *to++= 'x'; + *to++= 'X'; + *to++= '\''; to= octet2hex(to, from, len); + *to++= '\''; + *to= '\0'; } else to= strmov(to, "\"\""); @@ -652,7 +654,7 @@ append_query_string(THD *thd, CHARSET_INFO *csinfo, { char *beg, *ptr; uint32 const orig_len= to->length(); - if (to->reserve(orig_len + from->length()*2+3)) + if (to->reserve(orig_len + from->length() * 2 + 4)) return 1; beg= (char*) to->ptr() + to->length(); @@ -6295,7 +6297,7 @@ void User_var_log_event::pack_info(THD *thd, Protocol* protocol) buf.append(" ")) return; old_len= buf.length(); - if (buf.reserve(old_len + val_len*2 + 2 + sizeof(" COLLATE ") + + if (buf.reserve(old_len + val_len * 2 + 3 + sizeof(" COLLATE ") + MY_CS_NAME_SIZE)) return; beg= const_cast(buf.ptr()) + old_len; @@ -6563,7 +6565,8 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) char *hex_str; CHARSET_INFO *cs; - hex_str= (char *)my_malloc(2*val_len+1+2,MYF(MY_WME)); // 2 hex digits / byte + // 2 hex digits / byte + hex_str= (char *) my_malloc(2 * val_len + 1 + 3, MYF(MY_WME)); if (!hex_str) return; str_to_hex(hex_str, val, val_len); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 583aee6bc00..fdf53f7b521 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1411,7 +1411,7 @@ int lex_one_token(void *arg, void *yythd) yylval->lex_str=get_token(lip, 2, // skip x' length-3); // don't count x' and last ' - return (HEX_NUM); + return HEX_STRING; case MY_LEX_BIN_NUMBER: // Found b'bin-string' lip->yySkip(); // Accept opening ' diff --git a/sql/sql_string.h b/sql/sql_string.h index 8b09d449c2b..7a2f27da998 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -364,6 +364,16 @@ public: } return 0; } + bool append_hex(const char *src, uint32 srclen) + { + for (const char *end= src + srclen ; src != end ; src++) + { + if (append(_dig_vec_lower[((uchar) *src) >> 4]) || + append(_dig_vec_lower[((uchar) *src) & 0x0F])) + return true; + } + return false; + } bool fill(uint32 max_length,char fill); void strip_sp(); friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c89585ec609..c621c61aff3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1021,6 +1021,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token HAVING /* SQL-2003-R */ %token HELP_SYM %token HEX_NUM +%token HEX_STRING %token HIGH_PRIORITY %token HOST_SYM %token HOSTS_SYM @@ -1448,7 +1449,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %left INTERVAL_SYM %type - IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM + IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM + HEX_NUM HEX_STRING hex_num_or_string LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text IDENT_sys TEXT_STRING_sys TEXT_STRING_literal NCHAR_STRING opt_component key_cache_name @@ -5996,6 +5998,11 @@ now_or_signed_literal: { $$=$1; } ; +hex_num_or_string: + HEX_NUM {} + | HEX_STRING {} + ; + charset: CHAR_SYM SET {} | CHARSET {} @@ -12261,7 +12268,7 @@ text_string: } | HEX_NUM { - Item *tmp= new (YYTHD->mem_root) Item_hex_string($1.str, $1.length); + Item *tmp= new (YYTHD->mem_root) Item_hex_hybrid($1.str, $1.length); if (tmp == NULL) MYSQL_YYABORT; /* @@ -12271,6 +12278,14 @@ text_string: tmp->quick_fix_field(); $$= tmp->val_str((String*) 0); } + | HEX_STRING + { + Item *tmp= new (YYTHD->mem_root) Item_hex_string($1.str, $1.length); + if (tmp == NULL) + MYSQL_YYABORT; + tmp->quick_fix_field(); + $$= tmp->val_str((String*) 0); + } | BIN_NUM { Item *tmp= new (YYTHD->mem_root) Item_bin_string($1.str, $1.length); @@ -12339,6 +12354,12 @@ literal: MYSQL_YYABORT; } | HEX_NUM + { + $$ = new (YYTHD->mem_root) Item_hex_hybrid($1.str, $1.length); + if ($$ == NULL) + MYSQL_YYABORT; + } + | HEX_STRING { $$ = new (YYTHD->mem_root) Item_hex_string($1.str, $1.length); if ($$ == NULL) @@ -12350,7 +12371,7 @@ literal: if ($$ == NULL) MYSQL_YYABORT; } - | UNDERSCORE_CHARSET HEX_NUM + | UNDERSCORE_CHARSET hex_num_or_string { Item *tmp= new (YYTHD->mem_root) Item_hex_string($2.str, $2.length); if (tmp == NULL) From 4a0f2563d3d1747a4704e6241380071efbeb3882 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 8 May 2013 14:32:32 +0200 Subject: [PATCH 142/273] MDEV-4462 mysqld gets SIGFPE when mysql.user table is empty avoid divison by zero --- mysql-test/r/empty_user_table.result | 8 ++++++++ mysql-test/t/empty_user_table.test | 18 ++++++++++++++++++ sql/sql_acl.cc | 6 ++++++ 3 files changed, 32 insertions(+) create mode 100644 mysql-test/r/empty_user_table.result create mode 100644 mysql-test/t/empty_user_table.test diff --git a/mysql-test/r/empty_user_table.result b/mysql-test/r/empty_user_table.result new file mode 100644 index 00000000000..df9d803e5c0 --- /dev/null +++ b/mysql-test/r/empty_user_table.result @@ -0,0 +1,8 @@ +create table t1 as select * from mysql.user; +truncate table mysql.user; +flush privileges; +connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET); +ERROR 28000: Access denied for user 'u1'@'localhost' (using password: NO) +insert mysql.user select * from t1; +drop table t1; +flush privileges; diff --git a/mysql-test/t/empty_user_table.test b/mysql-test/t/empty_user_table.test new file mode 100644 index 00000000000..7e672cc64f6 --- /dev/null +++ b/mysql-test/t/empty_user_table.test @@ -0,0 +1,18 @@ +# +# MDEV-4462 mysqld gets SIGFPE when mysql.user table is empty +# + +source include/not_embedded.inc; + +create table t1 as select * from mysql.user; +truncate table mysql.user; +flush privileges; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect (fail,localhost,u1); + +insert mysql.user select * from t1; +drop table t1; +flush privileges; + diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 29922aa5321..9983c52abb5 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7367,6 +7367,12 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio, Security_context *sctx) cs->coll->hash_sort(cs, (uchar*) sctx->user, strlen(sctx->user), &nr1, &nr2); pthread_mutex_lock(&acl_cache->lock); + if (!acl_users.elements) + { + pthread_mutex_unlock(&acl_cache->lock); + login_failed_error(mpvio->thd); + return 1; + } uint i= nr1 % acl_users.elements; ACL_USER *acl_user_tmp= dynamic_element(&acl_users, i, ACL_USER*); mpvio->acl_user= acl_user_tmp->copy(mpvio->thd->mem_root); From f33178b99a0b88eb513b95ac4b74ca3d3f1d70b7 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 8 May 2013 20:37:17 +0200 Subject: [PATCH 143/273] MDEV-4206 : log all slow statements (do not use filters), if log_slow_filter is empty. --- mysql-test/r/log_slow.result | 13 +++++++++++++ mysql-test/t/log_slow.test | 13 ++++++++++++- sql/sql_parse.cc | 3 ++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/log_slow.result b/mysql-test/r/log_slow.result index 75e92e7a0b5..318dfa7568d 100644 --- a/mysql-test/r/log_slow.result +++ b/mysql-test/r/log_slow.result @@ -56,5 +56,18 @@ insert_id int(11) NO NULL server_id int(10) unsigned NO NULL sql_text mediumtext NO NULL flush slow logs; +set long_query_time=0.1; +set log_slow_filter=''; +set global slow_query_log=1; +set global log_output='TABLE'; +select sleep(0.5); +sleep(0.5) +0 +select count(*) FROM mysql.slow_log; +count(*) +1 +truncate mysql.slow_log; +set @@long_query_time=default; +set global slow_query_log=default; set @@log_slow_filter=default; set @@log_slow_verbosity=default; diff --git a/mysql-test/t/log_slow.test b/mysql-test/t/log_slow.test index af8a948d318..54f56e1bdfc 100644 --- a/mysql-test/t/log_slow.test +++ b/mysql-test/t/log_slow.test @@ -42,7 +42,18 @@ show fields from mysql.slow_log; flush slow logs; -# Reset used variables +# MDEV-4206 (empty filter should be no filter) +set long_query_time=0.1; +set log_slow_filter=''; +set global slow_query_log=1; +set global log_output='TABLE'; +select sleep(0.5); +select count(*) FROM mysql.slow_log; +truncate mysql.slow_log; + +# Reset used variables +set @@long_query_time=default; +set global slow_query_log=default; set @@log_slow_filter=default; set @@log_slow_verbosity=default; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 989f1ed66de..05957197817 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1497,7 +1497,8 @@ void log_slow_statement(THD *thd) /* Follow the slow log filter configuration. */ if (!thd->enable_slow_log || - !(thd->variables.log_slow_filter & thd->query_plan_flags)) + (thd->variables.log_slow_filter + && !(thd->variables.log_slow_filter & thd->query_plan_flags))) DBUG_VOID_RETURN; if (((thd->server_status & SERVER_QUERY_WAS_SLOW) || From be268bed3d893ef053ff35a4900cc1c125bb5769 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 9 May 2013 16:16:45 +0200 Subject: [PATCH 144/273] - Fix inverted test on am in MYSQLDEF::DefineAM modified: storage/connect/tabmysql.cpp --- storage/connect/tabmysql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index b3401530c1b..3ecfd6aa6c1 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -283,7 +283,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Desc = "MySQL Table"; - if (!stricmp(am, "MYPRX")) { + if (stricmp(am, "MYPRX")) { // Normal case of specific MYSQL table if (!url || !*url) { // Not using the connection URL From 55b3c844921580be362c16d3226c287a2f92ea96 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 9 May 2013 22:21:07 +0200 Subject: [PATCH 145/273] Small mysql_install_db.exe fixes - Use lc-messages-dir instead of deprecated --language when running mysqld in bootstrap mode. - Add some verbosity to mysql_install_db.exe when it runs in course of MSI installation. --- sql/mysql_install_db.cc | 14 ++++++++++---- win/packaging/extra.wxs.in | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 5d523abb8ae..9c1a234241f 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -54,6 +54,7 @@ static char *opt_os_password; static my_bool opt_default_user; static my_bool opt_allow_remote_root_access; static my_bool opt_skip_networking; +static my_bool opt_verbose_bootstrap; static my_bool verbose_errors; @@ -83,6 +84,8 @@ static struct my_option my_long_options[]= 0, 0}, {"silent", 's', "Print less information", &opt_silent, &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose-bootstrap", 'o', "Include mysqld bootstrap output",&opt_verbose_bootstrap, + &opt_verbose_bootstrap, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -244,11 +247,12 @@ static char *init_bootstrap_command_line(char *cmdline, size_t size) get_basedir(basedir, sizeof(basedir), mysqld_path); my_snprintf(cmdline, size-1, - "\"\"%s\" --no-defaults --bootstrap" - " \"--language=%s\\share\\english\"" + "\"\"%s\" --no-defaults %s --bootstrap" + " \"--lc-messages-dir=%s/share\"" " --basedir=. --datadir=. --default-storage-engine=myisam" " --max_allowed_packet=9M --loose-skip-innodb" - " --net-buffer-length=16k\"", mysqld_path, basedir); + " --net-buffer-length=16k\"", mysqld_path, + opt_verbose_bootstrap?"--console":"", basedir ); return cmdline; } @@ -552,7 +556,9 @@ static int create_db_instance() /* Do mysqld --bootstrap. */ init_bootstrap_command_line(cmdline, sizeof(cmdline)); - /* verbose("Executing %s", cmdline); */ + + if(opt_verbose_bootstrap) + printf("Executing %s\n", cmdline); in= popen(cmdline, "wt"); if (!in) diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in index e0a36ef2e41..124de5f4b40 100644 --- a/win/packaging/extra.wxs.in +++ b/win/packaging/extra.wxs.in @@ -692,7 +692,7 @@ From 3b944843d2c65f953dadc5d4908d1b8223d2f36e Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 9 May 2013 23:25:57 +0200 Subject: [PATCH 146/273] Fix compile error --- storage/xtradb/handler/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 8d8ca8bd7ba..3c2e9714f37 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -203,7 +203,7 @@ static ulong innobase_sys_stats_root_page = 0; #endif static my_bool innobase_buffer_pool_shm_checksum = TRUE; static uint innobase_buffer_pool_shm_key = 0; -static ulong srv_lazy_drop_table = 0; +static ulint srv_lazy_drop_table = 0; From 99d95c8a2fec8037738a4c700a163b206f9ab4c8 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 10 May 2013 20:22:21 +0200 Subject: [PATCH 147/273] - Added table type PIVOT modified: storage/connect/filamdbf.cpp storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/mycat.cc storage/connect/myconn.cpp storage/connect/odbconn.cpp storage/connect/plgcnx.h storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp storage/connect/tabfmt.cpp storage/connect/tabpivot.cpp storage/connect/tabpivot.h storage/connect/tabutil.cpp storage/connect/tabwmi.cpp storage/connect/tabxcl.cpp storage/connect/value.cpp storage/connect/value.h --- storage/connect/filamdbf.cpp | 7 +- storage/connect/ha_connect.cc | 10 +- storage/connect/ha_connect.h | 2 + storage/connect/mycat.cc | 9 +- storage/connect/myconn.cpp | 10 +- storage/connect/odbconn.cpp | 28 +- storage/connect/plgcnx.h | 11 - storage/connect/plgdbsem.h | 3 +- storage/connect/plgdbutl.cpp | 3 +- storage/connect/tabfmt.cpp | 6 +- storage/connect/tabpivot.cpp | 596 ++++++++++++++++++++-------------- storage/connect/tabpivot.h | 107 +++--- storage/connect/tabutil.cpp | 9 +- storage/connect/tabwmi.cpp | 6 +- storage/connect/tabxcl.cpp | 1 - storage/connect/value.cpp | 49 +-- storage/connect/value.h | 5 +- 17 files changed, 444 insertions(+), 418 deletions(-) diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp index 3575a6b422a..0a67195b200 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -178,15 +178,13 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf) /****************************************************************************/ PQRYRES DBFColumns(PGLOBAL g, const char *fn, BOOL info) { - static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR, - DB_INT, DB_INT, DB_SHORT}; static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_SCALE}; static unsigned int length[] = {11, 6, 8, 10, 10, 6}; char buf[2], filename[_MAX_PATH]; - int ncol = sizeof(dbtype) / sizeof(int); + int ncol = sizeof(buftyp) / sizeof(int); int rc, type, len, field, fields; BOOL bad; DBFHEADER mainhead; @@ -228,8 +226,7 @@ PQRYRES DBFColumns(PGLOBAL g, const char *fn, BOOL info) fields = 0; qrp = PlgAllocResult(g, ncol, fields, IDS_COLUMNS + 3, - dbtype, buftyp, fldtyp, length, true, false); -//qrp->Info = info || (rc == RC_INFO); + buftyp, fldtyp, length, true, false); if (info) return qrp; diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 2eefd1e20d2..298fb71b334 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -207,6 +207,8 @@ ha_create_table_option connect_table_option_list[]= HA_TOPTION_STRING("MODULE", module), HA_TOPTION_STRING("SUBTYPE", subtype), HA_TOPTION_STRING("CATFUNC", catfunc), + HA_TOPTION_STRING("SRCDEF", srcdef), + HA_TOPTION_STRING("COLIST", colist), HA_TOPTION_STRING("OPTION_LIST", oplist), HA_TOPTION_STRING("DATA_CHARSET", data_charset), HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1), @@ -590,7 +592,7 @@ static char *GetListOption(PGLOBAL g, const char *opname, } else { if (pn) { - n= pn - pk; + n= min(pn - pk, 15); memcpy(key, pk, n); key[n]= 0; } else @@ -655,6 +657,10 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) opval= (char*)options->subtype; else if (!stricmp(opname, "Catfunc")) opval= (char*)options->catfunc; + else if (!stricmp(opname, "Srcdef")) + opval= (char*)options->srcdef; + else if (!stricmp(opname, "Colist")) + opval= (char*)options->colist; else if (!stricmp(opname, "Data_charset")) opval= (char*)options->data_charset; @@ -2667,7 +2673,6 @@ bool ha_connect::check_privileges(THD *thd, PTOS options) case TAB_JCT: case TAB_DMY: case TAB_NIY: - case TAB_PIVOT: my_printf_error(ER_UNKNOWN_ERROR, "Unsupported table type %s", MYF(0), options->type); return true; @@ -2706,6 +2711,7 @@ bool ha_connect::check_privileges(THD *thd, PTOS options) case TAB_XCL: case TAB_PRX: case TAB_OCCUR: + case TAB_PIVOT: return false; } diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index 53339d168d0..0d6354ca078 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -83,6 +83,8 @@ struct ha_table_option_struct { const char *module; const char *subtype; const char *catfunc; + const char *srcdef; + const char *colist; const char *oplist; const char *data_charset; ulonglong lrecl; diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index badcdcb9514..7b7f79d7b58 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -132,6 +132,9 @@ TABTYPE GetTypeID(const char *type) : (!stricmp(type, "OCCUR")) ? TAB_OCCUR : (!stricmp(type, "CATLG")) ? TAB_PRX // Legacy : (!stricmp(type, "PROXY")) ? TAB_PRX +#ifdef PIVOT_SUPPORT + : (!stricmp(type, "PIVOT")) ? TAB_PIVOT +#endif : (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY; } // end of GetTypeID @@ -650,9 +653,9 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) #if defined(MYSQL_SUPPORT) case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; #endif // MYSQL_SUPPORT -//#if defined(PIVOT_SUPPORT) -// case TAB_PIVOT: tdp= new(g) PIVOTDEF; break; -//#endif // PIVOT_SUPPORT +#if defined(PIVOT_SUPPORT) + case TAB_PIVOT: tdp= new(g) PIVOTDEF; break; +#endif // PIVOT_SUPPORT default: sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); } // endswitch diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 53a2496b197..fab2af54aa7 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -74,10 +74,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, const char *table, const char *colpat, int port, bool key, bool info) { - static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR, DB_INT, - DB_CHAR, DB_SHORT, DB_SHORT, DB_SHORT, - DB_CHAR, DB_CHAR, DB_CHAR}; - static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, + static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING, TYPE_STRING, TYPE_STRING}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, @@ -85,7 +82,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, FLD_REM, FLD_NO, FLD_CHARSET}; static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 256, 32, 32}; char *fld, *fmt, cmd[128]; - int i, n, nf, ncol = sizeof(dbtype) / sizeof(int); + int i, n, nf, ncol = sizeof(buftyp) / sizeof(int); int len, type, prec, rc, k = 0; PQRYRES qrp; PCOLRES crp; @@ -134,7 +131,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, /* Allocate the structures used to refer to the result set. */ /**********************************************************************/ qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3, - dbtype, buftyp, fldtyp, length, true, true); + buftyp, fldtyp, length, true, true); // Some columns must be renamed for (i = 0, crp = qrp->Colresp; crp; crp = crp->Next) @@ -665,7 +662,6 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) crp->Prec = fld->decimals; crp->Length = fld->max_length; crp->Clen = GetTypeSize(crp->Type, crp->Length); - crp->DBtype = GetDBType((int)crp->Type); if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows, crp->Clen, 0, FALSE, TRUE))) { diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 6de2acef391..e32e666e1fe 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -230,11 +230,7 @@ void ResetNullValues(CATPARM *cap) PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table, char *colpat, bool info) { - static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR, - DB_CHAR, DB_SHORT, DB_CHAR, - DB_INT, DB_INT, DB_SHORT, - DB_SHORT, DB_SHORT, DB_CHAR}; - static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, + static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; @@ -285,7 +281,7 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table, /* Allocate the structures used to refer to the result set. */ /************************************************************************/ qrp = PlgAllocResult(g, ncol, maxres, IDS_COLUMNS, - dbtype, buftyp, fldtyp, length, true, true); + buftyp, fldtyp, length, true, true); if (info) // Info table return qrp; @@ -396,7 +392,6 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) /*************************************************************************/ PQRYRES ODBCDataSources(PGLOBAL g, bool info) { - static int dbtype[] = {DB_CHAR, DB_CHAR}; static int buftyp[] = {TYPE_STRING, TYPE_STRING}; static XFLD fldtyp[] = {FLD_NAME, FLD_REM}; static unsigned int length[] = {0, 256}; @@ -425,7 +420,7 @@ PQRYRES ODBCDataSources(PGLOBAL g, bool info) /* Allocate the structures used to refer to the result set. */ /************************************************************************/ qrp = PlgAllocResult(g, ncol, maxres, IDS_DSRC, - dbtype, buftyp, fldtyp, length, true, true); + buftyp, fldtyp, length, true, true); /************************************************************************/ /* Now get the results into blocks. */ @@ -446,7 +441,6 @@ PQRYRES ODBCDataSources(PGLOBAL g, bool info) /*************************************************************************/ PQRYRES ODBCDrivers(PGLOBAL g, bool info) { - static int dbtype[] = {DB_CHAR, DB_CHAR}; static int buftyp[] = {TYPE_STRING, TYPE_STRING}; static XFLD fldtyp[] = {FLD_NAME, FLD_REM}; static unsigned int length[] = {128, 256}; @@ -471,7 +465,7 @@ PQRYRES ODBCDrivers(PGLOBAL g, bool info) /* Allocate the structures used to refer to the result set. */ /************************************************************************/ qrp = PlgAllocResult(g, ncol, maxres, IDS_DRIVER, - dbtype, buftyp, fldtyp, length, true, true); + buftyp, fldtyp, length, true, true); /************************************************************************/ /* Now get the results into blocks. */ @@ -492,8 +486,7 @@ PQRYRES ODBCDrivers(PGLOBAL g, bool info) /***********************************************************************/ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info) { - static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR, DB_CHAR, DB_CHAR}; - static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, + static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING}; static XFLD fldtyp[] = {FLD_QUALIF, FLD_OWNER, FLD_NAME, FLD_TYPE, FLD_REM}; @@ -536,7 +529,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info) /************************************************************************/ /* Allocate the structures used to refer to the result set. */ /************************************************************************/ - qrp = PlgAllocResult(g, ncol, maxres, IDS_TABLES, dbtype, buftyp, + qrp = PlgAllocResult(g, ncol, maxres, IDS_TABLES, buftyp, fldtyp, length, true, true); if (info) @@ -579,8 +572,6 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info) /**************************************************************************/ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table) { - static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR, - DB_CHAR, DB_SHORT, DB_CHAR}; static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_SHORT, TYPE_STRING}; static unsigned int length[] = {0, 0, 0, 0, 6, 128}; @@ -623,7 +614,7 @@ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table) /* Allocate the structure used to refer to the result set. */ /************************************************************************/ qrp = PlgAllocResult(g, ncol, maxres, IDS_PKEY, - dbtype, buftyp, NULL, length, true, true); + buftyp, NULL, length, true, true); if (trace) htrc("Getting pkey results ncol=%d\n", qrp->Nbcol); @@ -662,9 +653,6 @@ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table) PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat, int un, int acc) { - static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR, DB_SHORT, DB_CHAR, - DB_CHAR, DB_SHORT, DB_SHORT, DB_CHAR, DB_CHAR, - DB_INT, DB_INT, DB_CHAR}; static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_STRING, @@ -708,7 +696,7 @@ PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat, /* Allocate the structure used to refer to the result set. */ /************************************************************************/ qrp = PlgAllocResult(g, ncol, maxres, IDS_STAT, - dbtype, buftyp, NULL, length, true, true); + buftyp, NULL, length, true, true); if (trace) htrc("Getting stat results ncol=%d\n", qrp->Nbcol); diff --git a/storage/connect/plgcnx.h b/storage/connect/plgcnx.h index 33b0ba64edc..7ce72b45268 100644 --- a/storage/connect/plgcnx.h +++ b/storage/connect/plgcnx.h @@ -49,17 +49,6 @@ enum RCODE {RC_OK = 0, /* No error return code */ RC_INFO = 4}; /* Success with info */ #endif // !RC_OK_DEFINED -/**************************************************************************/ -/* Data types. */ -/**************************************************************************/ -enum XDBTYPE {DB_ERROR = 0, /* Unknown or wrong type */ - DB_STRING = 1, /* Null terminated string */ - DB_CHAR = 2, /* Character array */ - DB_SHORT = 3, /* Used by some catalog functions */ - DB_INT = 4, /* Long integer array */ - DB_DOUBLE = 5, /* Double float array */ - DB_DATE = 6}; /* Datetime value array */ - /**************************************************************************/ /* Index of info values within the info int integer array. */ /**************************************************************************/ diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index a1eaf97bd10..5eb55c4a29b 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -513,7 +513,6 @@ typedef struct _colres { PVBLK Kdata; /* Column block of values */ char *Nulls; /* Column null value array */ int Type; /* Internal type */ - int DBtype; /* Data type */ int Datasize; /* Overall data size */ int Ncol; /* Column number */ int Clen; /* Data individual internal size */ @@ -545,7 +544,7 @@ int ExtractDate(char *, PDTP, int, int val[6]); /* Allocate the result structure that will contain result data. */ /**************************************************************************/ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, - int *dbtype, int *buftyp, XFLD *fldtyp, + int *buftyp, XFLD *fldtyp, unsigned int *length, bool blank, bool nonull); /***********************************************************************/ diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 6d1e502945b..32ee105c19c 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -270,7 +270,7 @@ void ptrc(char const *fmt, ...) /* Allocate the result structure that will contain result data. */ /**************************************************************************/ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, - int *dbtype, int *buftyp, XFLD *fldtyp, + int *buftyp, XFLD *fldtyp, unsigned int *length, bool blank, bool nonull) { char cname[NAM_LEN+1]; @@ -304,7 +304,6 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, crp->Length = length[i]; crp->Clen = GetTypeSize(crp->Type, length[i]); crp->Prec = 0; - crp->DBtype = dbtype[i]; if (ids > 0) { #if defined(XMSG) diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index 51631107f6e..aaa32a57f04 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -78,8 +78,6 @@ extern "C" int trace; PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q, int hdr, int mxr, bool info) { - static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR, - DB_INT, DB_INT, DB_SHORT}; static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, @@ -87,7 +85,7 @@ PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q, static unsigned int length[] = {6, 6, 8, 10, 10, 6}; char *p, *colname[MAXCOL], dechar, filename[_MAX_PATH], buf[4096]; int i, imax, hmax, n, nerr, phase, blank, digit, dec, type; - int ncol = sizeof(dbtype) / sizeof(int); + int ncol = sizeof(buftyp) / sizeof(int); int num_read = 0, num_max = 10000000; // Statistics int len[MAXCOL], typ[MAXCOL], prc[MAXCOL]; FILE *infile; @@ -341,7 +339,7 @@ PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q, /* Allocate the structures used to refer to the result set. */ /*********************************************************************/ qrp = PlgAllocResult(g, ncol, imax, IDS_COLUMNS + 3, - dbtype, buftyp, fldtyp, length, true, false); + buftyp, fldtyp, length, true, false); qrp->Nblin = imax; if (info) diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index fccd8338d8a..429bb88e0fc 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -1,11 +1,11 @@ /************ TabPivot C++ Program Source Code File (.CPP) *************/ /* PROGRAM NAME: TABPIVOT */ /* ------------- */ -/* Version 1.3 */ +/* Version 1.4 */ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -41,10 +41,13 @@ #include "global.h" #include "plgdbsem.h" #include "xtable.h" -#include "xindex.h" +//#include "xindex.h" +#include "tabcol.h" #include "colblk.h" -#include "tabmysql.h" +//#include "tabmysql.h" +#include "myconn.h" #include "csort.h" +#include "tabutil.h" #include "tabpivot.h" #include "valblk.h" #include "ha_connect.h" @@ -52,111 +55,7 @@ extern "C" int trace; -/* --------------- Implementation of the PIVOT classes --------------- */ - -/***********************************************************************/ -/* DefineAM: define specific AM block values from PIVOT table. */ -/***********************************************************************/ -bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) - { - char *p1, *p2; - PHC hc = ((MYCAT*)Cat)->GetHandler(); - - Host = Cat->GetStringCatInfo(g, Name, "Host", "localhost"); - User = Cat->GetStringCatInfo(g, Name, "User", "root"); - Pwd = Cat->GetStringCatInfo(g, Name, "Password", NULL); - DB = Cat->GetStringCatInfo(g, Name, "Database", (PSZ)hc->GetDBName(NULL)); - Tabsrc = Cat->GetStringCatInfo(g, Name, "SrcDef", NULL); - Tabname = Cat->GetStringCatInfo(g, Name, "Name", NULL); - Picol = Cat->GetStringCatInfo(g, Name, "PivotCol", NULL); - Fncol = Cat->GetStringCatInfo(g, Name, "FncCol", NULL); - - // If fncol is like avg(colname), separate Fncol and Function - if (Fncol && (p1 = strchr(Fncol, '(')) && (p2 = strchr(p1, ')')) && - (*Fncol != '"') && (!*(p2+1))) { - *p1++ = '\0'; *p2 = '\0'; - Function = Fncol; - Fncol = p1; - } else - Function = Cat->GetStringCatInfo(g, Name, "Function", "SUM"); - - GBdone = Cat->GetIntCatInfo(Name, "Groupby", 0) ? TRUE : FALSE; - Port = Cat->GetIntCatInfo(Name, "Port", 3306); - Desc = (*Tabname) ? Tabname : Tabsrc; - return FALSE; - } // end of DefineAM - -/***********************************************************************/ -/* GetTable: makes a new TDB of the proper type. */ -/***********************************************************************/ -PTDB PIVOTDEF::GetTable(PGLOBAL g, MODE m) - { - return new(g) TDBPIVOT(this); - } // end of GetTable - -/* ------------------------------------------------------------------- */ - -/***********************************************************************/ -/* Implementation of the TDBPIVOT class. */ -/***********************************************************************/ -TDBPIVOT::TDBPIVOT(PPIVOTDEF tdp) : TDBASE(tdp), CSORT(FALSE) - { - Tqrp = NULL; - Host = tdp->Host; - Database = tdp->DB; - User = tdp->User; - Pwd = tdp->Pwd; - Port = tdp->Port; - Qryp = NULL; - Tabname = tdp->Tabname; // Name of source table - Tabsrc = tdp->Tabsrc; // SQL description of source table - Picol = tdp->Picol; // Pivot column name - Fncol = tdp->Fncol; // Function column name - Function = tdp->Function; // Aggregate function name - Xcolp = NULL; // To the FNCCOL column -//Xresp = NULL; // To the pivot result column -//Rblkp = NULL; // The value block of the pivot column - Fcolp = NULL; // To the function column - GBdone = tdp->GBdone; - Mult = -1; // Estimated table size - N = 0; // The current table index - M = 0; // The occurence rank - FileStatus = 0; // Logical End-of-File - RowFlag = 0; // 0: Ok, 1: Same, 2: Skip - } // end of TDBPIVOT constructor - #if 0 -TDBPIVOT::TDBPIVOT(PTDBPIVOT tdbp) : TDBASE(tdbp), CSORT(FALSE) - { - Tdbp = tdbp->Tdbp; - Sqlp = tdbp->Sqlp; - Qryp = tdbp->Qryp; - Tabname = tdbp->Tabname; - Tabsrc = tdbp->Tabsrc; - Picol = tdbp->Picol; - Fncol = tdbp->Fncol; - Function = tdbp->Function; - Xcolp = tdbp->Xcolp; - Xresp = tdbp->Xresp; - Rblkp = tdbp->Rblkp; - Fcolp = tdbp->Fcolp; - Mult = tdbp->Mult; - N = tdbp->N; - M = tdbp->M; - FileStatus = tdbp->FileStatus; - RowFlag = tdbp->RowFlag; - } // end of TDBPIVOT copy constructor - -// Is this really useful ??? -PTDB TDBPIVOT::CopyOne(PTABS t) - { - PTDB tp = new(t->G) TDBPIVOT(this); - - tp->SetColumns(Columns); - return tp; - } // end of CopyOne -#endif // 0 - /***********************************************************************/ /* Prepare the source table Query. */ /***********************************************************************/ @@ -165,14 +64,17 @@ PQRYRES TDBPIVOT::GetSourceTable(PGLOBAL g) if (Qryp) return Qryp; // Already done - if (!Tabsrc && Tabname) { + if (Tabname) { char *def, *colist; size_t len = 0; PCOL colp; PDBUSER dup = (PDBUSER)g->Activityp->Aptr; + if (InitTable(g)) + return NULL; + // Evaluate the length of the column list - for (colp = Columns; colp; colp = colp->GetNext()) + for (colp = Tdbp->Columns; colp; colp = colp->GetNext()) len += (strlen(colp->GetName()) + 2); *(colist = (char*)PlugSubAlloc(g, NULL, len)) = 0; @@ -182,7 +84,7 @@ PQRYRES TDBPIVOT::GetSourceTable(PGLOBAL g) strcpy(def, "SELECT "); if (!Fncol) { - for (colp = Columns; colp; colp = colp->GetNext()) + for (colp = Tdbp->Columns; colp; colp = colp->GetNext()) if (!Picol || stricmp(Picol, colp->GetName())) Fncol = colp->GetName(); @@ -199,7 +101,7 @@ PQRYRES TDBPIVOT::GetSourceTable(PGLOBAL g) if (!Picol) { // Find default Picol as the last one not equal to Fncol - for (colp = Columns; colp; colp = colp->GetNext()) + for (colp = Tdbp->Columns; colp; colp = colp->GetNext()) if (!Fncol || stricmp(Fncol, colp->GetName())) Picol = colp->GetName(); @@ -357,7 +259,6 @@ int TDBPIVOT::MakePivotColumns(PGLOBAL g) return Mult; } // end of MakePivotColumns -#if 0 /***********************************************************************/ /* Update fields in the MySQL table structure */ /* Note: this does not work. Indeed the new rows are correctly made */ @@ -529,31 +430,257 @@ bool TDBPIVOT::UpdateTableFields(PGLOBAL g, int n) } // end of UpdateTableFields #endif // 0 +/* --------------- Implementation of the PIVOT classes --------------- */ + +/***********************************************************************/ +/* PIVOTDEF constructor. */ +/***********************************************************************/ + PIVOTDEF::PIVOTDEF(void) + { + Host = User = Pwd = DB = NULL; + Tabname = Tabsrc = Picol = Fncol = Function = NULL; + GBdone = Accept = false; + Port = 0; + } // end of PIVOTDEF constructor + +/***********************************************************************/ +/* DefineAM: define specific AM block values from PIVOT table. */ +/***********************************************************************/ +bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) + { + char *p1, *p2; + PHC hc = ((MYCAT*)Cat)->GetHandler(); + + if (!PRXDEF::DefineAM(g, am, poff)) { + Tabname = (char*)Tablep->GetName(); + DB = (char*)Tablep->GetQualifier(); + } else { + DB = Cat->GetStringCatInfo(g, "Database", "*"); + Tabsrc = Cat->GetStringCatInfo(g, "SrcDef", NULL); + } // endif + + Host = Cat->GetStringCatInfo(g, "Host", "localhost"); + User = Cat->GetStringCatInfo(g, "User", "*"); + Pwd = Cat->GetStringCatInfo(g, "Password", NULL); + Picol = Cat->GetStringCatInfo(g, "PivotCol", NULL); + Fncol = Cat->GetStringCatInfo(g, "FncCol", NULL); + + // If fncol is like avg(colname), separate Fncol and Function + if (Fncol && (p1 = strchr(Fncol, '(')) && (p2 = strchr(p1, ')')) && + (*Fncol != '"') && (!*(p2+1))) { + *p1++ = '\0'; *p2 = '\0'; + Function = Fncol; + Fncol = p1; + } else + Function = Cat->GetStringCatInfo(g, "Function", "SUM"); + + GBdone = Cat->GetBoolCatInfo("Groupby", false); + Accept = Cat->GetBoolCatInfo("Accept", false); + Port = Cat->GetIntCatInfo("Port", 3306); + Desc = (Tabname) ? Tabname : Tabsrc; + return FALSE; + } // end of DefineAM + +/***********************************************************************/ +/* GetTable: makes a new TDB of the proper type. */ +/***********************************************************************/ +PTDB PIVOTDEF::GetTable(PGLOBAL g, MODE m) + { + return new(g) TDBPIVOT(this); + } // end of GetTable + +/* ------------------------------------------------------------------- */ + +/***********************************************************************/ +/* Implementation of the TDBPIVOT class. */ +/***********************************************************************/ +TDBPIVOT::TDBPIVOT(PPIVOTDEF tdp) : TDBPRX(tdp) + { + Host = tdp->Host; + Database = tdp->DB; + User = tdp->User; + Pwd = tdp->Pwd; + Port = tdp->Port; + Tabname = tdp->Tabname; // Name of source table + Tabsrc = tdp->Tabsrc; // SQL description of source table + Picol = tdp->Picol; // Pivot column name + Fncol = tdp->Fncol; // Function column name + Function = tdp->Function; // Aggregate function name + Xcolp = NULL; // To the FNCCOL column +//Xresp = NULL; // To the pivot result column +//Rblkp = NULL; // The value block of the pivot column + Fcolp = NULL; // To the function column + Dcolp = NULL; // To the dump column + GBdone = tdp->GBdone; + Accept = tdp->Accept; + Mult = -1; // Estimated table size + N = 0; // The current table index + M = 0; // The occurence rank + FileStatus = 0; // Logical End-of-File + RowFlag = 0; // 0: Ok, 1: Same, 2: Skip + } // end of TDBPIVOT constructor + +/***********************************************************************/ +/* Prepare the source table Query. */ +/***********************************************************************/ +bool TDBPIVOT::GetSourceTable(PGLOBAL g) + { + if (Tdbp) + return false; // Already done + + if (Tabname) { + PTABDEF defp; + PCOLDEF cdp; + + if (InitTable(g)) + return true; + else + defp = Tdbp->GetDef(); + + if (!Fncol) { + for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) + if (!Picol || stricmp(Picol, cdp->GetName())) + Fncol = cdp->GetName(); + + if (!Fncol) { + strcpy(g->Message, MSG(NO_DEF_FNCCOL)); + return true; + } // endif Fncol + + } // endif Fncol + + if (!Picol) { + // Find default Picol as the last one not equal to Fncol + for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) + if (!Fncol || stricmp(Fncol, cdp->GetName())) + Picol = cdp->GetName(); + + if (!Picol) { + strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); + return true; + } // endif Picol + + } // endif Picol + + if (!GBdone) { + char *colist; + + // Locate the suballocated colist (size is not known yet) + *(colist = (char*)PlugSubAlloc(g, NULL, 0)) = 0; + + // Make the column list + for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext()) + if (!cdp->GetOffset()) + strcat(strcat(colist, cdp->GetName()), ", "); + + // Add the Pivot column at the end of the list + strcat(colist, Picol); + + // Now we know how much was suballocated + PlugSubAlloc(g, NULL, strlen(colist)); + + // Locate the source string (size is not known yet) + Tabsrc = (char*)PlugSubAlloc(g, NULL, 0); + + // Start making the definition + strcat(strcat(strcpy(Tabsrc, "SELECT "), colist), ", "); + + // Make it suitable for Pivot by doing the group by + strcat(strcat(Tabsrc, Function), "("); + strcat(strcat(strcat(Tabsrc, Fncol), ") "), Fncol); + strcat(strcat(Tabsrc, " FROM "), Tabname); + strcat(strcat(Tabsrc, " GROUP BY "), colist); + + // Now we know how much was suballocated + PlugSubAlloc(g, NULL, strlen(Tabsrc)); + } // endif !GBdone + + } else if (!Tabsrc) { + strcpy(g->Message, MSG(SRC_TABLE_UNDEF)); + return true; + } // endif + + if (Tabsrc) { + MYSQLC myc; // MySQL connection class + PQRYRES qryp; + PCOLRES crp; + int w; + + // Open a MySQL connection for this table + if (myc.Open(g, Host, Database, User, Pwd, Port)) + return true; + + // Send the source command to MySQL + if (myc.ExecSQL(g, Tabsrc, &w) == RC_FX) { + myc.Close(); + return true; + } // endif Exec + + // We must have a storage query to get pivot column values + qryp = myc.GetResult(g); + myc.Close(); + Tdbp = new(g) TDBQRS(qryp); + + if (!Fncol) { + for (crp = qryp->Colresp; crp; crp = crp->Next) + if (!Picol || stricmp(Picol, crp->Name)) + Fncol = crp->Name; + + if (!Fncol) { + strcpy(g->Message, MSG(NO_DEF_FNCCOL)); + return true; + } // endif Fncol + + } // endif Fncol + + if (!Picol) { + // Find default Picol as the last one not equal to Fncol + for (crp = qryp->Colresp; crp; crp = crp->Next) + if (!Fncol || stricmp(Fncol, crp->Name)) + Picol = crp->Name; + + if (!Picol) { + strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); + return true; + } // endif Picol + + } // endif Picol + + } // endif Tabsrc + + // Now it is time to allocate the pivot and function columns + if (!(Fcolp = Tdbp->ColDB(g, Fncol, 0))) { + // Function column not found in table + sprintf(g->Message, MSG(COL_ISNOT_TABLE), Fncol, Tabname); + return true; + } else if (Fcolp->InitValue(g)) + return true; + + if (!(Xcolp = Tdbp->ColDB(g, Picol, 0))) { + // Pivot column not found in table + sprintf(g->Message, MSG(COL_ISNOT_TABLE), Picol, Tabname); + return true; + } else if (Xcolp->InitValue(g)) + return true; + + return false; + } // end of GetSourceTable + /***********************************************************************/ /* Allocate source column description block. */ /***********************************************************************/ PCOL TDBPIVOT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) { - PCOL colp = NULL; + PCOL colp; -//if (stricmp(cdp->GetName(), Picol) && stricmp(cdp->GetName(), Fncol)) { - colp = new(g) COLBLK(cdp, this, n); + if (cdp->GetOffset()) { + colp = new(g) FNCCOL(cdp, this, cprec, n); -// if (((PSRCCOL)colp)->Init(g, this)) -// return NULL; + if (cdp->GetOffset() > 1) + Dcolp = colp; -//} else { -// sprintf(g->Message, MSG(NO_MORE_COL), cdp->GetName()); -// return NULL; -//} // endif Name - - if (cprec) { - colp->SetNext(cprec->GetNext()); - cprec->SetNext(colp); - } else { - colp->SetNext(Columns); - Columns = colp; - } // endif cprec + } else + colp = new(g) SRCCOL(cdp, this, cprec, n); return colp; } // end of MakeCol @@ -598,13 +725,6 @@ bool TDBPIVOT::OpenDB(PGLOBAL g) return FALSE; } // endif use - /*********************************************************************/ - /* Do it here if not done yet (should not be the case). */ - /*********************************************************************/ -//if (MakePivotColumns(g) < 0) - if (!(Qryp = GetSourceTable(g))) - return TRUE; - if (Mode != MODE_READ) { /*******************************************************************/ /* Currently PIVOT tables cannot be modified. */ @@ -621,6 +741,30 @@ bool TDBPIVOT::OpenDB(PGLOBAL g) return TRUE; } // endif To_Key_Col + /*********************************************************************/ + /* Do it here if not done yet (should not be the case). */ + /*********************************************************************/ + if (GetSourceTable(g)) + return TRUE; + + /*********************************************************************/ + /* Check and initialize the subtable columns. */ + /*********************************************************************/ + for (PCOL cp = Columns; cp; cp = cp->GetNext()) + if (cp->GetAmType() == TYPE_AM_SRC) { + if (((PPRXCOL)cp)->Init(g)) + return TRUE; + + } else if (cp->GetAmType() == TYPE_AM_FNC) + if (((PFNCCOL)cp)->InitColumn(g)) + return TRUE; + + /*********************************************************************/ + /* Physically open the object table. */ + /*********************************************************************/ + if (Tdbp->OpenDB(g)) + return TRUE; + return FALSE; } // end of OpenDB @@ -632,7 +776,6 @@ int TDBPIVOT::ReadDB(PGLOBAL g) int rc = RC_OK; bool newrow = FALSE; PCOL colp; - PVAL vp1, vp2; if (FileStatus == 2) return RC_EF; @@ -652,7 +795,7 @@ int TDBPIVOT::ReadDB(PGLOBAL g) /*********************************************************************/ do { if (RowFlag != 1) { - if ((rc = Tqrp->ReadDB(g)) != RC_OK) { + if ((rc = Tdbp->ReadDB(g)) != RC_OK) { if (FileStatus && rc == RC_EF) { // A prepared row remains to be sent FileStatus = 2; @@ -662,14 +805,16 @@ int TDBPIVOT::ReadDB(PGLOBAL g) break; } // endif rc - for (colp = Tqrp->GetColumns(); colp; colp = colp->GetNext()) + for (colp = Tdbp->GetColumns(); colp; colp = colp->GetNext()) colp->ReadColumn(g); for (colp = Columns; colp; colp = colp->GetNext()) if (colp->GetAmType() == TYPE_AM_SRC) if (FileStatus) { - if (((PSRCCOL)colp)->CompareColumn()) + if (((PSRCCOL)colp)->CompareLast()) { newrow = (RowFlag) ? TRUE : FALSE; + break; + } // endif CompareLast } else ((PSRCCOL)colp)->SetColumn(); @@ -683,21 +828,21 @@ int TDBPIVOT::ReadDB(PGLOBAL g) } else RowFlag = 2; - vp1 = Xcolp->GetValue(); - // Look for the column having this header for (colp = Columns; colp; colp = colp->GetNext()) if (colp->GetAmType() == TYPE_AM_FNC) { - vp2 = ((PFNCCOL)colp)->Hval; - - if (!vp1->CompareValue(vp2)) + if (((PFNCCOL)colp)->CompareColumn()) break; } // endif AmType - if (!colp) { - strcpy(g->Message, MSG(NO_MATCH_COL)); - return RC_FX; + if (!colp && !(colp = Dcolp)) { + if (!Accept) { + strcpy(g->Message, MSG(NO_MATCH_COL)); + return RC_FX; + } else + continue; + } // endif colp // Set the value of the matching column from the fonction value @@ -734,6 +879,7 @@ void TDBPIVOT::CloseDB(PGLOBAL g) //Tdbp->CloseDB(g); } // end of CloseDB +#if 0 /***********************************************************************/ /* TDBPIVOT: Compare routine for sorting pivot column values. */ /***********************************************************************/ @@ -742,120 +888,81 @@ int TDBPIVOT::Qcompare(int *i1, int *i2) // TODO: the actual comparison between pivot column result values. return Rblkp->CompVal(*i1, *i2); } // end of Qcompare +#endif // 0 // ------------------------ FNCCOL functions ---------------------------- /***********************************************************************/ /* FNCCOL public constructor. */ /***********************************************************************/ -FNCCOL::FNCCOL(PCOL col1, PTDBPIVOT tdbp) - : COLBLK(col1, tdbp) +FNCCOL::FNCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i) + : COLBLK(cdp, tdbp, i) { + if (cprec) { + Next = cprec->GetNext(); + cprec->SetNext(this); + } else { + Next = tdbp->GetColumns(); + tdbp->SetColumns(this); + } // endif cprec + Value = NULL; // We'll get a new one later - Hval = NULL; // The unconverted header value + Hval = NULL; // The unconverted header value + Xcolp = NULL; } // end of FNCCOL constructor /***********************************************************************/ -/* FNCCOL initialization function. */ +/* FNCCOL initialization function. */ /***********************************************************************/ -bool FNCCOL::InitColumn(PGLOBAL g, PVAL valp) +bool FNCCOL::InitColumn(PGLOBAL g) { - char *p, buf[128]; - int len; - // Must have its own value block if (InitValue(g)) return TRUE; - // Convert header value to a null terminated character string - Hval = valp; - p = Hval->GetCharString(buf); - len = strlen(p) + 1; + // Make a value from the column name + Hval = AllocateValue(g, Name, TYPE_STRING); + Hval->SetPrec(1); // Case insensitive - if (len > (signed)sizeof(buf)) { - strcpy(g->Message, MSG(COLNAM_TOO_LONG)); - return TRUE; - } // endif buf - - // Set the name of the functional pivot column - Name = (PSZ)PlugSubAlloc(g, NULL, len); - strcpy(Name, p); + Xcolp = ((PTDBPIVOT)To_Tdb)->Xcolp; AddStatus(BUF_READ); // All is done here return FALSE; } // end of InitColumn +/***********************************************************************/ +/* CompareColumn: Compare column value with source column value. */ +/***********************************************************************/ +bool FNCCOL::CompareColumn(void) + { + // Compare the unconverted values + return Hval->IsEqual(Xcolp->GetValue(), false); + } // end of CompareColumn + // ------------------------ SRCCOL functions ---------------------------- -#if 0 /***********************************************************************/ /* SRCCOL public constructor. */ /***********************************************************************/ -SRCCOL::SRCCOL(PCOLDEF cdp, PTDBPIVOT tdbp, int n) - : COLBLK(cdp, tdbp, n) +SRCCOL::SRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int n) + : PRXCOL(cdp, tdbp, cprec, n) { // Set additional SRC access method information for column. - Colp = NULL; - Cnval = NULL; +//Cnval = NULL; } // end of SRCCOL constructor -#endif // 0 - -/***********************************************************************/ -/* SRCCOL public constructor. */ -/***********************************************************************/ -SRCCOL::SRCCOL(PCOL cp, PTDBPIVOT tdbp, int n) - : COLBLK(cp, tdbp) - { - Index = n; - - // Set additional SRC access method information for column. - Colp = (PQRSCOL)cp; - - // Don't share Value with the source column so we can compare - Cnval = Value = NULL; - } // end of SRCCOL constructor - -#if 0 -/***********************************************************************/ -/* SRCCOL constructor used for copying columns. */ -/* tdbp is the pointer to the new table descriptor. */ -/***********************************************************************/ -SRCCOL::SRCCOL(SRCCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp) - { - Colp = col1->Colp; - } // end of SRCCOL copy constructor -#endif // 0 /***********************************************************************/ /* Initialize the column as pointing to the source column. */ /***********************************************************************/ -bool SRCCOL::Init(PGLOBAL g, PTDBPIVOT tdbp) +bool SRCCOL::Init(PGLOBAL g) { - // Currently we ignore the type of the create table column - bool conv = FALSE; + if (PRXCOL::Init(g)) + return true; -#if 0 - if (!Colp) { - // Column was defined in the Create Table statement - if (!(Colp = tdbp->ColDB(g, Name, 0))) - return TRUE; - - // We can have a conversion problem converting from numeric to - // character because GetCharValue does not exist for numeric types. - conv = (IsTypeChar(Buf_Type) && IsTypeNum(Colp->GetResultType())); - } else -#endif // 0 - conv = FALSE; - - if (InitValue(g)) - return TRUE; - -//if (conv) -// Cnval = AllocateValue(g, Colp->GetValue()); -//else - Cnval = Value; + // Will contain the last value +//Cnval = AllocateValue(g, Value, TYPE_VOID); AddStatus(BUF_READ); // All is done here - return FALSE; + return false; } // end of SRCCOL constructor /***********************************************************************/ @@ -863,25 +970,18 @@ bool SRCCOL::Init(PGLOBAL g, PTDBPIVOT tdbp) /***********************************************************************/ void SRCCOL::SetColumn(void) { -#if defined(_DEBUG) - Cnval->SetValue_pval(Colp->GetValue(), TRUE); -#else - Cnval->SetValue_pval(Colp->GetValue()); -#endif // _DEBUG - - if (Value != Cnval) - // Convert value - Value->SetValue_pval(Cnval); - +//Cnval->SetValue_pval(Value); + Value->SetValue_pval(To_Val); } // end of SetColumn /***********************************************************************/ /* SetColumn: Compare column value with source column value. */ /***********************************************************************/ -bool SRCCOL::CompareColumn(void) +bool SRCCOL::CompareLast(void) { // Compare the unconverted values - return Cnval->CompareValue(Colp->GetValue()); +//return !Cnval->IsEqual(Colp->GetValue(), true); + return !Value->IsEqual(To_Val, true); } // end of CompareColumn @@ -1019,18 +1119,8 @@ bool TDBQRS::OpenDB(PGLOBAL g) CurPos = -1; - if (Use == USE_OPEN) { - /*******************************************************************/ - /* Table already open, just replace it at its beginning. */ - /*******************************************************************/ - if (To_Kindex) - /*****************************************************************/ - /* Table is to be accessed through a sorted index table. */ - /*****************************************************************/ - To_Kindex->Reset(); - + if (Use == USE_OPEN) return FALSE; - } // endif use /*********************************************************************/ /* Open (retrieve data from) the query if not already open. */ @@ -1059,6 +1149,7 @@ int TDBQRS::ReadDB(PGLOBAL g) htrc("QRS ReadDB: R%d CurPos=%d key=%p link=%p Kindex=%p\n", GetTdb_No(), CurPos, To_Key_Col, To_Link, To_Kindex); +#if 0 if (To_Kindex) { /*******************************************************************/ /* Reading is by an index table. */ @@ -1086,6 +1177,7 @@ int TDBQRS::ReadDB(PGLOBAL g) htrc("Position is now %d\n", CurPos); } else +#endif // 0 /*******************************************************************/ /* !To_Kindex ---> sequential reading */ /*******************************************************************/ @@ -1117,10 +1209,10 @@ int TDBQRS::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ void TDBQRS::CloseDB(PGLOBAL g) { - if (To_Kindex) { - To_Kindex->Close(); - To_Kindex = NULL; - } // endif +//if (To_Kindex) { +// To_Kindex->Close(); +// To_Kindex = NULL; +// } // endif if (trace) htrc("Qryres CloseDB"); diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h index fb480b9abbf..3aa5288b5d8 100644 --- a/storage/connect/tabpivot.h +++ b/storage/connect/tabpivot.h @@ -22,13 +22,12 @@ typedef class QRSCOL *PQRSCOL; /***********************************************************************/ /* PIVOT table. */ /***********************************************************************/ -//ass DllExport PIVOTDEF : public TABDEF {/* Logical table description */ -class PIVOTDEF : public TABDEF { /* Logical table description */ +//ass DllExport PIVOTDEF : public PRXDEF {/* Logical table description */ +class PIVOTDEF : public PRXDEF { /* Logical table description */ friend class TDBPIVOT; public: // Constructor - PIVOTDEF(void) {Pseudo = 3; - Tabname = Tabsrc = Picol = Fncol = Function = NULL;} + PIVOTDEF(void); // Implementation virtual const char *GetType(void) {return "PIVOT";} @@ -39,26 +38,27 @@ class PIVOTDEF : public TABDEF { /* Logical table description */ protected: // Members - char *Host; /* Host machine to use */ - char *User; /* User logon info */ - char *Pwd; /* Password logon info */ - char *DB; /* Database to be used by server */ - char *Tabname; /* Name of source table */ + char *Host; /* Host machine to use */ + char *User; /* User logon info */ + char *Pwd; /* Password logon info */ + char *DB; /* Database to be used by server */ + char *Tabname; /* Name of source table */ char *Tabsrc; /* The source table SQL description */ - char *Picol; /* The pivot column */ + char *Picol; /* The pivot column */ char *Fncol; /* The function column */ char *Function; /* The function applying to group by */ bool GBdone; /* True if tabname as group by format */ - int Port; /* MySQL port number */ + bool Accept; /* TRUE if no match is accepted */ + int Port; /* MySQL port number */ }; // end of PIVOTDEF /***********************************************************************/ /* This is the class declaration for the PIVOT table. */ /***********************************************************************/ //ass DllExport TDBPIVOT : public TDBASE, public CSORT { -class TDBPIVOT : public TDBASE, public CSORT { +class TDBPIVOT : public TDBPRX { friend class FNCCOL; - friend class SRCCOL; +//friend class SRCCOL; public: // Constructor TDBPIVOT(PPIVOTDEF tdp); @@ -85,39 +85,41 @@ class TDBPIVOT : public TDBASE, public CSORT { virtual void CloseDB(PGLOBAL g); // The sorting function - virtual int Qcompare(int *, int *); +//virtual int Qcompare(int *, int *); protected: - PQRYRES GetSourceTable(PGLOBAL g); - int MakePivotColumns(PGLOBAL g); - bool UpdateTableFields(PGLOBAL g, int n); + bool GetSourceTable(PGLOBAL g); +//int MakePivotColumns(PGLOBAL g); +//bool UpdateTableFields(PGLOBAL g, int n); // Members - MYSQLC Myc; // MySQL connection class - PTDBQRS Tqrp; // To the source table result - char *Host; // Host machine to use - char *User; // User logon info - char *Pwd; // Password logon info - char *Database; // Database to be used by server - PQRYRES Qryp; // Points to Query result block - char *Tabname; // Name of source table - char *Tabsrc; // SQL of source table - char *Picol; // Pivot column name - char *Fncol; // Function column name - char *Function; // The function applying to group by - PQRSCOL Fcolp; // To the function column in source - PQRSCOL Xcolp; // To the pivot column in source - PCOLRES Xresp; // To the pivot result column -//PCOLRES To_Sort; // Saved Qryp To_Sort pointer - PVBLK Rblkp; // The value block of the pivot column - bool GBdone; // True when subtable is "Group by" - int Mult; // Multiplication factor - int Ncol; // The number of generated columns - int N; // The current table index - int M; // The occurence rank - int Port; // MySQL port number - BYTE FileStatus; // 0: First 1: Rows 2: End-of-File - BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip +//MYSQLC Myc; // MySQL connection class +//PTDBQRS Tqrp; // To the source table result + char *Host; // Host machine to use + char *User; // User logon info + char *Pwd; // Password logon info + char *Database; // Database to be used by server +//PQRYRES Qryp; // Points to Query result block + char *Tabname; // Name of source table + char *Tabsrc; // SQL of source table + char *Picol; // Pivot column name + char *Fncol; // Function column name + char *Function; // The function applying to group by + PCOL Fcolp; // To the function column in source + PCOL Xcolp; // To the pivot column in source + PCOL Dcolp; // To the dump column +//PCOLRES Xresp; // To the pivot result column +//PCOLRES To_Sort; // Saved Qryp To_Sort pointer +//PVBLK Rblkp; // The value block of the pivot column + bool GBdone; // True when subtable is "Group by" + bool Accept; // TRUE if no match is accepted + int Mult; // Multiplication factor + int Ncol; // The number of generated columns + int N; // The current table index + int M; // The occurence rank + int Port; // MySQL port number + BYTE FileStatus; // 0: First 1: Rows 2: End-of-File + BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip }; // end of class TDBPIVOT /***********************************************************************/ @@ -127,30 +129,30 @@ class FNCCOL : public COLBLK { friend class TDBPIVOT; public: // Constructor - FNCCOL(PCOL colp, PTDBPIVOT tdbp); + FNCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); // Implementation virtual int GetAmType(void) {return TYPE_AM_FNC;} // Methods virtual void Reset(void) {} - bool InitColumn(PGLOBAL g, PVAL valp); + bool InitColumn(PGLOBAL g); + bool CompareColumn(void); protected: // Member - PVAL Hval; // The original value used to generate the header + PVAL Hval; // The value containing the header + PCOL Xcolp; }; // end of class FNCCOL /***********************************************************************/ /* Class SRCCOL: for other source columns. */ /***********************************************************************/ -class SRCCOL : public COLBLK { +class SRCCOL : public PRXCOL { friend class TDBPIVOT; public: // Constructors -//SRCCOL(PCOLDEF cdp, PTDBPIVOT tdbp, int n); - SRCCOL(PCOL cp, PTDBPIVOT tdbp, int n); -//SRCCOL(SRCCOL *colp, PTDB tdbp); // Constructor used in copy process + SRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int n); // Implementation virtual int GetAmType(void) {return TYPE_AM_SRC;} @@ -158,16 +160,15 @@ class SRCCOL : public COLBLK { // Methods virtual void Reset(void) {} void SetColumn(void); - bool Init(PGLOBAL g, PTDBPIVOT tdbp); - bool CompareColumn(void); + bool Init(PGLOBAL g); + bool CompareLast(void); protected: // Default constructor not to be used SRCCOL(void) {} // Members - PQRSCOL Colp; - PVAL Cnval; +//PVAL Cnval; }; // end of class SRCCOL /***********************************************************************/ diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 2bd92ff9607..2c14b711f86 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -121,10 +121,7 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, const char *name, bool info) { - static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR, DB_INT, - DB_INT, DB_SHORT, DB_SHORT, DB_SHORT, - DB_CHAR, DB_CHAR, DB_CHAR}; - static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, + static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING, TYPE_STRING, TYPE_STRING}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, @@ -132,7 +129,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, FLD_REM, FLD_NO, FLD_CHARSET}; static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 256, 32, 32}; char *fld, *fmt; - int i, n, ncol = sizeof(dbtype) / sizeof(int); + int i, n, ncol = sizeof(buftyp) / sizeof(int); int len, type, prec; bool mysql; TABLE_SHARE *s; @@ -156,7 +153,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, /* Allocate the structures used to refer to the result set. */ /**********************************************************************/ qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3, - dbtype, buftyp, fldtyp, length, true, true); + buftyp, fldtyp, length, true, true); // Some columns must be renamed for (i = 0, crp = qrp->Colresp; crp; crp = crp->Next) diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp index d89d61dc11c..dbd4330a2f9 100644 --- a/storage/connect/tabwmi.cpp +++ b/storage/connect/tabwmi.cpp @@ -135,14 +135,12 @@ PWMIUT InitWMI(PGLOBAL g, char *nsp, char *classname) /***********************************************************************/ PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info) { - static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR, - DB_INT, DB_INT, DB_SHORT}; static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_SCALE}; static unsigned int len, length[] = {0, 6, 8, 10, 10, 6}; - int i = 0, n = 0, ncol = sizeof(dbtype) / sizeof(int); + int i = 0, n = 0, ncol = sizeof(buftyp) / sizeof(int); int lng, typ, prec; LONG low, upp; BSTR propname; @@ -213,7 +211,7 @@ PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info) /* Allocate the structures used to refer to the result set. */ /*********************************************************************/ qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3, - dbtype, buftyp, fldtyp, length, true, true); + buftyp, fldtyp, length, true, true); if (info) return qrp; diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index d64a730beb0..96da0571271 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -66,7 +66,6 @@ extern "C" int trace; /***********************************************************************/ XCLDEF::XCLDEF(void) { - Pseudo = 3; Xcol = NULL; Sep = ','; Mult = 10; diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 9053658b461..7a1146e6c32 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -154,46 +154,6 @@ int GetTypeSize(int type, int len) return len; } // end of GetTypeSize -/***********************************************************************/ -/* GetPLGType: returns the PlugDB type corresponding to a DB type. */ -/***********************************************************************/ -int GetPLGType(int type) - { - int tp; - - switch (type) { - case DB_CHAR: - case DB_STRING: tp = TYPE_STRING; break; - case DB_SHORT: tp = TYPE_SHORT; break; - case DB_INT: tp = TYPE_INT; break; - case DB_DOUBLE: tp = TYPE_FLOAT; break; - case DB_DATE: tp = TYPE_DATE; break; - default: tp = TYPE_ERROR; - } // endswitch type - - return tp; - } // end of GetPLGType - -/***********************************************************************/ -/* GetDBType: returns the DB type corresponding to a PlugDB type. */ -/***********************************************************************/ -int GetDBType(int type) - { - int tp; - - switch (type) { - case TYPE_STRING: tp = DB_CHAR; break; - case TYPE_SHORT: tp = DB_SHORT; break; - case TYPE_INT: tp = DB_INT; break; - case TYPE_BIGINT: - case TYPE_FLOAT: tp = DB_DOUBLE; break; - case TYPE_DATE: tp = DB_DATE; break; - default: tp = DB_ERROR; - } // endswitch type - - return tp; - } // end of GetPLGType - /***********************************************************************/ /* GetFormatType: returns the FORMAT character(s) according to type. */ /***********************************************************************/ @@ -1143,10 +1103,13 @@ bool TYPVAL::IsEqual(PVAL vp, bool chktype) return false; else if (Null || vp->IsNull()) return false; - else if (Ci || vp->IsCi()) - return !stricmp(Strp, vp->GetCharValue()); + + char buf[32]; + + if (Ci || vp->IsCi()) + return !stricmp(Strp, vp->GetCharString(buf)); else // (!Ci) - return !strcmp(Strp, vp->GetCharValue()); + return !strcmp(Strp, vp->GetCharString(buf)); } // end of IsEqual diff --git a/storage/connect/value.h b/storage/connect/value.h index 0f7b795c252..95d69dae92f 100644 --- a/storage/connect/value.h +++ b/storage/connect/value.h @@ -38,7 +38,6 @@ typedef struct _datpar *PDTP; // For DTVAL /***********************************************************************/ /* Utilities used to test types and to allocated values. */ /***********************************************************************/ -int GetPLGType(int); PVAL AllocateValue(PGLOBAL, void *, short); // Exported functions @@ -50,7 +49,6 @@ DllExport int TranslateSQLType(int stp, int prec, int& len); #endif DllExport char *GetFormatType(int); DllExport int GetFormatType(char); -DllExport int GetDBType(int); DllExport bool IsTypeChar(int type); DllExport bool IsTypeNum(int type); DllExport int ConvertType(int, int, CONV, bool match = false); @@ -82,12 +80,12 @@ class DllExport VALUE : public BLOCK { virtual longlong GetBigintValue(void) = 0; virtual double GetFloatValue(void) = 0; virtual void *GetTo_Val(void) = 0; + virtual void SetPrec(int prec) {Prec = prec;} bool IsNull(void) {return Null;} void SetNull(bool b) {Null = b;} void SetNullable(bool b) {Nullable = b;} int GetType(void) {return Type;} int GetClen(void) {return Clen;} - void SetPrec(int prec) {Prec = prec;} void SetGlobal(PGLOBAL g) {Global = g;} // Methods @@ -217,6 +215,7 @@ class DllExport TYPVAL: public VALUE { virtual longlong GetBigintValue(void) {return atoll(Strp);} virtual double GetFloatValue(void) {return atof(Strp);} virtual void *GetTo_Val(void) {return Strp;} + virtual void SetPrec(int prec) {Ci = prec != 0;} // Methods virtual bool SetValue_pval(PVAL valp, bool chktype); From 2cd63afe352ace53ca7069b71012121355ae565d Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 10 May 2013 23:05:16 +0200 Subject: [PATCH 148/273] - Add pivot table files and support modified: storage/connect/CMakeLists.txt --- storage/connect/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 41930c71aa4..4209ff40322 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -25,20 +25,20 @@ filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabmul.cpp tabsys.cpp tabvct.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp filamzip.cpp tabtbl.cpp myutil.cpp -tabutil.cpp tabxcl.cpp taboccur.cpp +tabutil.cpp tabxcl.cpp taboccur.cpp tabpivot.cpp block.h catalog.h checklvl.h colblk.h connect.h csort.h engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h global.h ha_connect.h maputil.h msgid.h mycat.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabmul.h tabsys.h tabtbl.h tabvct.h user_connect.h valblk.h value.h xindex.h xobject.h xtable.h -tabutil.h tabxcl.h taboccur.h) +tabutil.h tabxcl.h taboccur.h tabpivot.h) # # Definitions that are shared for all OSes # add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS ) -add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT ) +add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT ) # From 5b31f8785840d63e6a2516758bcd68ac1307d7a7 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 May 2013 12:20:21 +0300 Subject: [PATCH 149/273] MDEV-4231: Possible bug in function _ma_apply_undo_row_insert() Added comment to clearify the code. storage/maria/ma_blockrec.c: Added comment to clearify the code In case of out of memory or disk error, mark pages with LSN_IMPOSSIBLE to make it easier to know which pages have wrong information. --- storage/maria/ma_blockrec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 622d2581cc9..ab134bbac10 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -6937,6 +6937,7 @@ my_bool _ma_apply_undo_row_insert(MARIA_HA *info, LSN undo_lsn, res= 0; end: + /* The following is true only if _ma_bitmap_flushable() was called earlier */ if (info->non_flushable_state) _ma_bitmap_flushable(info, -1); _ma_unpin_all_pages_and_finalize_row(info, lsn); @@ -6946,6 +6947,11 @@ err: DBUG_ASSERT(!maria_assert_if_crashed_table); res= 1; _ma_mark_file_crashed(share); + /* + Don't write a new LSN on the used pages. Not important as the file is + marked as crashed and need to be repaired before it can be used. + */ + lsn= LSN_IMPOSSIBLE; goto end; } From 5657660ab07a905a018cee5132618a12f7fcc851 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 11 May 2013 13:21:15 +0200 Subject: [PATCH 150/273] - Added a test case for PIVOT tables added: storage/connect/mysql-test/connect/r/pivot.result storage/connect/mysql-test/connect/std_data/expenses.txt storage/connect/mysql-test/connect/t/pivot.test --- .../connect/mysql-test/connect/r/pivot.result | 230 ++++++++++++++++++ .../mysql-test/connect/std_data/expenses.txt | 24 ++ .../connect/mysql-test/connect/t/pivot.test | 144 +++++++++++ 3 files changed, 398 insertions(+) create mode 100644 storage/connect/mysql-test/connect/r/pivot.result create mode 100644 storage/connect/mysql-test/connect/std_data/expenses.txt create mode 100644 storage/connect/mysql-test/connect/t/pivot.test diff --git a/storage/connect/mysql-test/connect/r/pivot.result b/storage/connect/mysql-test/connect/r/pivot.result new file mode 100644 index 00000000000..4455d333e5a --- /dev/null +++ b/storage/connect/mysql-test/connect/r/pivot.result @@ -0,0 +1,230 @@ +# +# Testing the PIVOT table type +# +CREATE TABLE expenses ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +What CHAR(12) NOT NULL, +Amount DOUBLE(8,2)) +ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt'; +SELECT * FROM expenses; +Who Week What Amount +Joe 3 Beer 18.00 +Beth 4 Food 17.00 +Janet 5 Beer 14.00 +Joe 3 Food 12.00 +Joe 4 Beer 19.00 +Janet 5 Car 12.00 +Joe 3 Food 19.00 +Beth 4 Beer 15.00 +Janet 5 Beer 19.00 +Joe 3 Car 20.00 +Joe 4 Beer 16.00 +Beth 5 Food 12.00 +Beth 3 Beer 16.00 +Joe 4 Food 17.00 +Joe 5 Beer 14.00 +Janet 3 Car 19.00 +Joe 4 Food 17.00 +Beth 5 Beer 20.00 +Janet 3 Food 18.00 +Joe 4 Beer 14.00 +Joe 5 Food 12.00 +Janet 3 Beer 18.00 +Janet 4 Car 17.00 +Janet 5 Food 12.00 +# +# Pivoting from What +# +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +Beer DOUBLE(8,2) FLAG=1, +Car DOUBLE(8,2) FLAG=1, +Food DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; +ALTER TABLE pivex OPTION_LIST='port=PORT'; +Warnings: +Warning 1105 The current version of CONNECT did not check what you changed in ALTER. Use at your own risk +SELECT * FROM pivex; +Who Week Beer Car Food +Beth 3 16.00 0.00 0.00 +Beth 4 15.00 0.00 17.00 +Beth 5 20.00 0.00 12.00 +Janet 3 18.00 19.00 18.00 +Janet 4 0.00 17.00 0.00 +Janet 5 33.00 12.00 12.00 +Joe 3 18.00 20.00 31.00 +Joe 4 49.00 0.00 34.00 +Joe 5 14.00 0.00 12.00 +# +# Restricting the columns in a Pivot Table +# +ALTER TABLE pivex DROP COLUMN week; +SELECT * FROM pivex; +Who Beer Car Food +Beth 51.00 0.00 29.00 +Janet 51.00 48.00 30.00 +Joe 81.00 20.00 77.00 +# +# Using a source definition +# +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +Beer DOUBLE(8,2) FLAG=1, +Car DOUBLE(8,2) FLAG=1, +Food DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT +SRCDEF='select who, week, what, sum(amount) from expenses where week in (4,5) group by who, week, what'; +ALTER TABLE pivex OPTION_LIST='port=PORT'; +Warnings: +Warning 1105 The current version of CONNECT did not check what you changed in ALTER. Use at your own risk +SELECT * FROM pivex; +Who Week Beer Car Food +Beth 4 15.00 0.00 17.00 +Beth 5 20.00 0.00 12.00 +Janet 4 0.00 17.00 0.00 +Janet 5 33.00 12.00 12.00 +Joe 4 49.00 0.00 34.00 +Joe 5 14.00 0.00 12.00 +# +# Pivoting from Week +# +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +What CHAR(12) NOT NULL, +`3` DOUBLE(8,2) FLAG=1, +`4` DOUBLE(8,2) FLAG=1, +`5` DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; +ALTER TABLE pivex OPTION_LIST='PivotCol=Week,port=PORT'; +Warnings: +Warning 1105 The current version of CONNECT did not check what you changed in ALTER. Use at your own risk +SELECT * FROM pivex; +Who What 3 4 5 +Beth Beer 16.00 15.00 20.00 +Beth Food 0.00 17.00 12.00 +Janet Beer 18.00 0.00 33.00 +Janet Car 19.00 17.00 12.00 +Janet Food 18.00 0.00 12.00 +Joe Beer 18.00 49.00 14.00 +Joe Car 20.00 0.00 0.00 +Joe Food 31.00 34.00 12.00 +# +# Using scalar functions and expresssions +# +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +What CHAR(12) NOT NULL, +First DOUBLE(8,2) FLAG=1, +Middle DOUBLE(8,2) FLAG=1, +Last DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT +SRCDEF='select who, what, case when week=3 then ''First'' when week=5 then ''Last'' else ''Middle'' end as wk, sum(amount) * 6.56 as amnt from expenses group by who, what, wk'; +ALTER TABLE pivex OPTION_LIST='PivotCol=wk,port=PORT'; +Warnings: +Warning 1105 The current version of CONNECT did not check what you changed in ALTER. Use at your own risk +SELECT * FROM pivex; +Who What First Middle Last +Beth Beer 104.96 98.40 131.20 +Beth Food 0.00 111.52 78.72 +Janet Beer 118.08 0.00 216.48 +Janet Car 124.64 111.52 78.72 +Janet Food 118.08 0.00 78.72 +Joe Beer 118.08 321.44 91.84 +Joe Car 131.20 0.00 0.00 +Joe Food 203.36 223.04 78.72 +DROP TABLE pivex; +DROP TABLE expenses; +# +# Make the PETS table +# +CREATE TABLE pets ( +Name VARCHAR(12) NOT NULL, +Race CHAR(6) NOT NULL, +Number INT NOT NULL) ENGINE=MYISAM; +INSERT INTO pets VALUES('John','dog',2); +INSERT INTO pets VALUES('Bill','cat',1); +INSERT INTO pets VALUES('Mary','dog',1); +INSERT INTO pets VALUES('Mary','cat',1); +INSERT INTO pets VALUES('Lisbeth','rabbit',2); +INSERT INTO pets VALUES('Kevin','cat',2); +INSERT INTO pets VALUES('Kevin','bird',6); +INSERT INTO pets VALUES('Donald','dog',1); +INSERT INTO pets VALUES('Donald','fish',3); +SELECT * FROM pets; +Name Race Number +John dog 2 +Bill cat 1 +Mary dog 1 +Mary cat 1 +Lisbeth rabbit 2 +Kevin cat 2 +Kevin bird 6 +Donald dog 1 +Donald fish 3 +# +# Pivot the PETS table +# +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1, +rabbit INT NOT NULL DEFAULT 0 FLAG=1, +bird INT NOT NULL DEFAULT 0 FLAG=1, +fish INT NOT NULL DEFAULT 0 FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +SELECT * FROM pivet; +name dog cat rabbit bird fish +John 2 0 0 0 0 +Bill 0 1 0 0 0 +Mary 1 1 0 0 0 +Lisbeth 0 0 2 0 0 +Kevin 0 2 0 6 0 +Donald 1 0 0 0 3 +DROP TABLE pivet; +# +# Testing the "data" column list +# +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +SELECT * FROM pivet; +ERROR HY000: Got error 122 'Cannot find matching column' from CONNECT +ALTER TABLE pivet OPTION_LIST='PivotCol=race,groupby=1,accept=1'; +Warnings: +Warning 1105 The current version of CONNECT did not check what you changed in ALTER. Use at your own risk +SELECT * FROM pivet; +name dog cat +John 2 0 +Bill 0 1 +Mary 1 1 +Lisbeth 0 0 +Kevin 0 2 +Donald 1 0 +DROP TABLE pivet; +# +# Adding a "dump" column +# +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1, +other INT NOT NULL DEFAULT 0 FLAG=2) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +SELECT * FROM pivet; +name dog cat other +John 2 0 0 +Bill 0 1 0 +Mary 1 1 0 +Lisbeth 0 0 2 +Kevin 0 2 6 +Donald 1 0 3 +DROP TABLE pivet; +DROP TABLE pets; diff --git a/storage/connect/mysql-test/connect/std_data/expenses.txt b/storage/connect/mysql-test/connect/std_data/expenses.txt new file mode 100644 index 00000000000..66a94edbb9a --- /dev/null +++ b/storage/connect/mysql-test/connect/std_data/expenses.txt @@ -0,0 +1,24 @@ +Joe 3Beer 18.00 +Beth 4Food 17.00 +Janet 5Beer 14.00 +Joe 3Food 12.00 +Joe 4Beer 19.00 +Janet 5Car 12.00 +Joe 3Food 19.00 +Beth 4Beer 15.00 +Janet 5Beer 19.00 +Joe 3Car 20.00 +Joe 4Beer 16.00 +Beth 5Food 12.00 +Beth 3Beer 16.00 +Joe 4Food 17.00 +Joe 5Beer 14.00 +Janet 3Car 19.00 +Joe 4Food 17.00 +Beth 5Beer 20.00 +Janet 3Food 18.00 +Joe 4Beer 14.00 +Joe 5Food 12.00 +Janet 3Beer 18.00 +Janet 4Car 17.00 +Janet 5Food 12.00 diff --git a/storage/connect/mysql-test/connect/t/pivot.test b/storage/connect/mysql-test/connect/t/pivot.test new file mode 100644 index 00000000000..75a208e853b --- /dev/null +++ b/storage/connect/mysql-test/connect/t/pivot.test @@ -0,0 +1,144 @@ +let $MYSQLD_DATADIR= `select @@datadir`; +let $PORT= `select @@port`; +--copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt + +--echo # +--echo # Testing the PIVOT table type +--echo # +CREATE TABLE expenses ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +What CHAR(12) NOT NULL, +Amount DOUBLE(8,2)) +ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt'; +SELECT * FROM expenses; + +--echo # +--echo # Pivoting from What +--echo # +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +Beer DOUBLE(8,2) FLAG=1, +Car DOUBLE(8,2) FLAG=1, +Food DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; +--replace_result $PORT PORT +--eval ALTER TABLE pivex OPTION_LIST='port=$PORT' +SELECT * FROM pivex; + +--echo # +--echo # Restricting the columns in a Pivot Table +--echo # +ALTER TABLE pivex DROP COLUMN week; +SELECT * FROM pivex; + +--echo # +--echo # Using a source definition +--echo # +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +Beer DOUBLE(8,2) FLAG=1, +Car DOUBLE(8,2) FLAG=1, +Food DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT +SRCDEF='select who, week, what, sum(amount) from expenses where week in (4,5) group by who, week, what'; +--replace_result $PORT PORT +--eval ALTER TABLE pivex OPTION_LIST='port=$PORT' +SELECT * FROM pivex; + +--echo # +--echo # Pivoting from Week +--echo # +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +What CHAR(12) NOT NULL, +`3` DOUBLE(8,2) FLAG=1, +`4` DOUBLE(8,2) FLAG=1, +`5` DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; +--replace_result $PORT PORT +--eval ALTER TABLE pivex OPTION_LIST='PivotCol=Week,port=$PORT' +SELECT * FROM pivex; + +--echo # +--echo # Using scalar functions and expresssions +--echo # +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +What CHAR(12) NOT NULL, +First DOUBLE(8,2) FLAG=1, +Middle DOUBLE(8,2) FLAG=1, +Last DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT +SRCDEF='select who, what, case when week=3 then ''First'' when week=5 then ''Last'' else ''Middle'' end as wk, sum(amount) * 6.56 as amnt from expenses group by who, what, wk'; +--replace_result $PORT PORT +--eval ALTER TABLE pivex OPTION_LIST='PivotCol=wk,port=$PORT' +SELECT * FROM pivex; +DROP TABLE pivex; +DROP TABLE expenses; + +--echo # +--echo # Make the PETS table +--echo # +CREATE TABLE pets ( +Name VARCHAR(12) NOT NULL, +Race CHAR(6) NOT NULL, +Number INT NOT NULL) ENGINE=MYISAM; +INSERT INTO pets VALUES('John','dog',2); +INSERT INTO pets VALUES('Bill','cat',1); +INSERT INTO pets VALUES('Mary','dog',1); +INSERT INTO pets VALUES('Mary','cat',1); +INSERT INTO pets VALUES('Lisbeth','rabbit',2); +INSERT INTO pets VALUES('Kevin','cat',2); +INSERT INTO pets VALUES('Kevin','bird',6); +INSERT INTO pets VALUES('Donald','dog',1); +INSERT INTO pets VALUES('Donald','fish',3); +SELECT * FROM pets; + +--echo # +--echo # Pivot the PETS table +--echo # +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1, +rabbit INT NOT NULL DEFAULT 0 FLAG=1, +bird INT NOT NULL DEFAULT 0 FLAG=1, +fish INT NOT NULL DEFAULT 0 FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +SELECT * FROM pivet; +DROP TABLE pivet; + +--echo # +--echo # Testing the "data" column list +--echo # +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +--error ER_GET_ERRMSG +SELECT * FROM pivet; +ALTER TABLE pivet OPTION_LIST='PivotCol=race,groupby=1,accept=1'; +SELECT * FROM pivet; +DROP TABLE pivet; + +--echo # +--echo # Adding a "dump" column +--echo # +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1, +other INT NOT NULL DEFAULT 0 FLAG=2) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +SELECT * FROM pivet; + +DROP TABLE pivet; +DROP TABLE pets; +--remove_file $MYSQLD_DATADIR/test/expenses.txt From 4e9bf37f1f70ddc0c901760e4302dd4040a2730c Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 May 2013 15:55:11 +0300 Subject: [PATCH 151/273] MDEV-4280: Assertion `empty_size == empty_size_on_page' failure in ma_blockrec.c or ER_NOT_KEYFILE on query with DISTINCT and GROUP BY This could happen when using Aria for internal temporary files (default case) and using DISTINCT. _ma_scan_restore_block_record() didn't work correctly if there was rows inserted, updated or deleted on the handler between calls to _ma_scan_remember_block_record() and _ma_scan_restore_block_record(). The effect was that some DISTINCT queries that used remove_dup_with_compare() could fail. .bzrignore: Ignore sql_yacc.hh mysql-test/suite/maria/r/distinct.result: Test case for MDEV-4280 mysql-test/suite/maria/t/distinct.test: Test case for MDEV-4280 mysql-test/t/mysql.test: Fixed test suite (we could get error -1 in some cases) sql/sql_select.cc: Break loop if restart_rnd_next() gives an error storage/maria/ha_maria.cc: scan_restore_pos() can return disk fault error. storage/maria/ma_blockrec.c: _ma_scan_remember_block_record() did incorrectly update scan.dir instead of scan_save.dir . _ma_scan_restore_block_record() didn't work correctly if there was rows inserted,updated or deleted on the handler between calls to _ma_scan_remember_block_record() and _ma_scan_restore_block_record(). Fixed by adding counters for row changes and reading the current scan page if changes had been made. storage/maria/ma_blockrec.h: scan_restore_pos() can return disk fault error. storage/maria/ma_delete.c: Increment row_changes storage/maria/ma_scan.c: scan_restore_pos() can return disk fault error. storage/maria/ma_update.c: Increment row_changes storage/maria/ma_write.c: Increment row_changes storage/maria/maria_def.h: scan_restore_pos() can return disk fault error. --- .bzrignore | 1 + mysql-test/suite/maria/r/distinct.result | 25 +++++++++ mysql-test/suite/maria/t/distinct.test | 25 +++++++++ mysql-test/t/mysql.test | 2 +- sql/sql_select.cc | 3 +- storage/maria/ha_maria.cc | 4 +- storage/maria/ma_blockrec.c | 67 +++++++++++++++++++----- storage/maria/ma_blockrec.h | 4 +- storage/maria/ma_delete.c | 1 + storage/maria/ma_scan.c | 3 +- storage/maria/ma_update.c | 1 + storage/maria/ma_write.c | 1 + storage/maria/maria_def.h | 6 ++- 13 files changed, 121 insertions(+), 22 deletions(-) create mode 100644 mysql-test/suite/maria/r/distinct.result create mode 100644 mysql-test/suite/maria/t/distinct.test diff --git a/.bzrignore b/.bzrignore index 84ebe547912..5d89804d637 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1957,3 +1957,4 @@ CPackSourceConfig.cmake win/nmake_cache.txt *.manifest *.resource.txt +sql/sql_yacc.hh diff --git a/mysql-test/suite/maria/r/distinct.result b/mysql-test/suite/maria/r/distinct.result new file mode 100644 index 00000000000..04d5e3d6a2c --- /dev/null +++ b/mysql-test/suite/maria/r/distinct.result @@ -0,0 +1,25 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT, b INT) ENGINE=Aria; +INSERT t1 VALUES (3,2004),(2,2006),(1,2007),(3,2008),(2,2005),(2,2001); +SELECT GROUP_CONCAT(a) FROM t1 GROUP BY b; +GROUP_CONCAT(a) +2 +3 +2 +2 +1 +3 +SELECT DISTINCT GROUP_CONCAT(a) FROM t1 GROUP BY b; +GROUP_CONCAT(a) +2 +3 +1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b VARCHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,'q'),(2,NULL),(7,'g'),(6,'x'); +SELECT DISTINCT MAX( a ) FROM t1 GROUP BY b ORDER BY DES_DECRYPT( b ); +MAX( a ) +2 +7 +6 +DROP TABLE t1; diff --git a/mysql-test/suite/maria/t/distinct.test b/mysql-test/suite/maria/t/distinct.test new file mode 100644 index 00000000000..b30d97b8383 --- /dev/null +++ b/mysql-test/suite/maria/t/distinct.test @@ -0,0 +1,25 @@ +# +# MDEV-4280: +# Assertion `empty_size == empty_size_on_page' failure in ma_blockrec.c or +# ER_NOT_KEYFILE on query with DISTINCT and GROUP BY +# +# This issue was a bug in how we delete row during duplicate removal when +# we use Aria for internal temporary table. +# + +-- source include/have_maria.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (a INT, b INT) ENGINE=Aria; +INSERT t1 VALUES (3,2004),(2,2006),(1,2007),(3,2008),(2,2005),(2,2001); +SELECT GROUP_CONCAT(a) FROM t1 GROUP BY b; +SELECT DISTINCT GROUP_CONCAT(a) FROM t1 GROUP BY b; +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b VARCHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,'q'),(2,NULL),(7,'g'),(6,'x'); +SELECT DISTINCT MAX( a ) FROM t1 GROUP BY b ORDER BY DES_DECRYPT( b ); +DROP TABLE t1; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index dc6c8cf9be7..4ed776f1987 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -224,7 +224,7 @@ drop table t17583; --exec $MYSQL test -e "connect test invalid_hostname" 2>&1 --echo The commands reported in the bug report ---replace_regex /\([0-9]*\)/(errno)/ +--replace_regex /\([0-9|-]*\)/(errno)/ --error 1 --exec $MYSQL test -e "\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1 diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 24ca1ab0174..b76e8afac36 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14656,7 +14656,8 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, if (!found) break; // End of file /* Restart search on saved row */ - error=file->restart_rnd_next(record); + if ((error= file->restart_rnd_next(record))) + goto err; } file->extra(HA_EXTRA_NO_CACHE); diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 8b1fe4d05b3..ce308887516 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2255,7 +2255,9 @@ int ha_maria::remember_rnd_pos() int ha_maria::restart_rnd_next(uchar *buf) { - (*file->s->scan_restore_pos)(file, remember_pos); + int error; + if ((error= (*file->s->scan_restore_pos)(file, remember_pos))) + return error; return rnd_next(buf); } diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 71bbb389ca2..73b3326fd28 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -4008,6 +4008,8 @@ static int delete_dir_entry(uchar *buff, uint block_size, uint record_number, uint length, empty_space; uchar *dir; DBUG_ENTER("delete_dir_entry"); + DBUG_PRINT("enter", ("record_number: %u number_of_records: %u", + record_number, number_of_records)); #ifdef SANITY_CHECKS if (record_number >= number_of_records || @@ -4024,7 +4026,8 @@ static int delete_dir_entry(uchar *buff, uint block_size, uint record_number, check_directory(buff, block_size, 0, (uint) -1); empty_space= uint2korr(buff + EMPTY_SPACE_OFFSET); dir= dir_entry_pos(buff, block_size, record_number); - length= uint2korr(dir + 2); + length= uint2korr(dir + 2); /* Length of entry we just deleted */ + DBUG_ASSERT(uint2korr(dir) != 0 && length < block_size); if (record_number == number_of_records - 1) { @@ -5230,11 +5233,6 @@ void _ma_scan_end_block_record(MARIA_HA *info) For the moment we can only remember one position, but this is good enough for MySQL usage - @Warning - When this function is called, we assume that the thread is not deleting - or updating the current row before ma_scan_restore_block_record() - is called! - @return @retval 0 ok @retval HA_ERR_WRONG_IN_RECORD Could not allocate memory to hold position @@ -5254,15 +5252,18 @@ int _ma_scan_remember_block_record(MARIA_HA *info, info->scan_save->bitmap_buff= ((uchar*) info->scan_save + ALIGN_SIZE(sizeof(*info->scan_save))); } - /* Point to the last read row */ - *lastpos= info->cur_row.nextpos - 1; - info->scan.dir+= DIR_ENTRY_SIZE; + /* For checking if pages have changed since we last read it */ + info->scan.row_changes= info->row_changes; /* Remember used bitmap and used head page */ bitmap_buff= info->scan_save->bitmap_buff; memcpy(info->scan_save, &info->scan, sizeof(*info->scan_save)); info->scan_save->bitmap_buff= bitmap_buff; memcpy(bitmap_buff, info->scan.bitmap_buff, info->s->block_size * 2); + + /* Point to the last read row */ + *lastpos= info->cur_row.nextpos - 1; + info->scan_save->dir+= DIR_ENTRY_SIZE; DBUG_RETURN(0); } @@ -5270,15 +5271,22 @@ int _ma_scan_remember_block_record(MARIA_HA *info, /** @brief restore scan block it's original values + @return + 0 ok + # error + @note In theory we could swap bitmap buffers instead of copy them. For the moment we don't do that because there are variables pointing inside the buffers and it's a bit of hassle to either make them relative or repoint them. + + If the data file has changed, we will re-read the new block record + to ensure that when we continue scanning we can ignore any deleted rows. */ -void _ma_scan_restore_block_record(MARIA_HA *info, - MARIA_RECORD_POS lastpos) +int _ma_scan_restore_block_record(MARIA_HA *info, + MARIA_RECORD_POS lastpos) { uchar *bitmap_buff; DBUG_ENTER("_ma_scan_restore_block_record"); @@ -5289,7 +5297,26 @@ void _ma_scan_restore_block_record(MARIA_HA *info, info->scan.bitmap_buff= bitmap_buff; memcpy(bitmap_buff, info->scan_save->bitmap_buff, info->s->block_size * 2); - DBUG_VOID_RETURN; + if (info->scan.row_changes != info->row_changes) + { + /* + Table has been changed. We have to re-read the current page block as + data may have changed on it that we have to see. + */ + if (!(pagecache_read(info->s->pagecache, + &info->dfile, + ma_recordpos_to_page(info->scan.row_base_page), + 0, info->scan.page_buff, + info->s->page_type, + PAGECACHE_LOCK_LEFT_UNLOCKED, 0))) + DBUG_RETURN(my_errno); + info->scan.number_of_rows= + (uint) (uchar) info->scan.page_buff[DIR_COUNT_OFFSET]; + info->scan.dir_end= (info->scan.page_buff + info->s->block_size - + PAGE_SUFFIX_SIZE - + info->scan.number_of_rows * DIR_ENTRY_SIZE); + } + DBUG_RETURN(0); } @@ -5316,7 +5343,7 @@ void _ma_scan_restore_block_record(MARIA_HA *info, RETURN 0 ok - # Error code + # Error code (Normally HA_ERR_END_OF_FILE) */ int _ma_scan_block_record(MARIA_HA *info, uchar *record, @@ -5336,6 +5363,12 @@ restart_record_read: uchar *data, *end_of_data; int error; + /* Ensure that scan.dir and record_pos are in sync */ + DBUG_ASSERT(info->scan.dir == dir_entry_pos(info->scan.page_buff, + share->block_size, + record_pos)); + + /* Search for a valid directory entry (not 0) */ while (!(offset= uint2korr(info->scan.dir))) { info->scan.dir-= DIR_ENTRY_SIZE; @@ -5348,13 +5381,19 @@ restart_record_read: } #endif } + /* + This should always be true as the directory should always start with + a valid entry. + */ + DBUG_ASSERT(info->scan.dir >= info->scan.dir_end); + /* found row */ info->cur_row.lastpos= info->scan.row_base_page + record_pos; info->cur_row.nextpos= record_pos + 1; data= info->scan.page_buff + offset; length= uint2korr(info->scan.dir + 2); end_of_data= data + length; - info->scan.dir-= DIR_ENTRY_SIZE; /* Point to previous row */ + info->scan.dir-= DIR_ENTRY_SIZE; /* Point to next row to process */ #ifdef SANITY_CHECKS if (end_of_data > info->scan.dir_end || offset < PAGE_HEADER_SIZE || length < share->base.min_block_length) diff --git a/storage/maria/ma_blockrec.h b/storage/maria/ma_blockrec.h index 2a323d16ffa..f6aae8d4759 100644 --- a/storage/maria/ma_blockrec.h +++ b/storage/maria/ma_blockrec.h @@ -168,8 +168,8 @@ my_bool _ma_scan_init_block_record(MARIA_HA *info); void _ma_scan_end_block_record(MARIA_HA *info); int _ma_scan_remember_block_record(MARIA_HA *info, MARIA_RECORD_POS *lastpos); -void _ma_scan_restore_block_record(MARIA_HA *info, - MARIA_RECORD_POS lastpos); +int _ma_scan_restore_block_record(MARIA_HA *info, + MARIA_RECORD_POS lastpos); MARIA_RECORD_POS _ma_write_init_block_record(MARIA_HA *info, const uchar *record); diff --git a/storage/maria/ma_delete.c b/storage/maria/ma_delete.c index ab66499ecfe..977c7c82cb7 100644 --- a/storage/maria/ma_delete.c +++ b/storage/maria/ma_delete.c @@ -112,6 +112,7 @@ int maria_delete(MARIA_HA *info,const uchar *record) info->state->checksum-= info->cur_row.checksum; info->state->records--; info->update= HA_STATE_CHANGED+HA_STATE_DELETED+HA_STATE_ROW_CHANGED; + info->row_changes++; share->state.changed|= (STATE_NOT_OPTIMIZED_ROWS | STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED); info->state->changed=1; diff --git a/storage/maria/ma_scan.c b/storage/maria/ma_scan.c index cbac463a2c8..ad526211615 100644 --- a/storage/maria/ma_scan.c +++ b/storage/maria/ma_scan.c @@ -68,7 +68,8 @@ int _ma_def_scan_remember_pos(MARIA_HA *info, MARIA_RECORD_POS *lastpos) } -void _ma_def_scan_restore_pos(MARIA_HA *info, MARIA_RECORD_POS lastpos) +int _ma_def_scan_restore_pos(MARIA_HA *info, MARIA_RECORD_POS lastpos) { info->cur_row.nextpos= lastpos; + return 0; } diff --git a/storage/maria/ma_update.c b/storage/maria/ma_update.c index abd9116a711..80b1fd86782 100644 --- a/storage/maria/ma_update.c +++ b/storage/maria/ma_update.c @@ -173,6 +173,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) We can't yet have HA_STATE_AKTIV here, as block_record dosn't support it */ info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED | key_changed); + info->row_changes++; share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED; info->state->changed= 1; diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index b4bf5086e0b..3c5efdc2ef0 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -288,6 +288,7 @@ int maria_write(MARIA_HA *info, uchar *record) info->state->records++; info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN | HA_STATE_ROW_CHANGED); + info->row_changes++; share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED; info->state->changed= 1; diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 41501b8eb74..fe9bf10fe24 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -317,7 +317,7 @@ typedef struct st_maria_share /* End scan */ void (*scan_end)(MARIA_HA *); int (*scan_remember_pos)(MARIA_HA *, MARIA_RECORD_POS*); - void (*scan_restore_pos)(MARIA_HA *, MARIA_RECORD_POS); + int (*scan_restore_pos)(MARIA_HA *, MARIA_RECORD_POS); /* Pre-write of row (some handlers may do the actual write here) */ MARIA_RECORD_POS (*write_record_init)(MARIA_HA *, const uchar *); /* Write record (or accept write_record_init) */ @@ -492,6 +492,7 @@ typedef struct st_maria_block_scan ulonglong bits; uint number_of_rows, bit_pos; MARIA_RECORD_POS row_base_page; + ulonglong row_changes; } MARIA_BLOCK_SCAN; @@ -533,6 +534,7 @@ struct st_maria_handler int (*read_record)(MARIA_HA *, uchar*, MARIA_RECORD_POS); invalidator_by_filename invalidator; /* query cache invalidator */ ulonglong last_auto_increment; /* auto value at start of statement */ + ulonglong row_changes; /* Incremented for each change */ ulong this_unique; /* uniq filenumber or thread */ ulong last_unique; /* last unique number */ ulong this_loop; /* counter for this open */ @@ -1175,7 +1177,7 @@ my_bool _ma_check_status(void *param); void _ma_restore_status(void *param); void _ma_reset_status(MARIA_HA *maria); int _ma_def_scan_remember_pos(MARIA_HA *info, MARIA_RECORD_POS *lastpos); -void _ma_def_scan_restore_pos(MARIA_HA *info, MARIA_RECORD_POS lastpos); +int _ma_def_scan_restore_pos(MARIA_HA *info, MARIA_RECORD_POS lastpos); #include "ma_commit.h" From 44cb1ce8a2d524c88cc8e2ea949cc933ba7a0832 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 11 May 2013 17:00:36 +0200 Subject: [PATCH 152/273] - Fix tabpivot compile errors on Linux. - Fix Tabpivot not closing the source table. - Fix pivot.test error on Linux by specifying ENDING=2 for the expenses table. modified: storage/connect/mysql-test/connect/r/pivot.result storage/connect/mysql-test/connect/t/pivot.test storage/connect/tabpivot.cpp storage/connect/tabpivot.h --- storage/connect/mysql-test/connect/r/pivot.result | 2 +- storage/connect/mysql-test/connect/t/pivot.test | 2 +- storage/connect/tabpivot.cpp | 8 ++++---- storage/connect/tabpivot.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/storage/connect/mysql-test/connect/r/pivot.result b/storage/connect/mysql-test/connect/r/pivot.result index 4455d333e5a..4480788332b 100644 --- a/storage/connect/mysql-test/connect/r/pivot.result +++ b/storage/connect/mysql-test/connect/r/pivot.result @@ -6,7 +6,7 @@ Who CHAR(10) NOT NULL, Week INT(2) NOT NULL, What CHAR(12) NOT NULL, Amount DOUBLE(8,2)) -ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt'; +ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt' ENDING=2; SELECT * FROM expenses; Who Week What Amount Joe 3 Beer 18.00 diff --git a/storage/connect/mysql-test/connect/t/pivot.test b/storage/connect/mysql-test/connect/t/pivot.test index 75a208e853b..f06c92828f9 100644 --- a/storage/connect/mysql-test/connect/t/pivot.test +++ b/storage/connect/mysql-test/connect/t/pivot.test @@ -10,7 +10,7 @@ Who CHAR(10) NOT NULL, Week INT(2) NOT NULL, What CHAR(12) NOT NULL, Amount DOUBLE(8,2)) -ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt'; +ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt' ENDING=2; SELECT * FROM expenses; --echo # diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 429bb88e0fc..efd9cf6a950 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -876,7 +876,7 @@ int TDBPIVOT::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ void TDBPIVOT::CloseDB(PGLOBAL g) { -//Tdbp->CloseDB(g); + Tdbp->CloseDB(g); } // end of CloseDB #if 0 @@ -1242,8 +1242,8 @@ QRSCOL::QRSCOL(PGLOBAL g, PCOLRES crp, PTDB tdbp, PCOL cprec, int i) Long = Crp->Clen; Buf_Type = crp->Type; strcpy(Format.Type, GetFormatType(Buf_Type)); - Format.Length = (SHORT)Long; - Format.Prec = (SHORT)Crp->Prec; + Format.Length = (short)Long; + Format.Prec = (short)Crp->Prec; if (trace) { htrc("Making new QRSCOL C%d %s at %p\n", Index, Name, this); @@ -1284,7 +1284,7 @@ void QRSCOL::ReadColumn(PGLOBAL g) /***********************************************************************/ /* Make file output of a Dos column descriptor block. */ /***********************************************************************/ -void QRSCOL::Print(PGLOBAL g, FILE *f, UINT n) +void QRSCOL::Print(PGLOBAL g, FILE *f, uint n) { COLBLK::Print(g, f, n); diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h index 3aa5288b5d8..bed288dc560 100644 --- a/storage/connect/tabpivot.h +++ b/storage/connect/tabpivot.h @@ -231,7 +231,7 @@ class DllExport QRSCOL : public COLBLK { // Methods virtual void ReadColumn(PGLOBAL g); - virtual void Print(PGLOBAL g, FILE *, UINT); + virtual void Print(PGLOBAL g, FILE *, uint); protected: QRSCOL(void) {} // Default constructor not to be used From 4b9a6c03fafe7f4c1901ba909796a3385184c516 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 May 2013 18:57:06 +0300 Subject: [PATCH 153/273] Fixed compiler warning --- client/mysqldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index b271cb8429b..ece88a51306 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1886,7 +1886,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name, const char *str_create) { uint i; - my_bool body_found= 0; + my_bool body_found __attribute__((unused)) = 0; char *create_stmt_ptr= NULL; ulong create_stmt_len= 0; MYSQL_FIELD *field; From 3b3f870994299c905627c7925c4af473e948d78d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 May 2013 20:23:57 +0300 Subject: [PATCH 154/273] Fixed compiler failure on solaris --- mysys/my_gethwaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index c96af3f1018..95306e71650 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -101,7 +101,7 @@ my_bool my_gethwaddr(uchar *to) uint i; for (i= 0; res && i < ifc.ifc_len / sizeof(ifr[0]); i++) { -#ifdef SIOCGIFHWADDR +#ifdef __linux__ if (ioctl(fd, SIOCGIFHWADDR, &ifr[i]) >= 0) res= memcpy_and_test(to, (uchar *)&ifr[i].ifr_hwaddr.sa_data, ETHER_ADDR_LEN); From 0737932b907214221bdf1b6fc1eec1d0d98bbfde Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 May 2013 20:31:50 +0300 Subject: [PATCH 155/273] Fixed that SHOW PROCESSLIST and information_schema.processlist uses the right length for user names. Fixed some failing tests mysql-test/mysql-test-run.pl: Removed warning from mysql-test-run mysql-test/r/create.result: Updated result mysql-test/r/log_slow.result: Fixed failing test mysql-test/suite/funcs_1/r/is_columns_is.result: Updated result mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result: Updated result mysql-test/suite/funcs_1/r/processlist_val_no_prot.result: Updated result mysql-test/t/log_slow.test: Ensure variables are properly reset at end of test sql/sql_show.cc: Fixed max length for user names --- mysql-test/mysql-test-run.pl | 2 +- mysql-test/r/create.result | 4 ++-- mysql-test/r/log_slow.result | 4 +++- mysql-test/suite/funcs_1/r/is_columns_is.result | 4 ++-- mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result | 4 ++-- mysql-test/suite/funcs_1/r/processlist_val_no_prot.result | 2 +- mysql-test/t/log_slow.test | 5 +++-- sql/sql_show.cc | 5 +++-- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ee2978e0a32..3f2d359eb98 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -524,7 +524,7 @@ sub main { } } - if ( not defined @$completed ) { + if ( not @$completed ) { mtr_error("Test suite aborted"); } diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 4cb14aabb2c..751dd939361 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1752,7 +1752,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `ID` bigint(4) NOT NULL DEFAULT '0', - `USER` varchar(16) NOT NULL DEFAULT '', + `USER` varchar(128) NOT NULL DEFAULT '', `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', @@ -1770,7 +1770,7 @@ show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( `ID` bigint(4) NOT NULL DEFAULT '0', - `USER` varchar(16) NOT NULL DEFAULT '', + `USER` varchar(128) NOT NULL DEFAULT '', `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', diff --git a/mysql-test/r/log_slow.result b/mysql-test/r/log_slow.result index 318dfa7568d..89846dc698c 100644 --- a/mysql-test/r/log_slow.result +++ b/mysql-test/r/log_slow.result @@ -13,6 +13,7 @@ log_slow_filter admin,filesort,filesort_on_disk,full_join,full_scan,query_cache, log_slow_queries ON log_slow_rate_limit 1 log_slow_verbosity +set @org_slow_query_log= @@global.slow_query_log; set @@log_slow_filter= "filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk,admin"; select @@log_slow_filter; @@log_slow_filter @@ -68,6 +69,7 @@ count(*) 1 truncate mysql.slow_log; set @@long_query_time=default; -set global slow_query_log=default; +set global slow_query_log= @org_slow_query_log; set @@log_slow_filter=default; set @@log_slow_verbosity=default; +set global log_output= default; diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index 5707dcbb3db..784eae541c6 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -230,7 +230,7 @@ def information_schema PROCESSLIST STAGE 10 0 NO tinyint NULL NULL 3 0 NULL NULL def information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select def information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(7) select def information_schema PROCESSLIST TIME_MS 9 0.000 NO decimal NULL NULL 22 3 NULL NULL NULL decimal(22,3) select -def information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) select +def information_schema PROCESSLIST USER 2 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128) select def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select @@ -688,7 +688,7 @@ NULL information_schema PARTITIONS CHECKSUM bigint NULL NULL NULL NULL bigint(21 3.0000 information_schema PLUGINS PLUGIN_MATURITY varchar 12 36 utf8 utf8_general_ci varchar(12) 3.0000 information_schema PLUGINS PLUGIN_AUTH_VERSION varchar 80 240 utf8 utf8_general_ci varchar(80) NULL information_schema PROCESSLIST ID bigint NULL NULL NULL NULL bigint(4) -3.0000 information_schema PROCESSLIST USER varchar 16 48 utf8 utf8_general_ci varchar(16) +3.0000 information_schema PROCESSLIST USER varchar 128 384 utf8 utf8_general_ci varchar(128) 3.0000 information_schema PROCESSLIST HOST varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema PROCESSLIST DB varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema PROCESSLIST COMMAND varchar 16 48 utf8 utf8_general_ci varchar(16) diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result index 2112da6761e..17009f79662 100644 --- a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result +++ b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result @@ -23,7 +23,7 @@ SHOW CREATE TABLE processlist; Table Create Table PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `ID` bigint(4) NOT NULL DEFAULT '0', - `USER` varchar(16) NOT NULL DEFAULT '', + `USER` varchar(128) NOT NULL DEFAULT '', `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', @@ -96,7 +96,7 @@ SHOW CREATE TABLE processlist; Table Create Table PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `ID` bigint(4) NOT NULL DEFAULT '0', - `USER` varchar(16) NOT NULL DEFAULT '', + `USER` varchar(128) NOT NULL DEFAULT '', `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', diff --git a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result index 0893fa3ca20..4f174318f58 100644 --- a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result +++ b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result @@ -13,7 +13,7 @@ SHOW CREATE TABLE INFORMATION_SCHEMA.PROCESSLIST; Table Create Table PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `ID` bigint(4) NOT NULL DEFAULT '0', - `USER` varchar(16) NOT NULL DEFAULT '', + `USER` varchar(128) NOT NULL DEFAULT '', `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', diff --git a/mysql-test/t/log_slow.test b/mysql-test/t/log_slow.test index 54f56e1bdfc..8d5a09d7a94 100644 --- a/mysql-test/t/log_slow.test +++ b/mysql-test/t/log_slow.test @@ -6,6 +6,7 @@ select @@log_slow_filter; select @@log_slow_rate_limit; select @@log_slow_verbosity; show variables like "log_slow%"; +set @org_slow_query_log= @@global.slow_query_log; # Some simple test to set log_slow_filter set @@log_slow_filter= "filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk,admin"; @@ -51,9 +52,9 @@ select sleep(0.5); select count(*) FROM mysql.slow_log; truncate mysql.slow_log; - # Reset used variables set @@long_query_time=default; -set global slow_query_log=default; +set global slow_query_log= @org_slow_query_log; set @@log_slow_filter=default; set @@log_slow_verbosity=default; +set global log_output= default; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2b004a4ea44..0229660be8d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2163,7 +2163,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) DBUG_ENTER("mysqld_list_processes"); field_list.push_back(new Item_int("Id", 0, MY_INT32_NUM_DECIMAL_DIGITS)); - field_list.push_back(new Item_empty_string("User",16)); + field_list.push_back(new Item_empty_string("User", USERNAME_CHAR_LENGTH)); field_list.push_back(new Item_empty_string("Host",LIST_PROCESS_HOST_LEN)); field_list.push_back(field=new Item_empty_string("db",NAME_CHAR_LEN)); field->maybe_null=1; @@ -8414,7 +8414,8 @@ ST_FIELD_INFO variables_fields_info[]= ST_FIELD_INFO processlist_fields_info[]= { {"ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE}, - {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE}, + {"USER", USERNAME_CHAR_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User", + SKIP_OPEN_TABLE}, {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host", SKIP_OPEN_TABLE}, {"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Db", SKIP_OPEN_TABLE}, From 3bd6e4b8ee7d32c0e2ecfd962e6debf07d9f3956 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 12 May 2013 11:29:16 +0300 Subject: [PATCH 156/273] MDEV-3999: Valgrind errors 'invalid write' or assorted server crashes on concurrent flow with partitioned Aria tables MDEV-3989: Server crashes on import from MariaDB mysqldump export with partitioned Aria table. Problem was that bulk insert in aria was not properly protected against concurrent selects. storage/maria/ha_maria.cc: Move settings of file->state to _ma_block_start_trans() to ensure that lock_key_trees is not changed by a concurrent bulk_insert. storage/maria/ma_check.c: Added DBUG_ASSERT() storage/maria/ma_open.c: Set start_trans to ma_start_trans for default behaviour. storage/maria/ma_pagecrc.c: Removed test for 'non_transactional' as a now_transactinal could be reset while a flush was happening. storage/maria/ma_state.c: Moved setting of info->state from external_lock to start_trans to protect against concurrent running bulk inserts. This works as the other threads will wait in thr_lock() until bulk_insert is done and keys are re-generated. storage/maria/ma_state.h: Added _ma_start_trans() --- storage/maria/ha_maria.cc | 17 -------------- storage/maria/ma_check.c | 3 +-- storage/maria/ma_open.c | 6 +++-- storage/maria/ma_pagecrc.c | 3 +-- storage/maria/ma_state.c | 45 +++++++++++++++++++++++++++++++++----- storage/maria/ma_state.h | 1 + 6 files changed, 47 insertions(+), 28 deletions(-) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 31b903871ce..dd5dfe5ce3a 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2638,23 +2638,6 @@ int ha_maria::external_lock(THD *thd, int lock_type) /* Transactional table */ if (lock_type != F_UNLCK) { - if (!file->s->lock_key_trees) // If we don't use versioning - { - /* - We come here in the following cases: - - The table is a temporary table - - It's a table which is crash safe but not yet versioned, for - example a table with fulltext or rtree keys - - Set the current state to point to save_state so that the - block_format code don't count the same record twice. - Copy also the current state. This may have been wrong if the - same file was used several times in the last statement - */ - file->state= file->state_start; - *file->state= file->s->state.state; - } - if (file->trn) { /* This can only happen with tables created with clone() */ diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 883261d5057..2c58bd6a964 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -2424,11 +2424,10 @@ static void restore_table_state_after_repair(MARIA_HA *info, { maria_versioning(info, info->s->have_versioning); info->s->lock_key_trees= org_share->lock_key_trees; + DBUG_ASSERT(!info->s->have_versioning || info->s->lock_key_trees); } - - /** @brief Drop all indexes diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 5f90f61c786..0933424436a 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -894,8 +894,10 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) &share->keyinfo[i].root_lock); mysql_rwlock_init(key_SHARE_mmap_lock, &share->mmap_lock); - share->row_is_visible= _ma_row_visible_always; - share->lock.get_status= _ma_reset_update_flag; + share->row_is_visible= _ma_row_visible_always; + share->lock.get_status= _ma_reset_update_flag; + share->lock.start_trans= _ma_start_trans; + if (!thr_lock_inited) { /* Probably a single threaded program; Don't use concurrent inserts */ diff --git a/storage/maria/ma_pagecrc.c b/storage/maria/ma_pagecrc.c index 58e3b4b203d..a79f34016c1 100644 --- a/storage/maria/ma_pagecrc.c +++ b/storage/maria/ma_pagecrc.c @@ -358,8 +358,7 @@ my_bool maria_flush_log_for_page(uchar *page, MARIA_SHARE *share= (MARIA_SHARE*) data_ptr; DBUG_ENTER("maria_flush_log_for_page"); /* share is 0 here only in unittest */ - DBUG_ASSERT(!share || (share->page_type == PAGECACHE_LSN_PAGE && - share->now_transactional)); + DBUG_ASSERT(!share || share->page_type == PAGECACHE_LSN_PAGE); lsn= lsn_korr(page); if (translog_flush(lsn)) DBUG_RETURN(1); diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c index 1f4a7504c56..f130da21d07 100644 --- a/storage/maria/ma_state.c +++ b/storage/maria/ma_state.c @@ -59,6 +59,8 @@ my_bool _ma_setup_live_state(MARIA_HA *info) MARIA_STATE_HISTORY *history; DBUG_ENTER("_ma_setup_live_state"); + DBUG_ASSERT(share->lock_key_trees); + if (maria_create_trn_hook(info)) DBUG_RETURN(1); @@ -377,6 +379,17 @@ void _ma_reset_update_flag(void *param, info->state->changed= 0; } +my_bool _ma_start_trans(void* param) +{ + MARIA_HA *info=(MARIA_HA*) param; + if (!info->s->lock_key_trees) + { + info->state= info->state_start; + *info->state= info->s->state.state; + } + return 0; +} + /** @brief Check if should allow concurrent inserts @@ -622,6 +635,22 @@ my_bool _ma_block_start_trans(void* param) */ return _ma_setup_live_state(info); } + else + { + /* + We come here in the following cases: + - The table is a temporary table + - It's a table which is crash safe but not yet versioned, for + example a table with fulltext or rtree keys + + Set the current state to point to save_state so that the + block_format code don't count the same record twice. + Copy also the current state. This may have been wrong if the + same file was used several times in the last statement + */ + info->state= info->state_start; + *info->state= info->s->state.state; + } /* Info->trn is set if this table is already handled and we are @@ -668,9 +697,11 @@ my_bool _ma_block_start_trans_no_versioning(void* param) { MARIA_HA *info=(MARIA_HA*) param; DBUG_ENTER("_ma_block_get_status_no_version"); - DBUG_ASSERT(info->s->base.born_transactional); + DBUG_ASSERT(info->s->base.born_transactional && !info->s->lock_key_trees); info->state->changed= 0; /* from _ma_reset_update_flag() */ + info->state= info->state_start; + *info->state= info->s->state.state; if (!info->trn) { /* @@ -689,18 +720,22 @@ my_bool _ma_block_start_trans_no_versioning(void* param) void maria_versioning(MARIA_HA *info, my_bool versioning) { + MARIA_SHARE *share= info->s; /* For now, this is a hack */ - if (info->s->have_versioning) + if (share->have_versioning) { enum thr_lock_type save_lock_type; - /* Assume is a non threaded application (for now) */ - info->s->lock_key_trees= 0; + share->lock_key_trees= versioning; /* Set up info->lock.type temporary for _ma_block_get_status() */ save_lock_type= info->lock.type; info->lock.type= versioning ? TL_WRITE_CONCURRENT_INSERT : TL_WRITE; _ma_block_get_status((void*) info, versioning); info->lock.type= save_lock_type; - info->state= info->state_start= &info->s->state.common; + if (versioning) + info->state= &share->state.common; + else + info->state= &share->state.state; /* Change global values by default */ + info->state_start= info->state; /* Initial values */ } } diff --git a/storage/maria/ma_state.h b/storage/maria/ma_state.h index 03ce5c2ea8c..2903986e32a 100644 --- a/storage/maria/ma_state.h +++ b/storage/maria/ma_state.h @@ -66,6 +66,7 @@ void _ma_update_status_with_lock(MARIA_HA *info); void _ma_restore_status(void *param); void _ma_copy_status(void* to, void *from); void _ma_reset_update_flag(void *param, my_bool concurrent_insert); +my_bool _ma_start_trans(void* param); my_bool _ma_check_status(void *param); void _ma_block_get_status(void* param, my_bool concurrent_insert); void _ma_block_update_status(void *param); From 8c9ce17359422c4cfe6c6c44e483d1b6ce9f8a56 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 12 May 2013 18:14:03 +0200 Subject: [PATCH 157/273] - Code cleaning. modified: storage/connect/connect.cc storage/connect/tabutil.h - Fix closing invalid tdbp in External_lock. modified: storage/connect/ha_connect.cc - Fix closing null Tdbp modified: storage/connect/tabpivot.cpp* - Fix regression error in table type TBL no more accepting missing columns in sub-tables even when Accept was set to TRUE. modified: storage/connect/tabtbl.cpp --- storage/connect/connect.cc | 5 ---- storage/connect/ha_connect.cc | 6 +++-- .../connect/mysql-test/connect/r/pivot.result | 0 .../connect/mysql-test/connect/t/pivot.test | 0 storage/connect/tabpivot.cpp | 4 ++- storage/connect/tabpivot.h | 0 storage/connect/tabtbl.cpp | 27 +++++-------------- storage/connect/tabutil.h | 16 ----------- 8 files changed, 13 insertions(+), 45 deletions(-) mode change 100644 => 100755 storage/connect/mysql-test/connect/r/pivot.result mode change 100644 => 100755 storage/connect/mysql-test/connect/t/pivot.test mode change 100644 => 100755 storage/connect/tabpivot.cpp mode change 100644 => 100755 storage/connect/tabpivot.h diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 54816f80e5c..6ae730f20b2 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -657,11 +657,6 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id) cdp= tdbp->Key(k)->GetCdp(); valp= AllocateValue(g, cdp->GetType(), cdp->GetLength()); tdbp->To_Link[k]= new(g) CONSTANT(valp); - -//if (kdp->Klen && tdbp->To_Link[k]->GetResultType() == TYPE_STRING) -// ((XCOLBLK*)tdbp->To_Link[k])->SetLength(kdp->Klen); - -//((PCOL)tdbp->To_Link[k])->InitValue(g); } // endfor k // Make the index on xdp diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 298fb71b334..ca0f9f7e08a 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3014,8 +3014,10 @@ int ha_connect::external_lock(THD *thd, int lock_type) // This can NOT be called without open called first, but // the table can have been closed since then } else if (!tdbp || xp->CheckQuery(valid_query_id) || xmod != newmode) { - if (tdbp) - CloseTable(g); + // If this is called by a later query, the table may have + // been already closed and the tdbp is not valid anymore. + if (tdbp && xp->last_query_id == valid_query_id) + rc= CloseTable(g); xmod= newmode; diff --git a/storage/connect/mysql-test/connect/r/pivot.result b/storage/connect/mysql-test/connect/r/pivot.result old mode 100644 new mode 100755 diff --git a/storage/connect/mysql-test/connect/t/pivot.test b/storage/connect/mysql-test/connect/t/pivot.test old mode 100644 new mode 100755 diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp old mode 100644 new mode 100755 index efd9cf6a950..4ae1b3ceae6 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -876,7 +876,9 @@ int TDBPIVOT::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ void TDBPIVOT::CloseDB(PGLOBAL g) { - Tdbp->CloseDB(g); + if (Tdbp) + Tdbp->CloseDB(g); + } // end of CloseDB #if 0 diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h old mode 100644 new mode 100755 diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 5a2089d04d6..7b10089ea36 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -214,8 +214,7 @@ PCOL TDBTBL::InsertSpecialColumn(PGLOBAL g, PCOL scp) /***********************************************************************/ bool TDBTBL::InitTableList(PGLOBAL g) { - char *colname; - int n, colpos; + int n; PTABLE tp, tabp; PTDB tdbp; PCOL colp; @@ -242,23 +241,9 @@ bool TDBTBL::InitTableList(PGLOBAL g) // Real initialization will be done later. for (PCOL cp = Columns; cp; cp = cp->GetNext()) if (!cp->IsSpecial()) { - colname = cp->GetName(); - colpos = ((PPRXCOL)cp)->Colnum; - - // We try first to get the column by name - if (!(colp = tdbp->ColDB(g, colname, 0)) && colpos) - // When unsuccessful, if a column number was specified - // try to get the column by its position in the table - colp = tdbp->ColDB(g, NULL, colpos); - - if (!colp) { - if (!Accept) { - sprintf(g->Message, MSG(NO_MATCHING_COL), - colname, tdbp->GetName()); - return TRUE; // Error return - } // endif !Accept - - } else // this is needed by some tables (which?) + if (((PPRXCOL)cp)->Init(g) && !Accept) + return TRUE; + else // this is needed by some tables (which?) colp->SetColUse(cp->GetColUse()); } // endif !special @@ -428,7 +413,7 @@ bool TDBTBL::OpenDB(PGLOBAL g) for (PCOL cp = Columns; cp; cp = cp->GetNext()) if (cp->GetAmType() == TYPE_AM_TABID) cp->COLBLK::Reset(); - else if (((PPRXCOL)cp)->Init(g)) + else if (((PPRXCOL)cp)->Init(g) && !Accept) return TRUE; if (trace) @@ -482,7 +467,7 @@ int TDBTBL::ReadDB(PGLOBAL g) for (PCOL cp = Columns; cp; cp = cp->GetNext()) if (cp->GetAmType() == TYPE_AM_TABID) cp->COLBLK::Reset(); - else if (((PPRXCOL)cp)->Init(g)) + else if (((PPRXCOL)cp)->Init(g) && !Accept) return RC_FX; if (trace) diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index b99cf959bca..81e2a44464a 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -14,28 +14,12 @@ typedef class XXLCOL *PXXLCOL; typedef class PRXCOL *PPRXCOL; typedef class TBCDEF *PTBCDEF; typedef class TDBTBC *PTDBTBC; -typedef class XTDBASE *PTDBX; -typedef class XCOLBLK *PCOLX; TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, const char *name, bool& mysql); PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, const char *name, bool info); -/***********************************************************************/ -/* This class is used to access protected members of TDBASE. */ -/***********************************************************************/ -class XTDBASE : public TDBASE { - friend class TDBXCL; - }; // end of class XCOLBLK - -/***********************************************************************/ -/* This class is used to access protected members of COLBLK. */ -/***********************************************************************/ -class XCOLBLK : public COLBLK { - friend class TDBXCL; - }; // end of class XCOLBLK - /* -------------------------- PROXY classes -------------------------- */ /***********************************************************************/ From 5ac8c8bea660129dfb31faa9de5594c5d4342a4c Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 12 May 2013 18:37:53 +0200 Subject: [PATCH 158/273] - Changing mode from +x to -x modified: storage/connect/mysql-test/connect/r/pivot.result* storage/connect/mysql-test/connect/t/pivot.test* storage/connect/tabpivot.cpp* storage/connect/tabpivot.h* --- storage/connect/mysql-test/connect/r/pivot.result | 0 storage/connect/mysql-test/connect/t/pivot.test | 0 storage/connect/tabpivot.cpp | 0 storage/connect/tabpivot.h | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 storage/connect/mysql-test/connect/r/pivot.result mode change 100755 => 100644 storage/connect/mysql-test/connect/t/pivot.test mode change 100755 => 100644 storage/connect/tabpivot.cpp mode change 100755 => 100644 storage/connect/tabpivot.h diff --git a/storage/connect/mysql-test/connect/r/pivot.result b/storage/connect/mysql-test/connect/r/pivot.result old mode 100755 new mode 100644 diff --git a/storage/connect/mysql-test/connect/t/pivot.test b/storage/connect/mysql-test/connect/t/pivot.test old mode 100755 new mode 100644 diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp old mode 100755 new mode 100644 diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h old mode 100755 new mode 100644 From 668306640edd3d3c6f55290000a7398ec7dd888d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 13 May 2013 00:43:46 +0300 Subject: [PATCH 159/273] Fixed MDEV-4291: Assertion `trid >= info->s->state.create_trid' failure or data corruption (key points to record outside datafile) on INSERT into an Aria table. The isssue was that the check if a table was moved between systems didn't take into account that create_trid could be bigger than the current max trid on the new system. This could only happen if one tried to move a table that one had just done a 'REPAIR TABLE' on. Tables that one had run 'aria_chk --zerofill' on worked. Fixed this by assuming that if create_trid is too big then the table has been moved from one system to another and we have to do an automatic zerofill. Other fixed: - Added a check to detect a wrong create_trid in 'check table'. - aria_chk -dvv will now write out also the create_trid (to make future error finding easier) - aria_chk --zerofill doesn't anymore require a aria_control_file - Removed some warnings from safemalloc when using aria_chk, ma_test1 and ma_test2. include/myisamchk.h: Removed wrong 'QQ' flags (the flags are used by myisamchk and aria_chk) storage/maria/ha_maria.cc: maria_chk_status() can now also return an error. storage/maria/ma_check.c: In maria_chk_status() check if create_trid value is too big. storage/maria/ma_open.c: Changed check if table is moved so that we can detect wrong create_trid values. Don't set STATE_NOT_MOVABLE flag if we are doing repair/check. This was done so that aria_chk can print out the movable flag. storage/maria/ma_test1.c: Added code to suppress memory leaks from safemalloc storage/maria/ma_test2.c: Added code to suppress memory leaks from safemalloc storage/maria/maria_chk.c: Added code to suppress memory leaks from safemalloc. Make help text a bit better for --HELP and --zerofill. Incresed version number. Don't require a control file if we are only doing --zerofill Print out 'create_trid' when doing --describe --verbose storage/maria/unittest/ma_test_recovery.expected: Updated result file --- include/myisamchk.h | 20 +- storage/maria/ha_maria.cc | 5 +- storage/maria/ma_check.c | 23 +- storage/maria/ma_open.c | 24 +- storage/maria/ma_test1.c | 3 +- storage/maria/ma_test2.c | 4 + storage/maria/maria_chk.c | 66 +-- .../maria/unittest/ma_test_recovery.expected | 384 +++++++++--------- 8 files changed, 291 insertions(+), 238 deletions(-) diff --git a/include/myisamchk.h b/include/myisamchk.h index 0ee03c03c49..19c2bf47ddb 100644 --- a/include/myisamchk.h +++ b/include/myisamchk.h @@ -31,27 +31,27 @@ #define T_AUTO_REPAIR 2 /* QQ to be removed */ #define T_BACKUP_DATA 4 #define T_CALC_CHECKSUM 8 -#define T_CHECK 16 /* QQ to be removed */ -#define T_CHECK_ONLY_CHANGED 32 /* QQ to be removed */ +#define T_CHECK 16 +#define T_CHECK_ONLY_CHANGED 32 #define T_CREATE_MISSING_KEYS 64 #define T_DESCRIPT 128 #define T_DONT_CHECK_CHECKSUM 256 #define T_EXTEND 512 -#define T_FAST (1L << 10) /* QQ to be removed */ -#define T_FORCE_CREATE (1L << 11) /* QQ to be removed */ +#define T_FAST (1L << 10) +#define T_FORCE_CREATE (1L << 11) #define T_FORCE_UNIQUENESS (1L << 12) #define T_INFO (1L << 13) #define T_MEDIUM (1L << 14) -#define T_QUICK (1L << 15) /* QQ to be removed */ -#define T_READONLY (1L << 16) /* QQ to be removed */ +#define T_QUICK (1L << 15) +#define T_READONLY (1L << 16) #define T_REP (1L << 17) -#define T_REP_BY_SORT (1L << 18) /* QQ to be removed */ -#define T_REP_PARALLEL (1L << 19) /* QQ to be removed */ +#define T_REP_BY_SORT (1L << 18) +#define T_REP_PARALLEL (1L << 19) #define T_RETRY_WITHOUT_QUICK (1L << 20) #define T_SAFE_REPAIR (1L << 21) #define T_SILENT (1L << 22) -#define T_SORT_INDEX (1L << 23) /* QQ to be removed */ -#define T_SORT_RECORDS (1L << 24) /* QQ to be removed */ +#define T_SORT_INDEX (1L << 23) +#define T_SORT_RECORDS (1L << 24) #define T_STATISTICS (1L << 25) #define T_UNPACK (1L << 26) #define T_UPDATE_STATE (1L << 27) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index dd5dfe5ce3a..d050a65a1cb 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1309,8 +1309,9 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) old_proc_info= thd_proc_info(thd, "Checking status"); thd_progress_init(thd, 3); - (void) maria_chk_status(¶m, file); // Not fatal - error= maria_chk_size(¶m, file); + error= maria_chk_status(¶m, file); // Not fatal + if (maria_chk_size(¶m, file)) + error= 1; if (!error) error|= maria_chk_del(¶m, file, param.testflag); thd_proc_info(thd, "Checking keys"); diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 2c58bd6a964..d63ac8be3cb 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -140,13 +140,22 @@ void maria_chk_init_for_check(HA_CHECK *param, MARIA_HA *info) Set up transaction handler so that we can see all rows. When rows is read we will check the found id against param->max_tried */ - if (param->max_trid == 0) + if (!info->s->base.born_transactional) + { + /* + There are no trids. Howver we want to set max_trid to make test of + create_trid simpler. + */ + param->max_trid= ~(TrID) 0; + } + else if (param->max_trid == 0) { if (!ma_control_file_inited()) param->max_trid= 0; /* Give warning for first trid found */ else param->max_trid= max_trid_in_system(); } + maria_ignore_trids(info); } @@ -179,6 +188,13 @@ int maria_chk_status(HA_CHECK *param, MARIA_HA *info) if (param->testflag & T_UPDATE_STATE) param->warning_printed=save; } + if (share->state.create_trid > param->max_trid) + { + _ma_check_print_warning(param, + "Table create_trd (%llu) > current max_transaction id (%llu). Table needs to be repaired or zerofilled to be usable", + share->state.create_trid, param->max_trid); + return 1; + } return 0; } @@ -3552,7 +3568,10 @@ int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name) /* Ensure state is later flushed to disk, if within maria_chk */ info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - /* Reset create_trid to make file comparable */ + /* + Reset create_trid to make file comparable and to ensure that new + trid's in the file starts from 0. + */ share->state.create_trid= 0; } if (reenable_logging) diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 0933424436a..7cefb12faae 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -437,15 +437,23 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) share->open_count_not_zero_on_open= 1; /* + A transactional table is not usable on this system if: + - share->state.create_trid > trnman_get_max_trid() + - Critical as trid as stored releativel to create_trid. + - uuid is different + + STATE_NOT_MOVABLE is reset when a table is zerofilled + (has no LSN's and no trids) + We can ignore testing uuid if STATE_NOT_MOVABLE is set, as in this - case the uuid will be set in _ma_mark_file_changed() + case the uuid will be set in _ma_mark_file_changed(). */ - if ((share->state.changed & STATE_NOT_MOVABLE) && - share->base.born_transactional && - ((!(open_flags & HA_OPEN_IGNORE_MOVED_STATE) && - memcmp(share->base.uuid, maria_uuid, MY_UUID_SIZE)) || - (share->state.create_trid > trnman_get_max_trid() && - !maria_in_recovery))) + if (share->base.born_transactional && + ((share->state.create_trid > trnman_get_max_trid() && + !maria_in_recovery) || + ((share->state.changed & STATE_NOT_MOVABLE) && + ((!(open_flags & HA_OPEN_IGNORE_MOVED_STATE) && + memcmp(share->base.uuid, maria_uuid, MY_UUID_SIZE)))))) { DBUG_PRINT("warning", ("table is moved from another system. uuid_diff: %d create_trid: %lu max_trid: %lu", memcmp(share->base.uuid, maria_uuid, @@ -756,7 +764,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED_ON_USAGE); goto err; } - else + else if (!(open_flags & HA_OPEN_FOR_REPAIR)) { /* create_rename_lsn != LSN_NEEDS_NEW_STATE_LSNS */ share->state.changed|= STATE_NOT_MOVABLE; diff --git a/storage/maria/ma_test1.c b/storage/maria/ma_test1.c index 945654a0bbe..5a655d4412a 100644 --- a/storage/maria/ma_test1.c +++ b/storage/maria/ma_test1.c @@ -55,7 +55,6 @@ static void create_key(uchar *key,uint rownr); static void create_record(uchar *record,uint rownr); static void update_record(uchar *record); - /* These are here only for testing of recovery with undo. We are not including maria_def.h here as this test is also to be an example of @@ -506,6 +505,7 @@ end: break; } printf("Dying on request without maria_commit()/maria_close()\n"); + sf_leaking_memory= 1; exit(0); } @@ -514,6 +514,7 @@ end: if (maria_close(file)) goto err; maria_end(); + my_uuid_end(); my_end(MY_CHECK_ERROR); return (0); diff --git a/storage/maria/ma_test2.c b/storage/maria/ma_test2.c index ea1978b4ee5..a3b7a2a9e98 100644 --- a/storage/maria/ma_test2.c +++ b/storage/maria/ma_test2.c @@ -971,6 +971,7 @@ end: break; } printf("Dying on request without maria_commit()/maria_close()\n"); + sf_leaking_memory= 1; /* no memory leak reports here */ exit(0); } if (maria_commit(file)) @@ -1017,6 +1018,7 @@ reads: %10lu\n", } maria_end(); my_free(blob_buffer); + my_uuid_end(); my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO); return(0); err: @@ -1029,6 +1031,8 @@ err2: maria_close(file); } maria_end(); + my_uuid_end(); + my_end(0); return(1); } /* main */ diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 62225a7a4b0..7379af10c03 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -88,9 +88,22 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param, MARIA_PAGE *page, uint sortkey, File new_file, my_bool update_index); static my_bool write_log_record(HA_CHECK *param); +static void my_exit(int exit_code) __attribute__ ((noreturn)); HA_CHECK check_param; +/* Free memory and exit */ + +static void my_exit(int exit_code) +{ + free_tmpdir(&maria_chk_tmpdir); + free_defaults(default_argv); + my_end(check_param.testflag & T_INFO ? + MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR); + exit(exit_code); +} + + /* Main program */ int main(int argc, char **argv) @@ -178,12 +191,8 @@ end: printf("\nTotal of all %d Aria-files:\nData records: %9s Deleted blocks: %9s\n",check_param.total_files,llstr(check_param.total_records,buff), llstr(check_param.total_deleted,buff2)); } - free_defaults(default_argv); - free_tmpdir(&maria_chk_tmpdir); maria_end(); - my_end(check_param.testflag & T_INFO ? - MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR); - exit(error); + my_exit(error); #ifndef _lint return 0; /* No compiler warning */ #endif @@ -252,10 +261,10 @@ static struct my_option my_long_options[] = "Restart with -r if there are any errors in the table. States will be updated as with --update-state.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"HELP", 'H', - "Display this help and exit.", + "Print all argument options sorted alphabetically and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', - "Display this help and exit.", + "Print all options by groups and exit. See also --HELP", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"information", 'i', "Print statistics information about table that is checked.", @@ -406,7 +415,7 @@ static struct my_option my_long_options[] = (char**) &maria_stats_method_str, (char**) &maria_stats_method_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "zerofill", 'z', - "Fill empty space in data and index files with zeroes,", + "Fill empty space in data and index files with zeroes. This makes the data file movable between different servers.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, { "zerofill-keep-lsn", OPT_ZEROFILL_KEEP_LSN, "Like --zerofill but does not zero out LSN of data/index pages;" @@ -418,7 +427,7 @@ static struct my_option my_long_options[] = static void print_version(void) { - printf("%s Ver 1.1 for %s at %s\n", my_progname, SYSTEM_TYPE, + printf("%s Ver 1.2 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -437,8 +446,8 @@ static void usage(void) -#, --debug=... Output debug log. Often this is 'd:t:o,filename'.\n"); #endif printf("\ - -H, --HELP Display this help and exit.\n\ - -?, --help Display this help and exit.\n\ + -H, --HELP Print all argument options sorted alphabetically.\n\ + -?, --help Print all options by groups\n\ --datadir=path Path for control file (and logs if --logdir not used)\n\ --logdir=path Path for log files\n\ --ignore-control-file Don't open the control file. Only use this if you\n\ @@ -554,7 +563,9 @@ Recover (repair)/ options (When using '--recover' or '--safe-recover'):\n\ (It may be VERY slow to do a sort the first time!).\n\ -b, --block-search=#\n\ Find a record, a block at given offset belongs to.\n\ - -z, --zerofill Fill empty space in data and index files with zeroes\n\ + -z, --zerofill Fill empty space in data and index files with zeroes.\n\ + This makes the data file movable between different \n\ + servers.\n\ --zerofill-keep-lsn Like --zerofill but does not zero out LSN of\n\ data/index pages."); @@ -757,7 +768,7 @@ get_one_option(int optid, fprintf(stderr, "The value of the sort key is bigger than max key: %d.\n", MARIA_MAX_KEY); - exit(1); + my_exit(1); } } break; @@ -785,7 +796,7 @@ get_one_option(int optid, break; case 'V': print_version(); - exit(0); + my_exit(0); case OPT_CORRECT_CHECKSUM: if (argument == disabled_my_option) check_param.testflag&= ~T_CALC_CHECKSUM; @@ -800,7 +811,7 @@ get_one_option(int optid, if ((method=find_type(argument, &maria_stats_method_typelib, 2)) <= 0) { fprintf(stderr, "Invalid value of stats_method: %s.\n", argument); - exit(1); + my_exit(1); } switch (method-1) { case 0: @@ -836,10 +847,11 @@ get_one_option(int optid, break; case 'H': my_print_help(my_long_options); - exit(0); + my_print_variables(my_long_options); + my_exit(0); case '?': usage(); - exit(0); + my_exit(0); } return 0; } @@ -856,7 +868,7 @@ static void get_options(register int *argc,register char ***argv) check_param.testflag|=T_WRITE_LOOP; if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) - exit(ho_error); + my_exit(ho_error); /* If using repair, then update checksum if one uses --update-state */ if ((check_param.testflag & T_UPDATE_STATE) && @@ -866,7 +878,7 @@ static void get_options(register int *argc,register char ***argv) if (*argc == 0) { usage(); - exit(-1); + my_exit(-1); } if ((check_param.testflag & T_UNPACK) && @@ -874,7 +886,7 @@ static void get_options(register int *argc,register char ***argv) { fprintf(stderr, "%s: --unpack can't be used with --quick or --sort-records\n", my_progname_short); - exit(1); + my_exit(1); } if ((check_param.testflag & T_READONLY) && (check_param.testflag & @@ -883,7 +895,7 @@ static void get_options(register int *argc,register char ***argv) { fprintf(stderr, "%s: Can't use --readonly when repairing or sorting\n", my_progname_short); - exit(1); + my_exit(1); } if (!opt_debug) @@ -891,20 +903,26 @@ static void get_options(register int *argc,register char ***argv) DEBUGGER_OFF; /* Speed up things a bit */ } if (init_tmpdir(&maria_chk_tmpdir, opt_tmpdir)) - exit(1); + my_exit(1); check_param.tmpdir=&maria_chk_tmpdir; if (set_collation_name) if (!(set_collation= get_charset_by_name(set_collation_name, MYF(MY_WME)))) - exit(1); + my_exit(1); if (maria_data_root != default_log_dir && opt_log_dir == default_log_dir) { /* --datadir was used and --log-dir was not. Set log-dir to datadir */ opt_log_dir= maria_data_root; } + + /* If we are using zerofill, then we don't need to read the control file */ + if ((check_param.testflag & (T_ZEROFILL_KEEP_LSN | T_ZEROFILL)) && + !(check_param.testflag & ~(T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX | T_STATISTICS | T_CHECK | T_FAST | T_CHECK_ONLY_CHANGED))) + opt_ignore_control_file= 1; + return; } /* get options */ @@ -1475,6 +1493,8 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name) LSN_IN_PARTS(share->state.create_rename_lsn), LSN_IN_PARTS(share->state.is_of_horizon), LSN_IN_PARTS(share->state.skip_redo_lsn)); + printf("create_trid: %s\n", + llstr(share->state.create_trid, llbuff)); } compile_time_assert((MY_UUID_STRING_LENGTH + 1) <= sizeof(buff)); buff[MY_UUID_STRING_LENGTH]= 0; diff --git a/storage/maria/unittest/ma_test_recovery.expected b/storage/maria/unittest/ma_test_recovery.expected index 6a6051735c5..6aaff86e6cf 100644 --- a/storage/maria/unittest/ma_test_recovery.expected +++ b/storage/maria/unittest/ma_test_recovery.expected @@ -69,8 +69,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -78,8 +78,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -87,8 +87,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -98,8 +98,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -107,8 +107,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -116,8 +116,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -166,8 +166,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -175,8 +175,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -184,8 +184,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -195,8 +195,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -204,8 +204,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -213,8 +213,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -263,8 +263,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -272,8 +272,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -281,8 +281,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -292,8 +292,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -301,8 +301,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -310,8 +310,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -360,8 +360,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -369,8 +369,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -378,8 +378,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -389,8 +389,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -398,8 +398,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -407,8 +407,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -457,8 +457,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -466,8 +466,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -475,8 +475,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -486,8 +486,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -495,8 +495,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -504,8 +504,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -554,8 +554,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -563,8 +563,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -572,8 +572,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -583,8 +583,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -592,8 +592,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -601,8 +601,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -651,8 +651,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -660,8 +660,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -669,8 +669,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -680,8 +680,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -689,8 +689,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -698,8 +698,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -748,8 +748,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -757,8 +757,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -766,8 +766,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -777,8 +777,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -786,8 +786,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -795,8 +795,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -845,8 +845,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -854,8 +854,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -863,8 +863,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -874,8 +874,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -883,8 +883,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -892,8 +892,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -942,8 +942,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -951,8 +951,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -960,8 +960,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -971,8 +971,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -980,8 +980,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -989,8 +989,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1039,8 +1039,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1048,8 +1048,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1057,8 +1057,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1068,8 +1068,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1077,8 +1077,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1086,8 +1086,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1136,8 +1136,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1145,8 +1145,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1154,8 +1154,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1165,8 +1165,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1174,8 +1174,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1183,8 +1183,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1233,8 +1233,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1242,8 +1242,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1251,8 +1251,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1262,8 +1262,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1271,8 +1271,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1280,8 +1280,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1330,8 +1330,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1339,8 +1339,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1348,8 +1348,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1359,8 +1359,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1368,8 +1368,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1377,8 +1377,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1427,8 +1427,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1436,8 +1436,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1445,8 +1445,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1456,8 +1456,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1465,8 +1465,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1474,8 +1474,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1524,8 +1524,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1533,8 +1533,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1542,8 +1542,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1553,8 +1553,8 @@ Dying on request without maria_commit()/maria_close() applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1562,8 +1562,8 @@ testing idempotency applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= @@ -1571,8 +1571,8 @@ testing applying of CLRs to recreate table applying log Differences in aria_chk -dvv, recovery not yet perfect ! ========DIFF START======= -6c6 -< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled +7c7 +< Status: checked,analyzed,optimized keys,sorted index pages,zerofilled,movable --- > Status: changed ========DIFF END======= From 35f813143bbb4f3e06649678fc19a900667e6432 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 13 May 2013 10:37:35 +0200 Subject: [PATCH 160/273] - Set tdbp to NULL when ignored modified: storage/connect/ha_connect.cc --- storage/connect/ha_connect.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index ca0f9f7e08a..a4611c83ffe 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3014,10 +3014,15 @@ int ha_connect::external_lock(THD *thd, int lock_type) // This can NOT be called without open called first, but // the table can have been closed since then } else if (!tdbp || xp->CheckQuery(valid_query_id) || xmod != newmode) { - // If this is called by a later query, the table may have - // been already closed and the tdbp is not valid anymore. - if (tdbp && xp->last_query_id == valid_query_id) - rc= CloseTable(g); + if (tdbp) { + // If this is called by a later query, the table may have + // been already closed and the tdbp is not valid anymore. + if (xp->last_query_id == valid_query_id) + rc= CloseTable(g); + else + tdbp= NULL; + + }// endif tdbp xmod= newmode; From 53e2023952d74e0b0dc76160c3a1ba5ee30f098c Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 13 May 2013 13:35:56 +0400 Subject: [PATCH 161/273] Enabling --suite=connect by default modified: mysql-test/mysql-test-run.pl --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a6780b5038c..47a3ccfc6d8 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -377,7 +377,7 @@ sub main { # directly before it executes them, like "make test-force-pl" in RPM builds. mtr_report("Logging: $0 ", join(" ", @ARGV)); - $DEFAULT_SUITES.=",sequence,sql_discovery" if $source_dist; + $DEFAULT_SUITES.=",sequence,sql_discovery,connect" if $source_dist; command_line_setup(); From dee955bdee939506804fdc36bf33224e2b104926 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 13 May 2013 11:37:34 +0200 Subject: [PATCH 162/273] - fix use of uninitialized variable (colp) modified: storage/connect/tabtbl.cpp storage/connect/tabutil.cpp --- storage/connect/tabtbl.cpp | 10 +++------- storage/connect/tabutil.cpp | 6 +++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 7b10089ea36..7e89cccf583 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -239,14 +239,10 @@ bool TDBTBL::InitTableList(PGLOBAL g) // We must allocate subtable columns before GetMaxSize is called // because some (PLG, ODBC?) need to have their columns attached. // Real initialization will be done later. - for (PCOL cp = Columns; cp; cp = cp->GetNext()) - if (!cp->IsSpecial()) { - if (((PPRXCOL)cp)->Init(g) && !Accept) + for (colp = Columns; colp; colp = colp->GetNext()) + if (!colp->IsSpecial()) + if (((PPRXCOL)colp)->Init(g) && !Accept) return TRUE; - else // this is needed by some tables (which?) - colp->SetColUse(cp->GetColUse()); - - } // endif !special if (Tablist) Tablist->Link(tabp); diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 2c14b711f86..c55b8d1fa5c 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -531,8 +531,12 @@ bool PRXCOL::Init(PGLOBAL g) Colp = tdbp->Tdbp->ColDB(g, NULL, Colnum); if (Colp) { - Colp->InitValue(g); // May not have been done elsewhere + // May not have been done elsewhere + Colp->InitValue(g); To_Val = Colp->GetValue(); + + // this may be needed by some tables (which?) + Colp->SetColUse(ColUse); } else { sprintf(g->Message, MSG(NO_MATCHING_COL), Name, tdbp->Tdbp->GetName()); return TRUE; From 24a7948343c712531236d4ec408178382433caa3 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 13 May 2013 12:20:08 +0200 Subject: [PATCH 163/273] - Code cleaning. Eliminating unused code, functions, and variables. modified: storage/connect/catalog.h storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/mycat.cc storage/connect/reldef.cpp storage/connect/tabcol.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xobject.h --- storage/connect/catalog.h | 10 ----- storage/connect/colblk.cpp | 13 ------- storage/connect/colblk.h | 1 - storage/connect/mycat.cc | 14 +------ storage/connect/reldef.cpp | 11 ++---- storage/connect/tabcol.h | 1 - storage/connect/tabsys.cpp | 79 ++++++++------------------------------ storage/connect/tabsys.h | 5 +-- storage/connect/xobject.h | 1 - 9 files changed, 21 insertions(+), 114 deletions(-) diff --git a/storage/connect/catalog.h b/storage/connect/catalog.h index 365169100d9..3a06aea7a30 100644 --- a/storage/connect/catalog.h +++ b/storage/connect/catalog.h @@ -62,14 +62,9 @@ class DllExport CATALOG { virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy // Implementation - void *GetDescp(void) {return Descp;} -//PRELDEF GetTo_Desc(void) {return To_Desc;} -//PSZ GetDescFile(void) {return DescFile;} int GetCblen(void) {return Cblen;} bool GetDefHuge(void) {return DefHuge;} void SetDefHuge(bool b) {DefHuge = b;} -//bool GetSepIndex(void) {return SepIndex;} -//void SetSepIndex(bool b) {SepIndex = b;} char *GetCbuf(void) {return Cbuf;} char *GetDataPath(void) {return (char*)DataPath;} @@ -115,15 +110,10 @@ class DllExport CATALOG { virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} // Members -//PRELDEF To_Desc; /* To chain of relation desc. */ - void *Descp; /* To DB description area */ -//AREADEF DescArea; /* Table desc. area size */ char *Cbuf; /* Buffer used for col section */ int Cblen; /* Length of suballoc. buffer */ CURTAB Ctb; /* Used to enumerate tables */ bool DefHuge; /* true: tables default to huge */ -//bool SepIndex; /* true: separate index files */ -//char DescFile[_MAX_PATH]; /* DB description filename */ LPCSTR DataPath; /* Is the Path of DB data dir */ }; // end of class CATALOG diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index cdbf6f4b42b..dfdc82e99a7 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -159,19 +159,6 @@ bool COLBLK::CheckSort(PTDB tdbp) return (tdbp == To_Tdb); } // end of CheckSort -/***********************************************************************/ -/* MarkCol: see PlugMarkCol for column references to mark. */ -/***********************************************************************/ -void COLBLK::MarkCol(ushort bits) - { - ColUse |= bits; - -#ifdef DEBTRACE - htrc(" column R%d.%s marked as %04X\n", - To_Tdb->GetTdb_No(), Name, ColUse); -#endif - } // end of MarkCol - /***********************************************************************/ /* InitValue: prepare a column block for read operation. */ /* Now we use Format.Length for the len parameter to avoid strings */ diff --git a/storage/connect/colblk.h b/storage/connect/colblk.h index cf6fb443308..5fbb118fc72 100644 --- a/storage/connect/colblk.h +++ b/storage/connect/colblk.h @@ -64,7 +64,6 @@ class DllExport COLBLK : public XOBJECT { virtual bool IsSpecial(void) {return false;} virtual int CheckSpcCol(PTDB tdbp, int n) {return 2;} virtual bool CheckSort(PTDB tdbp); - virtual void MarkCol(ushort bits); virtual bool Eval(PGLOBAL g); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual void SetTo_Val(PVAL valp) {} diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 7b7f79d7b58..35a66f0d1a2 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -256,15 +256,11 @@ uint GetFuncID(const char *func) /***********************************************************************/ CATALOG::CATALOG(void) { -//To_Desc= NULL; -//*DescFile= '\0'; #if defined(WIN32) DataPath= ".\\"; #else // !WIN32 DataPath= "./"; #endif // !WIN32 - Descp= NULL; -//memset(&DescArea, 0, sizeof(AREADEF)); memset(&Ctb, 0, sizeof(CURTAB)); Cbuf= NULL; Cblen= 0; @@ -279,17 +275,14 @@ CATALOG::CATALOG(void) MYCAT::MYCAT(PHC hc) : CATALOG() { Hc= hc; -//To_Desc= NULL; DefHuge= false; -//SepIndex= true; // Temporay until we can store offet and size } // end of MYCAT constructor /***********************************************************************/ -/* When using volatile storage, reset values pointing to Sarea. */ +/* Nothing to do for CONNECT. */ /***********************************************************************/ void MYCAT::Reset(void) { -//To_Desc= NULL; } // end of Reset /***********************************************************************/ @@ -597,10 +590,6 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, if (xtrace) printf("GetTableDesc: name=%s am=%s\n", name, SVP(type)); - // Firstly check whether this table descriptor is in memory -//if (To_Desc) -// return To_Desc; - // If not specified get the type of this table if (!type && !(type= Hc->GetStringOption("Type"))) type= (Hc->GetStringOption("Tabname")) ? "PROXY" : "DOS"; @@ -708,7 +697,6 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) /***********************************************************************/ void MYCAT::ClearDB(PGLOBAL g) { -//To_Desc= NULL; } // end of ClearDB /* ------------------------ End of MYCAT --------------------------- */ diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 6d16dcde04a..8525fd09cbc 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -90,11 +90,9 @@ TABDEF::TABDEF(void) /***********************************************************************/ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) { -//char buf[8]; int poff = 0; - void *memp = cat->Descp; - Name = (PSZ)PlugSubAlloc(g, memp, strlen(name) + 1); + Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1); strcpy(Name, name); Cat = cat; Catfunc = GetFuncID(Cat->GetStringCatInfo(g, "Catfunc", NULL)); @@ -127,7 +125,6 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) PTABDEF xdefp; XGETDEF getdef = NULL; PCATLG cat = Cat; - void *memp = cat->Descp; #if defined(WIN32) // Is the DLL already loaded? @@ -189,7 +186,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); // Get the table definition block - if (!(xdefp = getdef(g, memp))) + if (!(xdefp = getdef(g, NULL))) return NULL; // Have the external class do its complete definition @@ -223,15 +220,13 @@ bool OEMDEF::DeleteTableFile(PGLOBAL g) /***********************************************************************/ bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - void *memp = Cat->Descp; - Module = Cat->GetStringCatInfo(g, "Module", ""); Subtype = Cat->GetStringCatInfo(g, "Subtype", Module); if (!*Module) Module = Subtype; - Desc = (char*)PlugSubAlloc(g, memp, strlen(Module) + Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module) + strlen(Subtype) + 3); sprintf(Desc, "%s(%s)", Module, Subtype); return false; diff --git a/storage/connect/tabcol.h b/storage/connect/tabcol.h index 8c21fe6d1b2..4680e50f29e 100644 --- a/storage/connect/tabcol.h +++ b/storage/connect/tabcol.h @@ -86,7 +86,6 @@ class DllExport COLUMN: public XOBJECT { // Column Name/Qualifier block. virtual bool Eval(PGLOBAL) {assert(false); return true;} virtual int CheckSpcCol(PTDB, int) {assert(false); return 2;} virtual bool CheckSort(PTDB) {assert(false); return false;} - virtual void MarkCol(ushort) {assert(false);} private: // Members diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp index 9f933e4e2b8..705bb79bcb4 100644 --- a/storage/connect/tabsys.cpp +++ b/storage/connect/tabsys.cpp @@ -65,7 +65,6 @@ INIDEF::INIDEF(void) Pseudo = 3; Fn = NULL; Xname = NULL; - Subtype = '?'; Layout = '?'; Ln = 0; } // end of INIDEF constructor @@ -75,63 +74,23 @@ INIDEF::INIDEF(void) /***********************************************************************/ bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - char buf[8], ds[2]; - void *memp = Cat->GetDescp(); - - if (!stricmp(am, "SYS")) - strcpy(ds, "T"); // SYS tables default to T(able) - else - strcpy(ds, "I"); // INI tables default to I(ni) + char buf[8]; Fn = Cat->GetStringCatInfo(g, "Filename", NULL); - Cat->GetCharCatInfo("Subtype", ds, buf, sizeof(buf)); - Subtype = toupper(*buf); Cat->GetCharCatInfo("Layout", "C", buf, sizeof(buf)); Layout = toupper(*buf); - switch (Subtype) { -#if 0 - case 'C': - case 'T': - // Restricted table - Xname = Cat->GetStringCatInfo(g, "Name", "?"); + if (Fn) { + char *p = (char*)PlugSubAlloc(g, NULL, _MAX_PATH); - if (!strcmp(Xname, "?")) - Xname = NULL; - - if (*Fn == '?') - Fn = Cat->GetStringCatInfo(g, "Database", "?"); - - if (*Fn != '?') { - char *p = (char*)PlugSubAlloc(g, memp, _MAX_PATH); - - if (!PlgSetXdbPath(g, Fn, NULL, p, _MAX_PATH, NULL, 0)) - Fn = p; - - } else - Fn = Cat->GetDescFile(); - - Ln = GetIniSize("Database", "Tabsize", "2K", Fn); - break; -#endif // 0 - case 'I': - if (*Fn != '?') { - char *p = (char*)PlugSubAlloc(g, memp, _MAX_PATH); - - PlugSetPath(p, Fn, GetPath()); - Fn = p; - } else { - strcpy(g->Message, MSG(MISSING_FNAME)); - return true; - } // endif Fn - - Ln = Cat->GetSizeCatInfo("Secsize", "8K"); - break; - default: - sprintf(g->Message, MSG(INV_SUBTYPE), buf); - return true; - } // endswitch Subtype + PlugSetPath(p, Fn, GetPath()); + Fn = p; + } else { + strcpy(g->Message, MSG(MISSING_FNAME)); + return true; + } // endif Fn + Ln = Cat->GetSizeCatInfo("Secsize", "8K"); Desc = Fn; return false; } // end of DefineAM @@ -143,17 +102,10 @@ PTDB INIDEF::GetTable(PGLOBAL g, MODE m) { PTDBASE tdbp; - switch (Subtype) { - case 'I': - if (Layout == 'C') - tdbp = new(g) TDBINI(this); - else - tdbp = new(g) TDBXIN(this); - - break; - default: - return NULL; - } // endswitch Subtype + if (Layout == 'C') + tdbp = new(g) TDBINI(this); + else + tdbp = new(g) TDBXIN(this); if (Multiple) tdbp = new(g) TDBMUL(tdbp); // No block optimization yet @@ -163,7 +115,6 @@ PTDB INIDEF::GetTable(PGLOBAL g, MODE m) /***********************************************************************/ /* DeleteTableFile: Delete INI table files using platform API. */ -/* SysTable and SysColumn tables are readonly and not erasable. */ /***********************************************************************/ bool INIDEF::DeleteTableFile(PGLOBAL g) { @@ -171,7 +122,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g) bool rc; // Delete the INI table file if not protected - if (Subtype == 'I' && !IsReadOnly()) { + if (!IsReadOnly()) { PlugSetPath(filename, Fn, GetPath()); #if defined(WIN32) rc = !DeleteFile(filename); diff --git a/storage/connect/tabsys.h b/storage/connect/tabsys.h index ac8ae05aee9..2780eb3ca98 100644 --- a/storage/connect/tabsys.h +++ b/storage/connect/tabsys.h @@ -38,7 +38,6 @@ class DllExport INIDEF : public TABDEF { /* INI table description */ // Members char *Fn; /* Path/Name of corresponding file */ char *Xname; /* The eventual table name */ - char Subtype; /* I: INI, T: Table, C: Column */ char Layout; /* R: Row, C: Column */ int Ln; /* Length of section list buffer */ }; // end of INIDEF @@ -83,8 +82,8 @@ class TDBINI : public TDBASE { // Members char *Ifile; // The INI file char *Seclist; // The section list - char *Section; // The current section - int Seclen; // Length of seclist buffer + char *Section; // The current section + int Seclen; // Length of seclist buffer int N; // The current section index }; // end of class TDBINI diff --git a/storage/connect/xobject.h b/storage/connect/xobject.h index c77fb703823..79325f155cf 100644 --- a/storage/connect/xobject.h +++ b/storage/connect/xobject.h @@ -71,7 +71,6 @@ class DllExport XOBJECT : public BLOCK { virtual bool VerifyColumn(PTBX txp) {return false;} virtual bool VerifyTdb(PTDB& tdbp) {return false;} virtual bool IsColInside(PCOL colp) {return false;} - virtual void MarkCol(ushort) {} protected: PVAL Value; // The current value of the object. From d22b1a0b35e794212c92e65f1d7f7d3e108cceef Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 13 May 2013 14:59:59 +0400 Subject: [PATCH 164/273] Fixing a few compilation warnings ("no previous declaration for XXX") added: storage/connect/inihandl.h modified: storage/connect/CMakeLists.txt storage/connect/connect.h storage/connect/ha_connect.cc storage/connect/inihandl.c storage/connect/osutil.h storage/connect/tabsys.cpp storage/connect/user_connect.cc --- storage/connect/CMakeLists.txt | 2 +- storage/connect/connect.h | 1 + storage/connect/ha_connect.cc | 5 +-- storage/connect/inihandl.c | 12 +++++--- storage/connect/inihandl.h | 54 +++++++++++++++++++++++++++++++++ storage/connect/osutil.h | 46 ---------------------------- storage/connect/tabsys.cpp | 4 +-- storage/connect/user_connect.cc | 6 +--- 8 files changed, 68 insertions(+), 62 deletions(-) create mode 100644 storage/connect/inihandl.h diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index d3663c5eee3..81dd8c77b67 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -28,7 +28,7 @@ filamzip.cpp tabtbl.cpp myutil.cpp tabutil.cpp tabxcl.cpp taboccur.cpp tabpivot.cpp block.h catalog.h checklvl.h colblk.h connect.h csort.h engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h -global.h ha_connect.h maputil.h msgid.h mycat.h myutil.h os.h +global.h ha_connect.h inihandl.h maputil.h msgid.h mycat.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabmul.h tabsys.h tabtbl.h tabvct.h user_connect.h valblk.h value.h xindex.h xobject.h xtable.h diff --git a/storage/connect/connect.h b/storage/connect/connect.h index 3fd52d283c6..e81e54776c9 100644 --- a/storage/connect/connect.h +++ b/storage/connect/connect.h @@ -44,6 +44,7 @@ RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all); bool CntInfo(PGLOBAL g, PTDB tdbp, PXF info); int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, bool *incl, key_part_map *kmap); +PGLOBAL CntExit(PGLOBAL g); /***********************************************************************/ /* Definition of classes XCOLCRT, XIXDEF, XKPDEF, DOXDEF, TDBDOX */ diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index a4611c83ffe..214ad8ba049 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -137,6 +137,7 @@ #include "mycat.h" #include "myutil.h" #include "preparse.h" +#include "inihandl.h" #define PLGXINI "plgcnx.ini" /* Configuration settings file */ #define my_strupr(p) my_caseup_str(default_charset_info, (p)); @@ -3252,8 +3253,8 @@ static char *encode(PGLOBAL g, char *cnm) Return 0 if ok */ -bool add_field(String *sql, const char *field_name, const char *type, - int len, int dec, uint tm, const char *rem) +static bool add_field(String *sql, const char *field_name, const char *type, + int len, int dec, uint tm, const char *rem) { bool error= false; diff --git a/storage/connect/inihandl.c b/storage/connect/inihandl.c index 25629b04e60..60b72bd2604 100644 --- a/storage/connect/inihandl.c +++ b/storage/connect/inihandl.c @@ -29,9 +29,8 @@ //#include //#include #include "my_global.h" -//#include "osutil.h" #include "global.h" - +#include "inihandl.h" // The types and variables used locally //typedef int bool; @@ -672,7 +671,7 @@ static BOOL PROFILE_DeleteKey(PROFILESECTION* *section, * * Delete all keys from a profile tree. ***********************************************************************/ -void PROFILE_DeleteAllKeys(LPCSTR section_name) +static void PROFILE_DeleteAllKeys(LPCSTR section_name) { PROFILESECTION* *section= &CurProfile->section; @@ -1038,6 +1037,7 @@ static BOOL PROFILE_SetString(LPCSTR section_name, LPCSTR key_name, * Convenience function that turns a string 'xxx, yyy, zzz' into * the 'xxx\0 yyy, zzz' and returns a pointer to the 'yyy, zzz'. ***********************************************************************/ +#if 0 char *PROFILE_GetStringItem(char* start) { char *lpchX, *lpch; @@ -1065,6 +1065,7 @@ char *PROFILE_GetStringItem(char* start) return NULL; } // end of PROFILE_GetStringItem +#endif /********************************************************************** * if allow_section_name_copy is TRUE, allow the copying : @@ -1132,7 +1133,7 @@ static int PROFILE_GetPrivateProfileString(LPCSTR section, LPCSTR entry, * GetPrivateProfileStringA (KERNEL32.@) ***********************************************************************/ int GetPrivateProfileString(LPCSTR section, LPCSTR entry, LPCSTR def_val, - LPSTR buffer, uint len, LPCSTR filename) + LPSTR buffer, DWORD len, LPCSTR filename) { return PROFILE_GetPrivateProfileString(section, entry, def_val, buffer, len, filename, TRUE); @@ -1308,7 +1309,8 @@ BOOL WritePrivateProfileSection(LPCSTR section, * Note that when the buffer is big enough then the return value may be any * value between 1 and len-1 (or len in Win95), including len-2. */ -DWORD GetPrivateProfileSectionNames(LPSTR buffer, DWORD size, LPCSTR filename) +static DWORD +GetPrivateProfileSectionNames(LPSTR buffer, DWORD size, LPCSTR filename) { DWORD ret = 0; diff --git a/storage/connect/inihandl.h b/storage/connect/inihandl.h new file mode 100644 index 00000000000..7f6fcb1f582 --- /dev/null +++ b/storage/connect/inihandl.h @@ -0,0 +1,54 @@ +#ifndef __INIHANDL_H__ +#define __INIHANDL_H__ + +#if defined(UNIX) || defined(UNIV_LINUX) + +#ifdef __cplusplus +extern "C" { +#endif + +void PROFILE_Close(LPCSTR filename); + +int GetPrivateProfileString( + LPCTSTR lpAppName, // section name + LPCTSTR lpKeyName, // key name + LPCTSTR lpDefault, // default string + LPTSTR lpReturnedString, // destination buffer + DWORD nSize, // size of destination buffer + LPCTSTR lpFileName // initialization file name + ); + +uint GetPrivateProfileInt( + LPCTSTR lpAppName, // section name + LPCTSTR lpKeyName, // key name + INT nDefault, // return value if key name not found + LPCTSTR lpFileName // initialization file name + ); + +BOOL WritePrivateProfileString( + LPCTSTR lpAppName, // section name + LPCTSTR lpKeyName, // key name + LPCTSTR lpString, // string to add + LPCTSTR lpFileName // initialization file + ); + +int GetPrivateProfileSection( + LPCTSTR lpAppName, // section name + LPTSTR lpReturnedString, // return buffer + DWORD nSize, // size of return buffer + LPCTSTR lpFileName // initialization file name + ); + +BOOL WritePrivateProfileSection( + LPCTSTR lpAppName, // section name + LPCTSTR lpString, // data + LPCTSTR lpFileName // file name + ); + +#ifdef __cplusplus +} +#endif + +#endif /* defined(UNIX) */ + +#endif /* __INIHANDL_H__ */ diff --git a/storage/connect/osutil.h b/storage/connect/osutil.h index 440373dd7a1..148a22321f4 100644 --- a/storage/connect/osutil.h +++ b/storage/connect/osutil.h @@ -32,44 +32,6 @@ char *_fullpath(char *absPath, const char *relPath, size_t maxLength); BOOL MessageBeep(uint); unsigned long _filelength(int fd); -void PROFILE_Close(LPCSTR filename); - -int GetPrivateProfileString( - LPCTSTR lpAppName, // section name - LPCTSTR lpKeyName, // key name - LPCTSTR lpDefault, // default string - LPTSTR lpReturnedString, // destination buffer - int nSize, // size of destination buffer - LPCTSTR lpFileName // initialization file name - ); - -uint GetPrivateProfileInt( - LPCTSTR lpAppName, // section name - LPCTSTR lpKeyName, // key name - INT nDefault, // return value if key name not found - LPCTSTR lpFileName // initialization file name - ); - -BOOL WritePrivateProfileString( - LPCTSTR lpAppName, // section name - LPCTSTR lpKeyName, // key name - LPCTSTR lpString, // string to add - LPCTSTR lpFileName // initialization file - ); - -int GetPrivateProfileSection( - LPCTSTR lpAppName, // section name - LPTSTR lpReturnedString, // return buffer - int nSize, // size of return buffer - LPCTSTR lpFileName // initialization file name - ); - -BOOL WritePrivateProfileSection( - LPCTSTR lpAppName, // section name - LPCTSTR lpString, // data - LPCTSTR lpFileName // file name - ); - PSZ strupr(PSZ s); PSZ strlwr(PSZ s); @@ -90,12 +52,4 @@ typedef __int64 FILEPOS; #define XSTR(x) ((x)?(x):"") -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - #endif /* __OSUTIL_H__ */ diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp index 705bb79bcb4..6434e011882 100644 --- a/storage/connect/tabsys.cpp +++ b/storage/connect/tabsys.cpp @@ -41,9 +41,7 @@ #include "tabdos.h" #include "tabsys.h" #include "tabmul.h" -#if defined(UNIX) -#include "osutil.h" -#endif // UNIX +#include "inihandl.h" #define CSZ 36 // Column section name length #define CDZ 256 // Column definition length diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc index 3fd3ac43e32..d85f11d1950 100644 --- a/storage/connect/user_connect.cc +++ b/storage/connect/user_connect.cc @@ -43,6 +43,7 @@ #include "osutil.h" #include "global.h" #include "plgdbsem.h" +#include "connect.h" #include "user_connect.h" #include "mycat.h" @@ -54,11 +55,6 @@ extern int xtrace; /****************************************************************************/ PCONNECT user_connect::to_users= NULL; -/****************************************************************************/ -/* CONNECT functions called externally. */ -/****************************************************************************/ -PGLOBAL CntExit(PGLOBAL g); - /* -------------------------- class user_connect -------------------------- */ /****************************************************************************/ From 35a879d06dbd58f4ae8203419915d7de67e821a9 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 13 May 2013 15:23:24 +0400 Subject: [PATCH 165/273] Fixing a few "no previous declaration" warnings modified: storage/connect/ha_connect.cc storage/connect/odbconn.cpp storage/connect/plgdbutl.cpp storage/connect/plugutil.c storage/connect/value.cpp --- storage/connect/ha_connect.cc | 2 +- storage/connect/odbconn.cpp | 3 ++- storage/connect/plgdbutl.cpp | 4 +++- storage/connect/plugutil.c | 3 ++- storage/connect/value.cpp | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 214ad8ba049..4d6889f7f8b 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3829,7 +3829,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); return HA_ERR_INTERNAL_ERROR; } // endif tab - + default: /* do nothing */; } // endswitch ttp if (type == TAB_XML) { diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index e32e666e1fe..881e554163e 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -36,6 +36,7 @@ //#include "kindex.h" #include "xtable.h" #include "tabodbc.h" +#include "odbccat.h" #include "plgcnx.h" // For DB types #include "resource.h" #include "valblk.h" @@ -203,7 +204,7 @@ CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *tab, PQRYRES qrp) /***********************************************************************/ /* Check for nulls and reset them to Null (?) values. */ /***********************************************************************/ -void ResetNullValues(CATPARM *cap) +static void ResetNullValues(CATPARM *cap) { int i, n, ncol; PCOLRES crp; diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 32ee105c19c..d0f3896bc4f 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -519,6 +519,7 @@ bool PlgSetXdbPath(PGLOBAL g, PSZ dbname, PSZ dbpath, /* Extract from a path name the required component. */ /* This function assumes there is enough space in the buffer. */ /***********************************************************************/ +#if 0 char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op) { char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL; @@ -539,13 +540,14 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op) _splitpath(FileName, drive, direc, fname, ftype); return pBuff; } // end of PlgExtractFromPath +#endif /***********************************************************************/ /* Check the occurence and matching of a pattern against a string. */ /* Because this function is only used for catalog name checking, */ /* it must be case insensitive. */ /***********************************************************************/ -bool PlugCheckPattern(PGLOBAL g, LPCSTR string, LPCSTR pat) +static bool PlugCheckPattern(PGLOBAL g, LPCSTR string, LPCSTR pat) { if (pat && strlen(pat)) { // This leaves 512 bytes (MAX_STR / 2) for each components diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 693ae96cf52..2c7eaa893b6 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -491,9 +491,10 @@ void *MakePtr(void *memp, OFFSET offset) /***********************************************************************/ /* This routine makes an offset from a pointer new format. */ /***********************************************************************/ +#if 0 OFFSET MakeOff(void *memp, void *ptr) { return ((!ptr) ? 0 : (OFFSET)((char *)ptr - (char *)memp)); } /* end of MakeOff */ - +#endif /*--------------------- End of PLUGUTIL program -----------------------*/ diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 7a1146e6c32..6152fdc238f 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -93,7 +93,7 @@ PSZ strlwr(PSZ s); /* met when returning from TestValue for a given operator. */ /* Bit one is EQ, bit 2 is LT, and bit 3 is GT. */ /***********************************************************************/ -BYTE OpBmp(PGLOBAL g, OPVAL opc) +static BYTE OpBmp(PGLOBAL g, OPVAL opc) { BYTE bt; From 33d1689fcf252d29a24cf05ca88c6711d682fb2e Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 13 May 2013 15:57:49 +0400 Subject: [PATCH 166/273] Fixing compiler warnings ("no previous declaration for ...") added: storage/connect/rcmsg.h modified: storage/connect/CMakeLists.txt storage/connect/odbconn.cpp storage/connect/plgdbutl.cpp storage/connect/plugutil.c storage/connect/rcmsg.c storage/connect/tabodbc.cpp --- storage/connect/CMakeLists.txt | 5 +---- storage/connect/odbconn.cpp | 4 +--- storage/connect/plgdbutl.cpp | 2 +- storage/connect/plugutil.c | 2 +- storage/connect/rcmsg.c | 1 + storage/connect/rcmsg.h | 15 +++++++++++++++ storage/connect/tabodbc.cpp | 1 - 7 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 storage/connect/rcmsg.h diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 81dd8c77b67..6cae17c4dd9 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -18,7 +18,7 @@ SET(CONNECT_PLUGIN_DYNAMIC "connect") SET(CONNECT_SOURCES ha_connect.cc connect.cc user_connect.cc mycat.cc -fmdlex.c osutil.c plugutil.c rcmsg.c +fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h csort.cpp maputil.cpp plgdbutl.cpp colblk.cpp reldef.cpp tabcol.cpp table.cpp filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp @@ -48,7 +48,6 @@ IF(UNIX) # Bar: -Wfatal-errors removed (does not present in gcc on solaris10) if(WITH_WARNINGS) add_definitions(-Wall -Wextra -Wmissing-declarations) - add_definitions(-Wno-non-virtual-dtor) message(STATUS "CONNECT: GCC: All warnings enabled") else() add_definitions(-Wall -Wmissing-declarations) @@ -64,13 +63,11 @@ IF(UNIX) # add_definitions(-Wno-int-to-pointer-cast) # Bar: -Wno-narrowing commented (does not present in gcc on solaris10) # add_definitions(-Wno-narrowing) - add_definitions(-Wno-non-virtual-dtor) # This switch is for pure C only: # add_definitions(-Wno-implicit-function-declaration) # These switches are for C++ only # add_definitions(-Wno-reorder) -# add_definitions(-Wno-delete-non-virtual-dtor) message(STATUS "CONNECT: GCC: Some warnings disabled") endif(WITH_WARNINGS) diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 881e554163e..14b5f582962 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -48,9 +48,7 @@ /***********************************************************************/ #pragma comment(lib, "odbc32.lib") extern "C" HINSTANCE s_hModule; // Saved module handle -#else // !WIN32 -extern "C" int GetRcString(int id, char *buf, int bufsize); -#endif // !WIN32 +#endif // WIN32 /***********************************************************************/ /* Some macro's (should be defined elsewhere to be more accessible) */ diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index d0f3896bc4f..598075ac52a 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -67,6 +67,7 @@ #include "xtable.h" // header of TBX, TDB and TDBASE classes #include "tabcol.h" // header of XTAB and COLUMN classes #include "valblk.h" +#include "rcmsg.h" /***********************************************************************/ /* Macro or external routine definition */ @@ -129,7 +130,6 @@ void CloseXMLFile(PGLOBAL, PFBLOCK, bool); void CloseXML2File(PGLOBAL, PFBLOCK, bool); #endif // LIBXML2_SUPPORT -extern "C" int GetRcString(int id, char *buf, int bufsize); /***********************************************************************/ /* Routines for file IO with error reporting to g->Message */ diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 2c7eaa893b6..12810d74284 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -107,7 +107,7 @@ ACTIVITY defActivity = { /* Describes activity and language */ #endif // XMSG || NEWMSG #if defined(UNIX) || defined(UNIV_LINUX) -int GetRcString(int id, char *buf, int bufsize); +#include "rcmsg.h" #endif // UNIX /**************************************************************************/ diff --git a/storage/connect/rcmsg.c b/storage/connect/rcmsg.c index e1a71cde9c6..0c63fd55242 100644 --- a/storage/connect/rcmsg.c +++ b/storage/connect/rcmsg.c @@ -14,6 +14,7 @@ /***********************************************************************/ #include #include "resource.h" +#include "rcmsg.h" char *GetMsgid(int id) { diff --git a/storage/connect/rcmsg.h b/storage/connect/rcmsg.h new file mode 100644 index 00000000000..b22e77f5175 --- /dev/null +++ b/storage/connect/rcmsg.h @@ -0,0 +1,15 @@ +#ifndef __RCMSG_H__ +#define __RCMSG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +char *GetMsgid(int id); +int GetRcString(int id, char *buf, int bufsize); + +#ifdef __cplusplus +} +#endif + +#endif /* __RCMSG_H__ */ diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index 5bbc9effa92..909fcda4abf 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -75,7 +75,6 @@ #include "sql_string.h" -extern "C" char *GetMsgid(int id); extern "C" int trace; /***********************************************************************/ From 54f32928315f7f1863dd43589d1a67cbf05b254a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 13 May 2013 16:48:03 +0400 Subject: [PATCH 167/273] Fixing warnings (mostly "no previous declaration") modified: storage/connect/ha_connect.cc storage/connect/maputil.h storage/connect/odbconn.cpp storage/connect/osutil.c storage/connect/osutil.h storage/connect/tabmysql.cpp storage/connect/tabutil.cpp storage/connect/tabutil.h --- storage/connect/ha_connect.cc | 2 -- storage/connect/maputil.h | 1 - storage/connect/odbconn.cpp | 2 +- storage/connect/osutil.c | 4 ++++ storage/connect/osutil.h | 10 ++++++++++ storage/connect/tabmysql.cpp | 4 +--- storage/connect/tabutil.cpp | 2 +- storage/connect/tabutil.h | 2 ++ 8 files changed, 19 insertions(+), 8 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 4d6889f7f8b..4466b19dd6d 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3311,7 +3311,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, bool ok= false, dbf= false; TABTYPE ttp= TAB_UNDEF; MEM_ROOT *mem= thd->mem_root; - CHARSET_INFO *cs; PQRYRES qrp; PCOLRES crp; PGLOBAL g= GetPlug(thd, NULL); @@ -3567,7 +3566,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, rem= NULL; typ= len= dec= 0; tm= NOT_NULL_FLAG; - cs= NULL; for (crp= qrp->Colresp; crp; crp= crp->Next) switch (crp->Fld) { diff --git a/storage/connect/maputil.h b/storage/connect/maputil.h index 8ab41487a63..b5e54affcea 100644 --- a/storage/connect/maputil.h +++ b/storage/connect/maputil.h @@ -13,7 +13,6 @@ typedef struct { HANDLE CreateFileMap(PGLOBAL, LPCSTR, MEMMAP *, MODE, bool); bool CloseMemMap(void *memory, size_t dwSize); -my_bool CloseFileHandle(HANDLE h); #ifdef __cplusplus } diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 14b5f582962..b39f1c9ba5b 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -175,7 +175,7 @@ int TranslateSQLType(int stp, int prec, int& len) /***********************************************************************/ /* Allocate the structure used to refer to the result set. */ /***********************************************************************/ -CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *tab, PQRYRES qrp) +static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *tab, PQRYRES qrp) { size_t i, m, n; CATPARM *cap; diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c index 45c834a4cfc..1b7332357e6 100644 --- a/storage/connect/osutil.c +++ b/storage/connect/osutil.c @@ -142,10 +142,12 @@ my_bool CloseFileHandle(HANDLE h) return (close(h)) ? TRUE : FALSE; } /* end of CloseFileHandle */ +#if 0 void Sleep(DWORD time) { //FIXME: TODO } /* end of Sleep */ +#endif int GetLastError() { @@ -213,6 +215,7 @@ int _isatty(int fileNo) return isatty(fileNo); } /* end of _isatty */ +#if 0 /* This function is ridiculous and should be revisited */ DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, ...) @@ -227,5 +230,6 @@ DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, strncpy(lpBuffer, buff, nSize); return min(n, nSize); } /* end of FormatMessage */ +#endif #endif // UNIX diff --git a/storage/connect/osutil.h b/storage/connect/osutil.h index 148a22321f4..63a3e18084c 100644 --- a/storage/connect/osutil.h +++ b/storage/connect/osutil.h @@ -52,4 +52,14 @@ typedef __int64 FILEPOS; #define XSTR(x) ((x)?(x):"") + +#ifdef __cplusplus +extern "C" { +#endif +my_bool CloseFileHandle(HANDLE h); +#ifdef __cplusplus +} +#endif + + #endif /* __OSUTIL_H__ */ diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 3ecfd6aa6c1..b99823a8c4f 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -57,6 +57,7 @@ #include "reldef.h" #include "tabmysql.h" #include "valblk.h" +#include "tabutil.h" #if defined(_CONSOLE) void PrintResult(PGLOBAL, PSEM, PQRYRES); @@ -65,9 +66,6 @@ void PrintResult(PGLOBAL, PSEM, PQRYRES); extern "C" int trace; extern MYSQL_PLUGIN_IMPORT uint mysqld_port; -// This function is located in tabutil.cpp -void Remove_tshp(PCATLG cat); - /* -------------- Implementation of the MYSQLDEF class --------------- */ /***********************************************************************/ diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index c55b8d1fa5c..487555b52a8 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -396,7 +396,7 @@ int TDBPRX::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { if (InitTable(g)) - return NULL; + return 0; MaxSize = Tdbp->GetMaxSize(g); } // endif MaxSize diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index 81e2a44464a..76e1d1153b9 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -20,6 +20,8 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, const char *name, bool info); +void Remove_tshp(PCATLG cat); + /* -------------------------- PROXY classes -------------------------- */ /***********************************************************************/ From 17b230783f553581788004f9266c78fff635522f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 13 May 2013 15:46:58 +0200 Subject: [PATCH 168/273] fix test cases --- mysql-test/suite/funcs_1/r/is_columns_is_embedded.result | 4 ++-- mysql-test/suite/funcs_1/r/processlist_priv_ps.result | 4 ++-- mysql-test/suite/funcs_1/r/processlist_val_ps.result | 2 +- .../suite/sys_vars/t/innodb_buffer_pool_evict_basic.test | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index 61b98480d4f..323e5fea518 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -231,7 +231,7 @@ def information_schema PROCESSLIST STAGE 10 0 NO tinyint NULL NULL 3 0 NULL NULL def information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) def information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(7) def information_schema PROCESSLIST TIME_MS 9 0.000 NO decimal NULL NULL 22 3 NULL NULL NULL decimal(22,3) -def information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) +def information_schema PROCESSLIST USER 2 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128) def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) @@ -693,7 +693,7 @@ NULL information_schema PARTITIONS CHECKSUM bigint NULL NULL NULL NULL bigint(21 3.0000 information_schema PLUGINS PLUGIN_MATURITY varchar 12 36 utf8 utf8_general_ci varchar(12) 3.0000 information_schema PLUGINS PLUGIN_AUTH_VERSION varchar 80 240 utf8 utf8_general_ci varchar(80) NULL information_schema PROCESSLIST ID bigint NULL NULL NULL NULL bigint(4) -3.0000 information_schema PROCESSLIST USER varchar 16 48 utf8 utf8_general_ci varchar(16) +3.0000 information_schema PROCESSLIST USER varchar 128 384 utf8 utf8_general_ci varchar(128) 3.0000 information_schema PROCESSLIST HOST varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema PROCESSLIST DB varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema PROCESSLIST COMMAND varchar 16 48 utf8 utf8_general_ci varchar(16) diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result index 421636f3d92..52ed7a4d0ac 100644 --- a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result +++ b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result @@ -23,7 +23,7 @@ SHOW CREATE TABLE processlist; Table Create Table PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `ID` bigint(4) NOT NULL DEFAULT '0', - `USER` varchar(16) NOT NULL DEFAULT '', + `USER` varchar(128) NOT NULL DEFAULT '', `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', @@ -96,7 +96,7 @@ SHOW CREATE TABLE processlist; Table Create Table PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `ID` bigint(4) NOT NULL DEFAULT '0', - `USER` varchar(16) NOT NULL DEFAULT '', + `USER` varchar(128) NOT NULL DEFAULT '', `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', diff --git a/mysql-test/suite/funcs_1/r/processlist_val_ps.result b/mysql-test/suite/funcs_1/r/processlist_val_ps.result index b64afa84279..c3112bc573c 100644 --- a/mysql-test/suite/funcs_1/r/processlist_val_ps.result +++ b/mysql-test/suite/funcs_1/r/processlist_val_ps.result @@ -13,7 +13,7 @@ SHOW CREATE TABLE INFORMATION_SCHEMA.PROCESSLIST; Table Create Table PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `ID` bigint(4) NOT NULL DEFAULT '0', - `USER` varchar(16) NOT NULL DEFAULT '', + `USER` varchar(128) NOT NULL DEFAULT '', `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test index 564a48d9473..ce42f64395f 100644 --- a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test @@ -2,9 +2,9 @@ # This is a debug variable for now -- source include/have_debug.inc -if (`select plugin_auth_version <= "5.5.31-MariaDB-30.1" from information_schema.plugins where plugin_name='innodb'`) +if (`select plugin_auth_version <= "5.5.31-MariaDB-30.2" from information_schema.plugins where plugin_name='innodb'`) { - --skip Not fixed in XtraDB 5.5.31-MariaDB-30.1 or earlier + --skip Not fixed in XtraDB 5.5.31-MariaDB-30.2 or earlier } SELECT @@global.innodb_buffer_pool_evict; From 76421547255bb7c1f9a539bc810c8cd2f9ccc525 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 13 May 2013 15:49:27 +0200 Subject: [PATCH 169/273] MDEV-4199 Installing postfix on CentOS 5.9 requires MariaDB-server to match distribution packages better: remove "mysql" from server.rpm Provides, add it to the shared.rpm Provides. fake provides that "mysql" and "mysql-libs" packages would've had. cleanup: remove auto-generated provides from the manual provides list. --- cmake/cpack_rpm.cmake | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index ee7c4af7155..ee800fca4e4 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -95,7 +95,7 @@ SET(CPACK_RPM_devel_USER_FILELIST ${ignored}) SET(CPACK_RPM_test_USER_FILELIST ${ignored}) SET(CPACK_RPM_client_PACKAGE_OBSOLETES "mysql-client MySQL-client MySQL-OurDelta-client") -SET(CPACK_RPM_client_PACKAGE_PROVIDES "MariaDB-client MySQL-client mysql-client") +SET(CPACK_RPM_client_PACKAGE_PROVIDES "MySQL-client mysql-client") # this is a workaround for CPackRPM.cmake (as of 2.8.8) bug. # If a package group does not specify OBSOLETES/REQUIRES the values of the @@ -104,22 +104,40 @@ SET(CPACK_RPM_common_PACKAGE_OBSOLETES "MySQL-common") SET(CPACK_RPM_common_PACKAGE_PROVIDES "MariaDB-common") SET(CPACK_RPM_devel_PACKAGE_OBSOLETES "mysql-devel MySQL-devel MySQL-OurDelta-devel") -SET(CPACK_RPM_devel_PACKAGE_PROVIDES "MariaDB-devel MySQL-devel mysql-devel") +SET(CPACK_RPM_devel_PACKAGE_PROVIDES "MySQL-devel mysql-devel") -SET(CPACK_RPM_server_PACKAGE_OBSOLETES "MariaDB mysql mysql-server MySQL-server MySQL-OurDelta-server") -SET(CPACK_RPM_server_PACKAGE_PROVIDES "MariaDB MariaDB-server MySQL-server config(MariaDB-server) msqlormysql mysql mysql(x86-32) mysql(x86-64) mysql-server") +SET(CPACK_RPM_server_PACKAGE_OBSOLETES "MariaDB MySQL mysql-server MySQL-server MySQL-OurDelta-server") +SET(CPACK_RPM_server_PACKAGE_PROVIDES "MariaDB MySQL MySQL-server msqlormysql mysql-server") SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh) SET(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-preun.sh) SET(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postin.sh) SET(CPACK_RPM_server_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postun.sh) SET(CPACK_RPM_shared_PACKAGE_OBSOLETES "mysql-shared MySQL-shared-standard MySQL-shared-pro MySQL-shared-pro-cert MySQL-shared-pro-gpl MySQL-shared-pro-gpl-cert MySQL-shared MySQL-OurDelta-shared mysql-libs") -SET(CPACK_RPM_shared_PACKAGE_PROVIDES "MariaDB-shared MySQL-shared mysql-shared libmysqlclient.so.18 libmysqlclient.so.18(libmysqlclient_16) libmysqlclient.so.18(libmysqlclient_18) libmysqlclient_r.so.18 libmysqlclient_r.so.18(libmysqlclient_18) mysql-libs") +SET(CPACK_RPM_shared_PACKAGE_PROVIDES "MySQL-shared mysql-shared") + SET(CPACK_RPM_shared_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) SET(CPACK_RPM_shared_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) SET(CPACK_RPM_test_PACKAGE_OBSOLETES "mysql-test MySQL-test MySQL-OurDelta-test") -SET(CPACK_RPM_test_PACKAGE_PROVIDES "MariaDB-test MySQL-test mysql-test") +SET(CPACK_RPM_test_PACKAGE_PROVIDES "MySQL-test mysql-test") + +# Argh! Different distributions call packages differently, to be a drop-in replacement +# we have to fake distribution-speficic dependencies +MACRO(ALTERNATIVE_NAME real alt) + SET(p "CPACK_RPM_${real}_PACKAGE_PROVIDES") + SET(${p} "${${p}} ${alt} ${alt}(x86-32) ${alt}(x86-64) config(${alt})") +ENDMACRO(ALTERNATIVE_NAME) + +IF(RPM MATCHES "(rhel|centos)5") + ALTERNATIVE_NAME("shared" "mysql") +ELSEIF(RPM MATCHES "(rhel|centos)6") + ALTERNATIVE_NAME("client" "mysql") + ALTERNATIVE_NAME("shared" "mysql-libs") +ELSEIF(RPM MATCHES "fedora") + ALTERNATIVE_NAME("client" "mysql") + ALTERNATIVE_NAME("shared" "mysql-libs") +ENDIF() # workaround for lots of perl dependencies added by rpmbuild SET(CPACK_RPM_test_PACKAGE_PROVIDES "${CPACK_RPM_test_PACKAGE_PROVIDES} perl(lib::mtr_gcov.pl) perl(lib::mtr_gprof.pl) perl(lib::mtr_io.pl) perl(lib::mtr_misc.pl) perl(lib::mtr_process.pl) perl(lib::v1/mtr_cases.pl) perl(lib::v1/mtr_gcov.pl) perl(lib::v1/mtr_gprof.pl) perl(lib::v1/mtr_im.pl) perl(lib::v1/mtr_io.pl) perl(lib::v1/mtr_match.pl) perl(lib::v1/mtr_misc.pl) perl(lib::v1/mtr_process.pl) perl(lib::v1/mtr_report.pl) perl(lib::v1/mtr_stress.pl) perl(lib::v1/mtr_timer.pl) perl(lib::v1/mtr_unique.pl) perl(mtr_cases) perl(mtr_io.pl) perl(mtr_match) perl(mtr_misc.pl) perl(mtr_report) perl(mtr_results) perl(mtr_unique)") From 3aa50f64bb129ed38cd16031ec40ae1fe3082ee4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 13 May 2013 15:49:48 +0200 Subject: [PATCH 170/273] MDEV-4505 Buffer overrun when processing --log-bin parameter without file name because --log-bin sets opt_bin_logname to "" (same for any OPT_ARG GET_STR (or GET_STR_ALLOC) option) --- sql/mysqld.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d612d920ad4..d743be03c1a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4253,11 +4253,13 @@ will be ignored as the --log-bin option is not defined."); } #endif + DBUG_ASSERT(!opt_bin_log || opt_bin_logname); + if (opt_bin_log) { /* Reports an error and aborts, if the --log-bin's path is a directory.*/ - if (opt_bin_logname && + if (opt_bin_logname[0] && opt_bin_logname[strlen(opt_bin_logname) - 1] == FN_LIBCHAR) { sql_print_error("Path '%s' is a directory name, please specify \ @@ -4279,7 +4281,7 @@ a file name for --log-bin-index option", opt_binlog_index_name); char buf[FN_REFLEN]; const char *ln; ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf); - if (!opt_bin_logname && !opt_binlog_index_name) + if (!opt_bin_logname[0] && !opt_binlog_index_name) { /* User didn't give us info to name the binlog index file. From 66cc6196092b44447f64ef32b90febc748cb81ee Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 13 May 2013 16:11:39 +0200 Subject: [PATCH 171/273] MDEV-4514 After increasing user name length mysql.db is reported broken and event scheduler does not start --- mysql-test/r/grant_4332.result | 3 +-- mysql-test/t/grant_4332.test | 7 ++++--- sql/sql_acl.cc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/grant_4332.result b/mysql-test/r/grant_4332.result index f0286173b4c..ef92b62ab32 100644 --- a/mysql-test/r/grant_4332.result +++ b/mysql-test/r/grant_4332.result @@ -1,4 +1,3 @@ -set global event_scheduler = on; select user(); Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def user() 253 77 14 N 1 31 8 @@ -13,7 +12,7 @@ alter table mysql.columns_priv modify User char(80) binary not null default ''; alter table mysql.procs_priv modify User char(80) binary not null default ''; alter table mysql.proc modify definer char(141) collate utf8_bin not null default ''; alter table mysql.event modify definer char(141) collate utf8_bin not null default ''; -flush privileges; +set global event_scheduler = on; select user(); Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def user() 253 141 14 N 1 31 8 diff --git a/mysql-test/t/grant_4332.test b/mysql-test/t/grant_4332.test index 4d8d769680d..f77d3be350f 100644 --- a/mysql-test/t/grant_4332.test +++ b/mysql-test/t/grant_4332.test @@ -8,8 +8,6 @@ --source include/not_embedded.inc -set global event_scheduler = on; - --enable_metadata select user(); --disable_metadata @@ -24,7 +22,10 @@ alter table mysql.columns_priv modify User char(80) binary not null default ''; alter table mysql.procs_priv modify User char(80) binary not null default ''; alter table mysql.proc modify definer char(141) collate utf8_bin not null default ''; alter table mysql.event modify definer char(141) collate utf8_bin not null default ''; -flush privileges; + +--source include/restart_mysqld.inc + +set global event_scheduler = on; --enable_metadata select user(); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index d331c4b00ea..a7b840beb03 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -70,7 +70,7 @@ TABLE_FIELD_TYPE mysql_db_table_fields[MYSQL_DB_FIELD_COUNT] = { }, { { C_STRING_WITH_LEN("User") }, - { C_STRING_WITH_LEN("char(16)") }, + { C_STRING_WITH_LEN("char(") }, {NULL, 0} }, { From 97463576ad78b02269c9e2ba633220b21ad45547 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 14 May 2013 14:49:52 +0200 Subject: [PATCH 172/273] Fix test failure in plugins.unix_socket when running tests as user root. (The problem is that if $USER is root, then the authentication will log in with the mysqld user root. And then CURRENT_USER() returns a valid user, giving .result file difference). --- mysql-test/suite/plugins/t/unix_socket.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/suite/plugins/t/unix_socket.test b/mysql-test/suite/plugins/t/unix_socket.test index fc2e6c5b3c6..72106fab46d 100644 --- a/mysql-test/suite/plugins/t/unix_socket.test +++ b/mysql-test/suite/plugins/t/unix_socket.test @@ -1,4 +1,7 @@ --source include/not_embedded.inc +# If we run this as root, $USER gets authenticated as the `root' user, and we +# get .result differences from CURRENT_USER(). +--source include/not_as_root.inc if (!$AUTH_SOCKET_SO) { skip No auth_socket plugin; From d0265a632fbcd5f4bbf48c290d06498746e3d02c Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 14 May 2013 18:32:16 +0300 Subject: [PATCH 173/273] When one does 'REPAIR TABLE', update uuid() to the current system mysql-test/suite/maria/maria-autozerofill.result: Updated result mysql-test/suite/maria/maria-autozerofill.test: Added test that zerofilled table should not give any warnings when table is used mysql-test/suite/maria/maria-recovery2.result: More tests to make it easier to find bugs mysql-test/suite/maria/maria-recovery2.test: More tests to make it easier to find bugs storage/maria/ha_maria.cc: Set create_trid after repair (needed if table was moved from another system) Set uuid after repair (needed if table was moved from another system) storage/maria/maria_chk.c: Reset share->state.create_trid if we reset share->state.create_rename_lsn. Make the table moveable --- .../suite/maria/maria-autozerofill.result | 13 ++++++++++ .../suite/maria/maria-autozerofill.test | 25 +++++++++++++------ mysql-test/suite/maria/maria-recovery2.result | 6 +++++ mysql-test/suite/maria/maria-recovery2.test | 2 ++ storage/maria/ha_maria.cc | 9 +++++++ storage/maria/maria_chk.c | 3 +++ 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/maria/maria-autozerofill.result b/mysql-test/suite/maria/maria-autozerofill.result index 22856fe54b0..ef9e2f77345 100644 --- a/mysql-test/suite/maria/maria-autozerofill.result +++ b/mysql-test/suite/maria/maria-autozerofill.result @@ -12,6 +12,8 @@ create table t4 (a int) engine=aria; INSERT INTO t4 VALUES (1),(2); create table t5 (a int) engine=aria; INSERT INTO t5 VALUES (1),(2); +create table t6 (a int) engine=aria; +INSERT INTO t6 VALUES (1),(2); flush tables; create_rename_lsn has non-magic value * shut down mysqld, removed logs, restarted it @@ -25,6 +27,10 @@ Status: changed,sorted index pages,zerofilled insert into t1 values(2); flush table t1; create_rename_lsn has non-magic value +# +# BUG#44422 "mysql_upgrade destroys Maria tables?" +# Check repair and optimize of moved table +# check table t2; Table Op Msg_type Msg_text mysqltest.t2 check error Table is from another system and must be zerofilled or repaired to be usable on this system @@ -59,4 +65,11 @@ mysqltest.t5 repair status OK check table t5; Table Op Msg_type Msg_text mysqltest.t5 check status OK +select * from t6; +a +1 +2 +check table t6; +Table Op Msg_type Msg_text +mysqltest.t6 check status OK drop database mysqltest; diff --git a/mysql-test/suite/maria/maria-autozerofill.test b/mysql-test/suite/maria/maria-autozerofill.test index 9bb2782105a..e56f71d2c5f 100644 --- a/mysql-test/suite/maria/maria-autozerofill.test +++ b/mysql-test/suite/maria/maria-autozerofill.test @@ -33,11 +33,13 @@ create table t4 (a int) engine=aria; INSERT INTO t4 VALUES (1),(2); create table t5 (a int) engine=aria; INSERT INTO t5 VALUES (1),(2); +create table t6 (a int) engine=aria; +INSERT INTO t6 VALUES (1),(2); flush tables; # Check that table is not zerofilled, not movable let $MYSQLD_DATADIR= `select @@datadir`; ---exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt +--exec $MARIA_CHK -dv --ignore-control-file $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt perl; use strict; use warnings; @@ -62,7 +64,7 @@ enable_ps_protocol; flush table t1; # Check that table is auto-zerofilled, movable ---exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt +--exec $MARIA_CHK -dv --ignore-control-file $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt perl; use strict; use warnings; @@ -79,7 +81,7 @@ insert into t1 values(2); flush table t1; # Check that table is not zerofilled, not movable ---exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt +--exec $MARIA_CHK -dv --ignore-control-file $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt perl; use strict; use warnings; @@ -91,10 +93,13 @@ perl; close FILE; EOF -# -# BUG#44422 "mysql_upgrade destroys Maria tables?" -# Check repair and optimize of moved table -# +--echo # +--echo # BUG#44422 "mysql_upgrade destroys Maria tables?" +--echo # Check repair and optimize of moved table +--echo # + +# Table t2 is regarded as it would be from another server as we removed +# the aria control file earlier check table t2; check table t2; repair table t2; @@ -108,4 +113,10 @@ check table t5; repair table t5; check table t5; +# Check that if we zerofill with aria_chk, we should not get any warnings when +# accessing the table +--exec $MARIA_CHK --zerofill $MYSQLD_DATADIR/mysqltest/t6 >$MYSQLTEST_VARDIR/tmp/ariachk.txt +select * from t6; +check table t6; + drop database mysqltest; diff --git a/mysql-test/suite/maria/maria-recovery2.result b/mysql-test/suite/maria/maria-recovery2.result index 149ce5a01af..1dcb476af42 100644 --- a/mysql-test/suite/maria/maria-recovery2.result +++ b/mysql-test/suite/maria/maria-recovery2.result @@ -107,6 +107,9 @@ flush table t1; * copied t1 for comparison lock tables t1 write, t2 read; delete from t1 limit 1; +select count(*) from t1; +count(*) +0 insert into t1 select * from t2; SET SESSION debug_dbug="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash"; * crashing mysqld intentionally @@ -123,6 +126,9 @@ use mysqltest; show keys from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t1 1 a 1 a A 1 NULL NULL YES BTREE +select count(*) from t1; +count(*) +1 drop table t1; * TEST of recovery when OPTIMIZE has replaced the index file and crash create table t_corrupted1 (a varchar(100), key(a)) engine=aria; diff --git a/mysql-test/suite/maria/maria-recovery2.test b/mysql-test/suite/maria/maria-recovery2.test index 8d27d9aaaac..21944026cf6 100644 --- a/mysql-test/suite/maria/maria-recovery2.test +++ b/mysql-test/suite/maria/maria-recovery2.test @@ -130,9 +130,11 @@ insert into t1 values(30); lock tables t1 write, t2 read; delete from t1 limit 1; # 127 rows in t2, >100, so this will use repair-at-end +select count(*) from t1; insert into t1 select * from t2; -- source include/maria_verify_recovery.inc show keys from t1; # should be enabled +select count(*) from t1; drop table t1; --echo * TEST of recovery when OPTIMIZE has replaced the index file and crash diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index d050a65a1cb..722fb059d5f 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1668,6 +1668,11 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) } } thd_proc_info(thd, "Saving state"); + if (optimize_done && !error && !(param->testflag & T_NO_CREATE_RENAME_LSN)) + { + /* Set trid (needed if the table was moved from another system) */ + share->state.create_trid= trnman_get_min_safe_trid(); + } mysql_mutex_lock(&share->intern_lock); if (!error) { @@ -1683,6 +1688,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) */ if (file->state != &share->state.state) *file->state= share->state.state; + if (share->base.auto_key) _ma_update_auto_increment_key(param, file, 1); if (optimize_done) @@ -1690,6 +1696,9 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) UPDATE_TIME | UPDATE_OPEN_COUNT | (local_testflag & T_STATISTICS ? UPDATE_STAT : 0)); + /* File is repaired; Mark the file as moved to this system */ + (void) _ma_set_uuid(share, 0); + info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE | HA_STATUS_CONST); if (rows != file->state->records && !(param->testflag & T_VERY_SILENT)) diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 7379af10c03..05a5aefb4f4 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -1205,8 +1205,11 @@ static int maria_chk(HA_CHECK *param, char *filename) ((param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX | T_ZEROFILL | T_ZEROFILL_KEEP_LSN)) != (T_ZEROFILL | T_ZEROFILL_KEEP_LSN))) + { share->state.create_rename_lsn= share->state.is_of_horizon= share->state.skip_redo_lsn= LSN_NEEDS_NEW_STATE_LSNS; + share->state.create_trid= 0; + } } if (!error && (param->testflag & T_REP_ANY)) { From c2ee0218baf3e560b93c8dffa20ae377e303bc13 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Wed, 15 May 2013 02:33:29 +0500 Subject: [PATCH 174/273] MDEV-4521 MBRContains, MBRWithin no longer work with geometries of different type. get_mm_leaf function can store all sorts of spatial features in one type of field it receives from an Item_field. So we just allow that by setting the type of this field to GEOMETRY. per-file comments: mysql-test/r/gis-rtree.result result updated mysql-test/t/gis-rtree.test test case added. sql/opt_range.cc set geom_type=GEOMETRY if we got Field_geom. --- mysql-test/r/gis-rtree.result | 20 ++++++++++++++++++++ mysql-test/t/gis-rtree.test | 20 ++++++++++++++++++++ sql/opt_range.cc | 8 ++++++++ 3 files changed, 48 insertions(+) diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index c394aec8851..22c30479125 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -1576,3 +1576,23 @@ a ASTEXT(b) 0 POINT(1 1) DROP TABLE t1; End of 5.1 tests +CREATE TABLE t1 ( +l LINESTRING NOT NULL, +SPATIAL KEY(l) +) ENGINE = myisam; +INSERT INTO t1 VALUES(GeomFromText('LINESTRING(0 0, 1 1)')); +INSERT INTO t1 VALUES(GeomFromText('LINESTRING(1 1, 2 2)')); +INSERT INTO t1 VALUES(GeomFromText('LINESTRING(2 2, 3 3)')); +SELECT COUNT(*) FROM t1 IGNORE INDEX(l) WHERE MBRContains(l, GEOMFROMTEXT('POINT(0 0)')); +COUNT(*) +1 +SELECT COUNT(*) FROM t1 IGNORE INDEX(l) WHERE MBRWithin(GEOMFROMTEXT('POINT(0 0)'), l); +COUNT(*) +1 +SELECT COUNT(*) FROM t1 FORCE INDEX(l) WHERE MBRContains(l, GEOMFROMTEXT('POINT(0 0)')); +COUNT(*) +1 +SELECT COUNT(*) FROM t1 FORCE INDEX(l) WHERE MBRWithin(GEOMFROMTEXT('POINT(0 0)'), l); +COUNT(*) +1 +DROP TABLE t1; diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index 731efe5648e..404f0447f56 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -956,3 +956,23 @@ SELECT a, ASTEXT(b) FROM t1; DROP TABLE t1; --echo End of 5.1 tests + +# +# MDEV-4521 MBRContains, MBRWithin no longer work with geometries of different type. +# +CREATE TABLE t1 ( + l LINESTRING NOT NULL, + SPATIAL KEY(l) +) ENGINE = myisam; + +INSERT INTO t1 VALUES(GeomFromText('LINESTRING(0 0, 1 1)')); +INSERT INTO t1 VALUES(GeomFromText('LINESTRING(1 1, 2 2)')); +INSERT INTO t1 VALUES(GeomFromText('LINESTRING(2 2, 3 3)')); + +SELECT COUNT(*) FROM t1 IGNORE INDEX(l) WHERE MBRContains(l, GEOMFROMTEXT('POINT(0 0)')); +SELECT COUNT(*) FROM t1 IGNORE INDEX(l) WHERE MBRWithin(GEOMFROMTEXT('POINT(0 0)'), l); + +SELECT COUNT(*) FROM t1 FORCE INDEX(l) WHERE MBRContains(l, GEOMFROMTEXT('POINT(0 0)')); +SELECT COUNT(*) FROM t1 FORCE INDEX(l) WHERE MBRWithin(GEOMFROMTEXT('POINT(0 0)'), l); + +DROP TABLE t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 1209e7c9223..5d71ec71903 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7294,6 +7294,14 @@ static SEL_TREE *get_full_func_mm_tree(RANGE_OPT_PARAM *param, param->current_table); DBUG_ENTER("get_full_func_mm_tree"); +#ifdef HAVE_SPATIAL + if (field_item->field->type() == MYSQL_TYPE_GEOMETRY) + { + /* We have to be able to store all sorts of spatial features here */ + ((Field_geom*) field_item->field)->geom_type= Field::GEOM_GEOMETRY; + } +#endif /*HAVE_SPATIAL*/ + for (uint i= 0; i < cond_func->arg_count; i++) { Item *arg= cond_func->arguments()[i]->real_item(); From 19cb1c4748eab1f658373ad1b3893843ad46e749 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Wed, 15 May 2013 02:36:37 +0500 Subject: [PATCH 175/273] MDEV-4266 Server upgrade via apt-get install does not work. Now empty 'highlevel' packages strictly depend on the same versions of files. These are mariadb-server, mariadb-client, mariadb-test per-file comments: debian/dist/Debian/control MDEV-4266 Server upgrade via apt-get install does not work. dependencies on the current version added. debian/dist/Ubuntu/control MDEV-4266 Server upgrade via apt-get install does not work. dependencies on the current version added. --- debian/dist/Debian/control | 6 +++--- debian/dist/Ubuntu/control | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/debian/dist/Debian/control b/debian/dist/Debian/control index 95bde727093..9c96313045d 100644 --- a/debian/dist/Debian/control +++ b/debian/dist/Debian/control @@ -204,7 +204,7 @@ Description: MariaDB database server binaries Package: mariadb-server Section: database Architecture: all -Depends: mariadb-server-5.5, ${misc:Depends} +Depends: mariadb-server-5.5 (= ${source:Version}), ${misc:Depends} Description: MariaDB database server (metapackage depending on the latest version) This is an empty package that depends on the current "best" version of mariadb-server (currently mariadb-server-5.5), as determined by the MariaDB @@ -220,7 +220,7 @@ Description: MariaDB database server (metapackage depending on the latest versio Package: mariadb-client Section: database Architecture: all -Depends: mariadb-client-5.5, ${misc:Depends} +Depends: mariadb-client-5.5 (= ${source:Version}), ${misc:Depends} Description: MariaDB database client (metapackage depending on the latest version) This is an empty package that depends on the current "best" version of mariadb-client (currently mariadb-client-5.5), as determined by the MariaDB @@ -230,7 +230,7 @@ Description: MariaDB database client (metapackage depending on the latest versio Package: mariadb-test Section: database Architecture: all -Depends: mariadb-test-5.5 +Depends: mariadb-test-5.5 (= ${source:Version}) Description: MariaDB database regression test suite (metapackage depending on the latest version) This is an empty package that depends on the current "best" version of mariadb-test (currently mariadb-test-5.5), as determined by the MariaDB diff --git a/debian/dist/Ubuntu/control b/debian/dist/Ubuntu/control index 70ef5fd2ecf..d1c4917ed63 100644 --- a/debian/dist/Ubuntu/control +++ b/debian/dist/Ubuntu/control @@ -198,7 +198,7 @@ Description: MariaDB database server binaries Package: mariadb-server Section: database Architecture: all -Depends: mariadb-server-5.5, ${misc:Depends} +Depends: mariadb-server-5.5 (= ${source:Version}), ${misc:Depends} Description: MariaDB database server (metapackage depending on the latest version) This is an empty package that depends on the current "best" version of mariadb-server (currently mariadb-server-5.5), as determined by the MariaDB @@ -214,7 +214,7 @@ Description: MariaDB database server (metapackage depending on the latest versio Package: mariadb-client Section: database Architecture: all -Depends: mariadb-client-5.5, ${misc:Depends} +Depends: mariadb-client-5.5 (= ${source:Version}), ${misc:Depends} Description: MariaDB database client (metapackage depending on the latest version) This is an empty package that depends on the current "best" version of mariadb-client (currently mariadb-client-5.5), as determined by the MariaDB @@ -224,7 +224,7 @@ Description: MariaDB database client (metapackage depending on the latest versio Package: mariadb-test Section: database Architecture: all -Depends: mariadb-test-5.5 +Depends: mariadb-test-5.5 (= ${source:Version}) Description: MariaDB database regression test suite (metapackage depending on the latest version) This is an empty package that depends on the current "best" version of mariadb-test (currently mariadb-test-5.5), as determined by the MariaDB From 0fa7729954c1be9ad20f1a39fc89d3e485a4d9eb Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 15 May 2013 16:28:12 +0300 Subject: [PATCH 176/273] - Solaris fixes: - Fixed that wait_timeout_func and wait_timeout tests works on solaris - We have to compile without NO_ALARM on Solaris as Solaris doesn't support timeouts on sockets with setsockopt(.. SO_RCVTIMEO). - Fixed that compile-solaris-amd64-debug works (before that we got a wrong ELF class: ELFCLASS64 on linkage) - Fixed some compiler warnings - Fixed some failing tests BUILD/compile-solaris-amd64-debug: Fixed that compile-solaris-amd64-debug works (before that we got a wrong ELF class: ELFCLASS64 on linkage) configure.cmake: We have to compile without NO_ALARM on Solaris as Solaris doesn't support timeouts on sockets with setsockopt(.. SO_RCVTIMEO) mysql-test/suite/parts/t/partition_basic_innodb.test: Mark test as big test (as otherwise we get timeout on our opensolaris machine in buildbot) mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test: Remove warning --- BUILD/FINISH.sh | 3 +-- BUILD/compile-solaris-amd64-debug | 2 +- configure.cmake | 3 +++ mysql-test/suite/parts/t/partition_basic_innodb.test | 2 +- mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test | 2 ++ support-files/compiler_warnings.supp | 2 ++ 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/BUILD/FINISH.sh b/BUILD/FINISH.sh index e29b6936849..86085fcc593 100644 --- a/BUILD/FINISH.sh +++ b/BUILD/FINISH.sh @@ -42,8 +42,7 @@ path=`dirname $0` if [ -z "$just_clean" ] then commands="$commands -CC=\"$CC\" CFLAGS=\"$cflags\" CXX=\"$CXX\" CXXFLAGS=\"$cxxflags\" CXXLDFLAGS=\"$CXXLDFLAGS\" \ -$configure" +CC=\"$CC\" CFLAGS=\"$cflags\" CXX=\"$CXX\" CXXFLAGS=\"$cxxflags\" CXXLDFLAGS=\"$CXXLDFLAGS\" $configure" fi if [ -z "$just_configure" -a -z "$just_clean" ] diff --git a/BUILD/compile-solaris-amd64-debug b/BUILD/compile-solaris-amd64-debug index 4d6d3f6fce4..770572bd1d7 100755 --- a/BUILD/compile-solaris-amd64-debug +++ b/BUILD/compile-solaris-amd64-debug @@ -20,7 +20,7 @@ path=`dirname $0` extra_flags="$amd64_cflags -D__sun -m64 -mtune=athlon64 $debug_cflags" extra_configs="$amd64_configs $debug_configs $max_configs --with-libevent" -LDFLAGS="-lmtmalloc -R/usr/sfw/lib/64" +LDFLAGS="-m64 -lmtmalloc -R/usr/sfw/lib/64" export LDFLAGS . "$path/FINISH.sh" diff --git a/configure.cmake b/configure.cmake index 05e19509a78..db2779a2bf9 100644 --- a/configure.cmake +++ b/configure.cmake @@ -959,12 +959,15 @@ CHECK_CXX_SOURCE_COMPILES(" # they are silently ignored. For those OS's we will not attempt # to use SO_SNDTIMEO and SO_RCVTIMEO even if it is said to work. # See Bug#29093 for the problem with SO_SND/RCVTIMEO on HP/UX. +# Solaris11 has a similar problem # To use alarm is simple, simply avoid setting anything. IF(WIN32) SET(HAVE_SOCKET_TIMEOUT 1) ELSEIF(CMAKE_SYSTEM MATCHES "HP-UX") SET(HAVE_SOCKET_TIMEOUT 0) +ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS") + SET(HAVE_SOCKET_TIMEOUT 0) ELSEIF(CMAKE_CROSSCOMPILING) SET(HAVE_SOCKET_TIMEOUT 0) ELSE() diff --git a/mysql-test/suite/parts/t/partition_basic_innodb.test b/mysql-test/suite/parts/t/partition_basic_innodb.test index 8240257f087..398f62dab28 100644 --- a/mysql-test/suite/parts/t/partition_basic_innodb.test +++ b/mysql-test/suite/parts/t/partition_basic_innodb.test @@ -22,7 +22,7 @@ # any of the variables. # ---source include/long_test.inc +--source include/big_test.inc #------------------------------------------------------------------------------# # General not engine specific settings and requirements diff --git a/mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test b/mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test index 86ee64b5e73..a97801f9ab0 100644 --- a/mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test +++ b/mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test @@ -67,7 +67,9 @@ stop slave; reset slave; # Table was created from binlog, it may not be created if SQL thread is running # slowly and IO thread reaches incident before SQL thread applies it. +--disable_warnings drop table if exists t; +--enable_warnings reset master; --echo End of the tests diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 809369bc436..edccc6e5975 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -47,6 +47,8 @@ btr/btr0cur\.c: null argument where non-null required: 1800-3000 btr/btr0btr\.c: null argument where non-null required: 2500-3000 ibuf/ibuf0ibuf.c: null argument where non-null required: 700-1000 fsp0fsp\.c: result of 32-bit shift implicitly converted to 64 bits +log/log0log\.c : passing arg 1 of `atomic_add_64_nv' from incompatible pointer type +log/log0online\.c : passing arg 1 of `atomic_add_64_nv' from incompatible pointer type # # bdb is not critical to keep up to date From 3ef880cb595084de968c6663b382589edf7f03a8 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 17 May 2013 10:16:56 +0400 Subject: [PATCH 177/273] Bug#MDEV-4518 Server crashes in is_white_space when it's run with query cache, charset ucs2 and collation ucs2_unicode_ci @ mysql-test/r/ctype_ucs2_query_cache.result @ mysql-test/t/ctype_ucs2_query_cache-master.opt @ mysql-test/t/ctype_ucs2_query_cache.test Adding tests @ sql/sql_cache.cc Fixing not to use default_character_set->state_map, which can point to a non-ASCII character set (utc2, utf16, utf32) and thus have state_map undefined. --- mysql-test/r/ctype_ucs2_query_cache.result | 19 ++++++++++++++ .../t/ctype_ucs2_query_cache-master.opt | 1 + mysql-test/t/ctype_ucs2_query_cache.test | 19 ++++++++++++++ sql/sql_cache.cc | 25 ++++++++++++++++++- 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/ctype_ucs2_query_cache.result create mode 100644 mysql-test/t/ctype_ucs2_query_cache-master.opt create mode 100644 mysql-test/t/ctype_ucs2_query_cache.test diff --git a/mysql-test/r/ctype_ucs2_query_cache.result b/mysql-test/r/ctype_ucs2_query_cache.result new file mode 100644 index 00000000000..c5f1ef5918d --- /dev/null +++ b/mysql-test/r/ctype_ucs2_query_cache.result @@ -0,0 +1,19 @@ +# +# Start of 5.5 tests +# +# +# Bug#MDEV-4518 Server crashes in is_white_space when it's run +# with query cache, charset ucs2 and collation ucs2_unicode_ci +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +SELECT * FROM t1; +a +1 +2 +3 +4 +DROP TABLE t1; +# +# End of 5.5 tests +# diff --git a/mysql-test/t/ctype_ucs2_query_cache-master.opt b/mysql-test/t/ctype_ucs2_query_cache-master.opt new file mode 100644 index 00000000000..413ebb9f898 --- /dev/null +++ b/mysql-test/t/ctype_ucs2_query_cache-master.opt @@ -0,0 +1 @@ +--collation-server=ucs2_unicode_ci --character-set-server=ucs2,latin1 --query-cache-size=1048576 diff --git a/mysql-test/t/ctype_ucs2_query_cache.test b/mysql-test/t/ctype_ucs2_query_cache.test new file mode 100644 index 00000000000..bdc1d079d5e --- /dev/null +++ b/mysql-test/t/ctype_ucs2_query_cache.test @@ -0,0 +1,19 @@ +-- source include/have_query_cache.inc +-- source include/have_ucs2.inc + +--echo # +--echo # Start of 5.5 tests +--echo # + +--echo # +--echo # Bug#MDEV-4518 Server crashes in is_white_space when it's run +--echo # with query cache, charset ucs2 and collation ucs2_unicode_ci +--echo # +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index ab08b496dcd..1e5c99822ff 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -466,6 +466,8 @@ static void make_base_query(String *new_query, /* The following is guaranteed by the query_cache interface */ DBUG_ASSERT(query[query_length] == 0); DBUG_ASSERT(!is_white_space(query[0])); + /* We do not support UCS2, UTF16, UTF32 as a client character set */ + DBUG_ASSERT(current_thd->variables.character_set_client->mbminlen == 1); new_query->length(0); // Don't copy anything from old buffer if (new_query->realloc(query_length + additional_length)) @@ -2430,7 +2432,28 @@ void Query_cache::init() m_cache_status= Query_cache::OK; m_requests_in_progress= 0; initialized = 1; - query_state_map= default_charset_info->state_map; + /* + Using state_map from latin1 should be fine in all cases: + 1. We do not support UCS2, UTF16, UTF32 as a client character set. + 2. The other character sets are compatible on the lower ASCII-range + 0x00-0x20, and have the following characters marked as spaces: + + 0x09 TAB + 0x0A LINE FEED + 0x0B VERTICAL TAB + 0x0C FORM FEED + 0x0D CARRIAGE RETUR + 0x20 SPACE + + Additionally, only some of the ASCII-compatible character sets + (including latin1) can have 0xA0 mapped to "NON-BREAK SPACE" + and thus marked as space. + That should not be a problem for those charsets that map 0xA0 + to something else: the parser will just return syntax error + if this character appears straight in the query + (i.e. not inside a string literal or comment). + */ + query_state_map= my_charset_latin1.state_map; /* If we explicitly turn off query cache from the command line query cache will be disabled for the reminder of the server life From cbd300e7b028ab7716a4e02fa2e5067c4d8ee006 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 19 May 2013 16:22:33 +0200 Subject: [PATCH 178/273] Fix cpack error - safe_process.pl does not exist anymore. --- mysql-test/lib/My/SafeProcess/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt index 6edf9d45683..67755a065ea 100644 --- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt +++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt @@ -26,4 +26,4 @@ ELSE() MYSQL_ADD_EXECUTABLE(my_safe_process safe_process.cc ${INSTALL_ARGS}) ENDIF() -INSTALL(FILES safe_process.pl Base.pm DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess" COMPONENT Test) +INSTALL(FILES Base.pm DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess" COMPONENT Test) From dc56d56ce578d32e4bfba23f01a644da97c7ccb6 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 19 May 2013 16:38:56 +0200 Subject: [PATCH 179/273] MDEV-4544 - update MSI to include HeidiSQL 8.0 --- win/packaging/heidisql.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake index f826c9a6633..124f85bb87e 100644 --- a/win/packaging/heidisql.cmake +++ b/win/packaging/heidisql.cmake @@ -1,4 +1,4 @@ -SET(HEIDISQL_BASE_NAME "HeidiSQL_7.0_Portable") +SET(HEIDISQL_BASE_NAME "HeidiSQL_8.0_Portable") SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip") SET(HEIDISQL_URL "http://heidisql.googlecode.com/files/${HEIDISQL_ZIP}") SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME}) From b67ec975dcc0c4efcce14e8d5b967d8e38540d77 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 19 May 2013 17:41:22 +0200 Subject: [PATCH 180/273] MDEV-4544 : Update MSI installer to use latest HeidiSQL 8.0 --- win/packaging/heidisql.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake index f826c9a6633..124f85bb87e 100644 --- a/win/packaging/heidisql.cmake +++ b/win/packaging/heidisql.cmake @@ -1,4 +1,4 @@ -SET(HEIDISQL_BASE_NAME "HeidiSQL_7.0_Portable") +SET(HEIDISQL_BASE_NAME "HeidiSQL_8.0_Portable") SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip") SET(HEIDISQL_URL "http://heidisql.googlecode.com/files/${HEIDISQL_ZIP}") SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME}) From db7085dfae07e8cf4e98e41bd0dc111fb1b4896b Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 19 May 2013 17:42:30 +0200 Subject: [PATCH 181/273] remove start menu shortcut to upgrade wizard --- win/packaging/extra.wxs.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in index 124de5f4b40..da4ac6aa9ac 100644 --- a/win/packaging/extra.wxs.in +++ b/win/packaging/extra.wxs.in @@ -637,6 +637,7 @@ + From c035bde34c3a5a63451b51031d508a425ce9a3ae Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 19 May 2013 19:25:06 +0200 Subject: [PATCH 182/273] - Allowing views and queries as parameters for PROXY base tables NOTE: Checking for looping references cannot be done when using views as parameters. This should not be allowed on production servers and should be dependant on a system variable and/or on speciel grant. modified: storage/connect/CMakeLists.txt storage/connect/connect.cc storage/connect/ha_connect.cc storage/connect/myconn.cpp storage/connect/myconn.h storage/connect/mysql-test/connect/r/fmt.result storage/connect/mysql-test/connect/r/pivot.result storage/connect/mysql-test/connect/t/fmt.test storage/connect/mysql-test/connect/t/pivot.test storage/connect/plgdbsem.h storage/connect/plugutil.c storage/connect/tabcol.cpp storage/connect/tabcol.h storage/connect/tabfmt.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/taboccur.cpp storage/connect/taboccur.h storage/connect/tabpivot.cpp storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/xtable.h --- storage/connect/CMakeLists.txt | 2 +- storage/connect/connect.cc | 20 +- storage/connect/ha_connect.cc | 80 +- storage/connect/myconn.cpp | 38 +- storage/connect/myconn.h | 7 +- .../connect/mysql-test/connect/r/fmt.result | 4 +- .../connect/mysql-test/connect/r/pivot.result | 6 +- storage/connect/mysql-test/connect/t/fmt.test | 170 +-- .../connect/mysql-test/connect/t/pivot.test | 289 ++--- storage/connect/plgdbsem.h | 4 +- storage/connect/plugutil.c | 5 +- storage/connect/tabcol.cpp | 20 +- storage/connect/tabcol.h | 16 +- storage/connect/tabfmt.cpp | 22 +- storage/connect/tabmysql.cpp | 185 ++- storage/connect/tabmysql.h | 14 +- storage/connect/taboccur.cpp | 172 ++- storage/connect/taboccur.h | 23 +- storage/connect/tabpivot.cpp | 1017 +++-------------- storage/connect/tabpivot.h | 101 +- storage/connect/tabtbl.cpp | 4 +- storage/connect/tabutil.cpp | 95 +- storage/connect/tabutil.h | 3 +- storage/connect/xtable.h | 1 + 24 files changed, 907 insertions(+), 1391 deletions(-) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index d3663c5eee3..86dddcdb892 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -178,7 +178,7 @@ OPTION(CONNECT_WITH_MYSQL IF(CONNECT_WITH_MYSQL) SET(CONNECT_SOURCES ${CONNECT_SOURCES} - myconn.cpp myconn.h tabmysql.cpp tabxml.h) + myconn.cpp myconn.h tabmysql.cpp tabmysql.h) add_definitions(-DMYSQL_SUPPORT) IF(NOT UNIX) # diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 6ae730f20b2..7d9456c3259 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -71,10 +71,7 @@ int rename_file_ext(const char *from, const char *to,const char *ext); PGLOBAL CntExit(PGLOBAL g) { if (g) { - PDBUSER dup= PlgGetUser(g); - CntEndDB(g); - free(dup); if (g->Activityp) delete g->Activityp; @@ -94,13 +91,10 @@ void CntEndDB(PGLOBAL g) PDBUSER dbuserp= PlgGetUser(g); if (dbuserp) { - if (dbuserp->Catalog) { + if (dbuserp->Catalog) delete dbuserp->Catalog; - dbuserp->Catalog= NULL; - } // endif Catalog - *dbuserp->Name= '\0'; -// *dbuserp->Work= '\0'; + free(dbuserp); } // endif dbuserp } // end of CntEndDB @@ -258,10 +252,12 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, return true; } // endif tdbp - if (!c1) - // Allocate all column blocks for that table - tdbp->ColDB(g, NULL, 0); - else for (p= c1; *p; p+= n) { + if (!c1) { + if (mode == MODE_INSERT) + // Allocate all column blocks for that table + tdbp->ColDB(g, NULL, 0); + + } else for (p= c1; *p; p+= n) { // Allocate only used column blocks if (xtrace) printf("Allocating column %s\n", p); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index a4611c83ffe..9bc0d2a9942 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -696,7 +696,9 @@ bool ha_connect::GetBooleanOption(char *opname, bool bdef) char *pv; PTOS options= GetTableOptionStruct(table); - if (!options) + if (!stricmp(opname, "View")) + opval= (tshp) ? tshp->is_view : table->s->is_view; + else if (!options) ; else if (!stricmp(opname, "Mapped")) opval= options->mapped; @@ -838,7 +840,7 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) } else fldp= (tshp) ? tshp->field : table->field; - if (!(fp= *fldp)) + if (!fldp || !(fp= *fldp)) return NULL; // Get the CONNECT field options structure @@ -1843,11 +1845,13 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked) // Try to get the user if possible xp= GetUser(ha_thd(), xp); - PGLOBAL g= xp->g; + PGLOBAL g= (xp) ? xp->g : NULL; // Try to set the database environment if (g) rc= (CntCheckDB(g, this, name)) ? (-2) : 0; + else + rc= HA_ERR_INTERNAL_ERROR; DBUG_RETURN(rc); } // end of open @@ -2809,6 +2813,10 @@ int ha_connect::external_lock(THD *thd, int lock_type) bool oldsep= ((PCHK)g->Xchk)->oldsep; bool newsep= ((PCHK)g->Xchk)->newsep; PTDBDOS tdp= (PTDBDOS)(tdbp ? tdbp : GetTDB(g)); + + if (!tdp) + DBUG_RETURN(HA_ERR_INTERNAL_ERROR); + PDOSDEF ddp= (PDOSDEF)tdp->GetDef(); PIXDEF xp, xp1, xp2, drp=NULL, adp= NULL; PIXDEF oldpix= ((PCHK)g->Xchk)->oldpix; @@ -3300,7 +3308,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, { char spc= ',', qch= 0; const char *fncn= "?"; - const char *user, *fn, *db, *host, *pwd, *prt, *sep, *tbl; // *csn; + const char *user, *fn, *db, *host, *pwd, *prt, *sep, *tbl, *src; char *tab, *dsn; #if defined(WIN32) char *nsp= NULL, *cls= NULL; @@ -3324,16 +3332,17 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, sql.copy(STRING_WITH_LEN("CREATE TABLE whatever ("), system_charset_info); - user= host= pwd= prt= tbl= dsn= NULL; + user= host= pwd= prt= tbl= src= dsn= NULL; // Get the useful create options - ttp= GetTypeID(topt->type); - fn= topt->filename; - tab= (char*)topt->tabname; - db= topt->dbname; + ttp= GetTypeID(topt->type); + fn= topt->filename; + tab= (char*)topt->tabname; + src= topt->srcdef; + db= topt->dbname; fncn= topt->catfunc; fnc= GetFuncID(fncn); - sep= topt->separator; + sep= topt->separator; spc= (!sep || !strcmp(sep, "\\t")) ? '\t' : *sep; qch= topt->qchar ? *topt->qchar : topt->quoted >= 0 ? '"' : 0; hdr= (int)topt->header; @@ -3352,25 +3361,20 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, cls= GetListOption(g,"class", topt->oplist); #endif // WIN32 mxr= atoi(GetListOption(g,"maxerr", topt->oplist, "0")); - } // endif option_list + } else { + host= "localhost"; + user= "root"; + } // endif option_list if (!db) db= thd->db; // Default value // Check table type if (ttp == TAB_UNDEF) { - if (!tab) { - strcpy(g->Message, "No table_type. Was set to DOS"); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); - ttp= TAB_DOS; - topt->type= "DOS"; - } else { - strcpy(g->Message, "No table_type. Was set to PROXY"); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); - ttp= TAB_PRX; - topt->type= "PROXY"; - } // endif fnc - + topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS"; + ttp= GetTypeID(topt->type); + sprintf(g->Message, "No table_type. Was set to %s", topt->type); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); } else if (ttp == TAB_NIY) { sprintf(g->Message, "Unsupported table type %s", topt->type); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); @@ -3494,7 +3498,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, else return HA_ERR_INTERNAL_ERROR; // Should never happen - switch (ttp) { + if (src && fnc == FNC_NO) + qrp= SrcColumns(g, host, db, user, pwd, src, port); + else switch (ttp) { case TAB_DBF: qrp= DBFColumns(g, fn, fnc == FNC_COL); break; @@ -3523,7 +3529,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, #if defined(MYSQL_SUPPORT) case TAB_MYSQL: qrp= MyColumns(g, host, db, user, pwd, tab, - NULL, port, false, fnc == FNC_COL); + NULL, port, fnc == FNC_COL); break; #endif // MYSQL_SUPPORT case TAB_CSV: @@ -3549,7 +3555,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, return HA_ERR_INTERNAL_ERROR; } // endif qrp - if (fnc != FNC_NO) { + if (fnc != FNC_NO || src) { // Catalog table for (crp=qrp->Colresp; !b && crp; crp= crp->Next) { cnm= encode(g, crp->Name); @@ -3821,13 +3827,23 @@ int ha_connect::create(const char *name, TABLE *table_arg, case TAB_PRX: case TAB_XCL: case TAB_OCCUR: - if (!stricmp(options->tabname, create_info->alias) && - (!options->dbname || !stricmp(options->dbname, thd->db))) { - sprintf(g->Message, "A %s table cannot refer to itself", - options->type); + if (options->srcdef) { + strcpy(g->Message, "Cannot check looping reference"); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + } else if (options->tabname) { + if (!stricmp(options->tabname, create_info->alias) && + (!options->dbname || !stricmp(options->dbname, thd->db))) { + sprintf(g->Message, "A %s table cannot refer to itself", + options->type); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + DBUG_RETURN(HA_ERR_INTERNAL_ERROR); + } // endif tab + + } else { + strcpy(g->Message, "Missing object table name or definition"); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); - return HA_ERR_INTERNAL_ERROR; - } // endif tab + DBUG_RETURN(HA_ERR_INTERNAL_ERROR); + } // endif tabname } // endswitch ttp diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index fab2af54aa7..5320171beeb 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -66,13 +66,13 @@ extern MYSQL_PLUGIN_IMPORT uint mysqld_port; /************************************************************************/ /* MyColumns: constructs the result blocks containing all columns */ -/* of a MySQL table that will be retrieved by GetData commands. */ -/* key = TRUE when called from Create Table to get key informations. */ +/* of a MySQL table or view. */ +/* info = TRUE to get catalog column informations. */ /************************************************************************/ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, const char *user, const char *pwd, const char *table, const char *colpat, - int port, bool key, bool info) + int port, bool info) { static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, @@ -124,9 +124,6 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, length[0] = 128; } // endif info -//if (!key) // We are not called from Create table -// ncol--; // No date format column yet - /**********************************************************************/ /* Allocate the structures used to refer to the result set. */ /**********************************************************************/ @@ -219,6 +216,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, crp->Kdata->SetValue(fld, i); } // endfor i +#if 0 if (k > 1) { // Multicolumn primary key PVBLK vbp = qrp->Colresp->Next->Next->Next->Next->Kdata; @@ -228,6 +226,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, vbp->SetValue(k, i); } // endif k +#endif // 0 /**********************************************************************/ /* Close MySQL connection. */ @@ -240,6 +239,33 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, return qrp; } // end of MyColumns +/************************************************************************/ +/* SrcColumns: constructs the result blocks containing all columns */ +/* resulting from an SQL source definition query execution. */ +/************************************************************************/ +PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, + const char *user, const char *pwd, + const char *srcdef, int port) + { + int w; + MYSQLC myc; + PQRYRES qrp = NULL; + + if (!port) + port = mysqld_port; + + // Open a MySQL connection for this table + if (myc.Open(g, host, db, user, pwd, port)) + return NULL; + + // Send the source command to MySQL + if (myc.ExecSQL(g, srcdef, &w) == RC_OK) + qrp = myc.GetResult(g); + + myc.Close(); + return qrp; + } // end of SrcColumns + /* -------------------------- Class MYSQLC --------------------------- */ /***********************************************************************/ diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h index 72ce58e70aa..8148630b812 100644 --- a/storage/connect/myconn.h +++ b/storage/connect/myconn.h @@ -38,7 +38,11 @@ typedef class MYSQLC *PMYC; PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, const char *user, const char *pwd, const char *table, const char *colpat, - int port, bool key, bool info); + int port, bool info); + +PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, + const char *user, const char *pwd, + const char *srcdef, int port); /* -------------------------- MYCONN class --------------------------- */ @@ -47,6 +51,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, /***********************************************************************/ class DllItem MYSQLC { friend class TDBMYSQL; + friend class MYSQLCOL; // Construction public: MYSQLC(void); diff --git a/storage/connect/mysql-test/connect/r/fmt.result b/storage/connect/mysql-test/connect/r/fmt.result index dc3b42b2231..0be10f69bfd 100644 --- a/storage/connect/mysql-test/connect/r/fmt.result +++ b/storage/connect/mysql-test/connect/r/fmt.result @@ -18,7 +18,7 @@ CREATE TABLE t1 id INT NOT NULL field_format=' %n%d%n' ) ENGINE=CONNECT TABLE_TYPE=FMT FILE_NAME='t1.txt'; INSERT INTO t1 VALUES (10),(20); -ERROR HY000: Got error 122 'Writing FMT files is not implemented yet' from CONNECT +ERROR HY000: Got error 174 'Writing FMT files is not implemented yet' from CONNECT DROP TABLE t1; # # Testing manual examples @@ -59,7 +59,7 @@ ID NAME DEPNO SALARY 56 POIROT-DELMOTTE 0 18009.00 345 67 19000.25 UPDATE t1 SET SALARY=1234; -ERROR HY000: Got error 122 'Writing FMT files is not implemented yet' from CONNECT +ERROR HY000: Got error 174 'Writing FMT files is not implemented yet' from CONNECT DELETE FROM t1 WHERE ID=56; SELECT * FROM t1; ID NAME DEPNO SALARY diff --git a/storage/connect/mysql-test/connect/r/pivot.result b/storage/connect/mysql-test/connect/r/pivot.result index 4480788332b..1b790662c4b 100644 --- a/storage/connect/mysql-test/connect/r/pivot.result +++ b/storage/connect/mysql-test/connect/r/pivot.result @@ -77,8 +77,8 @@ Beer DOUBLE(8,2) FLAG=1, Car DOUBLE(8,2) FLAG=1, Food DOUBLE(8,2) FLAG=1) ENGINE=CONNECT TABLE_TYPE=PIVOT -SRCDEF='select who, week, what, sum(amount) from expenses where week in (4,5) group by who, week, what'; -ALTER TABLE pivex OPTION_LIST='port=PORT'; +SRCDEF='select who, week, what, sum(amount) as amount from expenses where week in (4,5) group by who, week, what'; +ALTER TABLE pivex OPTION_LIST='PivotCol=what,FncCol=amount,port=PORT'; Warnings: Warning 1105 The current version of CONNECT did not check what you changed in ALTER. Use at your own risk SELECT * FROM pivex; @@ -125,7 +125,7 @@ Middle DOUBLE(8,2) FLAG=1, Last DOUBLE(8,2) FLAG=1) ENGINE=CONNECT TABLE_TYPE=PIVOT SRCDEF='select who, what, case when week=3 then ''First'' when week=5 then ''Last'' else ''Middle'' end as wk, sum(amount) * 6.56 as amnt from expenses group by who, what, wk'; -ALTER TABLE pivex OPTION_LIST='PivotCol=wk,port=PORT'; +ALTER TABLE pivex OPTION_LIST='PivotCol=wk,FncCol=amnt,port=PORT'; Warnings: Warning 1105 The current version of CONNECT did not check what you changed in ALTER. Use at your own risk SELECT * FROM pivex; diff --git a/storage/connect/mysql-test/connect/t/fmt.test b/storage/connect/mysql-test/connect/t/fmt.test index de7f8c06c1b..662bc70c8b1 100644 --- a/storage/connect/mysql-test/connect/t/fmt.test +++ b/storage/connect/mysql-test/connect/t/fmt.test @@ -1,85 +1,85 @@ -let $MYSQLD_DATADIR= `select @@datadir`; ---copy_file $MTR_SUITE_DIR/std_data/funny.txt $MYSQLD_DATADIR/test/funny.txt ---copy_file $MTR_SUITE_DIR/std_data/funny2.txt $MYSQLD_DATADIR/test/funny2.txt - ---echo # ---echo # Testing errors ---echo # -CREATE TABLE t1 -( - ID INT NOT NULL field_format=' %n%d%n' -) Engine=CONNECT table_type=FMT file_name='nonexistent.txt'; ---replace_regex /on .*test.nonexistent.txt/on DATADIR\/test\/nonexistent.txt/ -# TODO: check why this is needed for Windows ---replace_result Open(rt) Open(rb) -SELECT * FROM t1; -DROP TABLE t1; - - ---echo # ---echo # Testing update on FMT tables ---echo # -CREATE TABLE t1 -( - id INT NOT NULL field_format=' %n%d%n' -) ENGINE=CONNECT TABLE_TYPE=FMT FILE_NAME='t1.txt'; ---error ER_GET_ERRMSG -INSERT INTO t1 VALUES (10),(20); -# TODO: -#--error ER_GET_ERRMSG -#UPDATE t1 SET id=20; -#TRUNCATE TABLE t1; -#DELETE FROM t1 WHERE id=10; -#SELECT * FROM t1; -DROP TABLE t1; ---remove_file $MYSQLD_DATADIR/test/t1.txt - - ---echo # ---echo # Testing manual examples ---echo # -CREATE TABLE t1 -( - ID Integer(5) not null field_format=' %n%d%n', - NAME Char(16) not null field_format=" , '%n%[^']%n'", - DEPNO Integer(4) not null field_format=' , #%n%d%n', - SALARY Double(12,2) not null field_format=' ; %n%f%n' -) Engine=CONNECT table_type=FMT file_name='funny.txt'; -SELECT * FROM t1; -DROP TABLE t1; - -# -# TODO: shoudn't a warning instead of error be returned on bad format? -# -CREATE TABLE t1 -( - ID Integer(5) not null field_format=' %n%d%n', - NAME Char(16) not null field_format=" , '%n%[^']%n'", - DEPNO Integer(4) not null field_format=' , #%n%d%n', - SALARY Double(12,2) not null field_format=' ; %n%f%n' -) Engine=CONNECT table_type=FMT file_name='funny2.txt'; ---error ER_GET_ERRMSG -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1 -( - ID Integer(5) not null field_format=' %n%d%n', - NAME Char(16) not null field_format=' , ''%n%[^'']%m', - DEPNO Integer(4) not null field_format=''' , #%n%d%m', - SALARY Double(12,2) not null field_format=' ; %n%f%n' -) Engine=CONNECT table_type=FMT file_name='funny2.txt'; -SELECT * FROM t1; ---error ER_GET_ERRMSG -UPDATE t1 SET SALARY=1234; -# TODO: this query crashes -# UPDATE t1 SET SALARY=1234 WHERE ID=56; -DELETE FROM t1 WHERE ID=56; -SELECT * FROM t1; -DROP TABLE t1; - -# -# Clean up -# ---remove_file $MYSQLD_DATADIR/test/funny.txt ---remove_file $MYSQLD_DATADIR/test/funny2.txt +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MTR_SUITE_DIR/std_data/funny.txt $MYSQLD_DATADIR/test/funny.txt +--copy_file $MTR_SUITE_DIR/std_data/funny2.txt $MYSQLD_DATADIR/test/funny2.txt + +--echo # +--echo # Testing errors +--echo # +CREATE TABLE t1 +( + ID INT NOT NULL field_format=' %n%d%n' +) Engine=CONNECT table_type=FMT file_name='nonexistent.txt'; +--replace_regex /on .*test.nonexistent.txt/on DATADIR\/test\/nonexistent.txt/ +# TODO: check why this is needed for Windows +--replace_result Open(rt) Open(rb) +SELECT * FROM t1; +DROP TABLE t1; + + +--echo # +--echo # Testing update on FMT tables +--echo # +CREATE TABLE t1 +( + id INT NOT NULL field_format=' %n%d%n' +) ENGINE=CONNECT TABLE_TYPE=FMT FILE_NAME='t1.txt'; +--error ER_GET_ERRMSG +INSERT INTO t1 VALUES (10),(20); +# TODO: +#--error ER_GET_ERRMSG +#UPDATE t1 SET id=20; +#TRUNCATE TABLE t1; +#DELETE FROM t1 WHERE id=10; +#SELECT * FROM t1; +DROP TABLE t1; +#--remove_file $MYSQLD_DATADIR/test/t1.txt + + +--echo # +--echo # Testing manual examples +--echo # +CREATE TABLE t1 +( + ID Integer(5) not null field_format=' %n%d%n', + NAME Char(16) not null field_format=" , '%n%[^']%n'", + DEPNO Integer(4) not null field_format=' , #%n%d%n', + SALARY Double(12,2) not null field_format=' ; %n%f%n' +) Engine=CONNECT table_type=FMT file_name='funny.txt'; +SELECT * FROM t1; +DROP TABLE t1; + +# +# TODO: shoudn't a warning instead of error be returned on bad format? +# +CREATE TABLE t1 +( + ID Integer(5) not null field_format=' %n%d%n', + NAME Char(16) not null field_format=" , '%n%[^']%n'", + DEPNO Integer(4) not null field_format=' , #%n%d%n', + SALARY Double(12,2) not null field_format=' ; %n%f%n' +) Engine=CONNECT table_type=FMT file_name='funny2.txt'; +--error ER_GET_ERRMSG +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 +( + ID Integer(5) not null field_format=' %n%d%n', + NAME Char(16) not null field_format=' , ''%n%[^'']%m', + DEPNO Integer(4) not null field_format=''' , #%n%d%m', + SALARY Double(12,2) not null field_format=' ; %n%f%n' +) Engine=CONNECT table_type=FMT file_name='funny2.txt'; +SELECT * FROM t1; +--error ER_GET_ERRMSG +UPDATE t1 SET SALARY=1234; +# TODO: this query crashes +# UPDATE t1 SET SALARY=1234 WHERE ID=56; +DELETE FROM t1 WHERE ID=56; +SELECT * FROM t1; +DROP TABLE t1; + +# +# Clean up +# +--remove_file $MYSQLD_DATADIR/test/funny.txt +--remove_file $MYSQLD_DATADIR/test/funny2.txt diff --git a/storage/connect/mysql-test/connect/t/pivot.test b/storage/connect/mysql-test/connect/t/pivot.test index f06c92828f9..87601a26d28 100644 --- a/storage/connect/mysql-test/connect/t/pivot.test +++ b/storage/connect/mysql-test/connect/t/pivot.test @@ -1,144 +1,145 @@ -let $MYSQLD_DATADIR= `select @@datadir`; -let $PORT= `select @@port`; ---copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt - ---echo # ---echo # Testing the PIVOT table type ---echo # -CREATE TABLE expenses ( -Who CHAR(10) NOT NULL, -Week INT(2) NOT NULL, -What CHAR(12) NOT NULL, -Amount DOUBLE(8,2)) -ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt' ENDING=2; -SELECT * FROM expenses; - ---echo # ---echo # Pivoting from What ---echo # -CREATE TABLE pivex ( -Who CHAR(10) NOT NULL, -Week INT(2) NOT NULL, -Beer DOUBLE(8,2) FLAG=1, -Car DOUBLE(8,2) FLAG=1, -Food DOUBLE(8,2) FLAG=1) -ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; ---replace_result $PORT PORT ---eval ALTER TABLE pivex OPTION_LIST='port=$PORT' -SELECT * FROM pivex; - ---echo # ---echo # Restricting the columns in a Pivot Table ---echo # -ALTER TABLE pivex DROP COLUMN week; -SELECT * FROM pivex; - ---echo # ---echo # Using a source definition ---echo # -DROP TABLE pivex; -CREATE TABLE pivex ( -Who CHAR(10) NOT NULL, -Week INT(2) NOT NULL, -Beer DOUBLE(8,2) FLAG=1, -Car DOUBLE(8,2) FLAG=1, -Food DOUBLE(8,2) FLAG=1) -ENGINE=CONNECT TABLE_TYPE=PIVOT -SRCDEF='select who, week, what, sum(amount) from expenses where week in (4,5) group by who, week, what'; ---replace_result $PORT PORT ---eval ALTER TABLE pivex OPTION_LIST='port=$PORT' -SELECT * FROM pivex; - ---echo # ---echo # Pivoting from Week ---echo # -DROP TABLE pivex; -CREATE TABLE pivex ( -Who CHAR(10) NOT NULL, -What CHAR(12) NOT NULL, -`3` DOUBLE(8,2) FLAG=1, -`4` DOUBLE(8,2) FLAG=1, -`5` DOUBLE(8,2) FLAG=1) -ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; ---replace_result $PORT PORT ---eval ALTER TABLE pivex OPTION_LIST='PivotCol=Week,port=$PORT' -SELECT * FROM pivex; - ---echo # ---echo # Using scalar functions and expresssions ---echo # -DROP TABLE pivex; -CREATE TABLE pivex ( -Who CHAR(10) NOT NULL, -What CHAR(12) NOT NULL, -First DOUBLE(8,2) FLAG=1, -Middle DOUBLE(8,2) FLAG=1, -Last DOUBLE(8,2) FLAG=1) -ENGINE=CONNECT TABLE_TYPE=PIVOT -SRCDEF='select who, what, case when week=3 then ''First'' when week=5 then ''Last'' else ''Middle'' end as wk, sum(amount) * 6.56 as amnt from expenses group by who, what, wk'; ---replace_result $PORT PORT ---eval ALTER TABLE pivex OPTION_LIST='PivotCol=wk,port=$PORT' -SELECT * FROM pivex; -DROP TABLE pivex; -DROP TABLE expenses; - ---echo # ---echo # Make the PETS table ---echo # -CREATE TABLE pets ( -Name VARCHAR(12) NOT NULL, -Race CHAR(6) NOT NULL, -Number INT NOT NULL) ENGINE=MYISAM; -INSERT INTO pets VALUES('John','dog',2); -INSERT INTO pets VALUES('Bill','cat',1); -INSERT INTO pets VALUES('Mary','dog',1); -INSERT INTO pets VALUES('Mary','cat',1); -INSERT INTO pets VALUES('Lisbeth','rabbit',2); -INSERT INTO pets VALUES('Kevin','cat',2); -INSERT INTO pets VALUES('Kevin','bird',6); -INSERT INTO pets VALUES('Donald','dog',1); -INSERT INTO pets VALUES('Donald','fish',3); -SELECT * FROM pets; - ---echo # ---echo # Pivot the PETS table ---echo # -CREATE TABLE pivet ( -name VARCHAR(12) NOT NULL, -dog INT NOT NULL DEFAULT 0 FLAG=1, -cat INT NOT NULL DEFAULT 0 FLAG=1, -rabbit INT NOT NULL DEFAULT 0 FLAG=1, -bird INT NOT NULL DEFAULT 0 FLAG=1, -fish INT NOT NULL DEFAULT 0 FLAG=1) -ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; -SELECT * FROM pivet; -DROP TABLE pivet; - ---echo # ---echo # Testing the "data" column list ---echo # -CREATE TABLE pivet ( -name VARCHAR(12) NOT NULL, -dog INT NOT NULL DEFAULT 0 FLAG=1, -cat INT NOT NULL DEFAULT 0 FLAG=1) -ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; ---error ER_GET_ERRMSG -SELECT * FROM pivet; -ALTER TABLE pivet OPTION_LIST='PivotCol=race,groupby=1,accept=1'; -SELECT * FROM pivet; -DROP TABLE pivet; - ---echo # ---echo # Adding a "dump" column ---echo # -CREATE TABLE pivet ( -name VARCHAR(12) NOT NULL, -dog INT NOT NULL DEFAULT 0 FLAG=1, -cat INT NOT NULL DEFAULT 0 FLAG=1, -other INT NOT NULL DEFAULT 0 FLAG=2) -ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; -SELECT * FROM pivet; - -DROP TABLE pivet; -DROP TABLE pets; ---remove_file $MYSQLD_DATADIR/test/expenses.txt +let $MYSQLD_DATADIR= `select @@datadir`; +let $PORT= `select @@port`; +--copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt +--copy_file $MTR_SUITE_DIR/std_data/connect.ini $MYSQLD_DATADIR/test/connect.ini + +--echo # +--echo # Testing the PIVOT table type +--echo # +CREATE TABLE expenses ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +What CHAR(12) NOT NULL, +Amount DOUBLE(8,2)) +ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt' ENDING=2; +SELECT * FROM expenses; + +--echo # +--echo # Pivoting from What +--echo # +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +Beer DOUBLE(8,2) FLAG=1, +Car DOUBLE(8,2) FLAG=1, +Food DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; +--replace_result $PORT PORT +--eval ALTER TABLE pivex OPTION_LIST='port=$PORT' +SELECT * FROM pivex; + +--echo # +--echo # Restricting the columns in a Pivot Table +--echo # +ALTER TABLE pivex DROP COLUMN week; +SELECT * FROM pivex; + +--echo # +--echo # Using a source definition +--echo # +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +Week INT(2) NOT NULL, +Beer DOUBLE(8,2) FLAG=1, +Car DOUBLE(8,2) FLAG=1, +Food DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT +SRCDEF='select who, week, what, sum(amount) as amount from expenses where week in (4,5) group by who, week, what'; +--replace_result $PORT PORT +--eval ALTER TABLE pivex OPTION_LIST='PivotCol=what,FncCol=amount,port=$PORT' +SELECT * FROM pivex; + +--echo # +--echo # Pivoting from Week +--echo # +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +What CHAR(12) NOT NULL, +`3` DOUBLE(8,2) FLAG=1, +`4` DOUBLE(8,2) FLAG=1, +`5` DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; +--replace_result $PORT PORT +--eval ALTER TABLE pivex OPTION_LIST='PivotCol=Week,port=$PORT' +SELECT * FROM pivex; + +--echo # +--echo # Using scalar functions and expresssions +--echo # +DROP TABLE pivex; +CREATE TABLE pivex ( +Who CHAR(10) NOT NULL, +What CHAR(12) NOT NULL, +First DOUBLE(8,2) FLAG=1, +Middle DOUBLE(8,2) FLAG=1, +Last DOUBLE(8,2) FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT +SRCDEF='select who, what, case when week=3 then ''First'' when week=5 then ''Last'' else ''Middle'' end as wk, sum(amount) * 6.56 as amnt from expenses group by who, what, wk'; +--replace_result $PORT PORT +--eval ALTER TABLE pivex OPTION_LIST='PivotCol=wk,FncCol=amnt,port=$PORT' +SELECT * FROM pivex; +DROP TABLE pivex; +DROP TABLE expenses; + +--echo # +--echo # Make the PETS table +--echo # +CREATE TABLE pets ( +Name VARCHAR(12) NOT NULL, +Race CHAR(6) NOT NULL, +Number INT NOT NULL) ENGINE=MYISAM; +INSERT INTO pets VALUES('John','dog',2); +INSERT INTO pets VALUES('Bill','cat',1); +INSERT INTO pets VALUES('Mary','dog',1); +INSERT INTO pets VALUES('Mary','cat',1); +INSERT INTO pets VALUES('Lisbeth','rabbit',2); +INSERT INTO pets VALUES('Kevin','cat',2); +INSERT INTO pets VALUES('Kevin','bird',6); +INSERT INTO pets VALUES('Donald','dog',1); +INSERT INTO pets VALUES('Donald','fish',3); +SELECT * FROM pets; + +--echo # +--echo # Pivot the PETS table +--echo # +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1, +rabbit INT NOT NULL DEFAULT 0 FLAG=1, +bird INT NOT NULL DEFAULT 0 FLAG=1, +fish INT NOT NULL DEFAULT 0 FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +SELECT * FROM pivet; +DROP TABLE pivet; + +--echo # +--echo # Testing the "data" column list +--echo # +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +--error ER_GET_ERRMSG +SELECT * FROM pivet; +ALTER TABLE pivet OPTION_LIST='PivotCol=race,groupby=1,accept=1'; +SELECT * FROM pivet; +DROP TABLE pivet; + +--echo # +--echo # Adding a "dump" column +--echo # +CREATE TABLE pivet ( +name VARCHAR(12) NOT NULL, +dog INT NOT NULL DEFAULT 0 FLAG=1, +cat INT NOT NULL DEFAULT 0 FLAG=1, +other INT NOT NULL DEFAULT 0 FLAG=2) +ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; +SELECT * FROM pivet; + +DROP TABLE pivet; +DROP TABLE pets; +--remove_file $MYSQLD_DATADIR/test/expenses.txt diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 5eb55c4a29b..6884c1c4176 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -24,8 +24,8 @@ #define DOS_BUFF_LEN 100 /* Number of lines in binary file buffer */ #undef DOMAIN /* For Unix version */ -enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Correl Block */ - TYPE_COLUMN = 51, /* Column Name/Correl Block */ +enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */ + TYPE_COLUMN = 51, /* Column Name/Qualifier Block */ // TYPE_OPVAL = 52, /* Operator value (OPVAL) */ TYPE_TDB = 53, /* Table Description Block */ TYPE_COLBLK = 54, /* Column Description Block */ diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 693ae96cf52..426401a0c47 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -147,6 +147,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize) if (!(g = malloc(sizeof(GLOBAL)))) { fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL)); + return NULL; } else { g->Sarea_Size = worksize; g->Trace = 0; @@ -180,7 +181,9 @@ int PlugExit(PGLOBAL g) if (!g) return rc; - free(g->Sarea); + if (g->Sarea) + free(g->Sarea); + free(g); return rc; } /* end of PlugExit */ diff --git a/storage/connect/tabcol.cpp b/storage/connect/tabcol.cpp index f0e010291c3..9af52043f0c 100644 --- a/storage/connect/tabcol.cpp +++ b/storage/connect/tabcol.cpp @@ -1,7 +1,7 @@ /************* TabCol C++ Functions Source Code File (.CPP) ************/ -/* Name: TABCOL.CPP Version 2.6 */ +/* Name: TABCOL.CPP Version 2.7 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */ /* */ /* This file contains the PlugDB++ XTAB, COLUMN and XORDER methods. */ /***********************************************************************/ @@ -23,18 +23,18 @@ #include "tabcol.h" /***********************************************************************/ -/* XTAB public constructor (in which Correl defaults to Name). */ +/* XTAB public constructor. */ /***********************************************************************/ -XTAB::XTAB(LPCSTR name, LPCSTR correl) : Name(name) +XTAB::XTAB(LPCSTR name, LPCSTR srcdef) : Name(name) { Next = NULL; To_Tdb = NULL; - Correl = (correl) ? correl : name; + Srcdef = srcdef; Creator = NULL; Qualifier = NULL; #ifdef DEBTRACE - htrc(" making new TABLE %s %s\n", Name, Correl); + htrc(" making new TABLE %s %s\n", Name, Srcdef); #endif } // end of XTAB constructor @@ -45,12 +45,12 @@ XTAB::XTAB(PTABLE tp) : Name(tp->Name) { Next = NULL; To_Tdb = NULL; - Correl = tp->Correl; + Srcdef = tp->Srcdef; Creator = tp->Creator; Qualifier = tp->Qualifier; #ifdef DEBTRACE - htrc(" making copy TABLE %s %s\n", Name, Correl); + htrc(" making copy TABLE %s %s\n", Name, Srcdef); #endif } // end of XTAB constructor @@ -83,7 +83,7 @@ void XTAB::Print(PGLOBAL g, FILE *f, uint n) for (PTABLE tp = this; tp; tp = tp->Next) { fprintf(f, "%sTABLE: %s.%s %s\n", - m, SVP(tp->Creator), tp->Name, SVP(tp->Correl)); + m, SVP(tp->Creator), tp->Name, SVP(tp->Srcdef)); PlugPutOut(g, f, TYPE_TDB, tp->To_Tdb, n + 2); } /* endfor tp */ @@ -101,7 +101,7 @@ void XTAB::Print(PGLOBAL g, char *ps, uint z) for (PTABLE tp = this; tp && n > 0; tp = tp->Next) { i = sprintf(buf, "TABLE: %s.%s %s To_Tdb=%p ", - SVP(tp->Creator), tp->Name, SVP(tp->Correl), tp->To_Tdb); + SVP(tp->Creator), tp->Name, SVP(tp->Srcdef), tp->To_Tdb); strncat(ps, buf, n); n -= i; } // endif tp diff --git a/storage/connect/tabcol.h b/storage/connect/tabcol.h index 4680e50f29e..20e23b80225 100644 --- a/storage/connect/tabcol.h +++ b/storage/connect/tabcol.h @@ -1,7 +1,7 @@ /*************** TabCol H Declares Source Code File (.H) ***************/ -/* Name: TABCOL.H Version 2.7 */ +/* Name: TABCOL.H Version 2.8 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */ /* */ /* This file contains the XTAB, COLUMN and XORDER class definitions. */ /***********************************************************************/ @@ -15,23 +15,23 @@ /***********************************************************************/ /* Definition of class XTAB with all its method functions. */ /***********************************************************************/ -class DllExport XTAB: public BLOCK { // Table Name-Owner-Correl block. +class DllExport XTAB: public BLOCK { // Table Name-Owner-Srcdef block. friend class TDBPRX; public: // Constructors - XTAB(LPCSTR name, LPCSTR correl = NULL); + XTAB(LPCSTR name, LPCSTR srcdef = NULL); XTAB(PTABLE tp); // Implementation PTABLE GetNext(void) {return Next;} PTDB GetTo_Tdb(void) {return To_Tdb;} LPCSTR GetName(void) {return Name;} - LPCSTR GetCorrel(void) {return Correl;} + LPCSTR GetSrc(void) {return Srcdef;} LPCSTR GetCreator(void) {return Creator;} LPCSTR GetQualifier(void) {return Qualifier;} void SetTo_Tdb(PTDB tdbp) {To_Tdb = tdbp;} void SetName(LPCSTR name) {Name = name;} - void SetCorrel(LPCSTR correl) {Correl = correl;} + void SetSrc(LPCSTR srcdef) {Srcdef = srcdef;} void SetCreator(LPCSTR crname) {Creator = crname;} void SetQualifier(LPCSTR qname) {Qualifier = qname;} @@ -44,8 +44,8 @@ class DllExport XTAB: public BLOCK { // Table Name-Owner-Correl block. // Members PTABLE Next; // Points to next table in chain PTDB To_Tdb; // Points to Table description Block - LPCSTR Name; // Table name (can be changed by LNA and PLG) - LPCSTR Correl; // Correlation name + LPCSTR Name; // Table name + LPCSTR Srcdef; // Table Source definition LPCSTR Creator; // Creator name LPCSTR Qualifier; // Qualifier name }; // end of class XTAB diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index aaa32a57f04..860a1304a14 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -1088,7 +1088,12 @@ bool TDBFMT::OpenDB(PGLOBAL g) { Linenum = 0; - if (Use != USE_OPEN && (Columns || Mode == MODE_UPDATE)) { + if (Mode == MODE_INSERT || Mode == MODE_UPDATE) { + sprintf(g->Message, MSG(FMT_WRITE_NIY), "FMT"); + return true; // NIY + } // endif Mode + + if (Use != USE_OPEN && Columns) { // Make the formats used to read records PSZ pfm; int i, n; @@ -1096,17 +1101,12 @@ bool TDBFMT::OpenDB(PGLOBAL g) PCOLDEF cdp; PDOSDEF tdp = (PDOSDEF)To_Def; -// if (Mode != MODE_UPDATE) { - for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next) - if (!colp->IsSpecial()) // Not a pseudo column - Fields = max(Fields, (int)colp->Fldnum); + for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next) + if (!colp->IsSpecial()) // Not a pseudo column + Fields = max(Fields, (int)colp->Fldnum); - if (Columns) - Fields++; // Fldnum was 0 based - -// } else -// for (cdp = tdp->GetCols(); cdp; cdp = cdp->GetNext()) -// Fields++; + if (Columns) + Fields++; // Fldnum was 0 based To_Fld = PlugSubAlloc(g, NULL, Lrecl + 1); FldFormat = (PSZ*)PlugSubAlloc(g, NULL, sizeof(PSZ) * Fields); diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 3ecfd6aa6c1..c9bb47792f5 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -79,9 +79,11 @@ MYSQLDEF::MYSQLDEF(void) Hostname = NULL; Database = NULL; Tabname = NULL; + Srcdef = NULL; Username = NULL; Password = NULL; Portnumber = 0; + Isview = FALSE; Bind = FALSE; Delayed = FALSE; } // end of MYSQLDEF constructor @@ -302,8 +304,8 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) } else { // MYSQL access from a PROXY table, not using URL Database = Cat->GetStringCatInfo(g, "Database", "*"); - Tabname = Cat->GetStringCatInfo(g, "Name", Name); // Deprecated - Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); + Tabname = Name; + Isview = Cat->GetBoolCatInfo("View", FALSE); // We must get connection parms from the calling table Remove_tshp(Cat); @@ -313,6 +315,9 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Portnumber = Cat->GetIntCatInfo("Port", mysqld_port); } // endif am + if ((Srcdef = Cat->GetStringCatInfo(g, "Srcdef", NULL))) + Isview = TRUE; + return FALSE; } // end of DefineAM @@ -339,18 +344,22 @@ TDBMYSQL::TDBMYSQL(PMYDEF tdp) : TDBASE(tdp) Host = tdp->GetHostname(); Database = tdp->GetDatabase(); Tabname = tdp->GetTabname(); + Srcdef = tdp->GetSrcdef(); User = tdp->GetUsername(); Pwd = tdp->GetPassword(); Port = tdp->GetPortnumber(); + Isview = tdp->Isview; Prep = tdp->Bind; Delayed = tdp->Delayed; } else { Host = NULL; Database = NULL; Tabname = NULL; + Srcdef = NULL; User = NULL; Pwd = NULL; Port = 0; + Isview = FALSE; Prep = FALSE; Delayed = FALSE; } // endif tdp @@ -370,9 +379,11 @@ TDBMYSQL::TDBMYSQL(PGLOBAL g, PTDBMY tdbp) : TDBASE(tdbp) Host = tdbp->Host; Database = tdbp->Database; Tabname = tdbp->Tabname; + Srcdef = tdbp->Srcdef; User = tdbp->User; Pwd = tdbp->Pwd; Port = tdbp->Port; + Isview = tdbp->Isview; Prep = tdbp->Prep; Delayed = tdbp->Delayed; Bind = NULL; @@ -418,55 +429,54 @@ PCOL TDBMYSQL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ bool TDBMYSQL::MakeSelect(PGLOBAL g) { - char *colist; char *tk = "`"; - int len = 0, ncol = 0, rank = 0; + int rank = 0; bool b = FALSE; PCOL colp; - PDBUSER dup = PlgGetUser(g); +//PDBUSER dup = PlgGetUser(g); if (Query) return FALSE; // already done - for (colp = Columns; colp; colp = colp->GetNext()) - ncol++; + if (Srcdef) { + Query = Srcdef; + return false; + } // endif Srcdef - if (ncol) { - colist = (char*)PlugSubAlloc(g, NULL, (NAM_LEN + 4) * ncol); - *colist = '\0'; + //Find the address of the suballocated query + Query = (char*)PlugSubAlloc(g, NULL, 0); + strcpy(Query, "SELECT "); + if (Columns) { for (colp = Columns; colp; colp = colp->GetNext()) if (colp->IsSpecial()) { strcpy(g->Message, MSG(NO_SPEC_COL)); return TRUE; } else { if (b) - strcat(colist, ", "); + strcat(Query, ", "); else b = TRUE; - strcat(strcat(strcat(colist, tk), colp->GetName()), tk); + strcat(strcat(strcat(Query, tk), colp->GetName()), tk); ((PMYCOL)colp)->Rank = rank++; } // endif colp } else { - // ncol == 0 can occur for queries such as Query count(*) from... - // for which we will count the rows from Query '*' from... + // ncol == 0 can occur for views or queries such as + // Query count(*) from... for which we will count the rows from + // Query '*' from... // (the use of a char constant minimize the result storage) - colist = (char*)PlugSubAlloc(g, NULL, 2); - strcpy(colist, "'*'"); + strcat(Query, (Isview) ? "*" : "'*'"); } // endif ncol - // Below 32 is space to contain extra stuff - len += (strlen(colist) + strlen(Tabname) + 32); - len += (To_Filter ? strlen(To_Filter) + 7 : 0); - Query = (char*)PlugSubAlloc(g, NULL, len); - strcat(strcpy(Query, "SELECT "), colist); strcat(strcat(strcat(strcat(Query, " FROM "), tk), Tabname), tk); if (To_Filter) strcat(strcat(Query, " WHERE "), To_Filter); + // Now we know how much to suballocate + PlugSubAlloc(g, NULL, strlen(Query) + 1); return FALSE; } // end of MakeSelect @@ -751,7 +761,7 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) /* Table already open, just replace it at its beginning. */ /*******************************************************************/ Myc.Rewind(); - return FALSE; + return false; } // endif use /*********************************************************************/ @@ -763,7 +773,7 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) /*********************************************************************/ if (!Myc.Connected()) { if (Myc.Open(g, Host, Database, User, Pwd, Port)) - return TRUE; + return true; } // endif Connected @@ -774,7 +784,24 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) if (!MakeSelect(g)) m_Rc = Myc.ExecSQL(g, Query); +#if 0 + if (!Myc.m_Res || !Myc.m_Fields) { + sprintf(g->Message, "%s result", (Myc.m_Res) ? "Void" : "No"); + Myc.Close(); + return true; + } // endif m_Res +#endif // 0 + + if (Srcdef) + if (SetColumnRanks(g)) + return true; + } else if (Mode == MODE_INSERT) { + if (Srcdef) { + strcpy(g->Message, "No insert into anonym views"); + return true; + } // endif Srcdef + if (!MakeInsert(g)) { #if defined(MYSQL_PREPARED_STATEMENTS) int n = (Prep) ? Myc.PrepareSQL(g, Query) : Nparm; @@ -826,6 +853,55 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) return FALSE; } // end of OpenDB +/***********************************************************************/ +/* Set the rank of columns in the result set. */ +/***********************************************************************/ +bool TDBMYSQL::SetColumnRanks(PGLOBAL g) + { + for (PCOL colp = Columns; colp; colp = colp->GetNext()) + if (((PMYCOL)colp)->FindRank(g)) + return TRUE; + + return FALSE; + } // end of SetColumnRanks + +/***********************************************************************/ +/* Called by Parent table to make the columns of a View. */ +/***********************************************************************/ +PCOL TDBMYSQL::MakeFieldColumn(PGLOBAL g, char *name) + { + int n; + MYSQL_FIELD *fld; + PCOL cp, colp = NULL; + + for (n = 0; n < Myc.m_Fields; n++) { + fld = &Myc.m_Res->fields[n]; + + if (!stricmp(name, fld->name)) { + colp = new(g) MYSQLCOL(fld, this, n); + + if (colp->InitValue(g)) + return NULL; + + if (!Columns) + Columns = colp; + else for (cp = Columns; cp; cp = cp->GetNext()) + if (!cp->GetNext()) { + cp->SetNext(colp); + break; + } // endif Next + + break; + } // endif name + + } // endfor n + + if (!colp) + sprintf(g->Message, "Column %s is not in view", name); + + return colp; + } // end of MakeFieldColumn + /***********************************************************************/ /* Data Base read routine for MYSQL access method. */ /***********************************************************************/ @@ -939,7 +1015,7 @@ MYSQLCOL::MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) tdbp->SetColumns(this); } // endif cprec - // Set additional Dos access method information for column. + // Set additional MySQL access method information for column. Long = cdp->GetLong(); Bind = NULL; To_Val = NULL; @@ -951,6 +1027,33 @@ MYSQLCOL::MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) } // end of MYSQLCOL constructor +/***********************************************************************/ +/* MYSQLCOL public constructor. */ +/***********************************************************************/ +MYSQLCOL::MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am) + : COLBLK(NULL, tdbp, i) + { + Name = fld->name; + Opt = 0; + Long = fld->length; + Buf_Type = MYSQLtoPLG(fld->type); + strcpy(Format.Type, GetFormatType(Buf_Type)); + Format.Length = Long; + Format.Prec = fld->decimals; + ColUse = U_P; + Nullable = !IS_NOT_NULL(fld->flags); + + // Set additional MySQL access method information for column. + Bind = NULL; + To_Val = NULL; + Slen = 0; + Rank = i; + + if (trace) + htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); + + } // end of MYSQLCOL constructor + /***********************************************************************/ /* MYSQLCOL constructor used for copying columns. */ /* tdbp is the pointer to the new table descriptor. */ @@ -964,6 +1067,24 @@ MYSQLCOL::MYSQLCOL(MYSQLCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp) Rank = col1->Rank; } // end of MYSQLCOL copy constructor +/***********************************************************************/ +/* FindRank: Find the rank of this column in the result set. */ +/***********************************************************************/ +bool MYSQLCOL::FindRank(PGLOBAL g) +{ + int n; + MYSQLC myc = ((PTDBMY)To_Tdb)->Myc; + + for (n = 0; n < myc.m_Fields; n++) + if (!stricmp(Name, myc.m_Res->fields[n].name)) { + Rank = n; + return false; + } // endif Name + + sprintf(g->Message, "Column %s not in result set", Name); + return true; +} // end of FindRank + /***********************************************************************/ /* SetBuffer: prepare a column block for write operation. */ /***********************************************************************/ @@ -1049,11 +1170,6 @@ void MYSQLCOL::ReadColumn(PGLOBAL g) int rc; PTDBMY tdbp = (PTDBMY)To_Tdb; - if (trace) - htrc("MySQL ReadColumn: name=%s\n", Name); - - assert (Rank >= 0); - /*********************************************************************/ /* If physical fetching of the line was deferred, do it now. */ /*********************************************************************/ @@ -1066,14 +1182,17 @@ void MYSQLCOL::ReadColumn(PGLOBAL g) } else tdbp->Fetched = TRUE; - if ((buf = ((PTDBMY)To_Tdb)->Myc.GetCharField(Rank))) + if ((buf = ((PTDBMY)To_Tdb)->Myc.GetCharField(Rank))) { + if (trace) + htrc("MySQL ReadColumn: name=%s buf=%s\n", Name, buf); + Value->SetValue_char(buf, Long); - else { + } else { if (Nullable) Value->SetNull(true); Value->Reset(); // Null value - } // endelse + } // endif buf } // end of ReadColumn @@ -1121,5 +1240,5 @@ TDBMCL::TDBMCL(PMYDEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBMCL::GetResult(PGLOBAL g) { - return MyColumns(g, Host, Db, User, Pwd, Tab, NULL, Port, false, false); + return MyColumns(g, Host, Db, User, Pwd, Tab, NULL, Port, false); } // end of GetResult diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h index 56d21550df6..5d8f32e9f21 100644 --- a/storage/connect/tabmysql.h +++ b/storage/connect/tabmysql.h @@ -30,6 +30,7 @@ class MYSQLDEF : public TABDEF {/* Logical table description */ inline PSZ GetHostname(void) {return Hostname;}; inline PSZ GetDatabase(void) {return Database;}; inline PSZ GetTabname(void) {return Tabname;} + inline PSZ GetSrcdef(void) {return Srcdef;} inline PSZ GetUsername(void) {return Username;}; inline PSZ GetPassword(void) {return Password;}; inline int GetPortnumber(void) {return Portnumber;} @@ -44,9 +45,11 @@ class MYSQLDEF : public TABDEF {/* Logical table description */ PSZ Hostname; /* Host machine to use */ PSZ Database; /* Database to be used by server */ PSZ Tabname; /* External table name */ + PSZ Srcdef; /* The source table SQL definition */ PSZ Username; /* User logon name */ PSZ Password; /* Password logon info */ int Portnumber; /* MySQL port number (0 = default) */ + bool Isview; /* TRUE if this table is a MySQL view */ bool Bind; /* Use prepared statement on insert */ bool Delayed; /* Delayed insert */ }; // end of MYSQLDEF @@ -72,6 +75,7 @@ class TDBMYSQL : public TDBASE { virtual int GetProgMax(PGLOBAL g); virtual void ResetDB(void) {N = 0;} virtual int RowNumber(PGLOBAL g, bool b = FALSE); + virtual bool IsView(void) {return Isview;} void SetDatabase(LPCSTR db) {Database = (char*)db;} // Database routines @@ -83,6 +87,10 @@ class TDBMYSQL : public TDBASE { virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g); + // Specific routines + bool SetColumnRanks(PGLOBAL g); + PCOL MakeFieldColumn(PGLOBAL g, char *name); + protected: // Internal functions bool MakeSelect(PGLOBAL g); @@ -99,9 +107,11 @@ class TDBMYSQL : public TDBASE { char *Pwd; // Password logon info char *Database; // Database to be used by server char *Tabname; // External table name + char *Srcdef; // The source table SQL definition char *Query; // Points to SQL query - char *Qbuf; // Used for not prepared insert + char *Qbuf; // Used for not prepared insert bool Fetched; // True when fetch was done + bool Isview; // True if this table is a MySQL view bool Prep; // Use prepared statement on insert bool Delayed; // Use delayed insert int m_Rc; // Return code from command @@ -119,6 +129,7 @@ class MYSQLCOL : public COLBLK { public: // Constructors MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "MYSQL"); + MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am = "MYSQL"); MYSQLCOL(MYSQLCOL *colp, PTDB tdbp); // Constructor used in copy process // Implementation @@ -129,6 +140,7 @@ class MYSQLCOL : public COLBLK { virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual void ReadColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g); + bool FindRank(PGLOBAL g); protected: // Default constructor not to be used diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 2f721c6a7cf..6c33aefbb68 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -85,19 +85,43 @@ PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m) /***********************************************************************/ TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp) { -//Tdbp = NULL; // Source table +//Tdbp = NULL; // Source table (in TDBPRX) Tabname = tdp->Tablep->GetName(); // Name of source table - Colist = tdp->Colist; // List of source columns - Xcolumn = tdp->Xcol; // Occur column name - Rcolumn = tdp->Rcol; // Rank column name - Xcolp = NULL; // To the OCCURCOL column - Col = NULL; // To source column blocks array - Mult = -1; // Multiplication factor - N = 0; // The current table index - M = 0; // The occurence rank - RowFlag = 0; // 0: Ok, 1: Same, 2: Skip + Colist = tdp->Colist; // List of source columns + Xcolumn = tdp->Xcol; // Occur column name + Rcolumn = tdp->Rcol; // Rank column name + Xcolp = NULL; // To the OCCURCOL column + Col = NULL; // To source column blocks array + Mult = PrepareColist(); // Multiplication factor + N = 0; // The current table index + M = 0; // The occurence rank + RowFlag = 0; // 0: Ok, 1: Same, 2: Skip } // end of TDBOCCUR constructor +/***********************************************************************/ +/* Prepare and count columns in the column list. */ +/***********************************************************************/ +int TDBOCCUR::PrepareColist(void) + { + char *p, *pn; + int n = 0; + + // Count the number of columns and change separator into null char + for (pn = Colist; ; pn += (strlen(pn) + 1)) + // Separator can be ; if colist was specified in the option_list + if ((p = strchr(pn, ',')) || (p = strchr(pn, ';'))) { + *p++ = '\0'; + n++; + } else { + if (*pn) + n++; + + break; + } // endif p + + return n; + } // end of PrepareColist + /***********************************************************************/ /* Allocate OCCUR/SRC column description block. */ /***********************************************************************/ @@ -111,14 +135,8 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) } else if (!stricmp(cdp->GetName(), Xcolumn)) { // Allocate the OCCUR column colp = Xcolp = new(g) OCCURCOL(cdp, this, n); - } else { - colp = new(g) PRXCOL(cdp, this, cprec, n); - - if (((PPRXCOL)colp)->Init(g)) - return NULL; - - return colp; - } //endif name + } else + return new(g) PRXCOL(cdp, this, cprec, n); if (cprec) { colp->SetNext(cprec->GetNext()); @@ -136,75 +154,100 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ bool TDBOCCUR::InitTable(PGLOBAL g) { - if (!Tdbp) { + if (!Tdbp) // Get the table description block of this table - if (!(Tdbp = (PTDBASE)GetSubTable(g, ((POCCURDEF)To_Def)->Tablep))) + if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE))) return TRUE; - if (MakeColumnList(g) < 0) + if (!Tdbp->IsView()) + if (MakeColumnList(g)) return TRUE; - } // endif Tdbp - return FALSE; } // end of InitTable /***********************************************************************/ /* Allocate OCCUR column description block. */ /***********************************************************************/ -int TDBOCCUR::MakeColumnList(PGLOBAL g) +bool TDBOCCUR::MakeColumnList(PGLOBAL g) { - if (Mult < 0) { - char *p, *pn; - int i; - int n = 0; + char *pn; + int i; + PCOL colp; - // Count the number of columns and change separator into null char - for (pn = Colist; ; pn += (strlen(pn) + 1)) - if ((p = strchr(pn, ',')) || (p = strchr(pn, ';'))) { - *p++ = '\0'; - n++; - } else { - if (*pn) - n++; + for (colp = Columns; colp; colp = colp->GetNext()) + if (colp->GetAmType() == TYPE_AM_PRX) + if (((PPRXCOL)colp)->Init(g)) + return true; - break; - } // endif p + Col = (PCOL*)PlugSubAlloc(g, NULL, Mult * sizeof(PCOL)); - Col = (PCOL*)PlugSubAlloc(g, NULL, n * sizeof(PCOL)); + for (i = 0, pn = Colist; i < Mult; i++, pn += (strlen(pn) + 1)) { + if (!(Col[i] = Tdbp->ColDB(g, pn, 0))) { + // Column not found in table + sprintf(g->Message, MSG(COL_ISNOT_TABLE), pn, Tabname); + return true; + } // endif Col - for (i = 0, pn = Colist; i < n; i++, pn += (strlen(pn) + 1)) { - if (!(Col[i] = Tdbp->ColDB(g, pn, 0))) { - // Column not found in table - sprintf(g->Message, MSG(COL_ISNOT_TABLE), pn, Tabname); - return -1; - } // endif Col + if (Col[i]->InitValue(g)) { + strcpy(g->Message, "OCCUR InitValue failed"); + return true; + } // endif InitValue - if (Col[i]->InitValue(g)) { - strcpy(g->Message, "OCCUR InitValue failed"); - return -1; - } // endif InitValue + } // endfor i - } // endfor i - - // OCCUR column name defaults to the name of the list first column - if (!Xcolumn) - Xcolumn = Colist; - - Mult = n; - } // endif Mult - - return Mult; + return false; } // end of MakeColumnList +/***********************************************************************/ +/* Allocate OCCUR column description block for a view. */ +/***********************************************************************/ +bool TDBOCCUR::ViewColumnList(PGLOBAL g) + { + char *pn; + int i; + PCOL colp, cp; + PTDBMY tdbp; + + if (!Tdbp->IsView()) + return false; + + if (Tdbp->GetAmType() != TYPE_AM_MYSQL) { + strcpy(g->Message, "View is not MySQL"); + return true; + } else + tdbp = (PTDBMY)Tdbp; + + for (cp = Columns; cp; cp = cp->GetNext()) + if (cp->GetAmType() == TYPE_AM_PRX) { + if ((colp = tdbp->MakeFieldColumn(g, cp->GetName()))) { + ((PPRXCOL)cp)->Colp = colp; + ((PPRXCOL)cp)->To_Val = colp->GetValue(); + } else + return true; + + } // endif Type + + Col = (PCOL*)PlugSubAlloc(g, NULL, Mult * sizeof(PCOL)); + + for (i = 0, pn = Colist; i < Mult; i++, pn += (strlen(pn) + 1)) + if (!(Col[i] = tdbp->MakeFieldColumn(g, pn))) { + // Column not found in table + sprintf(g->Message, MSG(COL_ISNOT_TABLE), pn, Tabname); + return true; + } // endif Col + + return false; + } // end of ViewColumnList + /***********************************************************************/ /* OCCUR GetMaxSize: returns the maximum number of rows in the table. */ /***********************************************************************/ int TDBOCCUR::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { - if (InitTable(g)) - return NULL; + if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE))) + return 0; MaxSize = Mult * Tdbp->GetMaxSize(g); } // endif MaxSize @@ -252,7 +295,7 @@ bool TDBOCCUR::OpenDB(PGLOBAL g) /* Do it here if not done yet. */ /*********************************************************************/ if (InitTable(g)) - return NULL; + return TRUE; if (Xcolp) // Lock this column so it is evaluated by its table only @@ -269,7 +312,10 @@ bool TDBOCCUR::OpenDB(PGLOBAL g) /*********************************************************************/ /* Do open the source table. */ /*********************************************************************/ - return Tdbp->OpenDB(g); + if (Tdbp->OpenDB(g)) + return TRUE; + + return ViewColumnList(g); } // end of OpenDB /***********************************************************************/ diff --git a/storage/connect/taboccur.h b/storage/connect/taboccur.h index 076202be477..b7d51e05b7d 100644 --- a/storage/connect/taboccur.h +++ b/storage/connect/taboccur.h @@ -52,21 +52,22 @@ class TDBOCCUR : public TDBPRX { TDBOCCUR(POCCURDEF tdp); // Implementation - virtual AMT GetAmType(void) {return TYPE_AM_OCCUR;} - void SetTdbp(PTDBASE tdbp) {Tdbp = tdbp;} + virtual AMT GetAmType(void) {return TYPE_AM_OCCUR;} + void SetTdbp(PTDBASE tdbp) {Tdbp = tdbp;} // Methods - virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} - virtual int RowNumber(PGLOBAL g, bool b = FALSE); - PTDB GetSourceTable(PGLOBAL g); - int MakeColumnList(PGLOBAL g); + virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} + virtual int RowNumber(PGLOBAL g, bool b = FALSE); + int PrepareColist(void); + bool MakeColumnList(PGLOBAL g); + bool ViewColumnList(PGLOBAL g); // Database routines - virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual bool InitTable(PGLOBAL g); - virtual int GetMaxSize(PGLOBAL g); - virtual bool OpenDB(PGLOBAL g); - virtual int ReadDB(PGLOBAL g); + virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); + virtual bool InitTable(PGLOBAL g); + virtual int GetMaxSize(PGLOBAL g); + virtual bool OpenDB(PGLOBAL g); + virtual int ReadDB(PGLOBAL g); protected: // Members diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 4ae1b3ceae6..1a73f353970 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -1,7 +1,7 @@ /************ TabPivot C++ Program Source Code File (.CPP) *************/ /* PROGRAM NAME: TABPIVOT */ /* ------------- */ -/* Version 1.4 */ +/* Version 1.5 */ /* */ /* COPYRIGHT: */ /* ---------- */ @@ -41,11 +41,9 @@ #include "global.h" #include "plgdbsem.h" #include "xtable.h" -//#include "xindex.h" #include "tabcol.h" #include "colblk.h" -//#include "tabmysql.h" -#include "myconn.h" +#include "tabmysql.h" #include "csort.h" #include "tabutil.h" #include "tabpivot.h" @@ -55,381 +53,6 @@ extern "C" int trace; -#if 0 -/***********************************************************************/ -/* Prepare the source table Query. */ -/***********************************************************************/ -PQRYRES TDBPIVOT::GetSourceTable(PGLOBAL g) - { - if (Qryp) - return Qryp; // Already done - - if (Tabname) { - char *def, *colist; - size_t len = 0; - PCOL colp; - PDBUSER dup = (PDBUSER)g->Activityp->Aptr; - - if (InitTable(g)) - return NULL; - - // Evaluate the length of the column list - for (colp = Tdbp->Columns; colp; colp = colp->GetNext()) - len += (strlen(colp->GetName()) + 2); - - *(colist = (char*)PlugSubAlloc(g, NULL, len)) = 0; - - // Locate the suballocated string (size is not known yet) - def = (char*)PlugSubAlloc(g, NULL, 0); - strcpy(def, "SELECT "); - - if (!Fncol) { - for (colp = Tdbp->Columns; colp; colp = colp->GetNext()) - if (!Picol || stricmp(Picol, colp->GetName())) - Fncol = colp->GetName(); - - if (!Fncol) { - strcpy(g->Message, MSG(NO_DEF_FNCCOL)); - return NULL; - } // endif Fncol - - } else if (!(ColDB(g, Fncol, 0))) { - // Function column not found in table - sprintf(g->Message, MSG(COL_ISNOT_TABLE), Fncol, Tabname); - return NULL; - } // endif Fcolp - - if (!Picol) { - // Find default Picol as the last one not equal to Fncol - for (colp = Tdbp->Columns; colp; colp = colp->GetNext()) - if (!Fncol || stricmp(Fncol, colp->GetName())) - Picol = colp->GetName(); - - if (!Picol) { - strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); - return NULL; - } // endif Picol - - } else if (!(ColDB(g, Picol, 0))) { - // Pivot column not found in table - sprintf(g->Message, MSG(COL_ISNOT_TABLE), Picol, Tabname); - return NULL; - } // endif Xcolp - - // Make the other column list - for (colp = Columns; colp; colp = colp->GetNext()) - if (stricmp(Picol, colp->GetName()) && - stricmp(Fncol, colp->GetName())) - strcat(strcat(colist, colp->GetName()), ", "); - - // Add the Pivot column at the end of the list - strcat(strcat(def, strcat(colist, Picol)), ", "); - - // Continue making the definition - if (!GBdone) { - // Make it suitable for Pivot by doing the group by - strcat(strcat(def, Function), "("); - strcat(strcat(strcat(def, Fncol), ") "), Fncol); - strcat(strcat(def, " FROM "), Tabname); - strcat(strcat(def, " GROUP BY "), colist); - } else // Gbdone - strcat(strcat(strcat(def, Fncol), " FROM "), Tabname); - - // Now we know how much was suballocated - Tabsrc = (char*)PlugSubAlloc(g, NULL, strlen(def)); - } else { - strcpy(g->Message, MSG(SRC_TABLE_UNDEF)); - return NULL; - } // endif Tabsrc - - int w; - - // Open a MySQL connection for this table - if (Myc.Open(g, Host, Database, User, Pwd, Port)) - return NULL; - - // Send the source command to MySQL - if (Myc.ExecSQL(g, Tabsrc, &w) == RC_FX) { - Myc.Close(); - return NULL; - } // endif Exec - - // We must have a storage query to get pivot column values - Qryp = Myc.GetResult(g); - Myc.Close(); - Tqrp = new(g) TDBQRS(Qryp); - Tqrp->OpenDB(g); - - if (MakePivotColumns(g) < 0) - return NULL; - - return Qryp; - } // end of GetSourceTable - -/***********************************************************************/ -/* Allocate PIVOT columns description block. */ -/***********************************************************************/ -int TDBPIVOT::MakePivotColumns(PGLOBAL g) - { - if (Mult < 0) { - int ndif, n = 0, nblin = Qryp->Nblin; - PVAL valp; - PCOL cp; - PSRCCOL colp; - PFNCCOL cfnp; - - // Allocate all the source columns - Tqrp->ColDB(g, NULL, 0); - Columns = NULL; // Discard dummy columns blocks - - for (cp = Tqrp->GetColumns(); cp; cp = cp->GetNext()) { - if (cp->InitValue(g)) - return -1; - - if (!stricmp(cp->GetName(), Picol)) { - Xcolp = (PQRSCOL)cp; - Xresp = Xcolp->GetCrp(); - Rblkp = Xresp->Kdata; - } else if (!stricmp(cp->GetName(), Fncol)) { - Fcolp = (PQRSCOL)cp; - } else - if ((colp = new(g) SRCCOL(cp, this, ++n))->Init(g, this)) - return -1; - - } // endfor cp - - if (!Xcolp) { - sprintf(g->Message, MSG(COL_ISNOT_TABLE), - Picol, Tabname ? Tabname : "TabSrc"); - return -1; - } else if (!Fcolp) { - sprintf(g->Message, MSG(COL_ISNOT_TABLE), - Fncol, Tabname ? Tabname : "TabSrc"); - return -1; - } // endif Fcolp - - // Before calling sort, initialize all - Index.Size = nblin * sizeof(int); - Index.Sub = TRUE; // Should be small enough - - if (!PlgDBalloc(g, NULL, Index)) - return -1; - - Offset.Size = (nblin + 1) * sizeof(int); - Offset.Sub = TRUE; // Should be small enough - - if (!PlgDBalloc(g, NULL, Offset)) - return -2; - - ndif = Qsort(g, nblin); - - if (ndif < 0) { // error - return -3; - } else - Ncol = ndif; - - // Now make the functional columns - for (int i = 0; i < Ncol; i++) { - // Allocate the Value used to retieve column names - if (!(valp = AllocateValue(g, Xcolp->GetResultType(), - Xcolp->GetLengthEx(), Xcolp->GetPrecision(), - Xcolp->GetDomain(), Xcolp->GetTo_Tdb()->GetCat()))) - return -4; - - // Get the value that will be the generated column name - valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]); - - // Copy the functional column with new Name and new Value - cfnp = (PFNCCOL)new(g) FNCCOL(Fcolp, this); - - // Initialize the generated column - if (cfnp->InitColumn(g, valp)) - return -5; - - } // endfor i - - // Fields must be updated for ha_connect -// if (UpdateTableFields(g, n + Ncol)) -// return -6; - - // This should be refined later - Mult = nblin; - } // endif Mult - - return Mult; - } // end of MakePivotColumns - -/***********************************************************************/ -/* Update fields in the MySQL table structure */ -/* Note: this does not work. Indeed the new rows are correctly made */ -/* but the final result still specify the unmodified table and the */ -/* returned table only contains the original column values. */ -/* In addition, a new query on the table, when it is into the cache, */ -/* specifies all the new columns and fails because they do not belong */ -/* to the original table. */ -/***********************************************************************/ -bool TDBPIVOT::UpdateTableFields(PGLOBAL g, int n) - { - uchar *trec, *srec, *tptr, *sptr; - int i = 0, k = 0; - uint len; - uint32 nmp, lwm; - size_t buffsize; - PCOL colp; - PHC hc = ((MYCAT*)((PIVOTDEF*)To_Def)->Cat)->GetHandler(); - TABLE *table = hc->GetTable(); - st_mem_root *tmr = &table->mem_root; - st_mem_root *smr = &table->s->mem_root; - Field* *field; - Field *fp, *tfncp, *sfncp; - Field* *ntf; - Field* *nsf; -//my_bitmap_map *org_bitmap; - const MY_BITMAP *map; - - // When sorting read_set selects all columns, so we use def_read_set - map= (const MY_BITMAP *)&table->def_read_set; - - // Find the function field - for (field= table->field; *field; field++) { - fp= *field; - - if (bitmap_is_set(map, fp->field_index)) - if (!stricmp(fp->field_name, Fncol)) { - tfncp = fp; - break; - } // endif Name - - } // endfor field - - for (field= table->s->field; *field; field++) { - fp= *field; - - if (bitmap_is_set(map, fp->field_index)) - if (!stricmp(fp->field_name, Fncol)) { - sfncp = fp; - break; - } // endif Name - - } // endfor field - - // Calculate the new buffer size - len = tfncp->max_data_length(); - buffsize = table->s->rec_buff_length + len * Ncol; - - // Allocate the new record space - if (!(tptr = trec = (uchar*)alloc_root(tmr, 2 * buffsize))) - return TRUE; - - if (!(sptr = srec = (uchar*)alloc_root(smr, 2 * buffsize))) - return TRUE; - - - // Allocate the array of all new table field pointers - if (!(ntf = (Field**)alloc_root(tmr, (uint)((n+1) * sizeof(Field*))))) - return TRUE; - - // Allocate the array of all new table share field pointers - if (!(nsf = (Field**)alloc_root(smr, (uint)((n+1) * sizeof(Field*))))) - return TRUE; - - // First fields are the the ones of the source columns - for (colp = Columns; colp; colp = colp->GetNext()) - if (colp->GetAmType() == TYPE_AM_SRC) { - for (field= table->field; *field; field++) { - fp= *field; - - if (bitmap_is_set(map, fp->field_index)) - if (!stricmp(colp->GetName(), fp->field_name)) { - ntf[i] = fp; - fp->field_index = i++; - fp->ptr = tptr; - tptr += fp->max_data_length(); - break; - } // endif Name - - } // endfor field - - for (field= table->s->field; *field; field++) { - fp= *field; - - if (bitmap_is_set(map, fp->field_index)) - if (!stricmp(colp->GetName(), fp->field_name)) { - nsf[k] = fp; - fp->field_index = k++; - fp->ptr = srec; - srec += fp->max_data_length(); - break; - } // endif Name - - } // endfor field - - } // endif AmType - - // Now add the pivot generated columns - for (colp = Columns; colp; colp = colp->GetNext()) - if (colp->GetAmType() == TYPE_AM_FNC) { - if ((fp = (Field*)memdup_root(tmr, (char*)tfncp, tfncp->size_of()))) { - ntf[i] = fp; - fp->ptr = tptr; - fp->field_name = colp->GetName(); - fp->field_index = i++; - fp->vcol_info = NULL; - fp->stored_in_db = TRUE; - tptr += len; - } else - return TRUE; - - if ((fp = (Field*)memdup_root(smr, (char*)sfncp, sfncp->size_of()))) { - nsf[i] = fp; - fp->ptr = sptr; - fp->field_name = colp->GetName(); - fp->field_index = k++; - fp->vcol_info = NULL; - fp->stored_in_db = TRUE; - sptr += len; - } else - return TRUE; - - } // endif AM_FNC - - // Mark end of the list - ntf[i] = NULL; - nsf[k] = NULL; - - // Update the table fields - nmp = (uint32)((1<field = ntf; - table->used_fields = i; - table->record[0] = trec; - table->record[1] = trec + buffsize; - *table->def_read_set.bitmap = nmp; - *table->def_read_set.last_word_ptr = nmp; - table->def_read_set.last_word_mask = lwm; - table->def_read_set.n_bits = i; - *table->read_set->bitmap = nmp; - *table->read_set->last_word_ptr = nmp; - table->read_set->last_word_mask = lwm; - table->read_set->n_bits = i; - table->write_set->n_bits = i; - *table->vcol_set->bitmap = 0; - table->vcol_set->n_bits = i; - - // and the share fields - table->s->field = nsf; - table->s->reclength = sptr - srec; - table->s->stored_rec_length = sptr - srec; - table->s->fields = k; - table->s->stored_fields = k; - table->s->rec_buff_length = buffsize; -//table->s->varchar_fields = ???; -//table->s->db_record_offset = ???; -//table->s->null_field_first = ???; - return FALSE; - } // end of UpdateTableFields -#endif // 0 - /* --------------- Implementation of the PIVOT classes --------------- */ /***********************************************************************/ @@ -451,13 +74,12 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) char *p1, *p2; PHC hc = ((MYCAT*)Cat)->GetHandler(); - if (!PRXDEF::DefineAM(g, am, poff)) { - Tabname = (char*)Tablep->GetName(); - DB = (char*)Tablep->GetQualifier(); - } else { - DB = Cat->GetStringCatInfo(g, "Database", "*"); - Tabsrc = Cat->GetStringCatInfo(g, "SrcDef", NULL); - } // endif + if (PRXDEF::DefineAM(g, am, poff)) + return TRUE; + + Tabname = (char*)Tablep->GetName(); + DB = (char*)Tablep->GetQualifier(); + Tabsrc = (char*)Tablep->GetSrc(); Host = Cat->GetStringCatInfo(g, "Host", "localhost"); User = Cat->GetStringCatInfo(g, "User", "*"); @@ -477,7 +99,7 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) GBdone = Cat->GetBoolCatInfo("Groupby", false); Accept = Cat->GetBoolCatInfo("Accept", false); Port = Cat->GetIntCatInfo("Port", 3306); - Desc = (Tabname) ? Tabname : Tabsrc; + Desc = (Tabsrc) ? Tabsrc : Tabname; return FALSE; } // end of DefineAM @@ -520,6 +142,25 @@ TDBPIVOT::TDBPIVOT(PPIVOTDEF tdp) : TDBPRX(tdp) RowFlag = 0; // 0: Ok, 1: Same, 2: Skip } // end of TDBPIVOT constructor +/***********************************************************************/ +/* Allocate source column description block. */ +/***********************************************************************/ +PCOL TDBPIVOT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) + { + PCOL colp; + + if (cdp->GetOffset()) { + colp = new(g) FNCCOL(cdp, this, cprec, n); + + if (cdp->GetOffset() > 1) + Dcolp = colp; + + } else + colp = new(g) SRCCOL(cdp, this, cprec, n); + + return colp; + } // end of MakeCol + /***********************************************************************/ /* Prepare the source table Query. */ /***********************************************************************/ @@ -528,72 +169,74 @@ bool TDBPIVOT::GetSourceTable(PGLOBAL g) if (Tdbp) return false; // Already done - if (Tabname) { - PTABDEF defp; - PCOLDEF cdp; - - if (InitTable(g)) + if (!Tabsrc && Tabname) { + // Get the table description block of this table + if (!(Tdbp = GetSubTable(g, ((PPIVOTDEF)To_Def)->Tablep, true))) return true; - else - defp = Tdbp->GetDef(); - if (!Fncol) { - for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) - if (!Picol || stricmp(Picol, cdp->GetName())) - Fncol = cdp->GetName(); + if (!Tdbp->IsView()) { + PCOLDEF cdp; + PTABDEF defp = Tdbp->GetDef(); if (!Fncol) { - strcpy(g->Message, MSG(NO_DEF_FNCCOL)); - return true; + for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) + if (!Picol || stricmp(Picol, cdp->GetName())) + Fncol = cdp->GetName(); + + if (!Fncol) { + strcpy(g->Message, MSG(NO_DEF_FNCCOL)); + return true; + } // endif Fncol + } // endif Fncol - - } // endif Fncol - - if (!Picol) { - // Find default Picol as the last one not equal to Fncol - for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) - if (!Fncol || stricmp(Fncol, cdp->GetName())) - Picol = cdp->GetName(); - + if (!Picol) { - strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); - return true; + // Find default Picol as the last one not equal to Fncol + for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) + if (!Fncol || stricmp(Fncol, cdp->GetName())) + Picol = cdp->GetName(); + + if (!Picol) { + strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); + return true; + } // endif Picol + } // endif Picol + + if (!GBdone) { + char *colist; + + // Locate the suballocated colist (size is not known yet) + *(colist = (char*)PlugSubAlloc(g, NULL, 0)) = 0; + + // Make the column list + for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext()) + if (!cdp->GetOffset()) + strcat(strcat(colist, cdp->GetName()), ", "); + + // Add the Pivot column at the end of the list + strcat(colist, Picol); + + // Now we know how much was suballocated + PlugSubAlloc(g, NULL, strlen(colist)); + + // Locate the source string (size is not known yet) + Tabsrc = (char*)PlugSubAlloc(g, NULL, 0); + + // Start making the definition + strcat(strcat(strcpy(Tabsrc, "SELECT "), colist), ", "); + + // Make it suitable for Pivot by doing the group by + strcat(strcat(Tabsrc, Function), "("); + strcat(strcat(strcat(Tabsrc, Fncol), ") "), Fncol); + strcat(strcat(Tabsrc, " FROM "), Tabname); + strcat(strcat(Tabsrc, " GROUP BY "), colist); + + // Now we know how much was suballocated + PlugSubAlloc(g, NULL, strlen(Tabsrc)); + } // endif !GBdone - } // endif Picol - - if (!GBdone) { - char *colist; - - // Locate the suballocated colist (size is not known yet) - *(colist = (char*)PlugSubAlloc(g, NULL, 0)) = 0; - - // Make the column list - for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext()) - if (!cdp->GetOffset()) - strcat(strcat(colist, cdp->GetName()), ", "); - - // Add the Pivot column at the end of the list - strcat(colist, Picol); - - // Now we know how much was suballocated - PlugSubAlloc(g, NULL, strlen(colist)); - - // Locate the source string (size is not known yet) - Tabsrc = (char*)PlugSubAlloc(g, NULL, 0); - - // Start making the definition - strcat(strcat(strcpy(Tabsrc, "SELECT "), colist), ", "); - - // Make it suitable for Pivot by doing the group by - strcat(strcat(Tabsrc, Function), "("); - strcat(strcat(strcat(Tabsrc, Fncol), ") "), Fncol); - strcat(strcat(Tabsrc, " FROM "), Tabname); - strcat(strcat(Tabsrc, " GROUP BY "), colist); - - // Now we know how much was suballocated - PlugSubAlloc(g, NULL, strlen(Tabsrc)); - } // endif !GBdone + } // endif IsView } else if (!Tabsrc) { strcpy(g->Message, MSG(SRC_TABLE_UNDEF)); @@ -601,26 +244,76 @@ bool TDBPIVOT::GetSourceTable(PGLOBAL g) } // endif if (Tabsrc) { - MYSQLC myc; // MySQL connection class - PQRYRES qryp; - PCOLRES crp; - int w; + // Get the new table description block of this source table + PTABLE tablep = new(g) XTAB("whatever", Tabsrc); - // Open a MySQL connection for this table - if (myc.Open(g, Host, Database, User, Pwd, Port)) + tablep->SetQualifier(Database); + + if (!(Tdbp = GetSubTable(g, tablep, true))) return true; - // Send the source command to MySQL - if (myc.ExecSQL(g, Tabsrc, &w) == RC_FX) { - myc.Close(); + } // endif Tabsrc + + return false; + } // end of GetSourceTable + +/***********************************************************************/ +/* Make the required pivot columns. */ +/***********************************************************************/ +bool TDBPIVOT::MakePivotColumns(PGLOBAL g) + { + if (!Tdbp->IsView()) { + // Now it is time to allocate the pivot and function columns + if (!(Fcolp = Tdbp->ColDB(g, Fncol, 0))) { + // Function column not found in table + sprintf(g->Message, MSG(COL_ISNOT_TABLE), Fncol, Tabname); + return true; + } else if (Fcolp->InitValue(g)) return true; - } // endif Exec - // We must have a storage query to get pivot column values - qryp = myc.GetResult(g); - myc.Close(); - Tdbp = new(g) TDBQRS(qryp); + if (!(Xcolp = Tdbp->ColDB(g, Picol, 0))) { + // Pivot column not found in table + sprintf(g->Message, MSG(COL_ISNOT_TABLE), Picol, Tabname); + return true; + } else if (Xcolp->InitValue(g)) + return true; + // Check and initialize the subtable columns + for (PCOL cp = Columns; cp; cp = cp->GetNext()) + if (cp->GetAmType() == TYPE_AM_SRC) { + if (((PSRCCOL)cp)->Init(g)) + return TRUE; + + } else if (cp->GetAmType() == TYPE_AM_FNC) + if (((PFNCCOL)cp)->InitColumn(g)) + return TRUE; + + } // endif isview + + return false; + } // end of MakePivotColumns + +/***********************************************************************/ +/* Make the required pivot columns for an object view. */ +/***********************************************************************/ +bool TDBPIVOT::MakeViewColumns(PGLOBAL g) + { + if (Tdbp->IsView()) { + // Tdbp is a view ColDB cannot be used + PCOL colp, cp; + PTDBMY tdbp; + + if (Tdbp->GetAmType() != TYPE_AM_MYSQL) { + strcpy(g->Message, "View is not MySQL"); + return true; + } else + tdbp = (PTDBMY)Tdbp; + + if (!Fncol || !Picol) { + strcpy(g->Message, "Missing Function or Pivot column"); + return true; + } // endif +#if 0 if (!Fncol) { for (crp = qryp->Colresp; crp; crp = crp->Next) if (!Picol || stricmp(Picol, crp->Name)) @@ -645,45 +338,33 @@ bool TDBPIVOT::GetSourceTable(PGLOBAL g) } // endif Picol } // endif Picol +#endif // 0 - } // endif Tabsrc + // Now it is time to allocate the pivot and function columns + if (!(Fcolp = tdbp->MakeFieldColumn(g, Fncol))) + return true; - // Now it is time to allocate the pivot and function columns - if (!(Fcolp = Tdbp->ColDB(g, Fncol, 0))) { - // Function column not found in table - sprintf(g->Message, MSG(COL_ISNOT_TABLE), Fncol, Tabname); - return true; - } else if (Fcolp->InitValue(g)) - return true; + if (!(Xcolp = tdbp->MakeFieldColumn(g, Picol))) + return true; - if (!(Xcolp = Tdbp->ColDB(g, Picol, 0))) { - // Pivot column not found in table - sprintf(g->Message, MSG(COL_ISNOT_TABLE), Picol, Tabname); - return true; - } else if (Xcolp->InitValue(g)) - return true; + // Check and initialize the subtable columns + for (cp = Columns; cp; cp = cp->GetNext()) + if (cp->GetAmType() == TYPE_AM_SRC) { + if ((colp = tdbp->MakeFieldColumn(g, cp->GetName()))) { + ((PSRCCOL)cp)->Colp = colp; + ((PSRCCOL)cp)->To_Val = colp->GetValue(); + cp->AddStatus(BUF_READ); // All is done here + } else + return true; + + } else if (cp->GetAmType() == TYPE_AM_FNC) + if (((PFNCCOL)cp)->InitColumn(g)) + return TRUE; + + } // endif isview return false; - } // end of GetSourceTable - -/***********************************************************************/ -/* Allocate source column description block. */ -/***********************************************************************/ -PCOL TDBPIVOT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) - { - PCOL colp; - - if (cdp->GetOffset()) { - colp = new(g) FNCCOL(cdp, this, cprec, n); - - if (cdp->GetOffset() > 1) - Dcolp = colp; - - } else - colp = new(g) SRCCOL(cdp, this, cprec, n); - - return colp; - } // end of MakeCol + } // end of MakeViewColumns /***********************************************************************/ /* PIVOT GetMaxSize: returns the maximum number of rows in the table. */ @@ -696,7 +377,7 @@ int TDBPIVOT::GetMaxSize(PGLOBAL g) return MaxSize; #endif // 0 - return 0; + return 10; } // end of GetMaxSize /***********************************************************************/ @@ -713,8 +394,6 @@ int TDBPIVOT::RowNumber(PGLOBAL g, bool b) /***********************************************************************/ bool TDBPIVOT::OpenDB(PGLOBAL g) { -//PDBUSER dup = (PDBUSER)g->Activityp->Aptr; - if (Use == USE_OPEN) { /*******************************************************************/ /* Table already open, just replace it at its beginning. */ @@ -746,18 +425,10 @@ bool TDBPIVOT::OpenDB(PGLOBAL g) /*********************************************************************/ if (GetSourceTable(g)) return TRUE; - - /*********************************************************************/ - /* Check and initialize the subtable columns. */ - /*********************************************************************/ - for (PCOL cp = Columns; cp; cp = cp->GetNext()) - if (cp->GetAmType() == TYPE_AM_SRC) { - if (((PPRXCOL)cp)->Init(g)) - return TRUE; - - } else if (cp->GetAmType() == TYPE_AM_FNC) - if (((PFNCCOL)cp)->InitColumn(g)) - return TRUE; + + // For tables, columns must be allocated before opening + if (MakePivotColumns(g)) + return TRUE; /*********************************************************************/ /* Physically open the object table. */ @@ -765,7 +436,10 @@ bool TDBPIVOT::OpenDB(PGLOBAL g) if (Tdbp->OpenDB(g)) return TRUE; - return FALSE; + /*********************************************************************/ + /* Make all required pivot columns for object views. */ + /*********************************************************************/ + return MakeViewColumns(g); } // end of OpenDB /***********************************************************************/ @@ -881,17 +555,6 @@ void TDBPIVOT::CloseDB(PGLOBAL g) } // end of CloseDB -#if 0 -/***********************************************************************/ -/* TDBPIVOT: Compare routine for sorting pivot column values. */ -/***********************************************************************/ -int TDBPIVOT::Qcompare(int *i1, int *i2) - { - // TODO: the actual comparison between pivot column result values. - return Rblkp->CompVal(*i1, *i2); - } // end of Qcompare -#endif // 0 - // ------------------------ FNCCOL functions ---------------------------- /***********************************************************************/ @@ -948,8 +611,6 @@ bool FNCCOL::CompareColumn(void) SRCCOL::SRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int n) : PRXCOL(cdp, tdbp, cprec, n) { - // Set additional SRC access method information for column. -//Cnval = NULL; } // end of SRCCOL constructor /***********************************************************************/ @@ -960,9 +621,6 @@ bool SRCCOL::Init(PGLOBAL g) if (PRXCOL::Init(g)) return true; - // Will contain the last value -//Cnval = AllocateValue(g, Value, TYPE_VOID); - AddStatus(BUF_READ); // All is done here return false; } // end of SRCCOL constructor @@ -972,7 +630,6 @@ bool SRCCOL::Init(PGLOBAL g) /***********************************************************************/ void SRCCOL::SetColumn(void) { -//Cnval->SetValue_pval(Value); Value->SetValue_pval(To_Val); } // end of SetColumn @@ -982,315 +639,7 @@ void SRCCOL::SetColumn(void) bool SRCCOL::CompareLast(void) { // Compare the unconverted values -//return !Cnval->IsEqual(Colp->GetValue(), true); return !Value->IsEqual(To_Val, true); } // end of CompareColumn - -/* ------------------------------------------------------------------- */ - -/***********************************************************************/ -/* Implementation of the TDBQRS class. */ -/***********************************************************************/ -TDBQRS::TDBQRS(PTDBQRS tdbp) : TDBASE(tdbp) - { - Qrp = tdbp->Qrp; - CurPos = tdbp->CurPos; - } // end of TDBQRS copy constructor - -// Method -PTDB TDBQRS::CopyOne(PTABS t) - { - PTDB tp; - PQRSCOL cp1, cp2; - PGLOBAL g = t->G; // Is this really useful ??? - - tp = new(g) TDBQRS(this); - - for (cp1 = (PQRSCOL)Columns; cp1; cp1 = (PQRSCOL)cp1->GetNext()) { - cp2 = new(g) QRSCOL(cp1, tp); // Make a copy - NewPointer(t, cp1, cp2); - } // endfor cp1 - - return tp; - } // end of CopyOne - -#if 0 // The TDBASE functions return NULL when To_Def is NULL -/***********************************************************************/ -/* Return the pointer on the DB catalog this table belongs to. */ -/***********************************************************************/ -PCATLG TDBQRS::GetCat(void) - { - // To_Def is null for QRYRES tables - return NULL; - } // end of GetCat - -/***********************************************************************/ -/* Return the datapath of the DB this table belongs to. */ -/***********************************************************************/ -PSZ TDBQRS::GetPath(void) - { - // To_Def is null for QRYRES tables - return NULL; - } // end of GetPath -#endif // 0 - -/***********************************************************************/ -/* Initialize QRS column description block construction. */ -/* name is used to call columns by name. */ -/* num is used by LNA to construct columns by index number. */ -/* Note: name=Null and num=0 for constructing all columns (select *) */ -/***********************************************************************/ -PCOL TDBQRS::ColDB(PGLOBAL g, PSZ name, int num) - { - int i; - PCOLRES crp; - PCOL cp, colp = NULL, cprec = NULL; - - if (trace) - htrc("QRS ColDB: colname=%s tabname=%s num=%d\n", - SVP(name), Name, num); - - for (crp = Qrp->Colresp, i = 1; crp; crp = crp->Next, i++) - if ((!name && !num) || - (name && !stricmp(crp->Name, name)) || num == i) { - // Check for existence of desired column - // Also find where to insert the new block - for (cp = Columns; cp; cp = cp->GetNext()) - if (cp->GetIndex() < i) - cprec = cp; - else if (cp->GetIndex() == i) - break; - - if (trace) { - if (cp) - htrc("cp(%d).Name=%s cp=%p\n", i, cp->GetName(), cp); - else - htrc("cp(%d) cp=%p\n", i, cp); - } // endif trace - - // Now take care of Column Description Block - if (cp) - colp = cp; - else - colp = new(g) QRSCOL(g, crp, this, cprec, i); - - if (name || num) - break; - else - cprec = colp; - - } // endif Name - - return (colp); - } // end of ColDB - -/***********************************************************************/ -/* QRS GetMaxSize: returns maximum table size in number of lines. */ -/***********************************************************************/ -int TDBQRS::GetMaxSize(PGLOBAL g) - { - MaxSize = Qrp->Maxsize; - return MaxSize; - } // end of GetMaxSize - -/***********************************************************************/ -/* RowNumber: returns the current row ordinal number. */ -/***********************************************************************/ -int TDBQRS::RowNumber(PGLOBAL g, BOOL b) - { - return (CurPos + 1); - } // end of RowNumber - -/***********************************************************************/ -/* QRS Access Method opening routine. */ -/* New method now that this routine is called recursively (last table */ -/* first in reverse order): index blocks are immediately linked to */ -/* join block of next table if it exists or else are discarted. */ -/***********************************************************************/ -bool TDBQRS::OpenDB(PGLOBAL g) - { - if (trace) - htrc("QRS OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", - this, Tdb_No, Use, To_Key_Col, Mode); - - if (Mode != MODE_READ) { - sprintf(g->Message, MSG(BAD_QUERY_OPEN), Mode); - return TRUE; - } // endif Mode - - CurPos = -1; - - if (Use == USE_OPEN) - return FALSE; - - /*********************************************************************/ - /* Open (retrieve data from) the query if not already open. */ - /*********************************************************************/ - Use = USE_OPEN; // Do it now in case we are recursively called - - return FALSE; - } // end of OpenDB - -/***********************************************************************/ -/* GetRecpos: returns current position of next sequential read. */ -/***********************************************************************/ -int TDBQRS::GetRecpos(void) - { - return (CurPos); - } // end of GetRecpos - -/***********************************************************************/ -/* ReadDB: Data Base read routine for QRS access method. */ -/***********************************************************************/ -int TDBQRS::ReadDB(PGLOBAL g) - { - int rc = RC_OK; - - if (trace) - htrc("QRS ReadDB: R%d CurPos=%d key=%p link=%p Kindex=%p\n", - GetTdb_No(), CurPos, To_Key_Col, To_Link, To_Kindex); - -#if 0 - if (To_Kindex) { - /*******************************************************************/ - /* Reading is by an index table. */ - /*******************************************************************/ - int recpos = To_Kindex->Fetch(g); - - switch (recpos) { - case -1: // End of file reached - rc = RC_EF; - break; - case -2: // No match for join - rc = RC_NF; - break; - case -3: // Same record as last non null one - rc = RC_OK; - break; - default: - /***************************************************************/ - /* Set the file position according to record to read. */ - /***************************************************************/ - CurPos = recpos; - } // endswitch recpos - - if (trace) - htrc("Position is now %d\n", CurPos); - - } else -#endif // 0 - /*******************************************************************/ - /* !To_Kindex ---> sequential reading */ - /*******************************************************************/ - rc = (++CurPos < Qrp->Nblin) ? RC_OK : RC_EF; - - return rc; - } // end of ReadDB - -/***********************************************************************/ -/* Dummy WriteDB: just send back an error return. */ -/***********************************************************************/ -int TDBQRS::WriteDB(PGLOBAL g) - { - strcpy(g->Message, MSG(QRY_READ_ONLY)); - return RC_FX; - } // end of WriteDB - -/***********************************************************************/ -/* Dummy DeleteDB routine, just returns an error code. */ -/***********************************************************************/ -int TDBQRS::DeleteDB(PGLOBAL g, int irc) - { - strcpy(g->Message, MSG(NO_QRY_DELETE)); - return RC_FX; - } // end of DeleteDB - -/***********************************************************************/ -/* Data Base close routine for QRS access method. */ -/***********************************************************************/ -void TDBQRS::CloseDB(PGLOBAL g) - { -//if (To_Kindex) { -// To_Kindex->Close(); -// To_Kindex = NULL; -// } // endif - - if (trace) - htrc("Qryres CloseDB"); - -//Qryp->Sqlp->CloseDB(); - } // end of CloseDB - -// ------------------------ QRSCOL functions ---------------------------- - -/***********************************************************************/ -/* QRSCOL public constructor. */ -/***********************************************************************/ -QRSCOL::QRSCOL(PGLOBAL g, PCOLRES crp, PTDB tdbp, PCOL cprec, int i) - : COLBLK(NULL, tdbp, i) - { - if (cprec) { - Next = cprec->GetNext(); - cprec->SetNext(this); - } else { - Next = tdbp->GetColumns(); - tdbp->SetColumns(this); - } // endif cprec - - // Set additional QRS access method information for column. - Crp = crp; - Name = Crp->Name; - Long = Crp->Clen; - Buf_Type = crp->Type; - strcpy(Format.Type, GetFormatType(Buf_Type)); - Format.Length = (short)Long; - Format.Prec = (short)Crp->Prec; - - if (trace) { - htrc("Making new QRSCOL C%d %s at %p\n", Index, Name, this); - htrc(" BufType=%d Long=%d length=%d clen=%d\n", - Buf_Type, Long, Format.Length, Crp->Clen); - } // endif trace - - } // end of QRSCOL constructor - -/***********************************************************************/ -/* QRSCOL constructor used for copying columns. */ -/* tdbp is the pointer to the new table descriptor. */ -/***********************************************************************/ -QRSCOL::QRSCOL(QRSCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp) - { - Crp = col1->Crp; - } // end of QRSCOL copy constructor - -/***********************************************************************/ -/* ReadColumn: what this routine does is to extract the RESCOL block */ -/* current value and convert it to the column buffer type. */ -/***********************************************************************/ -void QRSCOL::ReadColumn(PGLOBAL g) - { - PTDBQRS tdbp = (PTDBQRS)To_Tdb; - - if (trace) - htrc("QRS RC: col %s R%d type=%d CurPos=%d Len=%d\n", - Name, tdbp->GetTdb_No(), Buf_Type, tdbp->CurPos, Crp->Clen); - - if (Crp->Kdata) - Value->SetValue_pvblk(Crp->Kdata, tdbp->CurPos); - else - Value->Reset(); - - } // end of ReadColumn - -/***********************************************************************/ -/* Make file output of a Dos column descriptor block. */ -/***********************************************************************/ -void QRSCOL::Print(PGLOBAL g, FILE *f, uint n) - { - COLBLK::Print(g, f, n); - - fprintf(f, " Crp=%p\n", Crp); - } // end of Print - /* --------------------- End of TabPivot/TabQrs ---------------------- */ diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h index bed288dc560..e869d1cae6c 100644 --- a/storage/connect/tabpivot.h +++ b/storage/connect/tabpivot.h @@ -1,15 +1,14 @@ /************** TabPivot H Declares Source Code File (.H) **************/ -/* Name: TABPIVOT.H Version 1.3 */ +/* Name: TABPIVOT.H Version 1.4 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* */ /* This file contains the PIVOT classes declares. */ /***********************************************************************/ +typedef class PIVOTDEF *PPIVOTDEF; typedef class TDBPIVOT *PTDBPIVOT; typedef class FNCCOL *PFNCCOL; typedef class SRCCOL *PSRCCOL; -typedef class TDBQRS *PTDBQRS; -typedef class QRSCOL *PQRSCOL; /* -------------------------- PIVOT classes -------------------------- */ @@ -22,7 +21,6 @@ typedef class QRSCOL *PQRSCOL; /***********************************************************************/ /* PIVOT table. */ /***********************************************************************/ -//ass DllExport PIVOTDEF : public PRXDEF {/* Logical table description */ class PIVOTDEF : public PRXDEF { /* Logical table description */ friend class TDBPIVOT; public: @@ -55,22 +53,16 @@ class PIVOTDEF : public PRXDEF { /* Logical table description */ /***********************************************************************/ /* This is the class declaration for the PIVOT table. */ /***********************************************************************/ -//ass DllExport TDBPIVOT : public TDBASE, public CSORT { class TDBPIVOT : public TDBPRX { friend class FNCCOL; -//friend class SRCCOL; public: // Constructor TDBPIVOT(PPIVOTDEF tdp); -//TDBPIVOT(PTDBPIVOT tdbp); // Implementation virtual AMT GetAmType(void) {return TYPE_AM_PIVOT;} -//virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBPIVOT(this);} -// void SetTdbp(PTDB tdbp) {Tdbp = tdbp;} // Methods -//virtual PTDB CopyOne(PTABS t); virtual int GetRecpos(void) {return N;} virtual void ResetDB(void) {N = 0;} virtual int RowNumber(PGLOBAL g, bool b = FALSE); @@ -84,22 +76,17 @@ class TDBPIVOT : public TDBPRX { virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g); - // The sorting function -//virtual int Qcompare(int *, int *); - protected: - bool GetSourceTable(PGLOBAL g); -//int MakePivotColumns(PGLOBAL g); -//bool UpdateTableFields(PGLOBAL g, int n); + // Internal routines + bool GetSourceTable(PGLOBAL g); + bool MakePivotColumns(PGLOBAL g); + bool MakeViewColumns(PGLOBAL g); // Members -//MYSQLC Myc; // MySQL connection class -//PTDBQRS Tqrp; // To the source table result char *Host; // Host machine to use char *User; // User logon info char *Pwd; // Password logon info char *Database; // Database to be used by server -//PQRYRES Qryp; // Points to Query result block char *Tabname; // Name of source table char *Tabsrc; // SQL of source table char *Picol; // Pivot column name @@ -108,9 +95,6 @@ class TDBPIVOT : public TDBPRX { PCOL Fcolp; // To the function column in source PCOL Xcolp; // To the pivot column in source PCOL Dcolp; // To the dump column -//PCOLRES Xresp; // To the pivot result column -//PCOLRES To_Sort; // Saved Qryp To_Sort pointer -//PVBLK Rblkp; // The value block of the pivot column bool GBdone; // True when subtable is "Group by" bool Accept; // TRUE if no match is accepted int Mult; // Multiplication factor @@ -168,75 +152,4 @@ class SRCCOL : public PRXCOL { SRCCOL(void) {} // Members -//PVAL Cnval; }; // end of class SRCCOL - -/***********************************************************************/ -/* TDBQRS: This is the Access Method class declaration for the Query */ -/* Result stored in memory in the current work area (volatil). */ -/***********************************************************************/ -class DllExport TDBQRS : public TDBASE { - friend class QRSCOL; - public: - // Constructor - TDBQRS(PQRYRES qrp) : TDBASE() {Qrp = qrp; CurPos = 0;} - TDBQRS(PTDBQRS tdbp); - - // Implementation - virtual AMT GetAmType(void) {return TYPE_AM_QRS;} - virtual PTDB Duplicate(PGLOBAL g) - {return (PTDB)new(g) TDBQRS(this);} - PQRYRES GetQrp(void) {return Qrp;} - - // Methods - virtual PTDB CopyOne(PTABS t); - virtual int RowNumber(PGLOBAL g, BOOL b = FALSE); - virtual int GetRecpos(void); -//virtual PCATLG GetCat(void); -//virtual PSZ GetPath(void); - virtual int GetBadLines(void) {return Qrp->BadLines;} - - // Database routines - virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); - virtual int GetMaxSize(PGLOBAL g); - virtual bool OpenDB(PGLOBAL g); - virtual int ReadDB(PGLOBAL g); - virtual int WriteDB(PGLOBAL g); - virtual int DeleteDB(PGLOBAL g, int irc); - virtual void CloseDB(PGLOBAL g); - - private: - TDBQRS(void) : TDBASE() {} // Standard constructor not to be used - - protected: - // Members - PQRYRES Qrp; // Points to Query Result block - int CurPos; // Current line position - }; // end of class TDBQRS - -/***********************************************************************/ -/* Class QRSCOL: QRS access method column descriptor. */ -/***********************************************************************/ -class DllExport QRSCOL : public COLBLK { - friend class TDBQRS; - public: - // Constructors - QRSCOL(PGLOBAL g, PCOLRES crp, PTDB tdbp, PCOL cprec, int i); - QRSCOL(QRSCOL *colp, PTDB tdbp); // Constructor used in copy process - - // Implementation - virtual int GetAmType(void) {return TYPE_AM_QRS;} - PCOLRES GetCrp(void) {return Crp;} - void *GetQrsData(void) {return Crp->Kdata;} - - // Methods - virtual void ReadColumn(PGLOBAL g); - virtual void Print(PGLOBAL g, FILE *, uint); - - protected: - QRSCOL(void) {} // Default constructor not to be used - - // Members - PCOLRES Crp; - }; // end of class QRSCOL - diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 7e89cccf583..43fbb27a715 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -216,7 +216,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) { int n; PTABLE tp, tabp; - PTDB tdbp; + PTDBASE tdbp; PCOL colp; PTBLDEF tdp = (PTBLDEF)To_Def; @@ -252,7 +252,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) n++; } // endif filp - } // endfor tblp + } // endfor tp //NumTables = n; To_Filter = NULL; // To avoid doing it several times diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index c55b8d1fa5c..8698d4697b7 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -90,20 +90,21 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, // 1 2 4 8 //flags = GTS_TABLE | GTS_VIEW | GTS_NOLOCK | GTS_FORCE_DISCOVERY; - if (!open_table_def(thd, s, GTS_TABLE)) { -#ifdef DBUG_OFF - if (stricmp(s->db_plugin->name.str, "connect")) { -#else - if (stricmp((*s->db_plugin)->name.str, "connect")) { -#endif + if (!open_table_def(thd, s, GTS_TABLE | GTS_VIEW)) { + if (!s->is_view) { + if (stricmp(plugin_name(s->db_plugin)->str, "connect")) { #if defined(MYSQL_SUPPORT) - mysql = true; + mysql = true; #else // !MYSQL_SUPPORT - sprintf(g->Message, "%s.%s is not a CONNECT table", db, name); - return NULL; + sprintf(g->Message, "%s.%s is not a CONNECT table", db, name); + return NULL; #endif // MYSQL_SUPPORT - } else - mysql = false; + } else + mysql = false; + + } else { + mysql = true; + } // endif is_view } else { sprintf(g->Message, "Error %d opening share\n", s->error); @@ -139,9 +140,12 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, PCOLRES crp; if (!info) { - if (!(s = GetTableShare(g, thd, db, name, mysql))) + if (!(s = GetTableShare(g, thd, db, name, mysql))) { return NULL; - else + } else if (s->is_view) { + strcpy(g->Message, "Cannot retreive Proxy columns from a view"); + return NULL; + } else n = s->fieldnames.count; } else { @@ -257,23 +261,27 @@ PRXDEF::PRXDEF(void) /***********************************************************************/ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - char *pn, *db, *tab; + char *pn, *db, *tab, *def = NULL; db = Cat->GetStringCatInfo(g, "Dbname", "*"); + def = Cat->GetStringCatInfo(g, "Srcdef", NULL); if (!(tab = Cat->GetStringCatInfo(g, "Tabname", NULL))) { - strcpy(g->Message, "Missing object table name"); - return TRUE; - } // endif tab + if (!def) { + strcpy(g->Message, "Missing object table definition"); + return TRUE; + } else + tab = "Noname"; - // Analyze the table name, it may have the format: [dbname.]tabname - if ((pn = strchr(tab, '.'))) { - *pn++ = 0; - db = tab; - tab = pn; - } // endif pn + } else + // Analyze the table name, it may have the format: [dbname.]tabname + if ((pn = strchr(tab, '.'))) { + *pn++ = 0; + db = tab; + tab = pn; + } // endif pn - Tablep = new(g) XTAB(tab); + Tablep = new(g) XTAB(tab, def); Tablep->SetQualifier(db); return FALSE; } // end of DefineAM @@ -303,12 +311,13 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp) /***********************************************************************/ /* Get the PTDB of the sub-table. */ /***********************************************************************/ -PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) +PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) { char *db, *name; - bool mysql; + bool mysql = true; PTDB tdbp = NULL; - TABLE_SHARE *s; + TABLE_SHARE *s = NULL; + Field* *fp; PCATLG cat = To_Def->GetCat(); PHC hc = ((MYCAT*)cat)->GetHandler(); LPCSTR cdb, curdb = hc->GetDBName(NULL); @@ -328,10 +337,20 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) } // endfor tp - if (!(s = GetTableShare(g, thd, db, name, mysql))) - return NULL; + if (!tabp->GetSrc()) { + if (!(s = GetTableShare(g, thd, db, name, mysql))) + return NULL; - hc->tshp = s; + if (s->is_view && !b) + s->field = hc->get_table()->s->field; + + hc->tshp = s; + } else if (b) { + // Don't use caller's columns + fp = hc->get_table()->field; + hc->get_table()->field = NULL; + hc->get_table()->s->option_struct->srcdef = tabp->GetSrc(); + } // endif srcdef if (mysql) { #if defined(MYSQL_SUPPORT) @@ -355,15 +374,23 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) tdbp = cat->GetTable(g, tabp); } // endif mysql - hc->tshp = NULL; + if (s) { + if (s->is_view && !b) + s->field = NULL; + + hc->tshp = NULL; + } else if (b) + hc->get_table()->field = fp; if (trace && tdbp) htrc("Subtable %s in %s\n", name, SVP(((PTDBASE)tdbp)->GetDef()->GetDB())); err: - free_table_share(s); - return tdbp; + if (s) + free_table_share(s); + + return (PTDBASE)tdbp; } // end of GetSubTable /***********************************************************************/ @@ -373,7 +400,7 @@ bool TDBPRX::InitTable(PGLOBAL g) { if (!Tdbp) { // Get the table description block of this table - if (!(Tdbp = (PTDBASE)GetSubTable(g, ((PPRXDEF)To_Def)->Tablep))) + if (!(Tdbp = GetSubTable(g, ((PPRXDEF)To_Def)->Tablep))) return TRUE; } // endif Tdbp diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index 81e2a44464a..a6b08bce3d4 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -78,7 +78,7 @@ class DllExport TDBPRX : public TDBASE { virtual int WriteDB(PGLOBAL g); virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g) {if (Tdbp) Tdbp->CloseDB(g);} - PTDB GetSubTable(PGLOBAL g, PTABLE tabp); + PTDBASE GetSubTable(PGLOBAL g, PTABLE tabp, bool b = false); void RemoveNext(PTABLE tp); protected: @@ -93,6 +93,7 @@ class DllExport TDBPRX : public TDBASE { class DllExport PRXCOL : public COLBLK { friend class TDBPRX; friend class TDBTBL; + friend class TDBOCCUR; public: // Constructors PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "PRX"); diff --git a/storage/connect/xtable.h b/storage/connect/xtable.h index 8475c46d52d..7ef2d26136c 100644 --- a/storage/connect/xtable.h +++ b/storage/connect/xtable.h @@ -173,6 +173,7 @@ class DllExport TDBASE : public TDB { virtual int GetRecpos(void) = 0; virtual bool SetRecpos(PGLOBAL g, int recpos); virtual bool IsReadOnly(void) {return Read_Only;} + virtual bool IsView(void) {return FALSE;} virtual CHARSET_INFO *data_charset() { /* From aacd6f55af5f84298d3d7be26673d1e063092dc1 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 19 May 2013 20:16:04 +0200 Subject: [PATCH 183/273] - Removing unused copy file modified: storage/connect/mysql-test/connect/t/pivot.test --- storage/connect/mysql-test/connect/t/pivot.test | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/connect/mysql-test/connect/t/pivot.test b/storage/connect/mysql-test/connect/t/pivot.test index 87601a26d28..e66d927bad5 100644 --- a/storage/connect/mysql-test/connect/t/pivot.test +++ b/storage/connect/mysql-test/connect/t/pivot.test @@ -1,7 +1,6 @@ let $MYSQLD_DATADIR= `select @@datadir`; let $PORT= `select @@port`; --copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt ---copy_file $MTR_SUITE_DIR/std_data/connect.ini $MYSQLD_DATADIR/test/connect.ini --echo # --echo # Testing the PIVOT table type From 38a5bb2c1b0f7c1daa121a603c345dbc83d10f5b Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 20 May 2013 13:12:34 +0200 Subject: [PATCH 184/273] - Save and restore srcdef when getting a sub-table (could stay in cache) modified: storage/connect/tabutil.cpp - Change order of tests when looking for valid tdbp. In rare cases an invalid tdbp was still existing causing a crash of the server. modified: storage/connect/ha_connect.cc --- storage/connect/ha_connect.cc | 5 +++-- storage/connect/tabutil.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 9020220f5d0..f41b584a377 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -1094,8 +1094,9 @@ PTDB ha_connect::GetTDB(PGLOBAL g) table_name= GetTableName(); - if (tdbp && !stricmp(tdbp->GetName(), table_name) - && tdbp->GetMode() == xmod && !xp->CheckQuery(valid_query_id)) { + if (!xp->CheckQuery(valid_query_id && tdbp + && !stricmp(tdbp->GetName(), table_name) + && tdbp->GetMode() == xmod)) { tp= tdbp; tp->SetMode(xmod); } else if ((tp= CntGetTDB(g, table_name, xmod, this))) diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 93c0a8a83ea..5c4b428b09a 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -313,6 +313,7 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp) /***********************************************************************/ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) { + const char *sp; char *db, *name; bool mysql = true; PTDB tdbp = NULL; @@ -349,6 +350,9 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) // Don't use caller's columns fp = hc->get_table()->field; hc->get_table()->field = NULL; + + // Make caller use the source definition + sp = hc->get_table()->s->option_struct->srcdef; hc->get_table()->s->option_struct->srcdef = tabp->GetSrc(); } // endif srcdef @@ -379,8 +383,11 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) s->field = NULL; hc->tshp = NULL; - } else if (b) + } else if (b) { + // Restore s structure that can be in cache hc->get_table()->field = fp; + hc->get_table()->s->option_struct->srcdef = sp; + } // endif s if (trace && tdbp) htrc("Subtable %s in %s\n", From 7e4150d7cd893d8f27276b2304bebb39e909feda Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 20 May 2013 13:41:03 +0200 Subject: [PATCH 185/273] increase MAX_HA (number of simultaneously installed storage engines) to 64 --- sql/handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/handler.h b/sql/handler.h index af9574d82f8..ac9905a0dc1 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -285,7 +285,7 @@ (yes, the sum is deliberately inaccurate) TODO remove the limit, use dynarrays */ -#define MAX_HA 15 +#define MAX_HA 64 /* Use this instead of 0 as the initial value for the slot number of From ca024d1c21649dec1caab2d4027b56f3fa01407e Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 20 May 2013 18:17:09 +0200 Subject: [PATCH 186/273] - Correct misplaced parenthesis in last change modified: storage/connect/ha_connect.cc - Tdbp must be assigned before calling PRX column init modified: storage/connect/tabtbl.cpp --- storage/connect/ha_connect.cc | 4 ++-- storage/connect/tabtbl.cpp | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index f41b584a377..7baffbb0684 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -1094,9 +1094,9 @@ PTDB ha_connect::GetTDB(PGLOBAL g) table_name= GetTableName(); - if (!xp->CheckQuery(valid_query_id && tdbp + if (!xp->CheckQuery(valid_query_id) && tdbp && !stricmp(tdbp->GetName(), table_name) - && tdbp->GetMode() == xmod)) { + && tdbp->GetMode() == xmod) { tp= tdbp; tp->SetMode(xmod); } else if ((tp= CntGetTDB(g, table_name, xmod, this))) diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 43fbb27a715..9207ad636cf 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -216,7 +216,6 @@ bool TDBTBL::InitTableList(PGLOBAL g) { int n; PTABLE tp, tabp; - PTDBASE tdbp; PCOL colp; PTBLDEF tdp = (PTBLDEF)To_Def; @@ -227,7 +226,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) tabp = new(g) XTAB(tp); // Get the table description block of this table - if (!(tdbp = GetSubTable(g, tabp))) { + if (!(Tdbp = GetSubTable(g, tabp))) { if (++Nbf > Maxerr) return TRUE; // Error return else From 62ab6982a43a99f9da1d4b140111a5db6f377de1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 20 May 2013 23:58:44 +0200 Subject: [PATCH 187/273] MDEV-388 Creating a federated table with a non-existing server returns a random error code --- mysql-test/suite/federated/federatedx.result | 7 +++++++ mysql-test/suite/federated/federatedx.test | 8 ++++++++ storage/federated/ha_federated.cc | 2 +- storage/federatedx/ha_federatedx.cc | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/federated/federatedx.result b/mysql-test/suite/federated/federatedx.result index 2ece1a32b4f..af34af05e7d 100644 --- a/mysql-test/suite/federated/federatedx.result +++ b/mysql-test/suite/federated/federatedx.result @@ -2157,6 +2157,13 @@ DROP TABLE federated.t1; End of 5.1 tests SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT; SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT; +CREATE TABLE t1 (a INT) ENGINE=FEDERATED CONNECTION='non_existing'; +ERROR HY000: Can't create/write to file 'server name: 'non_existing' doesn't exist!' (Errcode: 16) +SHOW WARNINGS; +Level Code Message +Error 1 Can't create/write to file 'server name: 'non_existing' doesn't exist!' (Errcode: 16) +Error 1 Can't create/write to file 'non_existing' (Errcode: 14) +Error 1005 Can't create table 'test.t1' (errno: 1) DROP TABLE IF EXISTS federated.t1; DROP DATABASE IF EXISTS federated; DROP TABLE IF EXISTS federated.t1; diff --git a/mysql-test/suite/federated/federatedx.test b/mysql-test/suite/federated/federatedx.test index 15fdd47c4da..688893bb856 100644 --- a/mysql-test/suite/federated/federatedx.test +++ b/mysql-test/suite/federated/federatedx.test @@ -1999,4 +1999,12 @@ connection slave; SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT; connection default; + +# +# MDEV-388 Creating a federated table with a non-existing server returns a random error code +# +--error 1 +CREATE TABLE t1 (a INT) ENGINE=FEDERATED CONNECTION='non_existing'; +SHOW WARNINGS; + source include/federated_cleanup.inc; diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 55394e859c5..40b8d3d24d9 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -587,7 +587,7 @@ static int parse_url_error(FEDERATED_SHARE *share, TABLE *table, int error_num) buf_len= min(table->s->connect_string.length, FEDERATED_QUERY_BUFFER_SIZE-1); strmake(buf, table->s->connect_string.str, buf_len); - my_error(error_num, MYF(0), buf); + my_error(error_num, MYF(0), buf, 14); DBUG_RETURN(error_num); } diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index eb4d7f11d33..2d6ae6ccc4d 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -525,7 +525,7 @@ static int parse_url_error(FEDERATEDX_SHARE *share, TABLE *table, int error_num) buf_len= min(table->s->connect_string.length, FEDERATEDX_QUERY_BUFFER_SIZE-1); strmake(buf, table->s->connect_string.str, buf_len); - my_error(error_num, MYF(0), buf); + my_error(error_num, MYF(0), buf, 14); DBUG_RETURN(error_num); } From fce7fc43ba165cd704889c9d35f92e15288f5730 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 21 May 2013 09:42:10 +0200 Subject: [PATCH 188/273] fixes for buildbot --- mysql-test/r/empty_user_table.result | 2 +- mysql-test/suite/maria/r/distinct.result | 2 +- mysql-test/suite/maria/t/distinct.test | 2 +- mysql-test/t/empty_user_table.test | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/empty_user_table.result b/mysql-test/r/empty_user_table.result index df9d803e5c0..b93596ab59a 100644 --- a/mysql-test/r/empty_user_table.result +++ b/mysql-test/r/empty_user_table.result @@ -2,7 +2,7 @@ create table t1 as select * from mysql.user; truncate table mysql.user; flush privileges; connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET); -ERROR 28000: Access denied for user 'u1'@'localhost' (using password: NO) +Got one of the listed errors insert mysql.user select * from t1; drop table t1; flush privileges; diff --git a/mysql-test/suite/maria/r/distinct.result b/mysql-test/suite/maria/r/distinct.result index 04d5e3d6a2c..7963e7b72ff 100644 --- a/mysql-test/suite/maria/r/distinct.result +++ b/mysql-test/suite/maria/r/distinct.result @@ -17,7 +17,7 @@ GROUP_CONCAT(a) DROP TABLE t1; CREATE TABLE t1 (a INT, b VARCHAR(1)) ENGINE=MyISAM; INSERT INTO t1 VALUES (7,'q'),(2,NULL),(7,'g'),(6,'x'); -SELECT DISTINCT MAX( a ) FROM t1 GROUP BY b ORDER BY DES_DECRYPT( b ); +SELECT DISTINCT MAX( a ) FROM t1 GROUP BY b ORDER BY MD5( b ); MAX( a ) 2 7 diff --git a/mysql-test/suite/maria/t/distinct.test b/mysql-test/suite/maria/t/distinct.test index b30d97b8383..c71a172597c 100644 --- a/mysql-test/suite/maria/t/distinct.test +++ b/mysql-test/suite/maria/t/distinct.test @@ -21,5 +21,5 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, b VARCHAR(1)) ENGINE=MyISAM; INSERT INTO t1 VALUES (7,'q'),(2,NULL),(7,'g'),(6,'x'); -SELECT DISTINCT MAX( a ) FROM t1 GROUP BY b ORDER BY DES_DECRYPT( b ); +SELECT DISTINCT MAX( a ) FROM t1 GROUP BY b ORDER BY MD5( b ); DROP TABLE t1; diff --git a/mysql-test/t/empty_user_table.test b/mysql-test/t/empty_user_table.test index 7e672cc64f6..b54f2109e30 100644 --- a/mysql-test/t/empty_user_table.test +++ b/mysql-test/t/empty_user_table.test @@ -8,8 +8,10 @@ create table t1 as select * from mysql.user; truncate table mysql.user; flush privileges; +# connecting via unix socket gives ER_ACCESS_DENIED_ERROR +# connecting via tcp/ip gives ER_HOST_NOT_PRIVILEGED --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT ---error ER_ACCESS_DENIED_ERROR +--error ER_ACCESS_DENIED_ERROR,ER_HOST_NOT_PRIVILEGED connect (fail,localhost,u1); insert mysql.user select * from t1; From d6315e29c8a1d6a28f1d61184ff2e907494210e7 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 21 May 2013 13:03:37 +0200 Subject: [PATCH 189/273] MDEV-388 Creating a federated table with a non-existing server returns a random error code (part 2) --- mysql-test/suite/federated/federated.result | 13 +++++++++++++ mysql-test/suite/federated/federated.test | 12 ++++++++++++ mysql-test/suite/federated/federatedx.result | 7 ------- mysql-test/suite/federated/federatedx.test | 7 ------- storage/federatedx/ha_federatedx.cc | 5 ++--- 5 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 mysql-test/suite/federated/federated.result create mode 100644 mysql-test/suite/federated/federated.test diff --git a/mysql-test/suite/federated/federated.result b/mysql-test/suite/federated/federated.result new file mode 100644 index 00000000000..6dcd6b1721b --- /dev/null +++ b/mysql-test/suite/federated/federated.result @@ -0,0 +1,13 @@ +CREATE DATABASE federated; +CREATE DATABASE federated; +CREATE TABLE t1 (a INT) ENGINE=FEDERATED CONNECTION='non_existing'; +ERROR HY000: server name: 'non_existing' doesn't exist! +SHOW WARNINGS; +Level Code Message +Error 1 server name: 'non_existing' doesn't exist! +Error 1 Can't create/write to file 'non_existing' (Errcode: 14) +Error 1005 Can't create table 'test.t1' (errno: 1) +DROP TABLE IF EXISTS federated.t1; +DROP DATABASE IF EXISTS federated; +DROP TABLE IF EXISTS federated.t1; +DROP DATABASE IF EXISTS federated; diff --git a/mysql-test/suite/federated/federated.test b/mysql-test/suite/federated/federated.test new file mode 100644 index 00000000000..ab0cfc4b36c --- /dev/null +++ b/mysql-test/suite/federated/federated.test @@ -0,0 +1,12 @@ +source include/federated.inc; + + +# +# MDEV-388 Creating a federated table with a non-existing server returns a random error code +# +--error 1 +CREATE TABLE t1 (a INT) ENGINE=FEDERATED CONNECTION='non_existing'; +SHOW WARNINGS; + +source include/federated_cleanup.inc; + diff --git a/mysql-test/suite/federated/federatedx.result b/mysql-test/suite/federated/federatedx.result index af34af05e7d..2ece1a32b4f 100644 --- a/mysql-test/suite/federated/federatedx.result +++ b/mysql-test/suite/federated/federatedx.result @@ -2157,13 +2157,6 @@ DROP TABLE federated.t1; End of 5.1 tests SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT; SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT; -CREATE TABLE t1 (a INT) ENGINE=FEDERATED CONNECTION='non_existing'; -ERROR HY000: Can't create/write to file 'server name: 'non_existing' doesn't exist!' (Errcode: 16) -SHOW WARNINGS; -Level Code Message -Error 1 Can't create/write to file 'server name: 'non_existing' doesn't exist!' (Errcode: 16) -Error 1 Can't create/write to file 'non_existing' (Errcode: 14) -Error 1005 Can't create table 'test.t1' (errno: 1) DROP TABLE IF EXISTS federated.t1; DROP DATABASE IF EXISTS federated; DROP TABLE IF EXISTS federated.t1; diff --git a/mysql-test/suite/federated/federatedx.test b/mysql-test/suite/federated/federatedx.test index 688893bb856..cfe6a425944 100644 --- a/mysql-test/suite/federated/federatedx.test +++ b/mysql-test/suite/federated/federatedx.test @@ -2000,11 +2000,4 @@ SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT; connection default; -# -# MDEV-388 Creating a federated table with a non-existing server returns a random error code -# ---error 1 -CREATE TABLE t1 (a INT) ENGINE=FEDERATED CONNECTION='non_existing'; -SHOW WARNINGS; - source include/federated_cleanup.inc; diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index 2d6ae6ccc4d..aac2414bca1 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -585,9 +585,8 @@ int get_connection(MEM_ROOT *mem_root, FEDERATEDX_SHARE *share) DBUG_RETURN(0); error: - sprintf(error_buffer, "server name: '%s' doesn't exist!", - share->connection_string); - my_error(error_num, MYF(0), error_buffer); + my_printf_error(error_num, "server name: '%s' doesn't exist!", + MYF(0), share->connection_string); DBUG_RETURN(error_num); } From 41bda068a5affa1f8b483784df532c5a3ee8dcfd Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 21 May 2013 18:29:10 +0400 Subject: [PATCH 190/273] "mtr --suite=connect --embedded" tests did not work for two reasons: 1. The Connect engine code assumed that mysql_home_directory is always "./", which is not the fact in case of embedded server. Fixing the routines creating file names to add the mysql_home_directory prefix. 2. FILE privilege is not checked in embedded server. Moving FILE related tests into separate files. Skipping the FILE related tests when running with --embedded. added: storage/connect/mysql-test/connect/r/grant.result storage/connect/mysql-test/connect/r/ini_grant.result storage/connect/mysql-test/connect/r/mysql_grant.result storage/connect/mysql-test/connect/r/xml_grant.result storage/connect/mysql-test/connect/t/grant.test storage/connect/mysql-test/connect/t/ini_grant.test storage/connect/mysql-test/connect/t/mysql_grant.test storage/connect/mysql-test/connect/t/xml_grant.test modified: storage/connect/global.h storage/connect/ha_connect.cc storage/connect/mycat.cc storage/connect/mysql-test/connect/r/bin.result storage/connect/mysql-test/connect/r/csv.result storage/connect/mysql-test/connect/r/dbf.result storage/connect/mysql-test/connect/r/dir.result storage/connect/mysql-test/connect/r/fix.result storage/connect/mysql-test/connect/r/ini.result storage/connect/mysql-test/connect/r/mysql.result storage/connect/mysql-test/connect/r/vec.result storage/connect/mysql-test/connect/r/xml.result storage/connect/mysql-test/connect/t/bin.test storage/connect/mysql-test/connect/t/csv.test storage/connect/mysql-test/connect/t/dbf.test storage/connect/mysql-test/connect/t/dir.test storage/connect/mysql-test/connect/t/fix.test storage/connect/mysql-test/connect/t/ini.test storage/connect/mysql-test/connect/t/mysql.test storage/connect/mysql-test/connect/t/vec.test storage/connect/mysql-test/connect/t/xml.test storage/connect/plgdbsem.h storage/connect/plugutil.c --- storage/connect/global.h | 3 +- storage/connect/ha_connect.cc | 80 ++- storage/connect/mycat.cc | 7 + .../connect/mysql-test/connect/r/bin.result | 94 --- .../connect/mysql-test/connect/r/csv.result | 94 --- .../connect/mysql-test/connect/r/dbf.result | 94 --- .../connect/mysql-test/connect/r/dir.result | 69 --- .../connect/mysql-test/connect/r/fix.result | 94 --- .../connect/mysql-test/connect/r/grant.result | 539 ++++++++++++++++++ .../connect/mysql-test/connect/r/ini.result | 79 --- .../mysql-test/connect/r/ini_grant.result | 79 +++ .../connect/mysql-test/connect/r/mysql.result | 63 -- .../mysql-test/connect/r/mysql_grant.result | 63 ++ .../connect/mysql-test/connect/r/vec.result | 94 --- .../connect/mysql-test/connect/r/xml.result | 104 +--- .../mysql-test/connect/r/xml_grant.result | 96 ++++ storage/connect/mysql-test/connect/t/bin.test | 4 - storage/connect/mysql-test/connect/t/csv.test | 4 - storage/connect/mysql-test/connect/t/dbf.test | 4 - storage/connect/mysql-test/connect/t/dir.test | 70 --- storage/connect/mysql-test/connect/t/fix.test | 4 - .../connect/mysql-test/connect/t/grant.test | 95 +++ storage/connect/mysql-test/connect/t/ini.test | 75 --- .../mysql-test/connect/t/ini_grant.test | 79 +++ .../connect/mysql-test/connect/t/mysql.test | 60 -- .../mysql-test/connect/t/mysql_grant.test | 78 +++ storage/connect/mysql-test/connect/t/vec.test | 4 - storage/connect/mysql-test/connect/t/xml.test | 17 +- .../mysql-test/connect/t/xml_grant.test | 23 + storage/connect/plgdbsem.h | 1 + storage/connect/plugutil.c | 30 +- 31 files changed, 1175 insertions(+), 1025 deletions(-) create mode 100644 storage/connect/mysql-test/connect/r/grant.result create mode 100644 storage/connect/mysql-test/connect/r/ini_grant.result create mode 100644 storage/connect/mysql-test/connect/r/mysql_grant.result create mode 100644 storage/connect/mysql-test/connect/r/xml_grant.result create mode 100644 storage/connect/mysql-test/connect/t/grant.test create mode 100644 storage/connect/mysql-test/connect/t/ini_grant.test create mode 100644 storage/connect/mysql-test/connect/t/mysql_grant.test create mode 100644 storage/connect/mysql-test/connect/t/xml_grant.test diff --git a/storage/connect/global.h b/storage/connect/global.h index ae50e5ac160..303078f5a18 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -239,7 +239,8 @@ DllExport short GetLineLength(PGLOBAL); // Console line length DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization DllExport int PlugExit(PGLOBAL); // Plug global termination DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); -DllExport LPCSTR PlugSetPath(LPSTR, LPCSTR, LPCSTR); +DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir); +DllExport BOOL PlugIsAbsolutePath(LPCSTR path); DllExport void *PlugAllocMem(PGLOBAL, uint); DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 7baffbb0684..3db86b8e607 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -289,6 +289,13 @@ static void init_connect_psi_keys() {} #endif +DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir) +{ + const char *res= PlugSetPath(to, mysql_data_home, name, dir); + return res; +} + + /** @brief If frm_error() is called then we will use this to determine @@ -3097,6 +3104,63 @@ THR_LOCK_DATA **ha_connect::store_lock(THD *thd, } +/** + Searches for a pointer to the last occurrence of the + character c in the string src. + Returns true on failure, false on success. +*/ +static bool +strnrchr(LEX_CSTRING *ls, const char *src, size_t length, int c) +{ + const char *srcend, *s; + for (s= srcend= src + length; s > src; s--) + { + if (s[-1] == c) + { + ls->str= s; + ls->length= srcend - s; + return false; + } + } + return true; +} + + +/** + Split filename into database and table name. +*/ +static bool +filename_to_dbname_and_tablename(const char *filename, + char *database, size_t database_size, + char *table, size_t table_size) +{ +#if defined(WIN32) + char slash= '\\'; +#else // !WIN32 + char slash= '/'; +#endif // !WIN32 + LEX_CSTRING d, t; + size_t length= strlen(filename); + + /* Find filename - the rightmost directory part */ + if (strnrchr(&t, filename, length, slash) || t.length + 1 > table_size) + return true; + memcpy(table, t.str, t.length); + table[t.length]= '\0'; + if (!(length-= t.length)) + return true; + + length--; /* Skip slash */ + + /* Find database name - the second rightmost directory part */ + if (strnrchr(&d, filename, length, slash) || d.length + 1 > database_size) + return true; + memcpy(database, d.str, d.length); + database[d.length]= '\0'; + return false; +} + + /** @brief Used to delete or rename a table. By the time delete_table() has been @@ -3123,22 +3187,20 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to) DBUG_ENTER("ha_connect::delete_or_rename_table"); /* We have to retrieve the information about this table options. */ ha_table_option_struct *pos; -#if defined(WIN32) - const char *fmt= ".\\%[^\\]\\%s"; -#else // !WIN32 - const char *fmt= "./%[^/]/%s"; -#endif // !WIN32 char key[MAX_DBKEY_LENGTH], db[128], tabname[128]; int rc; uint key_length; TABLE_SHARE *share; THD *thd= current_thd; - if (to) - if (sscanf(to, fmt, db, tabname) != 2 || *tabname == '#') - goto fin; + if (to && (filename_to_dbname_and_tablename(to, db, sizeof(db), + tabname, sizeof(tabname)) || + *tabname == '#')) + goto fin; - if (sscanf(name, fmt, db, tabname) != 2 || *tabname == '#') + if (filename_to_dbname_and_tablename(name, db, sizeof(db), + tabname, sizeof(tabname)) || + *tabname == '#') goto fin; key_length= create_table_def_key(key, db, tabname); diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 35a66f0d1a2..b5767b02180 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -293,6 +293,13 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path) if (path) { size_t len= strlen(path) + (*path != '.' ? 4 : 1); char *buf= (char*)PlugSubAlloc(g, NULL, len); + + if (PlugIsAbsolutePath(path)) + { + strcpy(buf, path); + *datapath= buf; + return; + } if (*path != '.') { #if defined(WIN32) diff --git a/storage/connect/mysql-test/connect/r/bin.result b/storage/connect/mysql-test/connect/r/bin.result index d476aef6293..c64b270b538 100644 --- a/storage/connect/mysql-test/connect/r/bin.result +++ b/storage/connect/mysql-test/connect/r/bin.result @@ -1,98 +1,4 @@ # -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN; -Warnings: -Warning 1105 No file name. Table will use t1.bin -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN; -Warnings: -Warning 1105 No file name. Table will use t1.bin -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# -# # Testing errors # CREATE TABLE t1 diff --git a/storage/connect/mysql-test/connect/r/csv.result b/storage/connect/mysql-test/connect/r/csv.result index 34734e164c0..b2498326edb 100644 --- a/storage/connect/mysql-test/connect/r/csv.result +++ b/storage/connect/mysql-test/connect/r/csv.result @@ -1,97 +1,3 @@ -# -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV; -Warnings: -Warning 1105 No file name. Table will use t1.csv -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV; -Warnings: -Warning 1105 No file name. Table will use t1.csv -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# SET NAMES utf8; # # Testing errors diff --git a/storage/connect/mysql-test/connect/r/dbf.result b/storage/connect/mysql-test/connect/r/dbf.result index 27abbb84dc6..2e84c5b3090 100644 --- a/storage/connect/mysql-test/connect/r/dbf.result +++ b/storage/connect/mysql-test/connect/r/dbf.result @@ -1,98 +1,4 @@ # -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF; -Warnings: -Warning 1105 No file name. Table will use t1.dbf -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF; -Warnings: -Warning 1105 No file name. Table will use t1.dbf -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# -# # Testing errors # CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; diff --git a/storage/connect/mysql-test/connect/r/dir.result b/storage/connect/mysql-test/connect/r/dir.result index 7beae815580..f4feb5fa960 100644 --- a/storage/connect/mysql-test/connect/r/dir.result +++ b/storage/connect/mysql-test/connect/r/dir.result @@ -1,72 +1,3 @@ -# -# Testing FILE privilege -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 ( -path VARCHAR(256) NOT NULL flag=1, -fname VARCHAR(256) NOT NULL, -ftype CHAR(4) NOT NULL, -size DOUBLE(12,0) NOT NULL flag=5 -) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 ( -path VARCHAR(256) NOT NULL flag=1, -fname VARCHAR(256) NOT NULL, -ftype CHAR(4) NOT NULL, -size DOUBLE(12,0) NOT NULL flag=5 -) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; -SELECT fname, ftype, size FROM t1 WHERE size>0; -fname ftype size -t1 .frm 1081 -SELECT user(); -user() -user@localhost -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO t1 VALUES (); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1 WHERE path='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET path='yyy' WHERE path='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (1,1,1,1); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET path=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -DROP USER user@localhost; -# -# Testing FILE privileges done -# CREATE TABLE t1 ( path VARCHAR(256) NOT NULL flag=1, fname VARCHAR(256) NOT NULL, diff --git a/storage/connect/mysql-test/connect/r/fix.result b/storage/connect/mysql-test/connect/r/fix.result index e9eb31d9bc8..c8f51abe961 100644 --- a/storage/connect/mysql-test/connect/r/fix.result +++ b/storage/connect/mysql-test/connect/r/fix.result @@ -1,98 +1,4 @@ # -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX; -Warnings: -Warning 1105 No file name. Table will use t1.fix -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX; -Warnings: -Warning 1105 No file name. Table will use t1.fix -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# -# # Testing errors # CREATE TABLE t1 diff --git a/storage/connect/mysql-test/connect/r/grant.result b/storage/connect/mysql-test/connect/r/grant.result new file mode 100644 index 00000000000..ba5728703a5 --- /dev/null +++ b/storage/connect/mysql-test/connect/r/grant.result @@ -0,0 +1,539 @@ +# +# Testing FILE privilege +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 ( +path VARCHAR(256) NOT NULL flag=1, +fname VARCHAR(256) NOT NULL, +ftype CHAR(4) NOT NULL, +size DOUBLE(12,0) NOT NULL flag=5 +) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 ( +path VARCHAR(256) NOT NULL flag=1, +fname VARCHAR(256) NOT NULL, +ftype CHAR(4) NOT NULL, +size DOUBLE(12,0) NOT NULL flag=5 +) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; +SELECT fname, ftype, size FROM t1 WHERE size>0; +fname ftype size +t1 .frm 1081 +SELECT user(); +user() +user@localhost +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO t1 VALUES (); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1 WHERE path='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET path='yyy' WHERE path='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (1,1,1,1); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET path=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +DROP USER user@localhost; +# +# Testing FILE privileges done +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN; +Warnings: +Warning 1105 No file name. Table will use t1.bin +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN; +Warnings: +Warning 1105 No file name. Table will use t1.bin +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV; +Warnings: +Warning 1105 No file name. Table will use t1.csv +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV; +Warnings: +Warning 1105 No file name. Table will use t1.csv +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF; +Warnings: +Warning 1105 No file name. Table will use t1.dbf +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF; +Warnings: +Warning 1105 No file name. Table will use t1.dbf +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX; +Warnings: +Warning 1105 No file name. Table will use t1.fix +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX; +Warnings: +Warning 1105 No file name. Table will use t1.fix +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100; +Warnings: +Warning 1105 No file name. Table will use t1.vec +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100 FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100; +Warnings: +Warning 1105 No file name. Table will use t1.vec +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# diff --git a/storage/connect/mysql-test/connect/r/ini.result b/storage/connect/mysql-test/connect/r/ini.result index da846d466ba..83ba98fbd84 100644 --- a/storage/connect/mysql-test/connect/r/ini.result +++ b/storage/connect/mysql-test/connect/r/ini.result @@ -1,83 +1,4 @@ # -# Checking FILE privileges -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI; -Warnings: -Warning 1105 No file name. Table will use t1.ini -INSERT INTO t1 VALUES ('sec1','val1'); -SELECT * FROM t1; -sec val -sec1 val1 -UPDATE t1 SET val='val11'; -SELECT * FROM t1; -sec val -sec1 val11 -DELETE FROM t1; -SELECT * FROM t1; -sec val -INSERT INTO t1 VALUES('sec2','val2'); -TRUNCATE TABLE t1; -SELECT * FROM t1; -sec val -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -sec val -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES ('sec1','val1'); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES ('sec2','val2'); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET val='val11'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES ('sec3','val3'); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET val='val11'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP VIEW v1; -DROP TABLE t1; -DROP USER user@localhost; -# -# Checking FILE privileges: done -# -# # Testing errors # CREATE TABLE t1 diff --git a/storage/connect/mysql-test/connect/r/ini_grant.result b/storage/connect/mysql-test/connect/r/ini_grant.result new file mode 100644 index 00000000000..c3acf7c8dfc --- /dev/null +++ b/storage/connect/mysql-test/connect/r/ini_grant.result @@ -0,0 +1,79 @@ +# +# Checking FILE privileges +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI; +Warnings: +Warning 1105 No file name. Table will use t1.ini +INSERT INTO t1 VALUES ('sec1','val1'); +SELECT * FROM t1; +sec val +sec1 val1 +UPDATE t1 SET val='val11'; +SELECT * FROM t1; +sec val +sec1 val11 +DELETE FROM t1; +SELECT * FROM t1; +sec val +INSERT INTO t1 VALUES('sec2','val2'); +TRUNCATE TABLE t1; +SELECT * FROM t1; +sec val +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +sec val +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES ('sec1','val1'); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES ('sec2','val2'); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET val='val11'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES ('sec3','val3'); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET val='val11'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP VIEW v1; +DROP TABLE t1; +DROP USER user@localhost; +# +# Checking FILE privileges: done +# diff --git a/storage/connect/mysql-test/connect/r/mysql.result b/storage/connect/mysql-test/connect/r/mysql.result index a538c57c5ce..8d5507e121a 100644 --- a/storage/connect/mysql-test/connect/r/mysql.result +++ b/storage/connect/mysql-test/connect/r/mysql.result @@ -1,66 +1,3 @@ -# -# Testing FILE privilege -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=PORT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1remote (a INT NOT NULL); -INSERT INTO t1remote VALUES (10),(20),(30); -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=PORT'; -SELECT * FROM t1; -a -10 -20 -30 -SELECT user(); -user() -user@localhost -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO t1 VALUES ('xxx'); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1 WHERE a='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a='yyy' WHERE a='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1, t1remote; -DROP USER user@localhost; -# -# Testing FILE privileges done -# CREATE TABLE t1 (a int, b char(10)); INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03'); SELECT * FROM t1; diff --git a/storage/connect/mysql-test/connect/r/mysql_grant.result b/storage/connect/mysql-test/connect/r/mysql_grant.result new file mode 100644 index 00000000000..f8d0ee6ad6f --- /dev/null +++ b/storage/connect/mysql-test/connect/r/mysql_grant.result @@ -0,0 +1,63 @@ +# +# Testing FILE privilege +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=PORT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1remote (a INT NOT NULL); +INSERT INTO t1remote VALUES (10),(20),(30); +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=PORT'; +SELECT * FROM t1; +a +10 +20 +30 +SELECT user(); +user() +user@localhost +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO t1 VALUES ('xxx'); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1 WHERE a='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a='yyy' WHERE a='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1, t1remote; +DROP USER user@localhost; +# +# Testing FILE privileges done +# diff --git a/storage/connect/mysql-test/connect/r/vec.result b/storage/connect/mysql-test/connect/r/vec.result index 9461966aef7..65513dc07db 100644 --- a/storage/connect/mysql-test/connect/r/vec.result +++ b/storage/connect/mysql-test/connect/r/vec.result @@ -1,97 +1,3 @@ -# -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100; -Warnings: -Warning 1105 No file name. Table will use t1.vec -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100 FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100; -Warnings: -Warning 1105 No file name. Table will use t1.vec -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# CREATE TABLE dir1 ( spath VARCHAR(256) NOT NULL flag=1, fname VARCHAR(256) NOT NULL, diff --git a/storage/connect/mysql-test/connect/r/xml.result b/storage/connect/mysql-test/connect/r/xml.result index 554039dc3f1..44fab646dcf 100644 --- a/storage/connect/mysql-test/connect/r/xml.result +++ b/storage/connect/mysql-test/connect/r/xml.result @@ -1,99 +1,5 @@ Warnings: Warning 1105 No file name. Table will use t1.xml -# -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; -Warnings: -Warning 1105 No file name. Table will use t1.xml -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; -Warnings: -Warning 1105 No file name. Table will use t1.xml -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# SET NAMES utf8; # # Testing tag values @@ -253,8 +159,8 @@ TITLE XML, Langage et Applications TRANSLATOR NULL PUBLISHER Eyrolles Paris DATEPUB 1998 -SELECT LOAD_FILE('test/xsample2.xml'); -LOAD_FILE('test/xsample2.xml') +SELECT LOAD_FILE('MYSQLD_DATADIR/test/xsample2.xml') AS xml; +xml @@ -467,7 +373,7 @@ SELECT node, hex(node) FROM t1; node ÀÁÂÃ hex(node) C0C1C2C3 DROP TABLE t1; -SET @a=LOAD_FILE('test/t1.xml'); +SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SELECT LEFT(@a,38); LEFT(@a,38) SELECT HEX(EXTRACTVALUE(@a,'/t1/line/node')); @@ -481,7 +387,7 @@ SELECT node, hex(node) FROM t1; node ÀÁÂÃ hex(node) C0C1C2C3 DROP TABLE t1; -SET @a=LOAD_FILE('test/t1.xml'); +SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SELECT LEFT(@a,43); LEFT(@a,43) SELECT HEX(EXTRACTVALUE(@a,'/t1/line/node')); @@ -504,7 +410,7 @@ hex(node) D090D091D092D093 node &<>"' hex(node) 263C3E2227 DROP TABLE t1; -SET @a=LOAD_FILE('test/t1.xml'); +SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SELECT CAST(@a AS CHAR CHARACTER SET latin1); CAST(@a AS CHAR CHARACTER SET latin1) diff --git a/storage/connect/mysql-test/connect/r/xml_grant.result b/storage/connect/mysql-test/connect/r/xml_grant.result new file mode 100644 index 00000000000..ea38e57af86 --- /dev/null +++ b/storage/connect/mysql-test/connect/r/xml_grant.result @@ -0,0 +1,96 @@ +Warnings: +Warning 1105 No file name. Table will use t1.xml +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; +Warnings: +Warning 1105 No file name. Table will use t1.xml +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; +Warnings: +Warning 1105 No file name. Table will use t1.xml +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# diff --git a/storage/connect/mysql-test/connect/t/bin.test b/storage/connect/mysql-test/connect/t/bin.test index 0266fd3e357..a9dab32987e 100644 --- a/storage/connect/mysql-test/connect/t/bin.test +++ b/storage/connect/mysql-test/connect/t/bin.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=BIN; -let $FILE_EXT=BIN; ---source grant.inc - --copy_file $MTR_SUITE_DIR/std_data/Testbal.dat $MYSQLD_DATADIR/test/Testbal.dat --echo # diff --git a/storage/connect/mysql-test/connect/t/csv.test b/storage/connect/mysql-test/connect/t/csv.test index 6578ba83a9a..685ac434df7 100644 --- a/storage/connect/mysql-test/connect/t/csv.test +++ b/storage/connect/mysql-test/connect/t/csv.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=CSV; -let $FILE_EXT=CSV; ---source grant.inc - --copy_file $MTR_SUITE_DIR/std_data/people.csv $MYSQLD_DATADIR/test/people.csv SET NAMES utf8; diff --git a/storage/connect/mysql-test/connect/t/dbf.test b/storage/connect/mysql-test/connect/t/dbf.test index fb0bc21f52d..b9a1b6e2183 100644 --- a/storage/connect/mysql-test/connect/t/dbf.test +++ b/storage/connect/mysql-test/connect/t/dbf.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=DBF; -let $FILE_EXT=DBF; ---source grant.inc - --echo # --echo # Testing errors --echo # diff --git a/storage/connect/mysql-test/connect/t/dir.test b/storage/connect/mysql-test/connect/t/dir.test index 073cdaa380b..fb69813d9f0 100644 --- a/storage/connect/mysql-test/connect/t/dir.test +++ b/storage/connect/mysql-test/connect/t/dir.test @@ -1,76 +1,6 @@ let $MYSQLD_DATADIR= `select @@datadir`; ---echo # ---echo # Testing FILE privilege ---echo # -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; ---connect(user,localhost,user,,) ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -CREATE TABLE t1 ( - path VARCHAR(256) NOT NULL flag=1, - fname VARCHAR(256) NOT NULL, - ftype CHAR(4) NOT NULL, - size DOUBLE(12,0) NOT NULL flag=5 -) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; ---connection default -SELECT user(); -CREATE TABLE t1 ( - path VARCHAR(256) NOT NULL flag=1, - fname VARCHAR(256) NOT NULL, - ftype CHAR(4) NOT NULL, - size DOUBLE(12,0) NOT NULL flag=5 -) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; -# "size>0" to skip directory names on Windows ---replace_result $MYSQLD_DATADIR DATADIR/ -SELECT fname, ftype, size FROM t1 WHERE size>0; - ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM t1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO t1 VALUES (); ---error ER_ACCESS_DENIED_ERROR -DELETE FROM t1 WHERE path='xxx'; ---error ER_ACCESS_DENIED_ERROR -UPDATE t1 SET path='yyy' WHERE path='xxx'; ---error ER_ACCESS_DENIED_ERROR -TRUNCATE TABLE t1; ---error ER_ACCESS_DENIED_ERROR -ALTER TABLE t1 READONLY=1; ---error ER_ACCESS_DENIED_ERROR -CREATE VIEW v1 AS SELECT * FROM t1; - ---echo # Testing a VIEW created with FILE privileges but accessed with no FILE ---connection default -SELECT user(); -CREATE VIEW v1 AS SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM v1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO v1 VALUES (1,1,1,1); ---error ER_ACCESS_DENIED_ERROR -UPDATE v1 SET path=123; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM v1; - ---disconnect user ---connection default -SELECT user(); -DROP VIEW v1; -DROP TABLE t1; -DROP USER user@localhost; ---echo # ---echo # Testing FILE privileges done ---echo # - - CREATE TABLE t1 ( path VARCHAR(256) NOT NULL flag=1, fname VARCHAR(256) NOT NULL, diff --git a/storage/connect/mysql-test/connect/t/fix.test b/storage/connect/mysql-test/connect/t/fix.test index d2dfeb21352..c3cec55a217 100644 --- a/storage/connect/mysql-test/connect/t/fix.test +++ b/storage/connect/mysql-test/connect/t/fix.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=FIX; -let $FILE_EXT=FIX; ---source grant.inc - --copy_file $MTR_SUITE_DIR/std_data/dept.dat $MYSQLD_DATADIR/test/dept.dat --copy_file $MTR_SUITE_DIR/std_data/boys.txt $MYSQLD_DATADIR/test/boys.txt --copy_file $MTR_SUITE_DIR/std_data/boyswin.txt $MYSQLD_DATADIR/test/boyswin.txt diff --git a/storage/connect/mysql-test/connect/t/grant.test b/storage/connect/mysql-test/connect/t/grant.test new file mode 100644 index 00000000000..909bb4117a1 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/grant.test @@ -0,0 +1,95 @@ +-- source include/not_embedded.inc + +let $MYSQLD_DATADIR= `select @@datadir`; + +--echo # +--echo # Testing FILE privilege +--echo # +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +--connect(user,localhost,user,,) +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +CREATE TABLE t1 ( + path VARCHAR(256) NOT NULL flag=1, + fname VARCHAR(256) NOT NULL, + ftype CHAR(4) NOT NULL, + size DOUBLE(12,0) NOT NULL flag=5 +) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; +--connection default +SELECT user(); +CREATE TABLE t1 ( + path VARCHAR(256) NOT NULL flag=1, + fname VARCHAR(256) NOT NULL, + ftype CHAR(4) NOT NULL, + size DOUBLE(12,0) NOT NULL flag=5 +) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; +# "size>0" to skip directory names on Windows +--replace_result $MYSQLD_DATADIR DATADIR/ +SELECT fname, ftype, size FROM t1 WHERE size>0; + +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM t1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO t1 VALUES (); +--error ER_ACCESS_DENIED_ERROR +DELETE FROM t1 WHERE path='xxx'; +--error ER_ACCESS_DENIED_ERROR +UPDATE t1 SET path='yyy' WHERE path='xxx'; +--error ER_ACCESS_DENIED_ERROR +TRUNCATE TABLE t1; +--error ER_ACCESS_DENIED_ERROR +ALTER TABLE t1 READONLY=1; +--error ER_ACCESS_DENIED_ERROR +CREATE VIEW v1 AS SELECT * FROM t1; + +--echo # Testing a VIEW created with FILE privileges but accessed with no FILE +--connection default +SELECT user(); +CREATE VIEW v1 AS SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM v1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO v1 VALUES (1,1,1,1); +--error ER_ACCESS_DENIED_ERROR +UPDATE v1 SET path=123; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM v1; + +--disconnect user +--connection default +SELECT user(); +DROP VIEW v1; +DROP TABLE t1; +DROP USER user@localhost; +--echo # +--echo # Testing FILE privileges done +--echo # + + +let $TABLE_OPTIONS=TABLE_TYPE=BIN; +let $FILE_EXT=BIN; +--source grant.inc + +let $TABLE_OPTIONS=TABLE_TYPE=CSV; +let $FILE_EXT=CSV; +--source grant.inc + +let $TABLE_OPTIONS=TABLE_TYPE=DBF; +let $FILE_EXT=DBF; +--source grant.inc + +let $TABLE_OPTIONS=TABLE_TYPE=FIX; +let $FILE_EXT=FIX; +--source grant.inc + +let $TABLE_OPTIONS=TABLE_TYPE=VEC MAX_ROWS=100; +let $FILE_EXT=VEC; +--source grant.inc + + diff --git a/storage/connect/mysql-test/connect/t/ini.test b/storage/connect/mysql-test/connect/t/ini.test index e862f3cd672..0d23142ac9e 100644 --- a/storage/connect/mysql-test/connect/t/ini.test +++ b/storage/connect/mysql-test/connect/t/ini.test @@ -1,80 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; ---echo # ---echo # Checking FILE privileges ---echo # -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; ---connect(user,localhost,user,,) ---connection user -SELECT user(); -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI; -INSERT INTO t1 VALUES ('sec1','val1'); -SELECT * FROM t1; -UPDATE t1 SET val='val11'; -SELECT * FROM t1; -DELETE FROM t1; -SELECT * FROM t1; -INSERT INTO t1 VALUES('sec2','val2'); -TRUNCATE TABLE t1; -SELECT * FROM t1; -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -DROP VIEW v1; -DROP TABLE t1; -# Making sure DROP erased the data file ---error 1 ---remove_file $MYSQLD_DATADIR/test/t1.ini ---error ER_ACCESS_DENIED_ERROR -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; ---connection default -SELECT user(); -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES ('sec1','val1'); ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -INSERT INTO t1 VALUES ('sec2','val2'); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM t1; ---error ER_ACCESS_DENIED_ERROR -UPDATE t1 SET val='val11'; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM t1; ---error ER_ACCESS_DENIED_ERROR -TRUNCATE TABLE t1; ---error ER_ACCESS_DENIED_ERROR -ALTER TABLE t1 READONLY=1; ---error ER_ACCESS_DENIED_ERROR -DROP TABLE t1; ---error ER_ACCESS_DENIED_ERROR -CREATE VIEW v1 AS SELECT * FROM t1; ---echo # Testing a VIEW created with FILE privileges but accessed with no FILE ---connection default -SELECT user(); -CREATE VIEW v1 AS SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM v1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO v1 VALUES ('sec3','val3'); ---error ER_ACCESS_DENIED_ERROR -UPDATE v1 SET val='val11'; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM v1; ---disconnect user ---connection default -DROP VIEW v1; -DROP TABLE t1; ---remove_file $MYSQLD_DATADIR/test/t1.EXT -DROP USER user@localhost; - ---echo # ---echo # Checking FILE privileges: done ---echo # - - --copy_file $MTR_SUITE_DIR/std_data/contact.ini $MYSQLD_DATADIR/test/contact.ini --echo # diff --git a/storage/connect/mysql-test/connect/t/ini_grant.test b/storage/connect/mysql-test/connect/t/ini_grant.test new file mode 100644 index 00000000000..30678645692 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/ini_grant.test @@ -0,0 +1,79 @@ +-- source include/not_embedded.inc + +let $MYSQLD_DATADIR= `select @@datadir`; + +--echo # +--echo # Checking FILE privileges +--echo # +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +--connect(user,localhost,user,,) +--connection user +SELECT user(); +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI; +INSERT INTO t1 VALUES ('sec1','val1'); +SELECT * FROM t1; +UPDATE t1 SET val='val11'; +SELECT * FROM t1; +DELETE FROM t1; +SELECT * FROM t1; +INSERT INTO t1 VALUES('sec2','val2'); +TRUNCATE TABLE t1; +SELECT * FROM t1; +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +DROP VIEW v1; +DROP TABLE t1; +# Making sure DROP erased the data file +--error 1 +--remove_file $MYSQLD_DATADIR/test/t1.ini +--error ER_ACCESS_DENIED_ERROR +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; +--connection default +SELECT user(); +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES ('sec1','val1'); +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +INSERT INTO t1 VALUES ('sec2','val2'); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM t1; +--error ER_ACCESS_DENIED_ERROR +UPDATE t1 SET val='val11'; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM t1; +--error ER_ACCESS_DENIED_ERROR +TRUNCATE TABLE t1; +--error ER_ACCESS_DENIED_ERROR +ALTER TABLE t1 READONLY=1; +--error ER_ACCESS_DENIED_ERROR +DROP TABLE t1; +--error ER_ACCESS_DENIED_ERROR +CREATE VIEW v1 AS SELECT * FROM t1; +--echo # Testing a VIEW created with FILE privileges but accessed with no FILE +--connection default +SELECT user(); +CREATE VIEW v1 AS SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM v1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO v1 VALUES ('sec3','val3'); +--error ER_ACCESS_DENIED_ERROR +UPDATE v1 SET val='val11'; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM v1; +--disconnect user +--connection default +DROP VIEW v1; +DROP TABLE t1; +--remove_file $MYSQLD_DATADIR/test/t1.EXT +DROP USER user@localhost; + +--echo # +--echo # Checking FILE privileges: done +--echo # + + diff --git a/storage/connect/mysql-test/connect/t/mysql.test b/storage/connect/mysql-test/connect/t/mysql.test index 45d26cdf9eb..7c90acdd149 100644 --- a/storage/connect/mysql-test/connect/t/mysql.test +++ b/storage/connect/mysql-test/connect/t/mysql.test @@ -14,66 +14,6 @@ if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES DROP TABLE t1; --enable_query_log ---echo # ---echo # Testing FILE privilege ---echo # -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; ---connect(user,localhost,user,,) ---connection user -SELECT user(); ---replace_result $PORT PORT ---error ER_ACCESS_DENIED_ERROR ---eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=$PORT' ---connection default -SELECT user(); -CREATE TABLE t1remote (a INT NOT NULL); -INSERT INTO t1remote VALUES (10),(20),(30); ---replace_result $PORT PORT ---eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=$PORT' -SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM t1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO t1 VALUES ('xxx'); ---error ER_ACCESS_DENIED_ERROR -DELETE FROM t1 WHERE a='xxx'; ---error ER_ACCESS_DENIED_ERROR -UPDATE t1 SET a='yyy' WHERE a='xxx'; ---error ER_ACCESS_DENIED_ERROR -TRUNCATE TABLE t1; ---error ER_ACCESS_DENIED_ERROR -ALTER TABLE t1 READONLY=1; ---error ER_ACCESS_DENIED_ERROR -CREATE VIEW v1 AS SELECT * FROM t1; - ---echo # Testing a VIEW created with FILE privileges but accessed with no FILE ---connection default -SELECT user(); -CREATE VIEW v1 AS SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM v1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO v1 VALUES (2); ---error ER_ACCESS_DENIED_ERROR -UPDATE v1 SET a=123; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM v1; - ---disconnect user ---connection default -SELECT user(); -DROP VIEW v1; -DROP TABLE t1, t1remote; -DROP USER user@localhost; ---echo # ---echo # Testing FILE privileges done ---echo # - # TODO: remote VARCHAR is displayed as CHAR CREATE TABLE t1 (a int, b char(10)); diff --git a/storage/connect/mysql-test/connect/t/mysql_grant.test b/storage/connect/mysql-test/connect/t/mysql_grant.test new file mode 100644 index 00000000000..e825e70a84b --- /dev/null +++ b/storage/connect/mysql-test/connect/t/mysql_grant.test @@ -0,0 +1,78 @@ +-- source include/not_embedded.inc + +let $PORT= `select @@port`; + +--disable_query_log +--replace_result $PORT PORT +--error 0,ER_UNKNOWN_ERROR +--eval CREATE TABLE t1 (a INT) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT' +if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' + AND ENGINE='CONNECT' + AND CREATE_OPTIONS LIKE '%`table_type`=MySQL%'`) +{ + Skip Need MySQL support; +} +DROP TABLE t1; +--enable_query_log + +--echo # +--echo # Testing FILE privilege +--echo # +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +--connect(user,localhost,user,,) +--connection user +SELECT user(); +--replace_result $PORT PORT +--error ER_ACCESS_DENIED_ERROR +--eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=$PORT' +--connection default +SELECT user(); +CREATE TABLE t1remote (a INT NOT NULL); +INSERT INTO t1remote VALUES (10),(20),(30); +--replace_result $PORT PORT +--eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=$PORT' +SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM t1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO t1 VALUES ('xxx'); +--error ER_ACCESS_DENIED_ERROR +DELETE FROM t1 WHERE a='xxx'; +--error ER_ACCESS_DENIED_ERROR +UPDATE t1 SET a='yyy' WHERE a='xxx'; +--error ER_ACCESS_DENIED_ERROR +TRUNCATE TABLE t1; +--error ER_ACCESS_DENIED_ERROR +ALTER TABLE t1 READONLY=1; +--error ER_ACCESS_DENIED_ERROR +CREATE VIEW v1 AS SELECT * FROM t1; + +--echo # Testing a VIEW created with FILE privileges but accessed with no FILE +--connection default +SELECT user(); +CREATE VIEW v1 AS SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM v1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO v1 VALUES (2); +--error ER_ACCESS_DENIED_ERROR +UPDATE v1 SET a=123; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM v1; + +--disconnect user +--connection default +SELECT user(); +DROP VIEW v1; +DROP TABLE t1, t1remote; +DROP USER user@localhost; +--echo # +--echo # Testing FILE privileges done +--echo # + diff --git a/storage/connect/mysql-test/connect/t/vec.test b/storage/connect/mysql-test/connect/t/vec.test index 79ed4eabd86..ee504e9925a 100644 --- a/storage/connect/mysql-test/connect/t/vec.test +++ b/storage/connect/mysql-test/connect/t/vec.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=VEC MAX_ROWS=100; -let $FILE_EXT=VEC; ---source grant.inc - CREATE TABLE dir1 ( spath VARCHAR(256) NOT NULL flag=1, fname VARCHAR(256) NOT NULL, diff --git a/storage/connect/mysql-test/connect/t/xml.test b/storage/connect/mysql-test/connect/t/xml.test index 96e7e1a3a97..3914bed307d 100644 --- a/storage/connect/mysql-test/connect/t/xml.test +++ b/storage/connect/mysql-test/connect/t/xml.test @@ -16,11 +16,6 @@ DROP TABLE t1; let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; -let $FILE_EXT=XML; ---source grant.inc - - SET NAMES utf8; --vertical_results @@ -132,7 +127,8 @@ INSERT INTO t1 (ISBN, LANG, SUBJECT, AUTHOR, TITLE, PUBLISHEr, DATEPUB) VALUES('9782212090529','fr','général','Alain Michard', 'XML, Langage et Applications','Eyrolles Paris',1998); SELECT * FROM t1; -SELECT LOAD_FILE('test/xsample2.xml'); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval SELECT LOAD_FILE('$MYSQLD_DATADIR/test/xsample2.xml') AS xml DROP TABLE t1; --remove_file $MYSQLD_DATADIR/test/xsample2.xml @@ -289,7 +285,8 @@ INSERT INTO t1 VALUES (_latin1 0xC0C1C2C3); SELECT node, hex(node) FROM t1; DROP TABLE t1; --chmod 0777 $MYSQLD_DATADIR/test/t1.xml -SET @a=LOAD_FILE('test/t1.xml'); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval SET @a=LOAD_FILE('$MYSQLD_DATADIR/test/t1.xml') SELECT LEFT(@a,38); SELECT HEX(EXTRACTVALUE(@a,'/t1/line/node')); --remove_file $MYSQLD_DATADIR/test/t1.xml @@ -302,7 +299,8 @@ INSERT INTO t1 VALUES (_latin1 0xC0C1C2C3); SELECT node, hex(node) FROM t1; DROP TABLE t1; --chmod 0777 $MYSQLD_DATADIR/test/t1.xml -SET @a=LOAD_FILE('test/t1.xml'); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval SET @a=LOAD_FILE('$MYSQLD_DATADIR/test/t1.xml') SELECT LEFT(@a,43); SELECT HEX(EXTRACTVALUE(@a,'/t1/line/node')); --remove_file $MYSQLD_DATADIR/test/t1.xml @@ -321,7 +319,8 @@ INSERT INTO t1 VALUES ('&<>"\''); SELECT node, hex(node) FROM t1; DROP TABLE t1; --chmod 0777 $MYSQLD_DATADIR/test/t1.xml -SET @a=LOAD_FILE('test/t1.xml'); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval SET @a=LOAD_FILE('$MYSQLD_DATADIR/test/t1.xml') SELECT CAST(@a AS CHAR CHARACTER SET latin1); --remove_file $MYSQLD_DATADIR/test/t1.xml diff --git a/storage/connect/mysql-test/connect/t/xml_grant.test b/storage/connect/mysql-test/connect/t/xml_grant.test new file mode 100644 index 00000000000..f8401efaa64 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/xml_grant.test @@ -0,0 +1,23 @@ +-- source include/not_embedded.inc + +--disable_query_log +--error 0,ER_UNKNOWN_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2'; +if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' + AND ENGINE='CONNECT' + AND CREATE_OPTIONS LIKE '%`table_type`=XML%' + AND CREATE_OPTIONS LIKE '%xmlsup=libxml2%'`) +{ + Skip Need LIBXML2; +} +DROP TABLE t1; +--enable_query_log + + +let $MYSQLD_DATADIR= `select @@datadir`; + +let $TABLE_OPTIONS=TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; +let $FILE_EXT=XML; +--source grant.inc diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 6884c1c4176..dfa46a650a6 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -577,5 +577,6 @@ DllExport void NewPointer(PTABS, void *, void *); FILE *global_fopen(GLOBAL *g, int msgid, const char *path, const char *mode); int global_open(GLOBAL *g, int msgid, const char *filename, int flags); int global_open(GLOBAL *g, int msgid, const char *filename, int flags, int mode); +DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir); bool PushWarning(PGLOBAL, PTDBASE); diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 67947e3042b..e8098bb2512 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -219,11 +219,23 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) return pBuff; } // end of PlugRemoveType + +BOOL PlugIsAbsolutePath(LPCSTR path) +{ +#if defined(WIN32) + return ((path[0] >= 'a' && path[0] <= 'z') || + (path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':'; +#else + return path[0] == '/'; +#endif +} + + /***********************************************************************/ /* Set the full path of a file relatively to a given path. */ /* Note: this routine is not really implemented for Unix. */ /***********************************************************************/ -LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR FileName, LPCSTR defpath) +LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) { char newname[_MAX_PATH]; char direc[_MAX_DIR], defdir[_MAX_DIR]; @@ -240,6 +252,22 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR FileName, LPCSTR defpath) return pBuff; } // endif + if (PlugIsAbsolutePath(FileName)) + { + strcpy(pBuff, FileName); // FileName includes absolute path + return pBuff; + } // endif + + if (strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath)) + { + char tmp[_MAX_PATH]; + int len= snprintf(tmp, sizeof(tmp) - 1, "%s%s%s", + prefix, defpath, FileName); + memcpy(pBuff, tmp, (size_t) len); + pBuff[len]= '\0'; + return pBuff; + } + _splitpath(FileName, drive, direc, fname, ftype); _splitpath(defpath, defdrv, defdir, NULL, NULL); From cb246b20d6e0dad16797b9e09bef6f0431b88d37 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 21 May 2013 18:56:35 +0200 Subject: [PATCH 191/273] fix for compiled-in FederatedX --- mysql-test/suite/federated/federated.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/federated/federated.test b/mysql-test/suite/federated/federated.test index ab0cfc4b36c..88d20817996 100644 --- a/mysql-test/suite/federated/federated.test +++ b/mysql-test/suite/federated/federated.test @@ -1,6 +1,6 @@ source include/federated.inc; - +connection master; # # MDEV-388 Creating a federated table with a non-existing server returns a random error code # From aebcd56ca912979c92a32513def44aa121d82bb2 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 22 May 2013 13:35:21 +0200 Subject: [PATCH 192/273] - Changing CONNECT version number and date modified: storage/connect/ha_connect.cc storage/connect/mysql-test/connect/r/xml.result - Testing default pivot columns for srcdef Fixing order by MariaDB bug for pivot tables modified: storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabpivot.cpp storage/connect/tabpivot.h --- storage/connect/ha_connect.cc | 2 +- .../connect/mysql-test/connect/r/xml.result | 2 +- storage/connect/tabmysql.cpp | 23 +++ storage/connect/tabmysql.h | 1 + storage/connect/tabpivot.cpp | 151 +++++++++--------- storage/connect/tabpivot.h | 1 + 6 files changed, 100 insertions(+), 80 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 3db86b8e607..5adf8747841 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -158,7 +158,7 @@ extern "C" char nmfile[]; extern "C" char pdebug[]; extern "C" { - char version[]= "Version 1.01.0005 April 27, 2013"; + char version[]= "Version 1.01.0006 Mai 21, 2013"; #if defined(XMSG) char msglang[]; // Default message language diff --git a/storage/connect/mysql-test/connect/r/xml.result b/storage/connect/mysql-test/connect/r/xml.result index 44fab646dcf..67fcc5f121e 100644 --- a/storage/connect/mysql-test/connect/r/xml.result +++ b/storage/connect/mysql-test/connect/r/xml.result @@ -413,7 +413,7 @@ DROP TABLE t1; SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SELECT CAST(@a AS CHAR CHARACTER SET latin1); CAST(@a AS CHAR CHARACTER SET latin1) - + ÀÁÂÃ diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 8b97a592d93..f06e8e9bd57 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -900,6 +900,29 @@ PCOL TDBMYSQL::MakeFieldColumn(PGLOBAL g, char *name) return colp; } // end of MakeFieldColumn +/***********************************************************************/ +/* Called by Pivot tables to find default column names in a View */ +/* as the name of last field not equal to the passed name. */ +/***********************************************************************/ +char *TDBMYSQL::FindFieldColumn(char *name) + { + int n; + MYSQL_FIELD *fld; + char *cp = NULL; + + for (n = Myc.m_Fields - 1; n >= 0; n--) { + fld = &Myc.m_Res->fields[n]; + + if (!name || stricmp(name, fld->name)) { + cp = fld->name; + break; + } // endif name + + } // endfor n + + return cp; + } // end of FindFieldColumn + /***********************************************************************/ /* Data Base read routine for MYSQL access method. */ /***********************************************************************/ diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h index 5d8f32e9f21..24f8c4cdef2 100644 --- a/storage/connect/tabmysql.h +++ b/storage/connect/tabmysql.h @@ -90,6 +90,7 @@ class TDBMYSQL : public TDBASE { // Specific routines bool SetColumnRanks(PGLOBAL g); PCOL MakeFieldColumn(PGLOBAL g, char *name); + PSZ FindFieldColumn(char *name); protected: // Internal functions diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 867689626f9..916a3c2584e 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -161,6 +161,42 @@ PCOL TDBPIVOT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) return colp; } // end of MakeCol +/***********************************************************************/ +/* Find default fonction and pivot columns. */ +/***********************************************************************/ +bool TDBPIVOT::FindDefaultColumns(PGLOBAL g) + { + PCOLDEF cdp; + PTABDEF defp = Tdbp->GetDef(); + + if (!Fncol) { + for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) + if (!Picol || stricmp(Picol, cdp->GetName())) + Fncol = cdp->GetName(); + + if (!Fncol) { + strcpy(g->Message, MSG(NO_DEF_FNCCOL)); + return true; + } // endif Fncol + + } // endif Fncol + + if (!Picol) { + // Find default Picol as the last one not equal to Fncol + for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) + if (stricmp(Fncol, cdp->GetName())) + Picol = cdp->GetName(); + + if (!Picol) { + strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); + return true; + } // endif Picol + + } // endif Picol + + return false; + } // end of FindDefaultColumns + /***********************************************************************/ /* Prepare the source table Query. */ /***********************************************************************/ @@ -174,69 +210,45 @@ bool TDBPIVOT::GetSourceTable(PGLOBAL g) if (!(Tdbp = GetSubTable(g, ((PPIVOTDEF)To_Def)->Tablep, true))) return true; - if (!Tdbp->IsView()) { + if (!GBdone) { + char *colist; PCOLDEF cdp; - PTABDEF defp = Tdbp->GetDef(); - if (!Fncol) { - for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) - if (!Picol || stricmp(Picol, cdp->GetName())) - Fncol = cdp->GetName(); + if (FindDefaultColumns(g)) + return true; - if (!Fncol) { - strcpy(g->Message, MSG(NO_DEF_FNCCOL)); - return true; - } // endif Fncol + // Locate the suballocated colist (size is not known yet) + *(colist = (char*)PlugSubAlloc(g, NULL, 0)) = 0; - } // endif Fncol + // Make the column list + for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext()) + if (!cdp->GetOffset()) + strcat(strcat(colist, cdp->GetName()), ", "); - if (!Picol) { - // Find default Picol as the last one not equal to Fncol - for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) - if (!Fncol || stricmp(Fncol, cdp->GetName())) - Picol = cdp->GetName(); + // Add the Pivot column at the end of the list + strcat(colist, Picol); - if (!Picol) { - strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); - return true; - } // endif Picol + // Now we know how much was suballocated + PlugSubAlloc(g, NULL, strlen(colist)); - } // endif Picol + // Locate the source string (size is not known yet) + Tabsrc = (char*)PlugSubAlloc(g, NULL, 0); - if (!GBdone) { - char *colist; + // Start making the definition + strcat(strcat(strcpy(Tabsrc, "SELECT "), colist), ", "); - // Locate the suballocated colist (size is not known yet) - *(colist = (char*)PlugSubAlloc(g, NULL, 0)) = 0; + // Make it suitable for Pivot by doing the group by + strcat(strcat(Tabsrc, Function), "("); + strcat(strcat(strcat(Tabsrc, Fncol), ") "), Fncol); + strcat(strcat(Tabsrc, " FROM "), Tabname); + strcat(strcat(Tabsrc, " GROUP BY "), colist); - // Make the column list - for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext()) - if (!cdp->GetOffset()) - strcat(strcat(colist, cdp->GetName()), ", "); - - // Add the Pivot column at the end of the list - strcat(colist, Picol); - - // Now we know how much was suballocated - PlugSubAlloc(g, NULL, strlen(colist)); - - // Locate the source string (size is not known yet) - Tabsrc = (char*)PlugSubAlloc(g, NULL, 0); - - // Start making the definition - strcat(strcat(strcpy(Tabsrc, "SELECT "), colist), ", "); - - // Make it suitable for Pivot by doing the group by - strcat(strcat(Tabsrc, Function), "("); - strcat(strcat(strcat(Tabsrc, Fncol), ") "), Fncol); - strcat(strcat(Tabsrc, " FROM "), Tabname); - strcat(strcat(Tabsrc, " GROUP BY "), colist); - - // Now we know how much was suballocated - PlugSubAlloc(g, NULL, strlen(Tabsrc)); - } // endif !GBdone + if (Tdbp->IsView()) // Until MariaDB bug is fixed + strcat(strcat(Tabsrc, " ORDER BY "), colist); - } // endif IsView + // Now we know how much was suballocated + PlugSubAlloc(g, NULL, strlen(Tabsrc)); + } // endif !GBdone } else if (!Tabsrc) { strcpy(g->Message, MSG(SRC_TABLE_UNDEF)); @@ -263,6 +275,10 @@ bool TDBPIVOT::GetSourceTable(PGLOBAL g) bool TDBPIVOT::MakePivotColumns(PGLOBAL g) { if (!Tdbp->IsView()) { + // This was not done yet if GBdone is true + if (FindDefaultColumns(g)) + return true; + // Now it is time to allocate the pivot and function columns if (!(Fcolp = Tdbp->ColDB(g, Fncol, 0))) { // Function column not found in table @@ -309,36 +325,15 @@ bool TDBPIVOT::MakeViewColumns(PGLOBAL g) } else tdbp = (PTDBMY)Tdbp; - if (!Fncol || !Picol) { - strcpy(g->Message, "Missing Function or Pivot column"); + if (!Fncol && !(Fncol = tdbp->FindFieldColumn(Picol))) { + strcpy(g->Message, MSG(NO_DEF_FNCCOL)); return true; - } // endif -#if 0 - if (!Fncol) { - for (crp = qryp->Colresp; crp; crp = crp->Next) - if (!Picol || stricmp(Picol, crp->Name)) - Fncol = crp->Name; - - if (!Fncol) { - strcpy(g->Message, MSG(NO_DEF_FNCCOL)); - return true; - } // endif Fncol - } // endif Fncol - if (!Picol) { - // Find default Picol as the last one not equal to Fncol - for (crp = qryp->Colresp; crp; crp = crp->Next) - if (!Fncol || stricmp(Fncol, crp->Name)) - Picol = crp->Name; - - if (!Picol) { - strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); - return true; - } // endif Picol - + if (!Picol && !(Picol = tdbp->FindFieldColumn(Fncol))) { + strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); + return true; } // endif Picol -#endif // 0 // Now it is time to allocate the pivot and function columns if (!(Fcolp = tdbp->MakeFieldColumn(g, Fncol))) diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h index e869d1cae6c..1617801298b 100644 --- a/storage/connect/tabpivot.h +++ b/storage/connect/tabpivot.h @@ -78,6 +78,7 @@ class TDBPIVOT : public TDBPRX { protected: // Internal routines + bool FindDefaultColumns(PGLOBAL g); bool GetSourceTable(PGLOBAL g); bool MakePivotColumns(PGLOBAL g); bool MakeViewColumns(PGLOBAL g); From 9bc4c4183df327140b5f477993f10f08282d977f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 24 May 2013 14:33:04 +0200 Subject: [PATCH 193/273] MDEV-4516 SELECT from I_S.QUERY_CACHE_INFO produces ER_UNKNOWN_ERROR when query cache size is 0 if qc->try_lock() fails, it's not an error --- mysql-test/suite/plugins/r/qc_info.result | 3 +++ mysql-test/suite/plugins/t/qc_info.test | 3 +++ plugin/qc_info/qc_info.cc | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/plugins/r/qc_info.result b/mysql-test/suite/plugins/r/qc_info.result index 3e967d55f43..ab646d74511 100644 --- a/mysql-test/suite/plugins/r/qc_info.result +++ b/mysql-test/suite/plugins/r/qc_info.result @@ -12,4 +12,7 @@ test select * from t1 1 512 drop table t1; select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info; statement_schema statement_text result_blocks_count result_blocks_size +set global query_cache_size = 0; +select * from information_schema.query_cache_info; +STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED set global query_cache_size= default; diff --git a/mysql-test/suite/plugins/t/qc_info.test b/mysql-test/suite/plugins/t/qc_info.test index fc6c9d5af3a..a081617c524 100644 --- a/mysql-test/suite/plugins/t/qc_info.test +++ b/mysql-test/suite/plugins/t/qc_info.test @@ -4,5 +4,8 @@ drop table t1; # the query was invalidated select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info; +set global query_cache_size = 0; +select * from information_schema.query_cache_info; + set global query_cache_size= default; diff --git a/plugin/qc_info/qc_info.cc b/plugin/qc_info/qc_info.cc index af13b6edf93..8489b14c5db 100644 --- a/plugin/qc_info/qc_info.cc +++ b/plugin/qc_info/qc_info.cc @@ -83,7 +83,7 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables, return 0; if (qc->try_lock(thd)) - return status; + return 0; // QC is or is being disabled /* loop through all queries in the query cache */ for (uint i= 0; i < queries->records; i++) From ef1e767ae37d82bf821bda5062989a05917b7211 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 27 May 2013 16:35:42 +0200 Subject: [PATCH 194/273] MDEV-4553 - Fixes for compilation under NetBSD. --- include/my_global.h | 2 ++ include/my_pthread.h | 6 +++++- sql/threadpool_unix.cc | 22 ++++++++++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index fcfc052d191..981425dc1b1 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1436,6 +1436,7 @@ static inline char *dlerror(void) #endif /* Provide __func__ macro definition for platforms that miss it. */ +#if !defined (__func__) #if __STDC_VERSION__ < 199901L # if __GNUC__ >= 2 # define __func__ __FUNCTION__ @@ -1453,6 +1454,7 @@ static inline char *dlerror(void) #else # define __func__ "" #endif +#endif /* !defined(__func__) */ #ifndef HAVE_RINT /** diff --git a/include/my_pthread.h b/include/my_pthread.h index 5a921fe0f26..d9aae5f47c9 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -119,7 +119,6 @@ int pthread_cancel(pthread_t thread); #define HAVE_LOCALTIME_R 1 #define _REENTRANT 1 #define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 -#define PTHREAD_STACK_MIN 65536 #undef SAFE_MUTEX /* This will cause conflicts */ #define pthread_key(T,V) DWORD V @@ -857,6 +856,11 @@ extern uint thd_lib_detected; #define mysql_mutex_record_order(A,B) do { } while(0) #endif +/* At least Windows and NetBSD do not have this definition */ +#ifndef PTHREAD_STACK_MIN +#define PTHREAD_STACK_MIN 65536 +#endif + #ifdef __cplusplus } #endif diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc index 94251660e37..41fe87e19d3 100644 --- a/sql/threadpool_unix.cc +++ b/sql/threadpool_unix.cc @@ -286,6 +286,20 @@ static void *native_event_get_userdata(native_event *event) } #elif defined(HAVE_KQUEUE) + +/* + NetBSD is incompatible with other BSDs , last parameter in EV_SET macro + (udata, user data) needs to be intptr_t, whereas it needs to be void* + everywhere else. +*/ + +#ifdef __NetBSD__ +#define MY_EV_SET(a, b, c, d, e, f, g) EV_SET(a, b, c, d, e, f, (intptr_t)g) +#else +#define MY_EV_SET(a, b, c, d, e, f, g) EV_SET(a, b, c, d, e, f, g) +#endif + + int io_poll_create() { return kqueue(); @@ -294,7 +308,7 @@ int io_poll_create() int io_poll_start_read(int pollfd, int fd, void *data) { struct kevent ke; - EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT, + MY_EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT, 0, 0, data); return kevent(pollfd, &ke, 1, 0, 0, 0); } @@ -303,7 +317,7 @@ int io_poll_start_read(int pollfd, int fd, void *data) int io_poll_associate_fd(int pollfd, int fd, void *data) { struct kevent ke; - EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT, + MY_EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT, 0, 0, data); return io_poll_start_read(pollfd,fd, data); } @@ -312,7 +326,7 @@ int io_poll_associate_fd(int pollfd, int fd, void *data) int io_poll_disassociate_fd(int pollfd, int fd) { struct kevent ke; - EV_SET(&ke,fd, EVFILT_READ, EV_DELETE, 0, 0, NULL); + MY_EV_SET(&ke,fd, EVFILT_READ, EV_DELETE, 0, 0, 0); return kevent(pollfd, &ke, 1, 0, 0, 0); } @@ -337,7 +351,7 @@ int io_poll_wait(int pollfd, struct kevent *events, int maxevents, int timeout_m static void* native_event_get_userdata(native_event *event) { - return event->udata; + return (void *)event->udata; } #elif defined (__sun) From 7ba2ff93ac647c5d3517c6eb79f9f63848c9fed2 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 22 May 2013 16:44:44 +0200 Subject: [PATCH 195/273] MDEV-4548 - compile sphinx.so/dll and include into packages replaced snippets_udf.cc with the latest version (2.0.8 from sphinxsource.com), fixed trivial errors on Windows. It will be compiled and installed into plugins directory now. --- storage/sphinx/CMakeLists.txt | 9 ++++++ storage/sphinx/snippets_udf.cc | 59 ++++++++++++++++++++++++++-------- 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/storage/sphinx/CMakeLists.txt b/storage/sphinx/CMakeLists.txt index d9320d10cf7..3e26637218f 100644 --- a/storage/sphinx/CMakeLists.txt +++ b/storage/sphinx/CMakeLists.txt @@ -3,3 +3,12 @@ IF(MSVC) LINK_LIBRARIES(ws2_32) ENDIF(MSVC) MYSQL_ADD_PLUGIN(sphinx ha_sphinx.cc STORAGE_ENGINE) + +IF(NOT WITHOUT_SPHINX_STORAGE_ENGINE) + ADD_LIBRARY(snippets_udf MODULE snippets_udf.cc) + TARGET_LINK_LIBRARIES(snippets_udf mysys) # my_error + ADD_DEPENDENCIES(snippets_udf GenError) # uses generated error constants + SET_TARGET_PROPERTIES(snippets_udf PROPERTIES OUTPUT_NAME sphinx PREFIX "") + INSTALL(TARGETS snippets_udf COMPONENT Server DESTINATION ${INSTALL_PLUGINDIR}) +ENDIF() + diff --git a/storage/sphinx/snippets_udf.cc b/storage/sphinx/snippets_udf.cc index 85fb66ab793..5318592ab5f 100644 --- a/storage/sphinx/snippets_udf.cc +++ b/storage/sphinx/snippets_udf.cc @@ -1,5 +1,5 @@ // -// $Id: snippets_udf.cc 3087 2012-01-30 23:07:35Z shodan $ +// $Id: snippets_udf.cc 3508 2012-11-05 11:48:48Z kevg $ // // @@ -17,12 +17,19 @@ #include #include +#ifndef __WIN__ #include #include +#else +#include +#endif #include -#if MYSQL_VERSION_ID>50100 +#if MYSQL_VERSION_ID>=50515 +#include "sql_class.h" +#include "sql_array.h" +#elif MYSQL_VERSION_ID>50100 #include "mysql_priv.h" #include #else @@ -84,9 +91,9 @@ void sphUnalignedWrite ( void * pPtr, const T & tVal ) #define SafeDeleteArray(_arg) { if ( _arg ) delete [] ( _arg ); (_arg) = NULL; } #define Min(a,b) ((a)<(b)?(a):(b)) - +#ifndef __WIN__ typedef unsigned int DWORD; - +#endif inline DWORD sphF2DW ( float f ) { union { float f; uint32 d; } u; u.f = f; return u.d; } static char * sphDup ( const char * sSrc, int iLen=-1 ) @@ -158,7 +165,7 @@ enum SEARCHD_COMMAND_EXCERPT = 1, - VER_COMMAND_EXCERPT = 0x103, + VER_COMMAND_EXCERPT = 0x104, }; /// known answers @@ -380,23 +387,44 @@ int CSphUrl::Connect() else { int tmp_errno; + bool bError = false; + +#if MYSQL_VERSION_ID>=50515 + struct addrinfo *hp = NULL; + tmp_errno = getaddrinfo ( m_sHost, NULL, NULL, &hp ); + if ( !tmp_errno || !hp || !hp->ai_addr ) + { + bError = true; + if ( hp ) + freeaddrinfo ( hp ); + } +#else struct hostent tmp_hostent, *hp; char buff2 [ GETHOSTBYNAME_BUFF_SIZE ]; - hp = my_gethostbyname_r ( m_sHost, &tmp_hostent, buff2, sizeof(buff2), &tmp_errno ); if ( !hp ) { my_gethostbyname_r_free(); + bError = true; + } +#endif + if ( bError ) + { char sError[256]; - snprintf ( sError, sizeof(sError), "failed to resolve searchd host (name=%s)", m_sHost ); + my_snprintf ( sError, sizeof(sError), "failed to resolve searchd host (name=%s)", m_sHost ); my_error ( ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), sError ); return -1; } +#if MYSQL_VERSION_ID>=50515 + memcpy ( &sin.sin_addr, hp->ai_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->ai_addrlen ) ); + freeaddrinfo ( hp ); +#else memcpy ( &sin.sin_addr, hp->h_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->h_length ) ); my_gethostbyname_r_free(); +#endif } } else { @@ -534,12 +562,16 @@ CSphResponse::Read ( int iSocket, int iClientVersion ) } /// udf - +#ifdef _MSC_VER +#define DLLEXPORT __declspec(dllexport) +#else +#define DLLEXPORT +#endif extern "C" { - my_bool sphinx_snippets_init ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sMessage ); - void sphinx_snippets_deinit ( UDF_INIT * pUDF ); - char * sphinx_snippets ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sResult, unsigned long * pLength, char * pIsNull, char * sError ); + DLLEXPORT my_bool sphinx_snippets_init ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sMessage ); + DLLEXPORT void sphinx_snippets_deinit ( UDF_INIT * pUDF ); + DLLEXPORT char * sphinx_snippets ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sResult, unsigned long * pLength, char * pIsNull, char * sError ); }; #define MAX_MESSAGE_LENGTH 255 @@ -608,7 +640,7 @@ struct CSphSnippets } #define STRING CHECK_TYPE(STRING_RESULT) -#define INT CHECK_TYPE(INT_RESULT); int iValue = *(long long *)pArgs->args[i] +#define INT CHECK_TYPE(INT_RESULT); int iValue =(int) *(long long *)pArgs->args[i] my_bool sphinx_snippets_init ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sMessage ) { @@ -662,6 +694,7 @@ my_bool sphinx_snippets_init ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sMessag KEYWORD("load_files") { INT; if ( iValue ) pOpts->m_iFlags |= 128; } KEYWORD("allow_empty") { INT; if ( iValue ) pOpts->m_iFlags |= 256; } KEYWORD("emit_zones") { INT; if ( iValue ) pOpts->m_iFlags |= 512; } + KEYWORD("load_files_scattered") { INT; if ( iValue ) pOpts->m_iFlags |= 1024; } else { snprintf ( sMessage, MAX_MESSAGE_LENGTH, "unrecognized argument: %.*s", @@ -787,5 +820,5 @@ void sphinx_snippets_deinit ( UDF_INIT * pUDF ) } // -// $Id: snippets_udf.cc 3087 2012-01-30 23:07:35Z shodan $ +// $Id: snippets_udf.cc 3508 2012-11-05 11:48:48Z kevg $ // From 7ef4c5df470e2c1ee0d5e7b57e05deebdcad753e Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 23 May 2013 12:04:52 +0400 Subject: [PATCH 196/273] Connect: fixing non thread-safe code. Passing "struct tm" buffer to GetGmTime() instead of using a static bufer. modified: storage/connect/tabodbc.cpp storage/connect/value.cpp storage/connect/value.h --- storage/connect/tabodbc.cpp | 2 +- storage/connect/value.cpp | 17 ++++++++--------- storage/connect/value.h | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index 909fcda4abf..599f9c7e80f 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -895,7 +895,7 @@ void ODBCCOL::WriteColumn(PGLOBAL g) Value->SetValue_pval(To_Val, false); // Convert the inserted value if (Buf_Type == TYPE_DATE) { - struct tm *dbtime = ((DTVAL*)Value)->GetGmTime(); + struct tm tm, *dbtime = ((DTVAL*)Value)->GetGmTime(&tm); Sqlbuf->second = dbtime->tm_sec; Sqlbuf->minute = dbtime->tm_min; diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 6152fdc238f..20e8f58a61c 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -1251,9 +1251,8 @@ static struct tm *gmtime_mysql(const time_t *timep, struct tm *tm) } -struct tm *DTVAL::GetGmTime(void) +struct tm *DTVAL::GetGmTime(struct tm *tm_buffer) { - static struct tm tm_static; /* TODO: Move as a parameter to GetGmTime() */ struct tm *datm; time_t t = (time_t)Tval; @@ -1263,13 +1262,13 @@ struct tm *DTVAL::GetGmTime(void) for (n = 0; t < 0; n += 4) t += FOURYEARS; - datm = gmtime_mysql(&t, &tm_static); + datm = gmtime_mysql(&t, tm_buffer); if (datm) datm->tm_year -= n; } else - datm = gmtime_mysql(&t, &tm_static); + datm = gmtime_mysql(&t, tm_buffer); return datm; } // end of GetGmTime @@ -1519,7 +1518,7 @@ char *DTVAL::GetCharString(char *p) { if (Pdtp) { size_t n = 0; - struct tm *ptm = GetGmTime(); + struct tm tm, *ptm= GetGmTime(&tm); if (ptm) n = strftime(Sdate, Len + 1, Pdtp->OutFmt, ptm); @@ -1545,7 +1544,7 @@ char *DTVAL::ShowValue(char *buf, int len) if (Pdtp) { char *p; size_t m, n = 0; - struct tm *ptm = GetGmTime(); + struct tm tm, *ptm = GetGmTime(&tm); if (Len < len) { p = buf; @@ -1575,7 +1574,7 @@ char *DTVAL::ShowValue(char *buf, int len) bool DTVAL::GetTmMember(OPVAL op, int& mval) { bool rc = false; - struct tm *ptm = GetGmTime(); + struct tm tm, *ptm = GetGmTime(&tm); switch (op) { case OP_MDAY: mval = ptm->tm_mday; break; @@ -1603,7 +1602,7 @@ bool DTVAL::WeekNum(PGLOBAL g, int& nval) { // w is the start of the week SUN=0, MON=1, etc. int m, n, w = nval % 7; - struct tm *ptm = GetGmTime(); + struct tm tm, *ptm = GetGmTime(&tm); // Which day is January 4th of this year? m = (367 + ptm->tm_wday - ptm->tm_yday) % 7; @@ -1627,7 +1626,7 @@ bool DTVAL::WeekNum(PGLOBAL g, int& nval) bool DTVAL::FormatValue(PVAL vp, char *fmt) { char *buf = (char*)vp->GetTo_Val(); // Should be big enough - struct tm *ptm = GetGmTime(); + struct tm tm, *ptm = GetGmTime(&tm); if (trace) htrc("FormatValue: ptm=%p len=%d\n", ptm, vp->GetValLen()); diff --git a/storage/connect/value.h b/storage/connect/value.h index 95d69dae92f..62b4ea4617a 100644 --- a/storage/connect/value.h +++ b/storage/connect/value.h @@ -288,7 +288,7 @@ class DllExport DTVAL : public TYPVAL { bool MakeDate(PGLOBAL g, int *val, int nval); bool WeekNum(PGLOBAL g, int& nval); - struct tm *GetGmTime(void); + struct tm *GetGmTime(struct tm *); protected: // Default constructor not to be used From b9ce8572d91aaaf1c6abcb6a1fa375f1d76bdf94 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 May 2013 17:05:31 +0300 Subject: [PATCH 197/273] MDEV-4520: Assertion `0' fails in Query_cache::end_of_result on concurrent drop event and event execution If there is no net.vio then query cache cant't get data via net_real_write() so it is better just do not try to cache such query. --- .../r/init_connection_query_cache.result | 19 ++++++++++++++ .../t/init_connection_query_cache-master.opt | 1 + mysql-test/t/init_connection_query_cache.test | 26 +++++++++++++++++++ sql/sql_cache.cc | 8 +++--- sql/sql_class.cc | 2 +- 5 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 mysql-test/r/init_connection_query_cache.result create mode 100644 mysql-test/t/init_connection_query_cache-master.opt create mode 100644 mysql-test/t/init_connection_query_cache.test diff --git a/mysql-test/r/init_connection_query_cache.result b/mysql-test/r/init_connection_query_cache.result new file mode 100644 index 00000000000..5a1e5c5244f --- /dev/null +++ b/mysql-test/r/init_connection_query_cache.result @@ -0,0 +1,19 @@ +# +# MDEV-4520: Assertion `0' fails in Query_cache::end_of_result on +# concurrent drop event and event execution +# +set GLOBAL query_cache_size=1355776; +create user mysqltest1@localhost; +grant SELECT on test.* to mysqltest1@localhost; +create table t1 (a int); +# This explain put here to be sure that init connection query +# has 'Impossible WHERE'. +explain extended select * from test.t1 where 0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0 +revoke all privileges, grant option from mysqltest1@localhost; +drop user mysqltest1@localhost; +drop table t1; +set GLOBAL query_cache_size=default; diff --git a/mysql-test/t/init_connection_query_cache-master.opt b/mysql-test/t/init_connection_query_cache-master.opt new file mode 100644 index 00000000000..7bef2af8d35 --- /dev/null +++ b/mysql-test/t/init_connection_query_cache-master.opt @@ -0,0 +1 @@ +--init_connect="select * from test.t1 where 0" diff --git a/mysql-test/t/init_connection_query_cache.test b/mysql-test/t/init_connection_query_cache.test new file mode 100644 index 00000000000..4d83304163e --- /dev/null +++ b/mysql-test/t/init_connection_query_cache.test @@ -0,0 +1,26 @@ +-- source include/have_query_cache.inc + +--echo # +--echo # MDEV-4520: Assertion `0' fails in Query_cache::end_of_result on +--echo # concurrent drop event and event execution +--echo # +set GLOBAL query_cache_size=1355776; + +create user mysqltest1@localhost; +grant SELECT on test.* to mysqltest1@localhost; + +create table t1 (a int); + +connect (con1,localhost,mysqltest1,,); +connection con1; +--echo # This explain put here to be sure that init connection query +--echo # has 'Impossible WHERE'. +explain extended select * from test.t1 where 0; +connection default; +disconnect con1; +revoke all privileges, grant option from mysqltest1@localhost; +drop user mysqltest1@localhost; + +drop table t1; + +set GLOBAL query_cache_size=default; diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 1e5c99822ff..10cdadd5d95 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -4000,7 +4000,8 @@ Query_cache::is_cacheable(THD *thd, LEX *lex, if (thd->lex->safe_to_cache_query && (thd->variables.query_cache_type == 1 || (thd->variables.query_cache_type == 2 && (lex->select_lex.options & - OPTION_TO_QUERY_CACHE)))) + OPTION_TO_QUERY_CACHE))) && + thd->net.vio) { DBUG_PRINT("qcache", ("options: %lx %lx type: %u", (long) OPTION_TO_QUERY_CACHE, @@ -4022,11 +4023,12 @@ Query_cache::is_cacheable(THD *thd, LEX *lex, } DBUG_PRINT("qcache", - ("not interesting query: %d or not cacheable, options %lx %lx type: %u", + ("not interesting query: %d or not cacheable, options %lx %lx type: %u net->vio present: %u", (int) lex->sql_command, (long) OPTION_TO_QUERY_CACHE, (long) lex->select_lex.options, - (int) thd->variables.query_cache_type)); + (int) thd->variables.query_cache_type, + (uint) test(thd->net.vio))); DBUG_RETURN(0); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5e0fe8425af..ca17cefff4c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4579,7 +4579,7 @@ void xid_cache_delete(XID_STATE *xid_state) int THD::decide_logging_format(TABLE_LIST *tables) { DBUG_ENTER("THD::decide_logging_format"); - DBUG_PRINT("info", ("query: %s", query())); + DBUG_PRINT("info", ("Query: %s", query())); DBUG_PRINT("info", ("variables.binlog_format: %lu", variables.binlog_format)); DBUG_PRINT("info", ("lex->get_stmt_unsafe_flags(): 0x%x", From 33b95315680e42754d41f63f72a003f0d69959d3 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 24 May 2013 00:19:26 +0200 Subject: [PATCH 198/273] - Fix setting default type to MYSQL->PROXY->DOS in some places where it was not done correctly. - Fix a bug causing add_field to generate a syntax error on DOUBLE columns with a 0 decimal value. - Column can be undefined when Srcdef is specified. modified: storage/connect/ha_connect.cc storage/connect/mycat.cc storage/connect/tabmysql.cpp storage/connect/tabutil.cpp storage/connect/tabutil.h --- storage/connect/ha_connect.cc | 49 ++++++++++++++++++++++------------- storage/connect/mycat.cc | 31 ++++++++++++---------- storage/connect/tabmysql.cpp | 2 +- storage/connect/tabutil.cpp | 10 ++++--- storage/connect/tabutil.h | 2 +- 5 files changed, 57 insertions(+), 37 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 5adf8747841..38b5e74c38c 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -680,6 +680,10 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) // Return the handler default value if (!stricmp(opname, "Dbname") || !stricmp(opname, "Database")) opval= (char*)GetDBName(NULL); // Current database + else if (!stricmp(opname, "Type")) // Default type + opval= (!options) ? NULL : + (options->srcdef) ? "MYSQL" : + (options->tabname) ? "PROXY" : "DOS"; else if (!stricmp(opname, "User")) // Connected user opval= table->in_use->main_security_ctx.user; else if (!stricmp(opname, "Host")) // Connected user host @@ -2671,7 +2675,9 @@ int ha_connect::delete_all_rows() bool ha_connect::check_privileges(THD *thd, PTOS options) { if (!options->type) { - if (options->tabname) + if (options->srcdef) + options->type= "MYSQL"; + else if (options->tabname) options->type= "PROXY"; else options->type= "DOS"; @@ -3336,7 +3342,7 @@ static bool add_field(String *sql, const char *field_name, const char *type, if (len) { error|= sql->append('('); error|= sql->append_ulonglong(len); - if (dec) { + if (dec || !strcmp(type, "DOUBLE")) { error|= sql->append(','); error|= sql->append_ulonglong(dec); } @@ -3379,7 +3385,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, #endif // WIN32 int port= 0, hdr= 0, mxr= 0, b= 0; uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL); - bool ok= false, dbf= false; + bool bif, ok= false, dbf= false; TABTYPE ttp= TAB_UNDEF; MEM_ROOT *mem= thd->mem_root; PQRYRES qrp; @@ -3546,6 +3552,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= false; } // endif supfnc + if (src && fnc != FNC_NO) { + strcpy(g->Message, "Cannot make catalog table from srcdef"); + ok= false; + } // endif src + // Here we should test the flag column options when // this function is called in case of CREATE .. SELECT @@ -3561,7 +3572,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, else return HA_ERR_INTERNAL_ERROR; // Should never happen - if (src && fnc == FNC_NO) + if (src) qrp= SrcColumns(g, host, db, user, pwd, src, port); else switch (ttp) { case TAB_DBF: @@ -3606,7 +3617,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, case TAB_PRX: case TAB_TBL: case TAB_XCL: - qrp= TabColumns(g, thd, db, tab, fnc == FNC_COL); + bif= fnc == FNC_COL; + qrp= TabColumns(g, thd, db, tab, bif); + + if (!qrp && bif && fnc != FNC_COL) // tab is a view + qrp= MyColumns(g, host, db, user, pwd, tab, NULL, port, false); + break; default: strcpy(g->Message, "System error during assisted discovery"); @@ -3624,9 +3640,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, cnm= encode(g, crp->Name); type= PLGtoMYSQLtype(crp->Type, dbf); len= crp->Length; + dec= crp->Prec; // Now add the field - if (add_field(&sql, cnm, type, len, 0, NOT_NULL_FLAG, 0)) + if (add_field(&sql, cnm, type, len, dec, NOT_NULL_FLAG, 0)) b= HA_ERR_OUT_OF_MEM; } // endfor crp @@ -3780,6 +3797,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, } // endif charset + if (xtrace) + printf("s_init: %.*s\n", sql.length(), sql.ptr()); + if (!b) b= table_s->init_from_sql_statement_string(thd, true, sql.ptr(), sql.length()); @@ -3837,18 +3857,11 @@ int ha_connect::create(const char *name, TABLE *table_arg, // Check table type if (type == TAB_UNDEF) { - if (!options->tabname) { - strcpy(g->Message, "No table_type. Will be set to DOS"); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); - type= TAB_DOS; - options->type= "DOS"; - } else { - strcpy(g->Message, "No table_type. Will be set to PROXY"); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); - type= TAB_PRX; - options->type= "PROXY"; - } // endif fnc - + options->type= (options->srcdef) ? "MYSQL" : + (options->tabname) ? "PROXY" : "DOS"; + type= GetTypeID(options->type); + sprintf(g->Message, "No table_type. Will be set to %s", options->type); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); } else if (type == TAB_NIY) { sprintf(g->Message, "Unsupported table type %s", options->type); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index b5767b02180..e243a706f01 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -390,20 +390,23 @@ char *MYCAT::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) strcpy(sval, s); } else if (!stricmp(what, "filename")) { // Return default file name - char *ftype= Hc->GetStringOption("Type", "dos"); + char *ftype= Hc->GetStringOption("Type", "*"); int i, n; - sval= (char*)PlugSubAlloc(g, NULL, strlen(Hc->GetTableName()) + 12); - strcat(strcpy(sval, Hc->GetTableName()), "."); - n= strlen(sval); + if (IsFileType(GetTypeID(ftype))) { + sval= (char*)PlugSubAlloc(g, NULL, strlen(Hc->GetTableName()) + 12); + strcat(strcpy(sval, Hc->GetTableName()), "."); + n= strlen(sval); + + // Fold ftype to lower case + for (i= 0; i < 12; i++) + if (!ftype[i]) { + sval[n+i]= 0; + break; + } else + sval[n+i]= tolower(ftype[i]); - // Fold ftype to lower case - for (i= 0; i < 12; i++) - if (!ftype[i]) { - sval[n+i]= 0; - break; - } else - sval[n+i]= tolower(ftype[i]); + } // endif FileType } else sval = NULL; @@ -416,7 +419,7 @@ char *MYCAT::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) /***********************************************************************/ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp) { - char *type= GetStringCatInfo(g, "Type", "DOS"); + char *type= GetStringCatInfo(g, "Type", "*"); int i, loff, poff, nof, nlg; void *field= NULL; TABTYPE tc; @@ -598,8 +601,8 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, printf("GetTableDesc: name=%s am=%s\n", name, SVP(type)); // If not specified get the type of this table - if (!type && !(type= Hc->GetStringOption("Type"))) - type= (Hc->GetStringOption("Tabname")) ? "PROXY" : "DOS"; + if (!type) + type= Hc->GetStringOption("Type","*"); return MakeTableDesc(g, name, type); } // end of GetTableDesc diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index f06e8e9bd57..1a19b4cbf33 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -790,7 +790,7 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) } // endif m_Res #endif // 0 - if (Srcdef) + if (!m_Rc && Srcdef) if (SetColumnRanks(g)) return true; diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 5c4b428b09a..04271d1a460 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -120,7 +120,7 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, /* of the object table that will be retrieved by GetData commands. */ /************************************************************************/ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, - const char *name, bool info) + const char *name, bool& info) { static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, @@ -143,7 +143,9 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, if (!(s = GetTableShare(g, thd, db, name, mysql))) { return NULL; } else if (s->is_view) { - strcpy(g->Message, "Cannot retreive Proxy columns from a view"); + strcpy(g->Message, "Use MYSQL type to see columns from a view"); + info = true; // To tell caller name is a view + free_table_share(s); return NULL; } else n = s->fieldnames.count; @@ -615,6 +617,8 @@ TDBTBC::TDBTBC(PPRXDEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBTBC::GetResult(PGLOBAL g) { - return TabColumns(g, current_thd, Db, Tab, false); + bool b = false; + + return TabColumns(g, current_thd, Db, Tab, b); } // end of GetResult diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index 1405ef211c7..ddf6c2eb601 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -18,7 +18,7 @@ typedef class TDBTBC *PTDBTBC; TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, const char *name, bool& mysql); PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, - const char *name, bool info); + const char *name, bool& info); void Remove_tshp(PCATLG cat); From f2e147365353070539851f016a0eb975780ebd23 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 24 May 2013 09:56:04 +0400 Subject: [PATCH 199/273] Removing direct access to thd, using functions: - thd_query_string() insted of thd->query_string - thd_sql_command() instead ot thd->lex->sql_command - table_share->s.db.str instead of thd->db modified: storage/connect/connect.cc storage/connect/ha_connect.cc --- storage/connect/connect.cc | 1 - storage/connect/ha_connect.cc | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 7d9456c3259..41fb061bd7f 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -31,7 +31,6 @@ /* global.h is header containing all global declarations. */ /* plgdbsem.h is header containing the DB applic. declarations. */ /***********************************************************************/ -#define MYSQL_SERVER 1 #define DONT_DEFINE_VOID #include "handler.h" #undef OFFSET diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 38b5e74c38c..f3f0fbfba90 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -2794,6 +2794,8 @@ int ha_connect::external_lock(THD *thd, int lock_type) PGLOBAL g= GetPlug(thd, xp); DBUG_ENTER("ha_connect::external_lock"); + DBUG_ASSERT(thd == current_thd); + if (xtrace) printf("%p external_lock: lock_type=%d\n", this, lock_type); @@ -2914,16 +2916,16 @@ int ha_connect::external_lock(THD *thd, int lock_type) } // endif MODE_ANY if (xtrace) { - printf("%p external_lock: cmdtype=%d\n", this, thd->lex->sql_command); - printf("Cmd=%.*s\n", (int) thd->query_string.length(), - thd->query_string.str()); + LEX_STRING *query_string= thd_query_string(thd); + printf("%p external_lock: cmdtype=%d\n", this, thd_sql_command(thd)); + printf("Cmd=%.*s\n", (int) query_string->length, query_string->str); } // endif xtrace // Next code is temporarily replaced until sql_command is set stop= false; if (newmode == MODE_WRITE) { - switch (thd->lex->sql_command) { + switch (thd_sql_command(thd)) { case SQLCOM_CREATE_TABLE: case SQLCOM_INSERT: case SQLCOM_LOAD: @@ -2963,13 +2965,13 @@ int ha_connect::external_lock(THD *thd, int lock_type) newmode= MODE_ANY; break; default: - printf("Unsupported sql_command=%d", thd->lex->sql_command); - sprintf(g->Message, "Unsupported sql_command=%d", thd->lex->sql_command); + printf("Unsupported sql_command=%d", thd_sql_command(thd)); + sprintf(g->Message, "Unsupported sql_command=%d", thd_sql_command(thd)); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } // endswitch newmode } else if (newmode == MODE_READ) { - switch (thd->lex->sql_command) { + switch (thd_sql_command(thd)) { case SQLCOM_CREATE_TABLE: xcheck= true; cras= true; @@ -3000,8 +3002,8 @@ int ha_connect::external_lock(THD *thd, int lock_type) newmode= MODE_ANY; break; default: - printf("Unsupported sql_command=%d", thd->lex->sql_command); - sprintf(g->Message, "Unsupported sql_command=%d", thd->lex->sql_command); + printf("Unsupported sql_command=%d", thd_sql_command(thd)); + sprintf(g->Message, "Unsupported sql_command=%d", thd_sql_command(thd)); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } // endswitch newmode @@ -3387,7 +3389,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL); bool bif, ok= false, dbf= false; TABTYPE ttp= TAB_UNDEF; - MEM_ROOT *mem= thd->mem_root; PQRYRES qrp; PCOLRES crp; PGLOBAL g= GetPlug(thd, NULL); @@ -3436,7 +3437,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, } // endif option_list if (!db) - db= thd->db; // Default value + db= table_s->db.str; // Default value // Check table type if (ttp == TAB_UNDEF) { @@ -3568,7 +3569,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, PCATLG cat= (dup) ? dup->Catalog : NULL; if (cat) - cat->SetDataPath(g, thd->db); + cat->SetDataPath(g, table_s->db.str); else return HA_ERR_INTERNAL_ERROR; // Should never happen @@ -3907,7 +3908,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); } else if (options->tabname) { if (!stricmp(options->tabname, create_info->alias) && - (!options->dbname || !stricmp(options->dbname, thd->db))) { + (!options->dbname || !stricmp(options->dbname, table_arg->s->db.str))) { sprintf(g->Message, "A %s table cannot refer to itself", options->type); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); From 5b0e3a5332d789ea7d9e05d6030065cbb54d41be Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 24 May 2013 11:31:43 +0400 Subject: [PATCH 200/273] Removing more cases of direct use of thd. Also, TABLE_TYPE=MySQL now uses "root@localhost" by default, instead of current user and current host name. modified: storage/connect/ha_connect.cc --- storage/connect/ha_connect.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index f3f0fbfba90..ba96f99e28a 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -685,9 +685,9 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) (options->srcdef) ? "MYSQL" : (options->tabname) ? "PROXY" : "DOS"; else if (!stricmp(opname, "User")) // Connected user - opval= table->in_use->main_security_ctx.user; + opval= (char *) "root"; else if (!stricmp(opname, "Host")) // Connected user host - opval= table->in_use->main_security_ctx.host; + opval= (char *) "localhost"; else opval= sdef; // Caller default @@ -3528,7 +3528,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= false; } else if (!user) - user= thd->main_security_ctx.user; + user= "root"; break; #endif // MYSQL_SUPPORT @@ -4121,7 +4121,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, PIXDEF xdp; // We should be in CREATE TABLE - if (table->in_use->lex->sql_command != SQLCOM_CREATE_TABLE) + if (thd_sql_command(table->in_use) != SQLCOM_CREATE_TABLE) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, "Wrong command in create, please contact CONNECT team"); @@ -4131,7 +4131,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, PCATLG cat= (dup) ? dup->Catalog : NULL; if (cat) { - cat->SetDataPath(g, table_arg->in_use->db); + cat->SetDataPath(g, table_arg->s->db.str); if ((rc= optimize(table->in_use, NULL))) { printf("Create rc=%d %s\n", rc, g->Message); From aa505ea3218b6b2d9753a854ffbc8b3728121447 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 24 May 2013 15:21:06 +0400 Subject: [PATCH 201/273] Splitting SQLite3 tests into two parts: 1. for both server and embedded 2. for server only added: storage/connect/mysql-test/connect/r/odbc_sqlite3_grant.result storage/connect/mysql-test/connect/t/have_odbc_sqlite3.inc storage/connect/mysql-test/connect/t/odbc_sqlite3_grant.test modified: storage/connect/mysql-test/connect/r/odbc_sqlite3.result storage/connect/mysql-test/connect/t/odbc_sqlite3.test --- .../mysql-test/connect/r/odbc_sqlite3.result | 69 +++++----------- .../connect/r/odbc_sqlite3_grant.result | 72 +++++++++++++++++ .../connect/t/have_odbc_sqlite3.inc | 15 ++++ .../mysql-test/connect/t/odbc_sqlite3.test | 71 ++--------------- .../connect/t/odbc_sqlite3_grant.test | 79 +++++++++++++++++++ 5 files changed, 193 insertions(+), 113 deletions(-) create mode 100644 storage/connect/mysql-test/connect/r/odbc_sqlite3_grant.result create mode 100644 storage/connect/mysql-test/connect/t/have_odbc_sqlite3.inc create mode 100644 storage/connect/mysql-test/connect/t/odbc_sqlite3_grant.test diff --git a/storage/connect/mysql-test/connect/r/odbc_sqlite3.result b/storage/connect/mysql-test/connect/r/odbc_sqlite3.result index 87f7803166c..339dbb6a53d 100644 --- a/storage/connect/mysql-test/connect/r/odbc_sqlite3.result +++ b/storage/connect/mysql-test/connect/r/odbc_sqlite3.result @@ -4,20 +4,6 @@ t1 CREATE TABLE `t1` ( `Attributes` varchar(256) NOT NULL ) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='ODBC' `CATFUNC`='Drivers' SET NAMES utf8; -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Sources; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;; SHOW CREATE TABLE t1; Table Create Table @@ -31,42 +17,27 @@ test2 тест1 тест2 ÆÇÈÉË -SELECT user(); -user() -user@localhost -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO t1 VALUES ('xxx'); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1 WHERE a='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a='yyy' WHERE a='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE TABLE t2 AS SELECT * FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(64) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * FROM t2; +a +test1 +test2 +тест1 +тест2 +ÆÇÈÉË +DROP TABLE t2; CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost +a +test1 +test2 +тест1 +тест2 +ÆÇÈÉË DROP VIEW v1; DROP TABLE t1; -DROP USER user@localhost; diff --git a/storage/connect/mysql-test/connect/r/odbc_sqlite3_grant.result b/storage/connect/mysql-test/connect/r/odbc_sqlite3_grant.result new file mode 100644 index 00000000000..87f7803166c --- /dev/null +++ b/storage/connect/mysql-test/connect/r/odbc_sqlite3_grant.result @@ -0,0 +1,72 @@ +Table Create Table +t1 CREATE TABLE `t1` ( + `Description` varchar(128) NOT NULL, + `Attributes` varchar(256) NOT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='ODBC' `CATFUNC`='Drivers' +SET NAMES utf8; +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Sources; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(64) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=utf8 CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' `TABLE_TYPE`='ODBC' `DATA_CHARSET`='utf8' +SELECT * FROM t1; +a +test1 +test2 +тест1 +тест2 +ÆÇÈÉË +SELECT user(); +user() +user@localhost +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO t1 VALUES ('xxx'); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1 WHERE a='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a='yyy' WHERE a='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +DROP USER user@localhost; diff --git a/storage/connect/mysql-test/connect/t/have_odbc_sqlite3.inc b/storage/connect/mysql-test/connect/t/have_odbc_sqlite3.inc new file mode 100644 index 00000000000..9528e00ff56 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/have_odbc_sqlite3.inc @@ -0,0 +1,15 @@ +--disable_query_log +--error 0,ER_UNKNOWN_ERROR +CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers; +if ($mysql_errno) +{ + Skip No ODBC support; +} +if (!`SELECT count(*) FROM t1 WHERE Description='SQLite3 ODBC Driver'`) +{ + DROP TABLE t1; + Skip Need SQLite3 ODBC Driver; +} +SHOW CREATE TABLE t1; +DROP TABLE t1; +--enable_query_log diff --git a/storage/connect/mysql-test/connect/t/odbc_sqlite3.test b/storage/connect/mysql-test/connect/t/odbc_sqlite3.test index 5f6abb0e2bc..f32196e3f04 100644 --- a/storage/connect/mysql-test/connect/t/odbc_sqlite3.test +++ b/storage/connect/mysql-test/connect/t/odbc_sqlite3.test @@ -1,3 +1,5 @@ +--source have_odbc_sqlite3.inc + # # To run this test, install SQLite3 ODBC Driver from # http://www.ch-werner.de/sqliteodbc/ @@ -18,42 +20,11 @@ # Note, the test does not need a DSN to be created. # ---disable_query_log ---error 0,ER_UNKNOWN_ERROR -CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers; -if ($mysql_errno) -{ - Skip No ODBC support; -} -if (!`SELECT count(*) FROM t1 WHERE Description='SQLite3 ODBC Driver'`) -{ - DROP TABLE t1; - Skip Need SQLite3 ODBC Driver; -} -SHOW CREATE TABLE t1; -DROP TABLE t1; ---enable_query_log - SET NAMES utf8; let $MYSQLD_DATADIR= `select @@datadir`; -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; ---connect(user,localhost,user,,) ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC; ---error ER_ACCESS_DENIED_ERROR -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers; ---error ER_ACCESS_DENIED_ERROR -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Sources; ---connection default -SELECT user(); - - # # For some reasons Windows does not allow to remove the data base # file after "DROP TABLE t1". So unlike in odbc_xls.test we won't copy @@ -66,42 +37,14 @@ let $Database=$MTR_SUITE_DIR/std_data/test.sqlite3; --replace_result $MTR_SUITE_DIR MTR_SUITE_DIR SHOW CREATE TABLE t1; SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM t1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO t1 VALUES ('xxx'); ---error ER_ACCESS_DENIED_ERROR -DELETE FROM t1 WHERE a='xxx'; ---error ER_ACCESS_DENIED_ERROR -UPDATE t1 SET a='yyy' WHERE a='xxx'; ---error ER_ACCESS_DENIED_ERROR -TRUNCATE TABLE t1; ---error ER_ACCESS_DENIED_ERROR -ALTER TABLE t1 READONLY=1; ---error ER_ACCESS_DENIED_ERROR -CREATE VIEW v1 AS SELECT * FROM t1; ---echo # Testing a VIEW created with FILE privileges but accessed with no FILE ---connection default -SELECT user(); +CREATE TABLE t2 AS SELECT * FROM t1; +SHOW CREATE TABLE t2; +SELECT * FROM t2; +DROP TABLE t2; + CREATE VIEW v1 AS SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR SELECT * FROM v1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO v1 VALUES (2); ---error ER_ACCESS_DENIED_ERROR -UPDATE v1 SET a=123; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM v1; ---disconnect user ---connection default -SELECT user(); DROP VIEW v1; DROP TABLE t1; - -DROP USER user@localhost; diff --git a/storage/connect/mysql-test/connect/t/odbc_sqlite3_grant.test b/storage/connect/mysql-test/connect/t/odbc_sqlite3_grant.test new file mode 100644 index 00000000000..7664a4473ba --- /dev/null +++ b/storage/connect/mysql-test/connect/t/odbc_sqlite3_grant.test @@ -0,0 +1,79 @@ +-- source include/not_embedded.inc +-- source have_odbc_sqlite3.inc + +# +# For the instructions on how to setup SQLite3 ODBC DSN, +# please see odbc_sqlite3.test +# + +SET NAMES utf8; + +let $MYSQLD_DATADIR= `select @@datadir`; + + +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +--connect(user,localhost,user,,) +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC; +--error ER_ACCESS_DENIED_ERROR +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers; +--error ER_ACCESS_DENIED_ERROR +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Sources; +--connection default +SELECT user(); + + +# +# For some reasons Windows does not allow to remove the data base +# file after "DROP TABLE t1". So unlike in odbc_xls.test we won't copy +# the data file, we'll use directly the file in std_data. +# As we do not do any modifications in the database, this should be OK. +# +let $Database=$MTR_SUITE_DIR/std_data/test.sqlite3; +--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR +--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8; +--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR +SHOW CREATE TABLE t1; +SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM t1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO t1 VALUES ('xxx'); +--error ER_ACCESS_DENIED_ERROR +DELETE FROM t1 WHERE a='xxx'; +--error ER_ACCESS_DENIED_ERROR +UPDATE t1 SET a='yyy' WHERE a='xxx'; +--error ER_ACCESS_DENIED_ERROR +TRUNCATE TABLE t1; +--error ER_ACCESS_DENIED_ERROR +ALTER TABLE t1 READONLY=1; +--error ER_ACCESS_DENIED_ERROR +CREATE VIEW v1 AS SELECT * FROM t1; + +--echo # Testing a VIEW created with FILE privileges but accessed with no FILE +--connection default +SELECT user(); +CREATE VIEW v1 AS SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM v1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO v1 VALUES (2); +--error ER_ACCESS_DENIED_ERROR +UPDATE v1 SET a=123; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM v1; + +--disconnect user +--connection default +SELECT user(); +DROP VIEW v1; +DROP TABLE t1; + +DROP USER user@localhost; From 74be65c6d8f3541dc4a83666e32f043a7b6b49fe Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 24 May 2013 15:27:20 +0400 Subject: [PATCH 202/273] Do not run mysql.test in case of embedded server. We need a running MySQL server for this test. modified: storage/connect/mysql-test/connect/t/mysql.test --- storage/connect/mysql-test/connect/t/mysql.test | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/storage/connect/mysql-test/connect/t/mysql.test b/storage/connect/mysql-test/connect/t/mysql.test index 7c90acdd149..c7eacbd3d06 100644 --- a/storage/connect/mysql-test/connect/t/mysql.test +++ b/storage/connect/mysql-test/connect/t/mysql.test @@ -1,3 +1,10 @@ +-- source include/not_embedded.inc + +# +# TODO: consider a possibility to run this test +# against some remote MySQL server +# + let $PORT= `select @@port`; --disable_query_log From 32bd0c7d1fd3e996bf4431ed2c2e22cc1bcde4cd Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 24 May 2013 19:09:59 +0400 Subject: [PATCH 203/273] Adding the timezone plugin service, to convert between MYSQL_TIME and my_time_t and back. Using the new service instead of direct access to thd. added: include/mysql/service_thd_timezone.h libservices/thd_timezone_service.c modified: include/my_time.h include/mysql.h.pp include/mysql/plugin.h include/mysql/plugin_audit.h.pp include/mysql/plugin_auth.h.pp include/mysql/plugin_ftparser.h.pp include/mysql/services.h include/mysql_time.h include/service_versions.h libservices/CMakeLists.txt sql/sql_class.cc sql/sql_plugin_services.h storage/connect/value.cpp --- include/my_time.h | 10 ---- include/mysql.h.pp | 1 + include/mysql/plugin.h | 2 +- include/mysql/plugin_audit.h.pp | 22 +++++++++ include/mysql/plugin_auth.h.pp | 22 +++++++++ include/mysql/plugin_ftparser.h.pp | 22 +++++++++ include/mysql/service_thd_timezone.h | 74 ++++++++++++++++++++++++++++ include/mysql/services.h | 1 + include/mysql_time.h | 11 +++++ include/service_versions.h | 2 +- libservices/CMakeLists.txt | 1 + libservices/thd_timezone_service.c | 18 +++++++ sql/sql_class.cc | 21 ++++++++ sql/sql_plugin_services.h | 8 ++- storage/connect/value.cpp | 5 +- 15 files changed, 203 insertions(+), 17 deletions(-) create mode 100644 include/mysql/service_thd_timezone.h create mode 100644 libservices/thd_timezone_service.c diff --git a/include/my_time.h b/include/my_time.h index 9bd545bb850..046b5c94923 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -29,16 +29,6 @@ C_MODE_START extern ulonglong log_10_int[20]; extern uchar days_in_month[]; -/* - Portable time_t replacement. - Should be signed and hold seconds for 1902 -- 2038-01-19 range - i.e at least a 32bit variable - - Using the system built in time_t is not an option as - we rely on the above requirements in the time functions -*/ -typedef long my_time_t; - #define MY_TIME_T_MAX LONG_MAX #define MY_TIME_T_MIN LONG_MIN diff --git a/include/mysql.h.pp b/include/mysql.h.pp index d33822b2021..02eb62655df 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -143,6 +143,7 @@ const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); my_bool my_thread_init(void); void my_thread_end(void); #include "mysql_time.h" +typedef long my_time_t; enum enum_mysql_timestamp_type { MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 38573180232..db9b8e2aa9a 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -72,7 +72,7 @@ typedef struct st_mysql_xid MYSQL_XID; #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103 /* MariaDB plugin interface version */ -#define MARIA_PLUGIN_INTERFACE_VERSION 0x0104 +#define MARIA_PLUGIN_INTERFACE_VERSION 0x0105 /* The allowable types of plugins diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 1c4b46c2a01..8592eb9f852 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -85,6 +85,28 @@ extern struct kill_statement_service_st { enum thd_kill_levels (*thd_kill_level_func)(const void*); } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); +#include +typedef char my_bool; +#include "mysql_time.h" +typedef long my_time_t; +enum enum_mysql_timestamp_type +{ + MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, + MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 +}; +typedef struct st_mysql_time +{ + unsigned int year, month, day, hour, minute, second; + unsigned long second_part; + my_bool neg; + enum enum_mysql_timestamp_type time_type; +} MYSQL_TIME; +extern struct thd_timezone_service_st { + my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); + void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t); +} *thd_timezone_service; +my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode); +void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index ac6e5e3b13d..81b717acc8f 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -85,6 +85,28 @@ extern struct kill_statement_service_st { enum thd_kill_levels (*thd_kill_level_func)(const void*); } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); +#include +typedef char my_bool; +#include "mysql_time.h" +typedef long my_time_t; +enum enum_mysql_timestamp_type +{ + MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, + MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 +}; +typedef struct st_mysql_time +{ + unsigned int year, month, day, hour, minute, second; + unsigned long second_part; + my_bool neg; + enum enum_mysql_timestamp_type time_type; +} MYSQL_TIME; +extern struct thd_timezone_service_st { + my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); + void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t); +} *thd_timezone_service; +my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode); +void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index f5d6ac3b849..f28a508d62b 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -85,6 +85,28 @@ extern struct kill_statement_service_st { enum thd_kill_levels (*thd_kill_level_func)(const void*); } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); +#include +typedef char my_bool; +#include "mysql_time.h" +typedef long my_time_t; +enum enum_mysql_timestamp_type +{ + MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, + MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 +}; +typedef struct st_mysql_time +{ + unsigned int year, month, day, hour, minute, second; + unsigned long second_part; + my_bool neg; + enum enum_mysql_timestamp_type time_type; +} MYSQL_TIME; +extern struct thd_timezone_service_st { + my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); + void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t); +} *thd_timezone_service; +my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode); +void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/service_thd_timezone.h b/include/mysql/service_thd_timezone.h new file mode 100644 index 00000000000..e6d92e73ece --- /dev/null +++ b/include/mysql/service_thd_timezone.h @@ -0,0 +1,74 @@ +#ifndef MYSQL_SERVICE_THD_TIMEZONE_INCLUDED +/* Copyright (C) 2013 MariaDB Foundation. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file + This service provdes functions to convert between my_time_t and + MYSQL_TIME taking into account the current value of the time_zone + session variable. + + The values of the my_time_t type are in Unix timestamp format, + i.e. the number of seconds since "1970-01-01 00:00:00 UTC". + + The values of the MYSQL_TIME type are in the current time zone, + according to thd->variables.time_zone. + + If the MYSQL_THD parameter is NULL, then global_system_variables.time_zone + is used for conversion. +*/ + +#ifndef MYSQL_ABI_CHECK +/* + This service currently does not depend on any system headers. + If it needs system headers in the future, make sure to put + them inside this ifndef. +*/ +#endif + +typedef char my_bool; +#include "mysql_time.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +extern struct thd_timezone_service_st { + my_time_t (*thd_TIME_to_gmt_sec)(MYSQL_THD thd, const MYSQL_TIME *ltime, unsigned int *errcode); + void (*thd_gmt_sec_to_TIME)(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t); +} *thd_timezone_service; + +#ifdef MYSQL_DYNAMIC_PLUGIN + +#define thd_TIME_to_gmt_sec(thd, ltime, errcode) \ + (thd_timezone_service->thd_TIME_to_gmt_sec((thd), (ltime), (errcode))) + +#define thd_gmt_sec_to_TIME(thd, ltime, t) \ + (thd_timezone_service->thd_gmt_sec_to_TIME((thd), (ltime), (t))) + +#else + +my_time_t thd_TIME_to_gmt_sec(MYSQL_THD thd, const MYSQL_TIME *ltime, uint *errcode); +void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t); + +#endif + +#ifdef __cplusplus +} +#endif + +#define MYSQL_SERVICE_THD_TIMEZONE_INCLUDED +#endif diff --git a/include/mysql/services.h b/include/mysql/services.h index e14523f4fa1..1145d19872b 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -25,6 +25,7 @@ extern "C" { #include #include #include +#include #ifdef __cplusplus } diff --git a/include/mysql_time.h b/include/mysql_time.h index 0a3f17a81fb..baa236e891e 100644 --- a/include/mysql_time.h +++ b/include/mysql_time.h @@ -16,6 +16,17 @@ #ifndef _mysql_time_h_ #define _mysql_time_h_ +/* + Portable time_t replacement. + Should be signed and hold seconds for 1902 -- 2038-01-19 range + i.e at least a 32bit variable + + Using the system built in time_t is not an option as + we rely on the above requirements in the time functions +*/ +typedef long my_time_t; + + /* Time declarations shared between the server and client API: you should not add anything to this header unless it's used diff --git a/include/service_versions.h b/include/service_versions.h index e0a717fea9e..2dffa7cf863 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -26,4 +26,4 @@ #define VERSION_progress_report 0x0100 #define VERSION_debug_sync 0x1000 #define VERSION_kill_statement 0x1000 - +#define VERSION_thd_timezone 0x0100 diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt index 86ed3493993..e7dcf20e547 100644 --- a/libservices/CMakeLists.txt +++ b/libservices/CMakeLists.txt @@ -19,6 +19,7 @@ SET(MYSQLSERVICES_SOURCES my_snprintf_service.c thd_alloc_service.c thd_wait_service.c + thd_timezone_service.c progress_report_service.c debug_sync_service.c kill_statement_service.c) diff --git a/libservices/thd_timezone_service.c b/libservices/thd_timezone_service.c new file mode 100644 index 00000000000..2c93453f8ca --- /dev/null +++ b/libservices/thd_timezone_service.c @@ -0,0 +1,18 @@ +/* Copyright (C) 2013 MariaDB Foundation + Use is subject to license terms. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include +SERVICE_VERSION thd_timezone_service= (void *) VERSION_thd_timezone; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 238bf46e528..016cff9c2d9 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -35,6 +35,7 @@ #include "sql_cache.h" // query_cache_abort #include "sql_base.h" // close_thread_tables #include "sql_time.h" // date_time_format_copy +#include "tztime.h" // MYSQL_TIME <-> my_time_t #include "sql_acl.h" // NO_ACCESS, // acl_getroot_no_password #include "sql_base.h" // close_temporary_tables @@ -1261,6 +1262,26 @@ void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid) *xid = *(MYSQL_XID *) &thd->transaction.xid_state.xid; } + +extern "C" +my_time_t thd_TIME_to_gmt_sec(MYSQL_THD thd, const MYSQL_TIME *ltime, + unsigned int *errcode) +{ + Time_zone *tz= thd ? thd->variables.time_zone : + global_system_variables.time_zone; + return tz->TIME_to_gmt_sec(ltime, errcode); +} + + +extern "C" +void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t) +{ + Time_zone *tz= thd ? thd->variables.time_zone : + global_system_variables.time_zone; + tz->gmt_sec_to_TIME(ltime, t); +} + + #ifdef _WIN32 extern "C" THD *_current_thd_noinline(void) { diff --git a/sql/sql_plugin_services.h b/sql/sql_plugin_services.h index d2f60a6e08c..838b994b6e8 100644 --- a/sql/sql_plugin_services.h +++ b/sql/sql_plugin_services.h @@ -54,6 +54,11 @@ static struct kill_statement_service_st thd_kill_statement_handler= { thd_kill_level }; +static struct thd_timezone_service_st thd_timezone_handler= { + thd_TIME_to_gmt_sec, + thd_gmt_sec_to_TIME +}; + static struct st_service_ref list_of_services[]= { { "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler }, @@ -61,6 +66,7 @@ static struct st_service_ref list_of_services[]= { "thd_wait_service", VERSION_thd_wait, &thd_wait_handler }, { "progress_report_service", VERSION_progress_report, &progress_report_handler }, { "debug_sync_service", VERSION_debug_sync, 0 }, // updated in plugin_init() - { "thd_kill_statement_service", VERSION_kill_statement, &thd_kill_statement_handler } + { "thd_kill_statement_service", VERSION_kill_statement, &thd_kill_statement_handler }, + { "thd_timezone_service", VERSION_thd_timezone, &thd_timezone_handler }, }; diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 20e8f58a61c..1c8182b6b8d 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -1224,9 +1224,6 @@ void DTVAL::SetTimeShift(void) /* though the gmtime C function. The purpose of this function is to */ /* extend the range of valid dates by accepting negative time values. */ /***********************************************************************/ -#define MYSQL_SERVER 1 -#include "tztime.h" -#include "sql_priv.h" #include "sql_class.h" #include "sql_time.h" @@ -1245,7 +1242,7 @@ static void TIME_to_localtime(struct tm *tm, const MYSQL_TIME *ltime) static struct tm *gmtime_mysql(const time_t *timep, struct tm *tm) { MYSQL_TIME ltime; - current_thd->variables.time_zone->gmt_sec_to_TIME(<ime, (my_time_t) *timep); + thd_gmt_sec_to_TIME(current_thd, <ime, (my_time_t) *timep); TIME_to_localtime(tm, <ime); return tm; } From 73d62e2cb158811157b66b82501d42ef3dda0613 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 27 May 2013 00:17:04 +0200 Subject: [PATCH 204/273] - Fix Windows compile error modified: include/mysql/service_thd_timezone.h --- include/mysql/service_thd_timezone.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mysql/service_thd_timezone.h b/include/mysql/service_thd_timezone.h index e6d92e73ece..f8bddba68bb 100644 --- a/include/mysql/service_thd_timezone.h +++ b/include/mysql/service_thd_timezone.h @@ -61,7 +61,7 @@ extern struct thd_timezone_service_st { #else -my_time_t thd_TIME_to_gmt_sec(MYSQL_THD thd, const MYSQL_TIME *ltime, uint *errcode); +my_time_t thd_TIME_to_gmt_sec(MYSQL_THD thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t); #endif From d9f90dc0ccef2fca12a1aa5ad41118b8ddf13bf7 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 27 May 2013 12:38:15 +0400 Subject: [PATCH 205/273] Fixing ABI template, to take into account the latest change in the thd_time_zone_service. modified: include/mysql/plugin_audit.h.pp --- include/mysql/plugin_audit.h.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 8592eb9f852..8648bd6383d 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -105,7 +105,7 @@ extern struct thd_timezone_service_st { my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t); } *thd_timezone_service; -my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode); +my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); struct st_mysql_xid { long formatID; From 941a20a48a4115123ed749c5b5d4234cb5656ec2 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 27 May 2013 12:42:39 +0400 Subject: [PATCH 206/273] Fixing ABI template, to take into account the latest change in the thd_time_zone_service. modified: include/mysql/plugin_auth.h.pp include/mysql/plugin_ftparser.h.pp --- include/mysql/plugin_auth.h.pp | 2 +- include/mysql/plugin_ftparser.h.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 81b717acc8f..d291a87012a 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -105,7 +105,7 @@ extern struct thd_timezone_service_st { my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t); } *thd_timezone_service; -my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode); +my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); struct st_mysql_xid { long formatID; diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index f28a508d62b..b0143db4784 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -105,7 +105,7 @@ extern struct thd_timezone_service_st { my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t); } *thd_timezone_service; -my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode); +my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); struct st_mysql_xid { long formatID; From 8b6e7f66aecc198a6d4156060a2c3359c4b853cd Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 27 May 2013 17:42:59 +0400 Subject: [PATCH 207/273] - Fixing embedded verision of the Connect engine when handling table_type=MySQL (and some other types) to connect only to remote MySQL server, do not try to establish embedded connections from the running embedded connection. - Disabling "mtr --embedded" for the tests that need a remote MySQL server. modified: storage/connect/myconn.cpp storage/connect/mysql-test/connect/t/occur.test storage/connect/mysql-test/connect/t/pivot.test storage/connect/mysql-test/connect/t/tbl.test --- storage/connect/myconn.cpp | 1 + storage/connect/mysql-test/connect/t/occur.test | 2 ++ storage/connect/mysql-test/connect/t/pivot.test | 2 ++ storage/connect/mysql-test/connect/t/tbl.test | 2 ++ 4 files changed, 7 insertions(+) diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 5320171beeb..220be7ca0be 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -316,6 +316,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, // This is critical, because the server will not accept the // client's options, and vice versa. mysql_options(m_DB, MYSQL_READ_DEFAULT_GROUP, "PlugDB_CLIENT"); + mysql_options(m_DB, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL); #if 0 if (pwd && !strcmp(pwd, "*")) { diff --git a/storage/connect/mysql-test/connect/t/occur.test b/storage/connect/mysql-test/connect/t/occur.test index 5b237742fd8..36a4caafda1 100644 --- a/storage/connect/mysql-test/connect/t/occur.test +++ b/storage/connect/mysql-test/connect/t/occur.test @@ -1,3 +1,5 @@ +-- source include/not_embedded.inc + let $MYSQLD_DATADIR= `select @@datadir`; let $PORT= `select @@port`; --copy_file $MTR_SUITE_DIR/std_data/employee.dat $MYSQLD_DATADIR/test/employee.dat diff --git a/storage/connect/mysql-test/connect/t/pivot.test b/storage/connect/mysql-test/connect/t/pivot.test index e66d927bad5..7679434bca8 100644 --- a/storage/connect/mysql-test/connect/t/pivot.test +++ b/storage/connect/mysql-test/connect/t/pivot.test @@ -1,3 +1,5 @@ +-- source include/not_embedded.inc + let $MYSQLD_DATADIR= `select @@datadir`; let $PORT= `select @@port`; --copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt diff --git a/storage/connect/mysql-test/connect/t/tbl.test b/storage/connect/mysql-test/connect/t/tbl.test index 143c7643afd..bdd928366ef 100644 --- a/storage/connect/mysql-test/connect/t/tbl.test +++ b/storage/connect/mysql-test/connect/t/tbl.test @@ -1,3 +1,5 @@ +-- source include/not_embedded.inc + let $MYSQLD_DATADIR= `select @@datadir`; let $PORT= `select @@port`; From cc8174db48942a7a81cb6a74265c8212afe03591 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 28 May 2013 13:11:45 +0400 Subject: [PATCH 208/273] Recording test results forgotten in the commit adding thd_timezone_service. modified: mysql-test/r/handlersocket.result mysql-test/r/plugin.result mysql-test/suite/plugins/r/show_all_plugins.result --- mysql-test/r/handlersocket.result | 2 +- mysql-test/r/plugin.result | 6 +++--- mysql-test/suite/plugins/r/show_all_plugins.result | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/handlersocket.result b/mysql-test/r/handlersocket.result index 9e5d273cbb6..765d954d3dc 100644 --- a/mysql-test/r/handlersocket.result +++ b/mysql-test/r/handlersocket.result @@ -5,7 +5,7 @@ plugin_version 1.0 plugin_status ACTIVE plugin_type DAEMON plugin_library handlersocket.so -plugin_library_version 1.4 +plugin_library_version 1.5 plugin_author higuchi dot akira at dena dot jp plugin_description Direct access into InnoDB plugin_license BSD diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result index 0eb49584c4a..e175d59cbac 100644 --- a/mysql-test/r/plugin.result +++ b/mysql-test/r/plugin.result @@ -15,7 +15,7 @@ PLUGIN_STATUS ACTIVE PLUGIN_TYPE STORAGE ENGINE PLUGIN_TYPE_VERSION # PLUGIN_LIBRARY ha_example.so -PLUGIN_LIBRARY_VERSION 1.4 +PLUGIN_LIBRARY_VERSION 1.5 PLUGIN_AUTHOR Brian Aker, MySQL AB PLUGIN_DESCRIPTION Example storage engine PLUGIN_LICENSE GPL @@ -28,7 +28,7 @@ PLUGIN_STATUS ACTIVE PLUGIN_TYPE DAEMON PLUGIN_TYPE_VERSION # PLUGIN_LIBRARY ha_example.so -PLUGIN_LIBRARY_VERSION 1.4 +PLUGIN_LIBRARY_VERSION 1.5 PLUGIN_AUTHOR Sergei Golubchik PLUGIN_DESCRIPTION Unusable Daemon PLUGIN_LICENSE GPL @@ -60,7 +60,7 @@ PLUGIN_STATUS DELETED PLUGIN_TYPE STORAGE ENGINE PLUGIN_TYPE_VERSION # PLUGIN_LIBRARY ha_example.so -PLUGIN_LIBRARY_VERSION 1.4 +PLUGIN_LIBRARY_VERSION 1.5 PLUGIN_AUTHOR Brian Aker, MySQL AB PLUGIN_DESCRIPTION Example storage engine PLUGIN_LICENSE GPL diff --git a/mysql-test/suite/plugins/r/show_all_plugins.result b/mysql-test/suite/plugins/r/show_all_plugins.result index f9cbbd849e2..b5703ffa739 100644 --- a/mysql-test/suite/plugins/r/show_all_plugins.result +++ b/mysql-test/suite/plugins/r/show_all_plugins.result @@ -4,8 +4,8 @@ Variable_name Value Opened_plugin_libraries 0 select * from information_schema.all_plugins where plugin_library='ha_example.so'; PLUGIN_NAME PLUGIN_VERSION PLUGIN_STATUS PLUGIN_TYPE PLUGIN_TYPE_VERSION PLUGIN_LIBRARY PLUGIN_LIBRARY_VERSION PLUGIN_AUTHOR PLUGIN_DESCRIPTION PLUGIN_LICENSE LOAD_OPTION PLUGIN_MATURITY PLUGIN_AUTH_VERSION -EXAMPLE 0.1 NOT INSTALLED STORAGE ENGINE 100002.0 ha_example.so 1.4 Brian Aker, MySQL AB Example storage engine GPL OFF Experimental 0.1 -UNUSABLE 3.14 NOT INSTALLED DAEMON 100002.0 ha_example.so 1.4 Sergei Golubchik Unusable Daemon GPL OFF Experimental 3.14.15.926 +EXAMPLE 0.1 NOT INSTALLED STORAGE ENGINE 100002.0 ha_example.so 1.5 Brian Aker, MySQL AB Example storage engine GPL OFF Experimental 0.1 +UNUSABLE 3.14 NOT INSTALLED DAEMON 100002.0 ha_example.so 1.5 Sergei Golubchik Unusable Daemon GPL OFF Experimental 3.14.15.926 show status like '%libraries%'; Variable_name Value Opened_plugin_libraries 1 From 9f7c3fedfacdc62a30e1c9cd4ef2cdf900abffba Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 28 May 2013 17:22:38 +0200 Subject: [PATCH 209/273] - Extending connect_assisted_discovery column automatic definition to OCCUR and PIVOT table types. modified: storage/connect/ha_connect.cc storage/connect/myconn.cpp storage/connect/myconn.h storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp storage/connect/taboccur.cpp storage/connect/taboccur.h storage/connect/tabpivot.cpp storage/connect/tabpivot.h - Fix wrong definition of GetVlen for TYPE template modified: storage/connect/valblk.h --- storage/connect/ha_connect.cc | 76 ++++++++--- storage/connect/myconn.cpp | 9 +- storage/connect/myconn.h | 2 + storage/connect/plgdbsem.h | 1 + storage/connect/plgdbutl.cpp | 1 + storage/connect/taboccur.cpp | 234 ++++++++++++++++++++++++++++++---- storage/connect/taboccur.h | 1 - storage/connect/tabpivot.cpp | 178 +++++++++++++++++++++++++- storage/connect/tabpivot.h | 36 +++++- storage/connect/valblk.h | 3 +- 10 files changed, 494 insertions(+), 47 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index ba96f99e28a..db789dda5bd 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -27,11 +27,12 @@ ha_connect will let you create/open/delete tables, the created table can be done specifying an already existing file, the drop table command will just suppress the table definition but not the eventual data file. - Indexes are not yet supported but data can be inserted, updated or deleted. + Indexes are not supported for all table types but data can be inserted, + updated or deleted. You can enable the CONNECT storage engine in your build by doing the following during your build process:
./configure - --with-connect-storage-engine (not implemented yet) + --with-connect-storage-engine You can install the CONNECT handler as all other storage handlers. @@ -166,6 +167,16 @@ extern "C" { int trace= 0; // The general trace value } // extern "C" +bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col, + const char *ocr, const char *rank); +bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col, + const char *ocr, const char *rank); +PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src, + const char *picol, const char *fncol, + const char *host, const char *db, + const char *user, const char *pwd, + int port); + /****************************************************************************/ /* Initialize the ha_connect static members. */ /****************************************************************************/ @@ -3333,7 +3344,7 @@ static char *encode(PGLOBAL g, char *cnm) */ static bool add_field(String *sql, const char *field_name, const char *type, - int len, int dec, uint tm, const char *rem) + int len, int dec, uint tm, const char *rem, int flag) { bool error= false; @@ -3341,15 +3352,18 @@ static bool add_field(String *sql, const char *field_name, const char *type, error|= sql->append(field_name); error|= sql->append("` "); error|= sql->append(type); + if (len) { error|= sql->append('('); error|= sql->append_ulonglong(len); + if (dec || !strcmp(type, "DOUBLE")) { error|= sql->append(','); error|= sql->append_ulonglong(dec); - } + } // endif dec + error|= sql->append(')'); - } + } // endif len if (tm) error|= sql->append(STRING_WITH_LEN(" NOT NULL"), system_charset_info); @@ -3358,10 +3372,14 @@ static bool add_field(String *sql, const char *field_name, const char *type, error|= sql->append(" COMMENT '"); error|= sql->append_for_single_quote(rem, strlen(rem)); error|= sql->append("'"); - } + } // endif rem + + if (flag) { + error|= sql->append(" FLAG="); + error|= sql->append_ulonglong(flag); + } // endif flag sql->append(','); - return error; } // end of add_field @@ -3381,6 +3399,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, char spc= ',', qch= 0; const char *fncn= "?"; const char *user, *fn, *db, *host, *pwd, *prt, *sep, *tbl, *src; + const char *col, *ocl, *rnk, *pic, *fcl; char *tab, *dsn; #if defined(WIN32) char *nsp= NULL, *cls= NULL; @@ -3402,7 +3421,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, sql.copy(STRING_WITH_LEN("CREATE TABLE whatever ("), system_charset_info); - user= host= pwd= prt= tbl= src= dsn= NULL; + user= host= pwd= prt= tbl= src= col= ocl= pic= fcl= rnk= dsn= NULL; // Get the useful create options ttp= GetTypeID(topt->type); @@ -3417,12 +3436,18 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, qch= topt->qchar ? *topt->qchar : topt->quoted >= 0 ? '"' : 0; hdr= (int)topt->header; tbl= topt->tablist; + col= topt->colist; if (topt->oplist) { host= GetListOption(g,"host", topt->oplist, "localhost"); user= GetListOption(g,"user", topt->oplist, "root"); // Default value db can come from the DBNAME=xxx option. db= GetListOption(g,"database", topt->oplist, db); + col= GetListOption(g,"colist", topt->oplist, col); + ocl= GetListOption(g,"occurcol", topt->oplist, NULL); + pic= GetListOption(g,"pivotcol", topt->oplist, NULL); + fcl= GetListOption(g,"fnccol", topt->oplist, NULL); + rnk= GetListOption(g,"rankcol", topt->oplist, NULL); pwd= GetListOption(g,"password", topt->oplist); prt= GetListOption(g,"port", topt->oplist); port= (prt) ? atoi(prt) : 0; @@ -3537,9 +3562,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= true; break; #endif // WIN32 + case TAB_PIVOT: + supfnc = FNC_NO; case TAB_PRX: case TAB_TBL: case TAB_XCL: + case TAB_OCCUR: ok= true; break; default: @@ -3563,7 +3591,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, if (ok) { char *cnm, *rem; - int i, len, dec, typ; + int i, len, dec, typ, flg; const char *type; PDBUSER dup= PlgGetUser(g); PCATLG cat= (dup) ? dup->Catalog : NULL; @@ -3573,9 +3601,16 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, else return HA_ERR_INTERNAL_ERROR; // Should never happen - if (src) + if (src && ttp != TAB_PIVOT) { qrp= SrcColumns(g, host, db, user, pwd, src, port); - else switch (ttp) { + + if (ttp == TAB_OCCUR) + if (OcrSrcCols(g, qrp, col, ocl, rnk)) { + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + return HA_ERR_INTERNAL_ERROR; + } // endif OcrSrcCols + + } else switch (ttp) { case TAB_DBF: qrp= DBFColumns(g, fn, fnc == FNC_COL); break; @@ -3618,12 +3653,22 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, case TAB_PRX: case TAB_TBL: case TAB_XCL: + case TAB_OCCUR: bif= fnc == FNC_COL; qrp= TabColumns(g, thd, db, tab, bif); if (!qrp && bif && fnc != FNC_COL) // tab is a view qrp= MyColumns(g, host, db, user, pwd, tab, NULL, port, false); + if (ttp == TAB_OCCUR && fnc != FNC_COL) + if (OcrColumns(g, qrp, col, ocl, rnk)) { + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + return HA_ERR_INTERNAL_ERROR; + } // endif OcrColumns + + break; + case TAB_PIVOT: + qrp= PivotColumns(g, tab, src, pic, fcl, host, db, user, pwd, port); break; default: strcpy(g->Message, "System error during assisted discovery"); @@ -3635,16 +3680,17 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, return HA_ERR_INTERNAL_ERROR; } // endif qrp - if (fnc != FNC_NO || src) { - // Catalog table + if (fnc != FNC_NO || src || ttp == TAB_PIVOT) { + // Catalog like table for (crp=qrp->Colresp; !b && crp; crp= crp->Next) { cnm= encode(g, crp->Name); type= PLGtoMYSQLtype(crp->Type, dbf); len= crp->Length; dec= crp->Prec; + flg= crp->Flag; // Now add the field - if (add_field(&sql, cnm, type, len, dec, NOT_NULL_FLAG, 0)) + if (add_field(&sql, cnm, type, len, dec, NOT_NULL_FLAG, 0, flg)) b= HA_ERR_OUT_OF_MEM; } // endfor crp @@ -3714,7 +3760,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, len= 0; // Now add the field - if (add_field(&sql, cnm, type, len, dec, tm, rem)) + if (add_field(&sql, cnm, type, len, dec, tm, rem, 0)) b= HA_ERR_OUT_OF_MEM; } // endfor i diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 220be7ca0be..9ebf77ff35a 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -64,6 +64,12 @@ static char *server_groups[] = { extern "C" int trace; extern MYSQL_PLUGIN_IMPORT uint mysqld_port; +// Returns the current used port +uint GetDefaultPort(void) +{ + return mysqld_port; +} // end of GetDefaultPort + /************************************************************************/ /* MyColumns: constructs the result blocks containing all columns */ /* of a MySQL table or view. */ @@ -673,6 +679,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) *pcrp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES)); crp = *pcrp; pcrp = &crp->Next; + memset(crp, 0, sizeof(COLRES)); crp->Ncol = ++qrp->Nbcol; crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1); @@ -686,7 +693,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) // For direct MySQL connection, display the MySQL date string crp->Type = TYPE_STRING; - crp->Prec = fld->decimals; + crp->Prec = (crp->Type == TYPE_FLOAT) ? fld->decimals : 0; crp->Length = fld->max_length; crp->Clen = GetTypeSize(crp->Type, crp->Length); diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h index 8148630b812..f8c8c3dcbae 100644 --- a/storage/connect/myconn.h +++ b/storage/connect/myconn.h @@ -44,6 +44,8 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, const char *user, const char *pwd, const char *srcdef, int port); +uint GetDefaultPort(void); + /* -------------------------- MYCONN class --------------------------- */ /***********************************************************************/ diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index dfa46a650a6..919f3452a4d 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -518,6 +518,7 @@ typedef struct _colres { int Clen; /* Data individual internal size */ int Length; /* Data individual print length */ int Prec; /* Precision */ + int Flag; /* Flag option value */ XFLD Fld; /* Type of field info */ } COLRES; diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 598075ac52a..73b468c9209 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -298,6 +298,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, *pcrp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES)); crp = *pcrp; pcrp = &crp->Next; + memset(crp, 0, sizeof(COLRES)); crp->Colp = NULL; crp->Ncol = ++qrp->Nbcol; crp->Type = buftyp[i]; diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 6c33aefbb68..065da269caa 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -1,5 +1,5 @@ /************ TabOccur CPP Declares Source Code File (.CPP) ************/ -/* Name: TABOCCUR.CPP Version 1.0 */ +/* Name: TABOCCUR.CPP Version 1.1 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2013 */ /* */ @@ -53,6 +53,210 @@ extern "C" int trace; +/***********************************************************************/ +/* Prepare and count columns in the column list. */ +/***********************************************************************/ +int PrepareColist(char *colist) + { + char *p, *pn; + int n = 0; + + // Count the number of columns and change separator into null char + for (pn = colist; ; pn += (strlen(pn) + 1)) + // Separator can be ; if colist was specified in the option_list + if ((p = strchr(pn, ',')) || (p = strchr(pn, ';'))) { + *p++ = '\0'; + n++; + } else { + if (*pn) + n++; + + break; + } // endif p + + return n; + } // end of PrepareColist + +/************************************************************************/ +/* OcrColumns: constructs the result blocks containing all the columns */ +/* of the object table that will be retrieved by GetData commands. */ +/************************************************************************/ +bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col, + const char *ocr, const char *rank) + { + char *pn, *colist; + int i, k, m, n = 0, c = 0, j = qrp->Nblin; + bool rk, b = false; + PCOLRES crp; + + if (!col || !*col) { + strcpy(g->Message, "Missing colist"); + return true; + } // endif col + + // Prepare the column list + colist = (char*)PlugSubAlloc(g, NULL, strlen(col) + 1); + strcpy(colist, col); + m = PrepareColist(colist); + + if ((rk = (rank && *rank))) { + if (m == 1) { + strcpy(g->Message, "Cannot handle one column colist and rank"); + return true; + } // endif m + + for (k = 0, pn = colist; k < m; k++, pn += (strlen(pn) + 1)) + n = max(n, (signed)strlen(pn)); + + } // endif k + + // Default occur column name is the 1st colist column name + if (!ocr || !*ocr) + ocr = colist; + + /**********************************************************************/ + /* Replace the columns of the colist by the rank and occur columns. */ + /**********************************************************************/ + for (i = 0; i < qrp->Nblin; i++) { + for (k = 0, pn = colist; k < m; k++, pn += (strlen(pn) + 1)) + if (!stricmp(pn, qrp->Colresp->Kdata->GetCharValue(i))) + break; + + if (k < m) { + // This column belongs to colist + if (rk) { + // Place the rank column here + for (crp = qrp->Colresp; crp; crp = crp->Next) + switch (crp->Fld) { + case FLD_NAME: crp->Kdata->SetValue((char*)rank, i); break; + case FLD_TYPE: crp->Kdata->SetValue(TYPE_STRING, i); break; + case FLD_PREC: crp->Kdata->SetValue(n, i); break; + case FLD_SCALE: crp->Kdata->SetValue(0, i); break; + case FLD_NULL: crp->Kdata->SetValue(0, i); break; + case FLD_REM: crp->Kdata->Reset(i); break; + default: ; // Ignored by CONNECT + } // endswich Fld + + rk = false; + } else if (!b) { + // First remaining listed column, will be the occur column + for (crp = qrp->Colresp; crp; crp = crp->Next) + switch (crp->Fld) { + case FLD_NAME: crp->Kdata->SetValue((char*)ocr, i); break; + case FLD_REM: crp->Kdata->Reset(i); break; + default: ; // Nothing to do + } // endswich Fld + + b = true; + } else if (j == qrp->Nblin) + j = i; // Column to remove + + c++; + } else if (j < i) { + // Move this column in empty spot + for (crp = qrp->Colresp; crp; crp = crp->Next) + crp->Kdata->Move(i, j); + + j++; + } // endif k + + } // endfor i + + // Check whether all columns of the list where found + if (c < m) { + strcpy(g->Message, "Some colist columns are not in the source table"); + return true; + } // endif crp + + /**********************************************************************/ + /* Set the number of columns of the table. */ + /**********************************************************************/ + qrp->Nblin = j; + return false; + } // end of OcrColumns + +/************************************************************************/ +/* OcrSrcCols: constructs the result blocks containing all the columns */ +/* of the object table that will be retrieved by GetData commands. */ +/************************************************************************/ +bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col, + const char *ocr, const char *rank) + { + char *pn, *colist; + int i, k, m, n = 0, c = 0; + bool rk, b = false; + PCOLRES crp, rcrp, *pcrp; + + if (!col || !*col) { + strcpy(g->Message, "Missing colist"); + return true; + } // endif col + + // Prepare the column list + colist = (char*)PlugSubAlloc(g, NULL, strlen(col) + 1); + strcpy(colist, col); + m = PrepareColist(colist); + + if ((rk = (rank && *rank))) + for (k = 0, pn = colist; k < m; k++, pn += (strlen(pn) + 1)) + n = max(n, (signed)strlen(pn)); + + // Default occur column name is the 1st colist column name + if (!ocr || !*ocr) + ocr = colist; + + /**********************************************************************/ + /* Replace the columns of the colist by the rank and occur columns. */ + /**********************************************************************/ + for (i = 0, pcrp = &qrp->Colresp; crp = *pcrp; ) { + for (k = 0, pn = colist; k < m; k++, pn += (strlen(pn) + 1)) + if (!stricmp(pn, crp->Name)) + break; + + if (k < m) { + // This column belongs to colist + c++; + + if (!b) { + if (rk) { + // Add the rank column here + rcrp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES)); + memset(rcrp, 0, sizeof(COLRES)); + rcrp->Next = crp; + rcrp->Name = (char*)rank; + rcrp->Type = TYPE_STRING; + rcrp->Length = n; + rcrp->Ncol = ++i; + *pcrp = rcrp; + } // endif rk + + // First remaining listed column, will be the occur column + crp->Name = (char*)ocr; + b = true; + } else { + *pcrp = crp->Next; // Remove this column + continue; + } // endif b + + } // endif k + + crp->Ncol = ++i; + pcrp = &crp->Next; + } // endfor pcrp + + // Check whether all columns of the list where found + if (c < m) { + strcpy(g->Message, "Some colist columns are not in the source table"); + return true; + } // endif crp + + /**********************************************************************/ + /* Set the number of columns of the table. */ + /**********************************************************************/ + qrp->Nblin = i; + return false; + } // end of OcrSrcCols + /* -------------- Implementation of the OCCUR classes ---------------- */ /***********************************************************************/ @@ -60,9 +264,9 @@ extern "C" int trace; /***********************************************************************/ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - Xcol = Cat->GetStringCatInfo(g, "OccurCol", ""); Rcol = Cat->GetStringCatInfo(g, "RankCol", ""); Colist = Cat->GetStringCatInfo(g, "Colist", ""); + Xcol = Cat->GetStringCatInfo(g, "OccurCol", Colist); return PRXDEF::DefineAM(g, am, poff); } // end of DefineAM @@ -92,36 +296,12 @@ TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp) Rcolumn = tdp->Rcol; // Rank column name Xcolp = NULL; // To the OCCURCOL column Col = NULL; // To source column blocks array - Mult = PrepareColist(); // Multiplication factor + Mult = PrepareColist(Colist); // Multiplication factor N = 0; // The current table index M = 0; // The occurence rank RowFlag = 0; // 0: Ok, 1: Same, 2: Skip } // end of TDBOCCUR constructor -/***********************************************************************/ -/* Prepare and count columns in the column list. */ -/***********************************************************************/ -int TDBOCCUR::PrepareColist(void) - { - char *p, *pn; - int n = 0; - - // Count the number of columns and change separator into null char - for (pn = Colist; ; pn += (strlen(pn) + 1)) - // Separator can be ; if colist was specified in the option_list - if ((p = strchr(pn, ',')) || (p = strchr(pn, ';'))) { - *p++ = '\0'; - n++; - } else { - if (*pn) - n++; - - break; - } // endif p - - return n; - } // end of PrepareColist - /***********************************************************************/ /* Allocate OCCUR/SRC column description block. */ /***********************************************************************/ diff --git a/storage/connect/taboccur.h b/storage/connect/taboccur.h index b7d51e05b7d..10f94329703 100644 --- a/storage/connect/taboccur.h +++ b/storage/connect/taboccur.h @@ -58,7 +58,6 @@ class TDBOCCUR : public TDBPRX { // Methods virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} virtual int RowNumber(PGLOBAL g, bool b = FALSE); - int PrepareColist(void); bool MakeColumnList(PGLOBAL g); bool ViewColumnList(PGLOBAL g); diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 916a3c2584e..dbe702c7462 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -1,7 +1,7 @@ /************ TabPivot C++ Program Source Code File (.CPP) *************/ /* PROGRAM NAME: TABPIVOT */ /* ------------- */ -/* Version 1.5 */ +/* Version 1.6 */ /* */ /* COPYRIGHT: */ /* ---------- */ @@ -53,6 +53,182 @@ extern "C" int trace; +/***********************************************************************/ +/* Make the Pivot table column list. */ +/***********************************************************************/ +PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src, + const char *picol, const char *fncol, + const char *host, const char *db, + const char *user, const char *pwd, + int port) + { + PIVAID pvd(tab, src, picol, fncol, host, db, user, pwd, port); + + return pvd.MakePivotColumns(g); + } // end of PivotColumns + +/* --------------- Implementation of the PIVAID classe --------------- */ + +/***********************************************************************/ +/* PIVAID constructor. */ +/***********************************************************************/ +PIVAID::PIVAID(const char *tab, const char *src, const char *picol, + const char *fncol, const char *host, const char *db, + const char *user, const char *pwd, int port) + : CSORT(false) + { + Host = (char*)host; + User = (char*)user; + Pwd = (char*)pwd; + Qryp = NULL; + Database = (char*)db; + Tabname = (char*)tab; + Tabsrc = (char*)src; + Picol = (char*)picol; + Fncol = (char*)fncol; + Rblkp = NULL; + Port = (port) ? port : GetDefaultPort(); + } // end of PIVAID constructor + +/***********************************************************************/ +/* Make the Pivot table column list. */ +/***********************************************************************/ +PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) + { + char *query, *colname, buf[32]; + int ndif, nblin, w = 0; + PVAL valp; + PCOLRES *pcrp, crp, fncrp = NULL; + + if (!Tabsrc && Tabname) { + // Locate the query + query = (char*)PlugSubAlloc(g, NULL, strlen(Tabname) + 16); + sprintf(query, "SELECT * FROM %s", Tabname); + } else if (!Tabsrc) { + strcpy(g->Message, MSG(SRC_TABLE_UNDEF)); + return NULL; + } else + query = Tabsrc; + + // Open a MySQL connection for this table + if (Myc.Open(g, Host, Database, User, Pwd, Port)) + return NULL; + + // Send the source command to MySQL + if (Myc.ExecSQL(g, query, &w) == RC_FX) { + Myc.Close(); + return NULL; + } // endif Exec + + // We must have a storage query to get pivot column values + Qryp = Myc.GetResult(g); + Myc.Close(); + + if (!Fncol) { + for (crp = Qryp->Colresp; crp; crp = crp->Next) + if (!Picol || stricmp(Picol, crp->Name)) + Fncol = crp->Name; + + if (!Fncol) { + strcpy(g->Message, MSG(NO_DEF_FNCCOL)); + return NULL; + } // endif Fncol + + } // endif Fncol + + if (!Picol) { + // Find default Picol as the last one not equal to Fncol + for (crp = Qryp->Colresp; crp; crp = crp->Next) + if (stricmp(Fncol, crp->Name)) + Picol = crp->Name; + + if (!Picol) { + strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); + return NULL; + } // endif Picol + + } // endif picol + + // Prepare the column list + for (pcrp = &Qryp->Colresp; crp = *pcrp; ) + if (!stricmp(Picol, crp->Name)) { + Rblkp = crp->Kdata; + *pcrp = crp->Next; + } else if (!stricmp(Fncol, crp->Name)) { + fncrp = crp; + *pcrp = crp->Next; + } else + pcrp = &crp->Next; + + if (!Rblkp) { + strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); + return NULL; + } else if (!fncrp) { + strcpy(g->Message, MSG(NO_DEF_FNCCOL)); + return NULL; + } // endif + + // Before calling sort, initialize all + nblin = Qryp->Nblin; + + Index.Size = nblin * sizeof(int); + Index.Sub = TRUE; // Should be small enough + + if (!PlgDBalloc(g, NULL, Index)) + return NULL; + + Offset.Size = (nblin + 1) * sizeof(int); + Offset.Sub = TRUE; // Should be small enough + + if (!PlgDBalloc(g, NULL, Offset)) + return NULL; + + ndif = Qsort(g, nblin); + + if (ndif < 0) // error + return NULL; + + // Allocate the Value used to retieve column names + if (!(valp = AllocateValue(g, Rblkp->GetType(), + Rblkp->GetVlen(), + Rblkp->GetPrec()))) + return NULL; + + // Now make the functional columns + for (int i = 0; i < ndif; i++) { + if (i) { + crp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES)); + memcpy(crp, fncrp, sizeof(COLRES)); + } else + crp = fncrp; + + // Get the value that will be the generated column name + valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]); + colname = valp->GetCharString(buf); + crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1); + strcpy(crp->Name, colname); + crp->Flag = 1; + + // Add this column + *pcrp = crp; + crp->Next = NULL; + pcrp = &crp->Next; + } // endfor i + + // We added ndif columns and removed 2 (picol and fncol) + Qryp->Nbcol += (ndif - 2); + return Qryp; + } // end of MakePivotColumns + +/***********************************************************************/ +/* PIVAID: Compare routine for sorting pivot column values. */ +/***********************************************************************/ +int PIVAID::Qcompare(int *i1, int *i2) + { + // TODO: the actual comparison between pivot column result values. + return Rblkp->CompVal(*i1, *i2); + } // end of Qcompare + /* --------------- Implementation of the PIVOT classes --------------- */ /***********************************************************************/ diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h index 1617801298b..4a766700162 100644 --- a/storage/connect/tabpivot.h +++ b/storage/connect/tabpivot.h @@ -1,5 +1,5 @@ /************** TabPivot H Declares Source Code File (.H) **************/ -/* Name: TABPIVOT.H Version 1.4 */ +/* Name: TABPIVOT.H Version 1.5 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* */ @@ -10,6 +10,40 @@ typedef class TDBPIVOT *PTDBPIVOT; typedef class FNCCOL *PFNCCOL; typedef class SRCCOL *PSRCCOL; +/***********************************************************************/ +/* This class is used to generate PIVOT table column definitions. */ +/***********************************************************************/ +class PIVAID : public CSORT { + friend class FNCCOL; + friend class SRCCOL; + public: + // Constructor + PIVAID(const char *tab, const char *src, const char *picol, + const char *fncol, const char *host, const char *db, + const char *user, const char *pwd, int port); + + // Methods + PQRYRES MakePivotColumns(PGLOBAL g); + + // The sorting function + virtual int Qcompare(int *, int *); + + protected: + // Members + MYSQLC Myc; // MySQL connection class + char *Host; // Host machine to use + char *User; // User logon info + char *Pwd; // Password logon info + char *Database; // Database to be used by server + PQRYRES Qryp; // Points to Query result block + char *Tabname; // Name of source table + char *Tabsrc; // SQL of source table + char *Picol; // Pivot column name + char *Fncol; // Function column name + PVBLK Rblkp; // The value block of the pivot column + int Port; // MySQL port number + }; // end of class PIVAID + /* -------------------------- PIVOT classes -------------------------- */ /***********************************************************************/ diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h index a7b1b5046d7..d9286b72f9f 100644 --- a/storage/connect/valblk.h +++ b/storage/connect/valblk.h @@ -36,6 +36,7 @@ class VALBLK : public BLOCK { void *GetValPointer(void) {return Blkp;} void SetValPointer(void *mp) {Blkp = mp;} int GetType(void) {return Type;} + int GetPrec(void) {return Prec;} void SetCheck(bool b) {Check = b;} void MoveNull(int i, int j) {if (To_Nulls) To_Nulls[j] = To_Nulls[j];} @@ -110,7 +111,7 @@ class TYPBLK : public VALBLK { // Implementation virtual void Init(PGLOBAL g, bool check); - virtual int GetVlen(void) {return sizeof(int);} + virtual int GetVlen(void) {return sizeof(TYPE);} //virtual PSZ GetCharValue(int n); virtual short GetShortValue(int n) {return (short)Typp[n];} virtual int GetIntValue(int n) {return (int)Typp[n];} From 0aa4fb73a49993d3a73550ee624b62d7556f8515 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 28 May 2013 21:06:15 +0200 Subject: [PATCH 210/273] - Fix crash when a null qrp is returned for OCCUR tables in connect_assisted_discovery modified: storage/connect/ha_connect.cc - Change CRLF line endings to LF modified: storage/connect/tabpivot.cpp storage/connect/tabpivot.h --- storage/connect/ha_connect.cc | 4 +- storage/connect/tabpivot.cpp | 104 +++++++++++++++++----------------- storage/connect/tabpivot.h | 64 ++++++++++----------- 3 files changed, 86 insertions(+), 86 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index db789dda5bd..829c194b61d 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3604,7 +3604,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, if (src && ttp != TAB_PIVOT) { qrp= SrcColumns(g, host, db, user, pwd, src, port); - if (ttp == TAB_OCCUR) + if (qrp && ttp == TAB_OCCUR) if (OcrSrcCols(g, qrp, col, ocl, rnk)) { my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); return HA_ERR_INTERNAL_ERROR; @@ -3660,7 +3660,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, if (!qrp && bif && fnc != FNC_COL) // tab is a view qrp= MyColumns(g, host, db, user, pwd, tab, NULL, port, false); - if (ttp == TAB_OCCUR && fnc != FNC_COL) + if (qrp && ttp == TAB_OCCUR && fnc != FNC_COL) if (OcrColumns(g, qrp, col, ocl, rnk)) { my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); return HA_ERR_INTERNAL_ERROR; diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index dbe702c7462..9beca56e773 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -63,7 +63,7 @@ PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src, int port) { PIVAID pvd(tab, src, picol, fncol, host, db, user, pwd, port); - + return pvd.MakePivotColumns(g); } // end of PivotColumns @@ -96,8 +96,8 @@ PIVAID::PIVAID(const char *tab, const char *src, const char *picol, PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) { char *query, *colname, buf[32]; - int ndif, nblin, w = 0; - PVAL valp; + int ndif, nblin, w = 0; + PVAL valp; PCOLRES *pcrp, crp, fncrp = NULL; if (!Tabsrc && Tabname) { @@ -110,20 +110,20 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) } else query = Tabsrc; - // Open a MySQL connection for this table - if (Myc.Open(g, Host, Database, User, Pwd, Port)) - return NULL; - - // Send the source command to MySQL - if (Myc.ExecSQL(g, query, &w) == RC_FX) { - Myc.Close(); - return NULL; - } // endif Exec - - // We must have a storage query to get pivot column values - Qryp = Myc.GetResult(g); - Myc.Close(); - + // Open a MySQL connection for this table + if (Myc.Open(g, Host, Database, User, Pwd, Port)) + return NULL; + + // Send the source command to MySQL + if (Myc.ExecSQL(g, query, &w) == RC_FX) { + Myc.Close(); + return NULL; + } // endif Exec + + // We must have a storage query to get pivot column values + Qryp = Myc.GetResult(g); + Myc.Close(); + if (!Fncol) { for (crp = Qryp->Colresp; crp; crp = crp->Next) if (!Picol || stricmp(Picol, crp->Name)) @@ -168,33 +168,33 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) return NULL; } // endif - // Before calling sort, initialize all + // Before calling sort, initialize all nblin = Qryp->Nblin; - Index.Size = nblin * sizeof(int); - Index.Sub = TRUE; // Should be small enough - - if (!PlgDBalloc(g, NULL, Index)) - return NULL; - - Offset.Size = (nblin + 1) * sizeof(int); - Offset.Sub = TRUE; // Should be small enough - - if (!PlgDBalloc(g, NULL, Offset)) - return NULL; - - ndif = Qsort(g, nblin); - - if (ndif < 0) // error - return NULL; - - // Allocate the Value used to retieve column names + Index.Size = nblin * sizeof(int); + Index.Sub = TRUE; // Should be small enough + + if (!PlgDBalloc(g, NULL, Index)) + return NULL; + + Offset.Size = (nblin + 1) * sizeof(int); + Offset.Sub = TRUE; // Should be small enough + + if (!PlgDBalloc(g, NULL, Offset)) + return NULL; + + ndif = Qsort(g, nblin); + + if (ndif < 0) // error + return NULL; + + // Allocate the Value used to retieve column names if (!(valp = AllocateValue(g, Rblkp->GetType(), - Rblkp->GetVlen(), - Rblkp->GetPrec()))) - return NULL; - - // Now make the functional columns + Rblkp->GetVlen(), + Rblkp->GetPrec()))) + return NULL; + + // Now make the functional columns for (int i = 0; i < ndif; i++) { if (i) { crp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES)); @@ -202,8 +202,8 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) } else crp = fncrp; - // Get the value that will be the generated column name - valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]); + // Get the value that will be the generated column name + valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]); colname = valp->GetCharString(buf); crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1); strcpy(crp->Name, colname); @@ -220,15 +220,15 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) return Qryp; } // end of MakePivotColumns -/***********************************************************************/ -/* PIVAID: Compare routine for sorting pivot column values. */ -/***********************************************************************/ -int PIVAID::Qcompare(int *i1, int *i2) - { - // TODO: the actual comparison between pivot column result values. - return Rblkp->CompVal(*i1, *i2); - } // end of Qcompare - +/***********************************************************************/ +/* PIVAID: Compare routine for sorting pivot column values. */ +/***********************************************************************/ +int PIVAID::Qcompare(int *i1, int *i2) + { + // TODO: the actual comparison between pivot column result values. + return Rblkp->CompVal(*i1, *i2); + } // end of Qcompare + /* --------------- Implementation of the PIVOT classes --------------- */ /***********************************************************************/ diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h index 4a766700162..170c6b67ea4 100644 --- a/storage/connect/tabpivot.h +++ b/storage/connect/tabpivot.h @@ -10,40 +10,40 @@ typedef class TDBPIVOT *PTDBPIVOT; typedef class FNCCOL *PFNCCOL; typedef class SRCCOL *PSRCCOL; -/***********************************************************************/ -/* This class is used to generate PIVOT table column definitions. */ -/***********************************************************************/ -class PIVAID : public CSORT { - friend class FNCCOL; - friend class SRCCOL; - public: - // Constructor +/***********************************************************************/ +/* This class is used to generate PIVOT table column definitions. */ +/***********************************************************************/ +class PIVAID : public CSORT { + friend class FNCCOL; + friend class SRCCOL; + public: + // Constructor PIVAID(const char *tab, const char *src, const char *picol, const char *fncol, const char *host, const char *db, - const char *user, const char *pwd, int port); - - // Methods - PQRYRES MakePivotColumns(PGLOBAL g); - - // The sorting function - virtual int Qcompare(int *, int *); - - protected: - // Members - MYSQLC Myc; // MySQL connection class - char *Host; // Host machine to use - char *User; // User logon info - char *Pwd; // Password logon info - char *Database; // Database to be used by server - PQRYRES Qryp; // Points to Query result block - char *Tabname; // Name of source table - char *Tabsrc; // SQL of source table - char *Picol; // Pivot column name - char *Fncol; // Function column name - PVBLK Rblkp; // The value block of the pivot column - int Port; // MySQL port number - }; // end of class PIVAID - + const char *user, const char *pwd, int port); + + // Methods + PQRYRES MakePivotColumns(PGLOBAL g); + + // The sorting function + virtual int Qcompare(int *, int *); + + protected: + // Members + MYSQLC Myc; // MySQL connection class + char *Host; // Host machine to use + char *User; // User logon info + char *Pwd; // Password logon info + char *Database; // Database to be used by server + PQRYRES Qryp; // Points to Query result block + char *Tabname; // Name of source table + char *Tabsrc; // SQL of source table + char *Picol; // Pivot column name + char *Fncol; // Function column name + PVBLK Rblkp; // The value block of the pivot column + int Port; // MySQL port number + }; // end of class PIVAID + /* -------------------------- PIVOT classes -------------------------- */ /***********************************************************************/ From 1db0c42e535d3cf97543e3bb0855f5283d73f075 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 28 May 2013 21:25:59 +0200 Subject: [PATCH 211/273] followup for revision 3751 "centos5 gcc 4.1 asm bug" remove the workaround from cmake/os/FreeBSD.cmake --- cmake/os/FreeBSD.cmake | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmake/os/FreeBSD.cmake b/cmake/os/FreeBSD.cmake index 27afe679f25..3a5a29f6de6 100644 --- a/cmake/os/FreeBSD.cmake +++ b/cmake/os/FreeBSD.cmake @@ -32,9 +32,3 @@ IF(EXECINFO) SET(LIBEXECINFO ${EXECINFO}) ENDIF() -# Use atomic builtins -IF(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686") - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=i686") -ENDIF() From 385780f571c752e871f806997acad4fb28b9085c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2013 11:41:25 +0200 Subject: [PATCH 212/273] MDEV-4485: Master did not allow slave to connect from the very start (empty GTID pos) if GTIDs from other multi_source master was present The idea in the code was to protect the user that tries to connect a slave to a master with completely different domains than what was intended. If none of the domains in the start position are present at all in the master binlog, we gave an error. However, this is a stupid idea. Because when a slave connects to a master to start replication from the very start of binlogs - such as when setting up new master->slave servers from scratch - there will be just this situation, the requested slave position is empty for all the domains in the master's binlog. So the code that gives this error is wrong, and the solution is simply to remove it. --- .../suite/rpl/r/rpl_gtid_mdev4485.result | 15 +++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf | 18 +++++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test | 40 +++++++++++++++++++ sql/sql_repl.cc | 17 -------- 4 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_gtid_mdev4485.result create mode 100644 mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf create mode 100644 mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test diff --git a/mysql-test/suite/rpl/r/rpl_gtid_mdev4485.result b/mysql-test/suite/rpl/r/rpl_gtid_mdev4485.result new file mode 100644 index 00000000000..34efd43f81b --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_mdev4485.result @@ -0,0 +1,15 @@ +include/rpl_init.inc [topology=1->3] +*** MDEV-4485. Master did not allow slave to connect from the very start (empty GTID pos) if GTIDs from other multi_source master was present *** +create table t1 (i int); +create table t2 (i int); +set default_master_connection = 'm2'; +change master to master_host='127.0.0.1', master_port=SERVER_MYPORT_2, master_user='root', master_use_gtid=slave_pos; +include/start_slave.inc +insert into t2 values (1); +drop table t1; +drop table t2; +set default_master_connection = 'm2'; +include/stop_slave.inc +RESET SLAVE ALL; +set default_master_connection = ''; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf b/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf new file mode 100644 index 00000000000..fccef215ccc --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf @@ -0,0 +1,18 @@ +!include suite/rpl/rpl_1slave_base.cnf +!include include/default_client.cnf + +[mysqld.1] +log-slave-updates +gtid-domain-id=1 + +[mysqld.2] +log-slave-updates +gtid-domain-id=2 + +[mysqld.3] +log-slave-updates +gtid-domain-id=3 + +[ENV] +SERVER_MYPORT_3= @mysqld.3.port +SERVER_MYSOCK_3= @mysqld.3.socket diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test b/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test new file mode 100644 index 00000000000..4a0c76d5c1d --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test @@ -0,0 +1,40 @@ +--let $rpl_topology= 1->3 +--source include/rpl_init.inc + +--echo *** MDEV-4485. Master did not allow slave to connect from the very start (empty GTID pos) if GTIDs from other multi_source master was present *** + +--connection server_1 +create table t1 (i int); + +--connection server_2 +create table t2 (i int); + +--connection server_3 + +set default_master_connection = 'm2'; +--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2 +eval change master to master_host='127.0.0.1', master_port=$SERVER_MYPORT_2, master_user='root', master_use_gtid=slave_pos; +--source include/start_slave.inc + +--connection server_2 +insert into t2 values (1); +--save_master_pos + +--connection server_3 +--sync_with_master 0,'m2' + +--connection server_1 +drop table t1; + +--connection server_2 +drop table t2; + +--connection server_3 +--sync_with_master 0,'m2' +set default_master_connection = 'm2'; +--source include/stop_slave.inc +RESET SLAVE ALL; +set default_master_connection = ''; + +--connection server_1 +--source include/rpl_end.inc diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 5ed73bf81f3..fd9ead71472 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -901,8 +901,6 @@ check_slave_start_position(THD *thd, slave_connection_state *st, rpl_gtid **delete_list= NULL; uint32 delete_idx= 0; bool slave_state_loaded= false; - uint32 missing_domains= 0; - rpl_gtid missing_domain_gtid; for (i= 0; i < st->hash.records; ++i) { @@ -943,14 +941,7 @@ check_slave_start_position(THD *thd, slave_connection_state *st, We do not have anything in this domain, neither in the binlog nor in the slave state. So we are probably one master in a multi-master setup, and this domain is served by a different master. - - This is not an error, however if we are missing _all_ domains - requested by the slave, then we still give error (below, after - the loop). */ - if (!missing_domains) - missing_domain_gtid= *slave_gtid; - ++missing_domains; continue; } @@ -1043,14 +1034,6 @@ check_slave_start_position(THD *thd, slave_connection_state *st, } } - if (missing_domains == st->hash.records && missing_domains > 0) - { - *errormsg= "Requested slave GTID state not found in binlog"; - *error_gtid= missing_domain_gtid; - err= ER_GTID_POSITION_NOT_FOUND_IN_BINLOG; - goto end; - } - /* Do any delayed deletes from the hash. */ if (delete_list) { From 6feadb10823c352b1eb9b24682c7d24d32175b0f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2013 14:23:40 +0200 Subject: [PATCH 213/273] MDEV-4485: Incorrect error handling in record_gtid(). Fix the error handling when access to the table mysql.gtid_slave_pos fails for whatever reason. Add some test cases. --- .../suite/rpl/r/rpl_gtid_mdev4484.result | 34 +++++++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test | 52 ++++++++++++++++ sql/rpl_gtid.cc | 59 ++++++++++++++++--- sql/rpl_gtid.h | 1 + 4 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_gtid_mdev4484.result create mode 100644 mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test diff --git a/mysql-test/suite/rpl/r/rpl_gtid_mdev4484.result b/mysql-test/suite/rpl/r/rpl_gtid_mdev4484.result new file mode 100644 index 00000000000..1acce9e65ff --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_mdev4484.result @@ -0,0 +1,34 @@ +include/master-slave.inc +[connection master] +CREATE TABLE t1 (i int) ENGINE=InnoDB; +*** MDEV-4484, incorrect error handling when entries in gtid_slave_pos not found. *** +TRUNCATE TABLE mysql.gtid_slave_pos; +INSERT INTO t1 VALUES (1); +include/stop_slave.inc +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug="+d,gtid_slave_pos_simulate_failed_delete"; +include/start_slave.inc +SET sql_log_bin= 0; +CALL mtr.add_suppression("Can't find file"); +SET sql_log_bin= 1; +INSERT INTO t1 VALUES (2); +include/wait_for_slave_sql_error.inc [errno=1942] +STOP SLAVE IO_THREAD; +SELECT domain_id, server_id, seq_no FROM mysql.gtid_slave_pos +ORDER BY domain_id, sub_id DESC LIMIT 1; +domain_id server_id seq_no +0 1 3 +SET GLOBAL debug_dbug= @old_dbug; +include/start_slave.inc +INSERT INTO t1 VALUES (3); +SELECT domain_id, server_id, seq_no FROM mysql.gtid_slave_pos +ORDER BY domain_id, sub_id DESC LIMIT 1; +domain_id server_id seq_no +0 1 4 +SELECT * FROM t1 ORDER BY i; +i +1 +2 +3 +DROP TABLE t1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test b/mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test new file mode 100644 index 00000000000..b3ff76c2afe --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test @@ -0,0 +1,52 @@ +--source include/master-slave.inc +--source include/have_innodb.inc +--source include/have_debug.inc + +CREATE TABLE t1 (i int) ENGINE=InnoDB; + +--sync_slave_with_master + +--echo *** MDEV-4484, incorrect error handling when entries in gtid_slave_pos not found. *** +TRUNCATE TABLE mysql.gtid_slave_pos; + +--connection master +INSERT INTO t1 VALUES (1); +--sync_slave_with_master + +# Inject an artificial error deleting entries, and check that the error handling code works. +--connection slave +--source include/stop_slave.inc +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug="+d,gtid_slave_pos_simulate_failed_delete"; +--source include/start_slave.inc +SET sql_log_bin= 0; +CALL mtr.add_suppression("Can't find file"); +SET sql_log_bin= 1; + +--connection master +INSERT INTO t1 VALUES (2); + +--connection slave +--let $slave_sql_errno= 1942 +--source include/wait_for_slave_sql_error.inc +STOP SLAVE IO_THREAD; +SELECT domain_id, server_id, seq_no FROM mysql.gtid_slave_pos + ORDER BY domain_id, sub_id DESC LIMIT 1; +SET GLOBAL debug_dbug= @old_dbug; +--source include/start_slave.inc + +--connection master +INSERT INTO t1 VALUES (3); +--sync_slave_with_master + +--connection slave +SELECT domain_id, server_id, seq_no FROM mysql.gtid_slave_pos + ORDER BY domain_id, sub_id DESC LIMIT 1; +SELECT * FROM t1 ORDER BY i; + + +# Clean up +--connection master +DROP TABLE t1; + +--source include/rpl_end.inc diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index b34b890060b..adaf9aa4e31 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -179,6 +179,22 @@ rpl_slave_state::get_element(uint32 domain_id) } +int +rpl_slave_state::put_back_list(uint32 domain_id, list_element *list) +{ + element *e; + if (!(e= (element *)my_hash_search(&hash, (const uchar *)&domain_id, 0))) + return 1; + while (list) + { + list_element *next= list->next; + e->add(list); + list= next; + } + return 0; +} + + int rpl_slave_state::truncate_state_table(THD *thd) { @@ -330,7 +346,10 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id, table->field[3]->store(gtid->seq_no, true); DBUG_EXECUTE_IF("inject_crash_before_write_rpl_slave_state", DBUG_SUICIDE();); if ((err= table->file->ha_write_row(table->record[0]))) - goto end; + { + table->file->print_error(err, MYF(0)); + goto end; + } lock(); if ((elem= get_element(gtid->domain_id)) == NULL) @@ -351,23 +370,42 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id, bitmap_set_bit(table->read_set, table->field[1]->field_index); if ((err= table->file->ha_index_init(0, 0))) + { + table->file->print_error(err, MYF(0)); goto end; + } while (elist) { uchar key_buffer[4+8]; + DBUG_EXECUTE_IF("gtid_slave_pos_simulate_failed_delete", + { err= ENOENT; + table->file->print_error(err, MYF(0)); + /* `break' does not work in DBUG_EXECUTE_IF */ + goto dbug_break; }); + next= elist->next; table->field[1]->store(elist->sub_id, true); /* domain_id is already set in table->record[0] from write_row() above. */ key_copy(key_buffer, table->record[0], &table->key_info[0], 0, false); - if ((err= table->file->ha_index_read_map(table->record[1], key_buffer, - HA_WHOLE_KEY, HA_READ_KEY_EXACT)) || - (err= table->file->ha_delete_row(table->record[1]))) - break; + if (table->file->ha_index_read_map(table->record[1], key_buffer, + HA_WHOLE_KEY, HA_READ_KEY_EXACT)) + /* We cannot find the row, assume it is already deleted. */ + ; + else if ((err= table->file->ha_delete_row(table->record[1]))) + table->file->print_error(err, MYF(0)); + /* + In case of error, we still discard the element from the list. We do + not want to endlessly error on the same element in case of table + corruption or such. + */ my_free(elist); elist= next; + if (err) + break; } +IF_DBUG(dbug_break:, ) table->file->ha_index_end(); if(!err && opt_bin_log && @@ -382,9 +420,16 @@ end: if (err) { /* - ToDo: If error, we need to put any remaining elist back into the HASH so - we can do another delete attempt later. + If error, we need to put any remaining elist back into the HASH so we + can do another delete attempt later. */ + if (elist) + { + lock(); + put_back_list(gtid->domain_id, elist); + unlock(); + } + ha_rollback_trans(thd, FALSE); close_thread_tables(thd); } diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index fefce684c2c..40d51568357 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -103,6 +103,7 @@ struct rpl_slave_state void unlock() { DBUG_ASSERT(inited); mysql_mutex_unlock(&LOCK_slave_state); } element *get_element(uint32 domain_id); + int put_back_list(uint32 domain_id, list_element *list); void update_state_hash(uint64 sub_id, rpl_gtid *gtid); int record_and_update_gtid(THD *thd, Relay_log_info *rli); From 22b60fa95cf1e33aff4bf7c43934d55e751f8908 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 May 2013 08:23:49 +0300 Subject: [PATCH 214/273] MDEV-4520: Assertion `0' fails in Query_cache::end_of_result on concurrent drop event and event executio Fix for embedded library, where thd->net.vio is not set which efficently switched off QC in emmbedded server for previous patch. --- sql/sql_cache.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 10cdadd5d95..086a6f2ff5b 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -3985,6 +3985,18 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used, } +/* +In non-embedded QC intercepts result in net_real_write +but if we have no net.vio then net_real_write +will not be called, so QC can't get results of the query +*/ +#ifdef EMBEDDED_LIBRARY +#define qc_is_able_to_intercept_result(T) 1 +#else +#define qc_is_able_to_intercept_result(T) ((T)->net.vio) +#endif + + /* If query is cacheable return number tables in query (query without tables are not cached) @@ -4001,7 +4013,7 @@ Query_cache::is_cacheable(THD *thd, LEX *lex, (thd->variables.query_cache_type == 1 || (thd->variables.query_cache_type == 2 && (lex->select_lex.options & OPTION_TO_QUERY_CACHE))) && - thd->net.vio) + qc_is_able_to_intercept_result(thd)) { DBUG_PRINT("qcache", ("options: %lx %lx type: %u", (long) OPTION_TO_QUERY_CACHE, @@ -4028,7 +4040,7 @@ Query_cache::is_cacheable(THD *thd, LEX *lex, (long) OPTION_TO_QUERY_CACHE, (long) lex->select_lex.options, (int) thd->variables.query_cache_type, - (uint) test(thd->net.vio))); + (uint) test(qc_is_able_to_intercept_result(thd)))); DBUG_RETURN(0); } From 689c1b44a99b9de1cbaf3939efa0c809aa3d4f43 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 1 Jun 2013 21:30:33 +0200 Subject: [PATCH 215/273] MDEV-4607 : libreadline-related compilation problems on NetBSD. Problem : libreadline.so was already present on the machine, however the cmake check NEW_READLINE_INTERFACE was unsuccessfull indicating, thus bundled library had to be used instead of system library. The problem was that the value for HAVE_HIST_ENTRY cmake variable was cached with incorrect value (1 on NetBSD). The fix is to change HAVE_HIST_ENTRY to 0 with CACHE FORCE, after switching to bundled readline. --- cmake/readline.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/readline.cmake b/cmake/readline.cmake index 285b436921e..c99557683a6 100644 --- a/cmake/readline.cmake +++ b/cmake/readline.cmake @@ -115,7 +115,7 @@ ENDMACRO() MACRO (MYSQL_USE_BUNDLED_READLINE) SET(USE_NEW_READLINE_INTERFACE 1) - SET(HAVE_HIST_ENTRY) + SET(HAVE_HIST_ENTRY 0 CACHE INTERNAL "" FORCE) SET(READLINE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/cmd-line-utils) SET(READLINE_LIBRARY readline) ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/cmd-line-utils/readline) From 33ef993773449cb3917665b188f6b6575d399bd0 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 1 Jun 2013 21:33:26 +0200 Subject: [PATCH 216/273] Fix a compile warning on NetBSD --- sql/sql_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 25ab84fe4db..311400c0c6c 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -627,7 +627,7 @@ Max used alarms: %u\n\ Next alarm time: %lu\n", alarm_info.active_alarms, alarm_info.max_used_alarms, - alarm_info.next_alarm_time); + (ulong)alarm_info.next_alarm_time); #endif display_table_locks(); fflush(stdout); From 7ad47ab0e080ca66f8a41de461b036d3bdff25fb Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Jun 2013 07:41:38 +0200 Subject: [PATCH 217/273] MDEV-4605: Failing to load GTID slave position from rpl.gtid_slave_pos There were several cases where the slave GTID position was not loaded correctly before being used. This caused various failures such as corrupting the position at slave start and empty values of @@gtid_slave_pos and @@gtid_current_pos. Fixed by adding more checks for loaded position, and by always loading the position at server startup. --- .../suite/rpl/r/rpl_gtid_stop_start.result | 10 +++ .../suite/rpl/t/rpl_gtid_stop_start.test | 25 +++++++ sql/mysqld.cc | 6 +- sql/mysqld.h | 2 +- sql/rpl_rli.cc | 16 +++- sql/share/errmsg-utf8.txt | 2 +- sql/slave.cc | 73 +++++++++++++++++++ sql/sys_vars.cc | 21 ++++++ 8 files changed, 150 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result index dcfdc567736..b524ab17c23 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result @@ -50,5 +50,15 @@ a 3 4 5 +*** Test that @@gtid_slave_pos and @@gtid_current_pos are correctly loaded even if slave threads have not started. *** +SET @slave_pos2= @@GLOBAL.gtid_slave_pos; +SET @current_pos2= @@GLOBAL.gtid_current_pos; +SELECT IF(@slave_pos1=@slave_pos2, "OK", CONCAT(@slave_pos1, " != ", @slave_pos2)); +IF(@slave_pos1=@slave_pos2, "OK", CONCAT(@slave_pos1, " != ", @slave_pos2)) +OK +SELECT IF(@current_pos1=@current_pos2, "OK", CONCAT(@current_pos1, " != ", @current_pos2)); +IF(@current_pos1=@current_pos2, "OK", CONCAT(@current_pos1, " != ", @current_pos2)) +OK +include/start_slave.inc DROP TABLE t1; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test index 0833dfe1224..cc1da6b3c85 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test @@ -93,6 +93,31 @@ INSERT INTO t1 VALUES(5); --source include/wait_condition.inc SELECT * FROM t1 ORDER BY a; +--echo *** Test that @@gtid_slave_pos and @@gtid_current_pos are correctly loaded even if slave threads have not started. *** +--let $slave_pos1= `SELECT @@GLOBAL.gtid_slave_pos` +--let $current_pos1= `SELECT @@GLOBAL.gtid_current_pos` + +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +wait +EOF +--shutdown_server 30 +--source include/wait_until_disconnected.inc + +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +restart: --skip-slave-start=1 --skip-log-bin +EOF +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_query_log +eval SET @slave_pos1= "$slave_pos1"; +eval SET @current_pos1= "$current_pos1"; +--enable_query_log +SET @slave_pos2= @@GLOBAL.gtid_slave_pos; +SET @current_pos2= @@GLOBAL.gtid_current_pos; +SELECT IF(@slave_pos1=@slave_pos2, "OK", CONCAT(@slave_pos1, " != ", @slave_pos2)); +SELECT IF(@current_pos1=@current_pos2, "OK", CONCAT(@current_pos1, " != ", @current_pos2)); +--source include/start_slave.inc + --connection server_1 DROP TABLE t1; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1102a527546..eb102696f64 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -931,7 +931,8 @@ static PSI_cond_info all_server_conds[]= PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert, key_thread_handle_manager, key_thread_main, - key_thread_one_connection, key_thread_signal_hand; + key_thread_one_connection, key_thread_signal_hand, + key_thread_slave_init; static PSI_thread_info all_server_threads[]= { @@ -956,7 +957,8 @@ static PSI_thread_info all_server_threads[]= { &key_thread_handle_manager, "manager", PSI_FLAG_GLOBAL}, { &key_thread_main, "main", PSI_FLAG_GLOBAL}, { &key_thread_one_connection, "one_connection", 0}, - { &key_thread_signal_hand, "signal_handler", PSI_FLAG_GLOBAL} + { &key_thread_signal_hand, "signal_handler", PSI_FLAG_GLOBAL}, + { &key_thread_slave_init, "slave_init", PSI_FLAG_GLOBAL} }; PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest, diff --git a/sql/mysqld.h b/sql/mysqld.h index 9c9bf71fec8..02d6b41cf69 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -283,7 +283,7 @@ extern PSI_cond_key key_TC_LOG_MMAP_COND_queue_busy; extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert, key_thread_handle_manager, key_thread_kill_server, key_thread_main, - key_thread_one_connection, key_thread_signal_hand; + key_thread_one_connection, key_thread_signal_hand, key_thread_slave_init; extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest, key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file, diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 03ec77e1433..9cb210f398f 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1425,7 +1425,10 @@ rpl_load_gtid_slave_state(THD *thd) bitmap_set_all(table->read_set); if ((err= table->file->ha_rnd_init_with_error(1))) + { + table->file->print_error(err, MYF(0)); goto end; + } table_scanned= true; for (;;) { @@ -1440,7 +1443,10 @@ rpl_load_gtid_slave_state(THD *thd) else if (err == HA_ERR_END_OF_FILE) break; else + { + table->file->print_error(err, MYF(0)); goto end; + } } domain_id= (ulonglong)table->field[0]->val_int(); sub_id= (ulonglong)table->field[1]->val_int(); @@ -1465,6 +1471,7 @@ rpl_load_gtid_slave_state(THD *thd) if (!(entry= (struct local_element *)my_malloc(sizeof(*entry), MYF(MY_WME)))) { + my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*entry)); err= 1; goto end; } @@ -1475,12 +1482,18 @@ rpl_load_gtid_slave_state(THD *thd) if ((err= my_hash_insert(&hash, (uchar *)entry))) { my_free(entry); + my_error(ER_OUT_OF_RESOURCES, MYF(0)); goto end; } } } rpl_global_gtid_slave_state.lock(); + if (rpl_global_gtid_slave_state.loaded) + { + rpl_global_gtid_slave_state.unlock(); + goto end; + } for (i= 0; i < hash.records; ++i) { entry= (struct local_element *)my_hash_element(&hash, i); @@ -1490,14 +1503,15 @@ rpl_load_gtid_slave_state(THD *thd) entry->gtid.seq_no))) { rpl_global_gtid_slave_state.unlock(); + my_error(ER_OUT_OF_RESOURCES, MYF(0)); goto end; } if (opt_bin_log && mysql_bin_log.bump_seq_no_counter_if_needed(entry->gtid.domain_id, entry->gtid.seq_no)) { - my_error(ER_OUT_OF_RESOURCES, MYF(0)); rpl_global_gtid_slave_state.unlock(); + my_error(ER_OUT_OF_RESOURCES, MYF(0)); goto end; } } diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index f08ba26fa4d..a6a331eeb18 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6538,7 +6538,7 @@ ER_GTID_OPEN_TABLE_FAILED ER_GTID_POSITION_NOT_FOUND_IN_BINLOG eng "Connecting slave requested to start from GTID %u-%u-%llu, which is not in the master's binlog" ER_CANNOT_LOAD_SLAVE_GTID_STATE - eng "Failed to load replication slave GTID state from table %s.%s" + eng "Failed to load replication slave GTID position from table %s.%s" ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG eng "Specified GTID %u-%u-%llu conflicts with the binary log which contains a more recent GTID %u-%u-%llu. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos." ER_MASTER_GTID_POS_MISSING_DOMAIN diff --git a/sql/slave.cc b/sql/slave.cc index 10411f9a5a5..6b876c5e863 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -253,6 +253,66 @@ static void init_slave_psi_keys(void) } #endif /* HAVE_PSI_INTERFACE */ + +static bool slave_init_thread_running; + + +pthread_handler_t +handle_slave_init(void *arg __attribute__((unused))) +{ + THD *thd; + + my_thread_init(); + thd= new THD; + thd->thread_stack= (char*) &thd; /* Set approximate stack start */ + mysql_mutex_lock(&LOCK_thread_count); + thd->thread_id= thread_id++; + mysql_mutex_unlock(&LOCK_thread_count); + thd->store_globals(); + + thd_proc_info(thd, "Loading slave GTID position from table"); + if (rpl_load_gtid_slave_state(thd)) + sql_print_warning("Failed to load slave replication state from table " + "%s.%s: %u: %s", "mysql", + rpl_gtid_slave_state_table_name.str, + thd->stmt_da->sql_errno(), thd->stmt_da->message()); + + mysql_mutex_lock(&LOCK_thread_count); + delete thd; + mysql_mutex_unlock(&LOCK_thread_count); + my_thread_end(); + + mysql_mutex_lock(&LOCK_thread_count); + slave_init_thread_running= false; + mysql_cond_signal(&COND_thread_count); + mysql_mutex_unlock(&LOCK_thread_count); + + return 0; +} + + +static int +run_slave_init_thread() +{ + pthread_t th; + + slave_init_thread_running= true; + if (mysql_thread_create(key_thread_slave_init, &th, NULL, + handle_slave_init, NULL)) + { + sql_print_error("Failed to create thread while initialising slave"); + return 1; + } + + mysql_mutex_lock(&LOCK_thread_count); + while (slave_init_thread_running) + mysql_cond_wait(&COND_thread_count, &LOCK_thread_count); + mysql_mutex_unlock(&LOCK_thread_count); + + return 0; +} + + /* Initialize slave structures */ int init_slave() @@ -264,6 +324,9 @@ int init_slave() init_slave_psi_keys(); #endif + if (run_slave_init_thread()) + return 1; + /* This is called when mysqld starts. Before client connections are accepted. However bootstrap may conflict with us if it does START SLAVE. @@ -3454,6 +3517,16 @@ pthread_handler_t handle_slave_io(void *arg) /* This must be called before run any binlog_relay_io hooks */ my_pthread_setspecific_ptr(RPL_MASTER_INFO, mi); + /* Load the set of seen GTIDs, if we did not already. */ + if (rpl_load_gtid_slave_state(thd)) + { + mi->report(ERROR_LEVEL, thd->stmt_da->sql_errno(), + "Unable to load replication GTID slave state from mysql.%s: %s", + rpl_gtid_slave_state_table_name.str, thd->stmt_da->message()); + goto err; + } + + if (RUN_HOOK(binlog_relay_io, thread_start, (thd, mi))) { mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 75d11589be6..b25f979cf79 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1262,6 +1262,12 @@ Sys_var_gtid_binlog_pos::global_value_ptr(THD *thd, LEX_STRING *base) String str(buf, sizeof(buf), system_charset_info); char *p; + if (!rpl_global_gtid_slave_state.loaded) + { + my_error(ER_CANNOT_LOAD_SLAVE_GTID_STATE, MYF(0), "mysql", + rpl_gtid_slave_state_table_name.str); + return NULL; + } str.length(0); if ((opt_bin_log && mysql_bin_log.append_state_pos(&str)) || !(p= thd->strmake(str.ptr(), str.length()))) @@ -1308,6 +1314,14 @@ Sys_var_gtid_slave_pos::do_check(THD *thd, set_var *var) bool running; DBUG_ASSERT(var->type == OPT_GLOBAL); + + if (!rpl_global_gtid_slave_state.loaded) + { + my_error(ER_CANNOT_LOAD_SLAVE_GTID_STATE, MYF(0), "mysql", + rpl_gtid_slave_state_table_name.str); + return true; + } + mysql_mutex_lock(&LOCK_active_mi); running= master_info_index->give_error_if_slave_running(); mysql_mutex_unlock(&LOCK_active_mi); @@ -1366,6 +1380,13 @@ Sys_var_gtid_slave_pos::global_value_ptr(THD *thd, LEX_STRING *base) String str; char *p; + if (!rpl_global_gtid_slave_state.loaded) + { + my_error(ER_CANNOT_LOAD_SLAVE_GTID_STATE, MYF(0), "mysql", + rpl_gtid_slave_state_table_name.str); + return NULL; + } + str.length(0); if (rpl_append_gtid_state(&str, false) || !(p= thd->strmake(str.ptr(), str.length()))) From 1fe92fb87db4a59ca0a4ac1ab1223e3cbe2b8232 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 3 Jun 2013 11:57:34 +0400 Subject: [PATCH 218/273] Fixing the problem with my_bool_t defined two times. (it worked fine with the modern gcc, but failed on some other compilers). modified: include/my_global.h include/mysql/plugin.h include/mysql/plugin_audit.h.pp include/mysql/plugin_auth.h.pp include/mysql/plugin_ftparser.h.pp include/mysql/service_thd_timezone.h sql/item_func.cc sql/mysqld.cc sql/set_var.cc sql/sql_plugin.cc sql/sql_plugin.h sql/sql_show.cc sql/sys_vars.cc storage/perfschema/ha_perfschema.cc --- include/my_global.h | 3 ++- include/mysql/plugin.h | 2 ++ include/mysql/plugin_audit.h.pp | 2 +- include/mysql/plugin_auth.h.pp | 2 +- include/mysql/plugin_ftparser.h.pp | 2 +- include/mysql/service_thd_timezone.h | 1 - sql/item_func.cc | 4 +--- sql/mysqld.cc | 2 +- sql/set_var.cc | 2 +- sql/sql_plugin.cc | 2 +- sql/sql_plugin.h | 3 +-- sql/sql_show.cc | 2 +- sql/sys_vars.cc | 2 +- storage/perfschema/ha_perfschema.cc | 4 +--- 14 files changed, 15 insertions(+), 18 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index b3c7819c9a5..b50db1fc5f3 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1002,8 +1002,9 @@ typedef struct st_mysql_lex_string LEX_STRING; #define SOCKET_EMFILE EMFILE #endif +#include /* my_bool */ + typedef ulong myf; /* Type of MyFlags in my_funcs */ -typedef char my_bool; /* Small bool */ #define MYF(v) (myf) (v) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index db9b8e2aa9a..a96e3e72b7b 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -45,6 +45,8 @@ class Item; #define MYSQL_THD void* #endif +typedef char my_bool; + #include #define MYSQL_XIDDATASIZE 128 diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 8648bd6383d..e51cbc4b851 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -1,4 +1,5 @@ #include "plugin.h" +typedef char my_bool; #include #include extern struct my_snprintf_service_st { @@ -86,7 +87,6 @@ extern struct kill_statement_service_st { } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); #include -typedef char my_bool; #include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index d291a87012a..28172286fb3 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -1,4 +1,5 @@ #include +typedef char my_bool; #include #include extern struct my_snprintf_service_st { @@ -86,7 +87,6 @@ extern struct kill_statement_service_st { } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); #include -typedef char my_bool; #include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index b0143db4784..532e049cf53 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -1,4 +1,5 @@ #include "plugin.h" +typedef char my_bool; #include #include extern struct my_snprintf_service_st { @@ -86,7 +87,6 @@ extern struct kill_statement_service_st { } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); #include -typedef char my_bool; #include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type diff --git a/include/mysql/service_thd_timezone.h b/include/mysql/service_thd_timezone.h index f8bddba68bb..f44f011b891 100644 --- a/include/mysql/service_thd_timezone.h +++ b/include/mysql/service_thd_timezone.h @@ -38,7 +38,6 @@ */ #endif -typedef char my_bool; #include "mysql_time.h" #ifdef __cplusplus diff --git a/sql/item_func.cc b/sql/item_func.cc index d0fca63688a..d412032fa0f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -25,7 +25,7 @@ #pragma implementation // gcc: Class implementation #endif -#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ +#include "sql_plugin.h" #include "sql_priv.h" /* It is necessary to include set_var.h instead of item.h because there @@ -52,8 +52,6 @@ #include "sp.h" #include "set_var.h" #include "debug_sync.h" -#include -#include #ifdef NO_EMBEDDED_ACCESS_CHECKS #define sp_restore_security_context(A,B) while (0) {} diff --git a/sql/mysqld.cc b/sql/mysqld.cc index fd8b990b6c3..38d58babd64 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ +#include "sql_plugin.h" #include "sql_priv.h" #include "unireg.h" #include diff --git a/sql/set_var.cc b/sql/set_var.cc index 18d86a13998..5f5faa83a45 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -16,7 +16,7 @@ /* variable declarations are in sys_vars.cc now !!! */ -#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ +#include "sql_plugin.h" #include "sql_class.h" // set_var.h: session_var_ptr #include "set_var.h" #include "sql_priv.h" diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 72f16ba7837..3c827ddda3b 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -15,9 +15,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "sql_plugin.h" #include "sql_priv.h" // SHOW_MY_BOOL #include "unireg.h" -#include "my_global.h" // REQUIRED by m_string.h #include "sql_class.h" // set_var.h: THD #include "sys_vars_shared.h" #include "sql_locale.h" diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index 906ff20ddb7..5327b27e97c 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -17,7 +17,6 @@ #ifndef _sql_plugin_h #define _sql_plugin_h -#include /* the following #define adds server-only members to enum_mysql_show_type, @@ -27,7 +26,7 @@ SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, \ SHOW_HAVE, SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, \ SHOW_LONG_NOFLUSH, SHOW_LONGLONG_STATUS, SHOW_LEX_STRING -#include +#include #undef SHOW_always_last #include "m_string.h" /* LEX_STRING */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 48fb926bfcc..623f737a62b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -17,7 +17,7 @@ /* Function with list databases, tables or fields */ -#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ +#include "sql_plugin.h" #include "sql_priv.h" #include "unireg.h" #include "sql_acl.h" // fill_schema_*_privileges diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 8c5a6c92a6b..cff36ac3bdd 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -31,7 +31,7 @@ (for example in storage/myisam/ha_myisam.cc) ! */ -#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ +#include "sql_plugin.h" #include "sql_priv.h" #include "sql_class.h" // set_var.h: THD #include "sys_vars.h" diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc index c6c967ceb9d..aca5ad8c731 100644 --- a/storage/perfschema/ha_perfschema.cc +++ b/storage/perfschema/ha_perfschema.cc @@ -18,11 +18,9 @@ Performance schema storage engine (implementation). */ -#include "my_global.h" +#include "sql_plugin.h" #include "my_pthread.h" #include "my_atomic.h" -#include "sql_plugin.h" -#include "mysql/plugin.h" #include "ha_perfschema.h" #include "pfs_engine_table.h" #include "pfs_column_values.h" From 0a01953c1a6e586f286d44222f9371a46da1ac45 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 3 Jun 2013 14:43:47 +0200 Subject: [PATCH 219/273] compiler warnings --- storage/connect/ha_connect.cc | 13 ++++++------- storage/connect/tabutil.cpp | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 829c194b61d..10e415d2f6a 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -693,8 +693,8 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) opval= (char*)GetDBName(NULL); // Current database else if (!stricmp(opname, "Type")) // Default type opval= (!options) ? NULL : - (options->srcdef) ? "MYSQL" : - (options->tabname) ? "PROXY" : "DOS"; + (options->srcdef) ? (char*)"MYSQL" : + (options->tabname) ? (char*)"PROXY" : (char*)"DOS"; else if (!stricmp(opname, "User")) // Connected user opval= (char *) "root"; else if (!stricmp(opname, "Host")) // Connected user host @@ -792,7 +792,7 @@ int ha_connect::GetIntegerOption(char *opname) else if (!stricmp(opname, "Compressed")) opval= (options->compressed); - if (opval == NO_IVAL && options && options->oplist) + if (opval == (ulonglong)NO_IVAL && options && options->oplist) if ((pv= GetListOption(xp->g, opname, options->oplist))) opval= (unsigned)atoll(pv); @@ -2799,7 +2799,7 @@ bool ha_connect::IsSameIndex(PIXDEF xp1, PIXDEF xp2) int ha_connect::external_lock(THD *thd, int lock_type) { int rc= 0; - bool del= false, xcheck=false, cras= false; + bool xcheck=false, cras= false; MODE newmode; PTOS options= GetTableOptionStruct(table); PGLOBAL g= GetPlug(thd, xp); @@ -2949,7 +2949,6 @@ int ha_connect::external_lock(THD *thd, int lock_type) // break; case SQLCOM_DELETE: case SQLCOM_DELETE_MULTI: - del= true; case SQLCOM_TRUNCATE: newmode= MODE_DELETE; break; @@ -3207,7 +3206,7 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to) /* We have to retrieve the information about this table options. */ ha_table_option_struct *pos; char key[MAX_DBKEY_LENGTH], db[128], tabname[128]; - int rc; + int rc = 0; uint key_length; TABLE_SHARE *share; THD *thd= current_thd; @@ -3253,7 +3252,7 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to) err: free_table_share(share); fin: - DBUG_RETURN(0); + DBUG_RETURN(rc); } // end of delete_or_rename_table int ha_connect::delete_table(const char *name) diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 04271d1a460..21dee4e1856 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -78,8 +78,8 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, //table_list.init_one_table(db, strlen(db), name, strlen(name), // NULL, TL_IGNORE); - k = sprintf(key, "%s", db); - k += sprintf(key + ++k, "%s", name); + k = sprintf(key, "%s", db) + 1; + k += sprintf(key + k, "%s", name); key[++k] = 0; if (!(s = alloc_table_share(db, name, key, ++k))) { From 9df57eba9f7b9bbee19bba5e880cbf611ef82d5b Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 4 Jun 2013 17:18:33 +0200 Subject: [PATCH 220/273] - Adding parallelism to the TBL table type modified: storage/connect/tabcol.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/value.cpp --- storage/connect/tabcol.h | 1 + storage/connect/tabtbl.cpp | 286 ++++++++++++++++++++++++++++++++++++- storage/connect/tabtbl.h | 73 +++++++++- storage/connect/value.cpp | 18 +-- 4 files changed, 358 insertions(+), 20 deletions(-) diff --git a/storage/connect/tabcol.h b/storage/connect/tabcol.h index 20e23b80225..c5ebfdbb10d 100644 --- a/storage/connect/tabcol.h +++ b/storage/connect/tabcol.h @@ -17,6 +17,7 @@ /***********************************************************************/ class DllExport XTAB: public BLOCK { // Table Name-Owner-Srcdef block. friend class TDBPRX; + friend class TDBTBM; public: // Constructors XTAB(LPCSTR name, LPCSTR srcdef = NULL); diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 9207ad636cf..61f9c8628d9 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -1,7 +1,7 @@ /************* TabTbl C++ Program Source Code File (.CPP) **************/ /* PROGRAM NAME: TABTBL */ /* ------------- */ -/* Version 1.5 */ +/* Version 1.6 */ /* */ /* COPYRIGHT: */ /* ---------- */ @@ -77,6 +77,16 @@ #include "ha_connect.h" #include "mycat.h" // For GetHandler +#if defined(WIN32) +#if defined(__BORLANDC__) +#define SYSEXIT void _USERENTRY +#else +#define SYSEXIT void +#endif +#else // !WIN32 +#define SYSEXIT void * +#endif // !WIN32 + extern "C" int trace; /* ---------------------------- Class TBLDEF ---------------------------- */ @@ -87,6 +97,9 @@ extern "C" int trace; TBLDEF::TBLDEF(void) { //To_Tables = NULL; + Accept = false; + Thread = false; + Maxerr = 0; Ntables = 0; Pseudo = 3; } // end of TBLDEF constructor @@ -143,8 +156,9 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) } // endfor pdb Maxerr = Cat->GetIntCatInfo("Maxerr", 0); - Accept = (Cat->GetBoolCatInfo("Accept", 0) != 0); - } // endif fsec || tablist + Accept = Cat->GetBoolCatInfo("Accept", false); + Thread = Cat->GetBoolCatInfo("Thread", false); + } // endif tablist return FALSE; } // end of DefineAM @@ -156,6 +170,8 @@ PTDB TBLDEF::GetTable(PGLOBAL g, MODE m) { if (Catfunc == FNC_COL) return new(g) TDBTBC(this); + else if (Thread) + return new(g) TDBTBM(this); else return new(g) TDBTBL(this); @@ -173,7 +189,7 @@ TDBTBL::TDBTBL(PTBLDEF tdp) : TDBPRX(tdp) //Tdbp = NULL; Accept = tdp->Accept; Maxerr = tdp->Maxerr; - Nbf = 0; + Nbc = 0; Rows = 0; Crp = 0; // NTables = 0; @@ -227,7 +243,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) // Get the table description block of this table if (!(Tdbp = GetSubTable(g, tabp))) { - if (++Nbf > Maxerr) + if (++Nbc > Maxerr) return TRUE; // Error return else continue; // Skip this table @@ -389,7 +405,7 @@ bool TDBTBL::OpenDB(PGLOBAL g) /*********************************************************************/ if (To_Filter && Tablist) { Tablist = NULL; - Nbf = 0; + Nbc = 0; } // endif To_Filter /*********************************************************************/ @@ -497,4 +513,262 @@ void TBTBLK::ReadColumn(PGLOBAL g) } // end of ReadColumn +/* ------------------------- Class TDBTBM ---------------------------- */ + +/***********************************************************************/ +/* Thread routine that check and open one remote connection. */ +/***********************************************************************/ +pthread_handler_t ThreadOpen(void *p) + { + PTBMT cmp = (PTBMT)p; + + if (!my_thread_init()) { + set_current_thd(cmp->Thd); + + // Try to open the connection + if (!cmp->Tap->GetTo_Tdb()->OpenDB(cmp->G)) { + cmp->Ready = true; + } else + cmp->Rc = RC_FX; + + my_thread_end(); + } else + cmp->Rc = RC_FX; + + return NULL; + } // end of ThreadOpen + +/***********************************************************************/ +/* TDBTBM constructors. */ +/***********************************************************************/ +TDBTBM::TDBTBM(PTBLDEF tdp) : TDBTBL(tdp) + { + Tmp = NULL; // To data table TBMT structures + Cmp = NULL; // Current data table TBMT + Bmp = NULL; // To bad (unconnected) TBMT structures + Done = false; // TRUE after first GetAllResults + Nrc = 0; // Number of remote connections + Nlc = 0; // Number of local connections + } // end of TDBTBL standard constructor + +/***********************************************************************/ +/* Reset read/write position values. */ +/***********************************************************************/ +void TDBTBM::ResetDB(void) + { + for (PCOL colp = Columns; colp; colp = colp->GetNext()) + if (colp->GetAmType() == TYPE_AM_TABID) + colp->COLBLK::Reset(); + + for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) + ((PTDBASE)tabp->GetTo_Tdb())->ResetDB(); + + Tdbp = (PTDBASE)Tablist->GetTo_Tdb(); + Crp = 0; + } // end of ResetDB + +/***********************************************************************/ +/* Returns RowId if b is false or Rownum if b is true. */ +/***********************************************************************/ +int TDBTBM::RowNumber(PGLOBAL g, bool b) + { + return Tdbp->RowNumber(g) + ((b) ? 0 : Rows); + } // end of RowNumber + +/***********************************************************************/ +/* Initialyze table parallel processing. */ +/***********************************************************************/ +bool TDBTBM::OpenTables(PGLOBAL g) + { + int k; + THD *thd = current_thd; + PTABLE tabp, *ptabp = &Tablist; + PTBMT tp, *ptp = &Tmp; + + // Allocates the TBMT blocks for the tables + for (tabp = Tablist; tabp; tabp = tabp->Next) + if (tabp->GetTo_Tdb()->GetAmType() == TYPE_AM_MYSQL) { + // Remove remote table from the local list + *ptabp = tabp->Next; + + // Make the remote table block + tp = (PTBMT)PlugSubAlloc(g, NULL, sizeof(TBMT)); + memset(tp, 0, sizeof(TBMT)); + tp->G = g; + tp->Tap = tabp; + tp->Thd = thd; + + // Create the thread that will do the table opening. + pthread_attr_init(&tp->attr); +// pthread_attr_setdetachstate(&tp->attr, PTHREAD_CREATE_JOINABLE); + + if ((k = pthread_create(&tp->Tid, &tp->attr, ThreadOpen, tp))) { + sprintf(g->Message, "pthread_create error %d", k); + Nbc++; + continue; + } // endif k + + // Add it to the remote list + *ptp = tp; + ptp = &tp->Next; + Nrc++; // Number of remote connections + } else { + ptabp = &tabp->Next; + Nlc++; // Number of local connections + } // endif Type + + return false; + } // end of OpenTables + +/***********************************************************************/ +/* TBL Access Method opening routine. */ +/* Open first file, other will be opened sequencially when reading. */ +/***********************************************************************/ +bool TDBTBM::OpenDB(PGLOBAL g) + { + if (trace) + htrc("TBM OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", + this, Tdb_No, Use, To_Key_Col, Mode); + + if (Use == USE_OPEN) { + /*******************************************************************/ + /* Table already open, replace it at its beginning. */ + /*******************************************************************/ + ResetDB(); + return Tdbp->OpenDB(g); // Re-open fist table + } // endif use + +#if 0 + /*********************************************************************/ + /* When GetMaxsize was called, To_Filter was not set yet. */ + /*********************************************************************/ + if (To_Filter && Tablist) { + Tablist = NULL; + Nbc = 0; + } // endif To_Filter +#endif // 0 + + /*********************************************************************/ + /* Make the table list. */ + /*********************************************************************/ + if (/*!Tablist &&*/ InitTableList(g)) + return TRUE; + + /*********************************************************************/ + /* Open all remote tables of the list. */ + /*********************************************************************/ + if (OpenTables(g)) + return TRUE; + + /*********************************************************************/ + /* Proceed with local tables. */ + /*********************************************************************/ + if ((CurTable = Tablist)) { + Tdbp = (PTDBASE)CurTable->GetTo_Tdb(); + Tdbp->SetMode(Mode); + + // Check and initialize the subtable columns + for (PCOL cp = Columns; cp; cp = cp->GetNext()) + if (cp->GetAmType() == TYPE_AM_TABID) + cp->COLBLK::Reset(); + else if (((PPRXCOL)cp)->Init(g) && !Accept) + return TRUE; + + if (trace) + htrc("Opening subtable %s\n", Tdbp->GetName()); + + // Now we can safely open the table + if (Tdbp->OpenDB(g)) + return TRUE; + + } // endif *Tablist + + Use = USE_OPEN; + return FALSE; + } // end of OpenDB + +/***********************************************************************/ +/* ReadDB: Data Base read routine for MUL access method. */ +/***********************************************************************/ +int TDBTBM::ReadDB(PGLOBAL g) + { + int rc; + + if (!Done) { + // Get result from local tables + if ((rc = TDBTBL::ReadDB(g)) != RC_EF) + return rc; + else if ((rc = ReadNextRemote(g)) != RC_OK) + return rc; + + Done = true; + } // endif Done + + /*********************************************************************/ + /* Now start the reading process of remote tables. */ + /*********************************************************************/ + retry: + rc = Tdbp->ReadDB(g); + + if (rc == RC_EF) { + // Total number of rows met so far + Rows += Tdbp->RowNumber(g) - 1; + Crp += Tdbp->GetProgMax(g); + Cmp->Complete = true; + + if ((rc = ReadNextRemote(g)) == RC_OK) + goto retry; + + } else if (rc == RC_FX) + strcat(strcat(strcat(g->Message, " ("), Tdbp->GetName()), ")"); + + return rc; + } // end of ReadDB + +/***********************************************************************/ +/* ReadNext: Continue reading from next table. */ +/***********************************************************************/ +int TDBTBM::ReadNextRemote(PGLOBAL g) + { + bool b = false; + + if (Tdbp) + Tdbp->CloseDB(g); + + Cmp = NULL; + + retry: + // Search for a remote table having its result set + for (PTBMT tp = Tmp; tp; tp = tp->Next) + if (tp->Ready) { + if (!tp->Complete) + Cmp = tp; + + } else + b = true; + + if (!Cmp) { + if (b) { // more result to come +// sleep(20); + goto retry; + } else + return RC_EF; + + } // endif Curtable + + Tdbp = (PTDBASE)Cmp->Tap->GetTo_Tdb(); + + // Check and initialize the subtable columns + for (PCOL cp = Columns; cp; cp = cp->GetNext()) + if (cp->GetAmType() == TYPE_AM_TABID) + cp->COLBLK::Reset(); + else if (((PPRXCOL)cp)->Init(g) && !Accept) + return RC_FX; + + if (trace) + htrc("Reading subtable %s\n", Tdbp->GetName()); + + return RC_OK; + } // end of ReadNextRemote + /* ------------------------------------------------------------------- */ diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index 69b862ebe4e..cdd84a1dd29 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -1,5 +1,5 @@ /*************** TabTbl H Declares Source Code File (.H) ***************/ -/* Name: TABTBL.H Version 1.2 */ +/* Name: TABTBL.H Version 1.3 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2008-2013 */ /* */ @@ -11,7 +11,29 @@ typedef class TBLDEF *PTBLDEF; typedef class TDBTBL *PTDBTBL; +typedef class TDBTBM *PTDBTBM; +typedef class MYSQLC *PMYC; +/***********************************************************************/ +/* Defines the structures used for distributed TBM tables. */ +/***********************************************************************/ +typedef struct _TBMtable *PTBMT; + +typedef struct _TBMtable { + PTBMT Next; // Points to next data table struct + PTABLE Tap; // Points to the sub table + PGLOBAL G; // Needed in thread routine + bool Complete; // TRUE when all results are read + bool Ready; // TRUE when results are there + int Rows; // Total number of rows read so far + int ProgCur; // Current pos + int ProgMax; // Max pos + int Rc; // Return code + THD *Thd; + pthread_attr_t attr; // ??? + pthread_t Tid; // CheckOpen thread ID + } TBMT; + /***********************************************************************/ /* TBL table. */ /***********************************************************************/ @@ -32,6 +54,7 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */ protected: // Members bool Accept; /* TRUE if bad tables are accepted */ + bool Thread; /* Use thread for remote tables */ int Maxerr; /* Maximum number of bad tables */ int Ntables; /* Number of tables */ }; // end of TBLDEF @@ -41,7 +64,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */ /***********************************************************************/ class DllExport TDBTBL : public TDBPRX { friend class TBTBLK; - friend class TDBPLG; public: // Constructor TDBTBL(PTBLDEF tdp = NULL); @@ -51,8 +73,8 @@ class DllExport TDBTBL : public TDBPRX { // Methods virtual void ResetDB(void); - virtual int GetRecpos(void) {return Rows;} - virtual int GetBadLines(void) {return (int)Nbf;} + virtual int GetRecpos(void) {return Rows;} + virtual int GetBadLines(void) {return (int)Nbc;} // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); @@ -72,7 +94,7 @@ class DllExport TDBTBL : public TDBPRX { PTABLE CurTable; // Points to the current table bool Accept; // TRUE if bad tables are accepted int Maxerr; // Maximum number of bad tables - int Nbf; // Number of bad connections + int Nbc; // Number of bad connections int Rows; // Used for RowID int Crp; // Used for CurPos }; // end of class TDBTBL @@ -100,3 +122,44 @@ class TBTBLK : public TIDBLK { protected: // Must not have additional members }; // end of class TBTBLK + +/***********************************************************************/ +/* This is the TBM Access Method class declaration. */ +/***********************************************************************/ +class DllExport TDBTBM : public TDBTBL { + friend class TBTBLK; + public: + // Constructor + TDBTBM(PTBLDEF tdp = NULL); + + // Implementation +//virtual AMT GetAmType(void) {return TYPE_AM_TBL;} + + // Methods + virtual void ResetDB(void); +//virtual int GetRecpos(void) {return Rows;} +//virtual int GetBadLines(void) {return (int)Nbc;} + + // Database routines +//virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); + virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary + virtual int RowNumber(PGLOBAL g, bool b = FALSE); +//virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); + virtual bool OpenDB(PGLOBAL g); + virtual int ReadDB(PGLOBAL g); + + protected: + // Internal functions +//bool InitTableList(PGLOBAL g); +//bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp); + bool OpenTables(PGLOBAL g); + int ReadNextRemote(PGLOBAL g); + + // Members + PTBMT Tmp; // To data table TBMT structures + PTBMT Cmp; // Current data table PLGF (to move to TDBTBL) + PTBMT Bmp; // To bad (unconnected) PLGF structures + bool Done; // TRUE after first GetAllResults + int Nrc; // Number of remote connections + int Nlc; // Number of local connections + }; // end of class TDBTBM diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 1c8182b6b8d..a770ac819c9 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -566,7 +566,7 @@ void TYPVAL::SetValue_char(char *p, int n) if (minus && Tval) Tval = - Tval; - if (trace) + if (trace > 1) htrc(strcat(strcat(strcpy(buf, " setting %s to: "), Fmt), "\n"), GetTypeName(Type), Tval); @@ -585,7 +585,7 @@ void TYPVAL::SetValue_char(char *p, int n) buf[n] = '\0'; Tval = atof(buf); - if (trace) + if (trace > 1) htrc(" setting double: '%s' -> %lf\n", buf, Tval); Null = false; @@ -900,7 +900,7 @@ void TYPVAL::SetValue_char(char *p, int n) *(++p) = '\0'; - if (trace) + if (trace > 1) htrc(" Setting string to: '%s'\n", Strp); Null = false; @@ -1291,7 +1291,7 @@ bool DTVAL::MakeTime(struct tm *ptm) int n, y = ptm->tm_year; time_t t = mktime_mysql(ptm); - if (trace) + if (trace > 1) htrc("MakeTime from (%d,%d,%d,%d,%d,%d)\n", ptm->tm_year, ptm->tm_mon, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); @@ -1314,7 +1314,7 @@ bool DTVAL::MakeTime(struct tm *ptm) } Tval= (int) t; - if (trace) + if (trace > 1) htrc("MakeTime Ival=%d\n", Tval); return false; @@ -1334,7 +1334,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) datm.tm_mon=0; datm.tm_year=70; - if (trace) + if (trace > 1) htrc("MakeDate from(%d,%d,%d,%d,%d,%d) nval=%d\n", val[0], val[1], val[2], val[3], val[4], val[5], nval); @@ -1398,7 +1398,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) } // endfor i - if (trace) + if (trace > 1) htrc("MakeDate datm=(%d,%d,%d,%d,%d,%d)\n", datm.tm_year, datm.tm_mon, datm.tm_mday, datm.tm_hour, datm.tm_min, datm.tm_sec); @@ -1459,7 +1459,7 @@ void DTVAL::SetValue_char(char *p, int n) ndv = ExtractDate(Sdate, Pdtp, DefYear, dval); MakeDate(NULL, dval, ndv); - if (trace) + if (trace > 1) htrc(" setting date: '%s' -> %d\n", Sdate, Tval); Null = false; @@ -1483,7 +1483,7 @@ void DTVAL::SetValue_psz(PSZ p) ndv = ExtractDate(Sdate, Pdtp, DefYear, dval); MakeDate(NULL, dval, ndv); - if (trace) + if (trace > 1) htrc(" setting date: '%s' -> %d\n", Sdate, Tval); Null = false; From e227d50203d6e6c94ad5727155a2df80114cb4a5 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 5 Jun 2013 00:46:06 +0200 Subject: [PATCH 221/273] - Change CRLF line endings to LF modified: storage/connect/tabtbl.cpp storage/connect/tabtbl.h --- storage/connect/tabtbl.cpp | 90 +++++++++++++++++++------------------- storage/connect/tabtbl.h | 50 ++++++++++----------- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 61f9c8628d9..89acc53fd4a 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -77,15 +77,15 @@ #include "ha_connect.h" #include "mycat.h" // For GetHandler -#if defined(WIN32) -#if defined(__BORLANDC__) -#define SYSEXIT void _USERENTRY -#else -#define SYSEXIT void -#endif -#else // !WIN32 -#define SYSEXIT void * -#endif // !WIN32 +#if defined(WIN32) +#if defined(__BORLANDC__) +#define SYSEXIT void _USERENTRY +#else +#define SYSEXIT void +#endif +#else // !WIN32 +#define SYSEXIT void * +#endif // !WIN32 extern "C" int trace; @@ -515,40 +515,40 @@ void TBTBLK::ReadColumn(PGLOBAL g) /* ------------------------- Class TDBTBM ---------------------------- */ -/***********************************************************************/ -/* Thread routine that check and open one remote connection. */ -/***********************************************************************/ -pthread_handler_t ThreadOpen(void *p) - { - PTBMT cmp = (PTBMT)p; - - if (!my_thread_init()) { +/***********************************************************************/ +/* Thread routine that check and open one remote connection. */ +/***********************************************************************/ +pthread_handler_t ThreadOpen(void *p) + { + PTBMT cmp = (PTBMT)p; + + if (!my_thread_init()) { set_current_thd(cmp->Thd); - // Try to open the connection - if (!cmp->Tap->GetTo_Tdb()->OpenDB(cmp->G)) { - cmp->Ready = true; - } else - cmp->Rc = RC_FX; - - my_thread_end(); - } else - cmp->Rc = RC_FX; - - return NULL; - } // end of ThreadOpen - + // Try to open the connection + if (!cmp->Tap->GetTo_Tdb()->OpenDB(cmp->G)) { + cmp->Ready = true; + } else + cmp->Rc = RC_FX; + + my_thread_end(); + } else + cmp->Rc = RC_FX; + + return NULL; + } // end of ThreadOpen + /***********************************************************************/ /* TDBTBM constructors. */ /***********************************************************************/ TDBTBM::TDBTBM(PTBLDEF tdp) : TDBTBL(tdp) { - Tmp = NULL; // To data table TBMT structures - Cmp = NULL; // Current data table TBMT - Bmp = NULL; // To bad (unconnected) TBMT structures - Done = false; // TRUE after first GetAllResults - Nrc = 0; // Number of remote connections - Nlc = 0; // Number of local connections + Tmp = NULL; // To data table TBMT structures + Cmp = NULL; // Current data table TBMT + Bmp = NULL; // To bad (unconnected) TBMT structures + Done = false; // TRUE after first GetAllResults + Nrc = 0; // Number of remote connections + Nlc = 0; // Number of local connections } // end of TDBTBL standard constructor /***********************************************************************/ @@ -580,8 +580,8 @@ int TDBTBM::RowNumber(PGLOBAL g, bool b) /***********************************************************************/ bool TDBTBM::OpenTables(PGLOBAL g) { - int k; - THD *thd = current_thd; + int k; + THD *thd = current_thd; PTABLE tabp, *ptabp = &Tablist; PTBMT tp, *ptp = &Tmp; @@ -598,16 +598,16 @@ bool TDBTBM::OpenTables(PGLOBAL g) tp->Tap = tabp; tp->Thd = thd; - // Create the thread that will do the table opening. + // Create the thread that will do the table opening. pthread_attr_init(&tp->attr); // pthread_attr_setdetachstate(&tp->attr, PTHREAD_CREATE_JOINABLE); - if ((k = pthread_create(&tp->Tid, &tp->attr, ThreadOpen, tp))) { - sprintf(g->Message, "pthread_create error %d", k); - Nbc++; - continue; - } // endif k - + if ((k = pthread_create(&tp->Tid, &tp->attr, ThreadOpen, tp))) { + sprintf(g->Message, "pthread_create error %d", k); + Nbc++; + continue; + } // endif k + // Add it to the remote list *ptp = tp; ptp = &tp->Next; diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index cdd84a1dd29..7cc2ff0b92c 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -14,26 +14,26 @@ typedef class TDBTBL *PTDBTBL; typedef class TDBTBM *PTDBTBM; typedef class MYSQLC *PMYC; -/***********************************************************************/ -/* Defines the structures used for distributed TBM tables. */ -/***********************************************************************/ -typedef struct _TBMtable *PTBMT; - -typedef struct _TBMtable { - PTBMT Next; // Points to next data table struct - PTABLE Tap; // Points to the sub table - PGLOBAL G; // Needed in thread routine - bool Complete; // TRUE when all results are read - bool Ready; // TRUE when results are there - int Rows; // Total number of rows read so far - int ProgCur; // Current pos - int ProgMax; // Max pos - int Rc; // Return code - THD *Thd; +/***********************************************************************/ +/* Defines the structures used for distributed TBM tables. */ +/***********************************************************************/ +typedef struct _TBMtable *PTBMT; + +typedef struct _TBMtable { + PTBMT Next; // Points to next data table struct + PTABLE Tap; // Points to the sub table + PGLOBAL G; // Needed in thread routine + bool Complete; // TRUE when all results are read + bool Ready; // TRUE when results are there + int Rows; // Total number of rows read so far + int ProgCur; // Current pos + int ProgMax; // Max pos + int Rc; // Return code + THD *Thd; pthread_attr_t attr; // ??? - pthread_t Tid; // CheckOpen thread ID - } TBMT; - + pthread_t Tid; // CheckOpen thread ID + } TBMT; + /***********************************************************************/ /* TBL table. */ /***********************************************************************/ @@ -156,10 +156,10 @@ class DllExport TDBTBM : public TDBTBL { int ReadNextRemote(PGLOBAL g); // Members - PTBMT Tmp; // To data table TBMT structures - PTBMT Cmp; // Current data table PLGF (to move to TDBTBL) - PTBMT Bmp; // To bad (unconnected) PLGF structures - bool Done; // TRUE after first GetAllResults - int Nrc; // Number of remote connections - int Nlc; // Number of local connections + PTBMT Tmp; // To data table TBMT structures + PTBMT Cmp; // Current data table PLGF (to move to TDBTBL) + PTBMT Bmp; // To bad (unconnected) PLGF structures + bool Done; // TRUE after first GetAllResults + int Nrc; // Number of remote connections + int Nlc; // Number of local connections }; // end of class TDBTBM From fab9a55d077b4f2a511b273d5f51272f1e3dc1ff Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 5 Jun 2013 13:51:28 +0300 Subject: [PATCH 222/273] - Fixed compiler warning - Don't abort InnoDB if one can't allocate resources for AIO (this patch was in 5.5 and 10.0-base but was missing in 10.0) sql/mdl.cc: Fixed compiler warning storage/innobase/os/os0file.cc: Don't abort InnoDB if one can't allocate resources for AIO --- sql/mdl.cc | 2 +- storage/innobase/os/os0file.cc | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sql/mdl.cc b/sql/mdl.cc index 9402de02c36..03593f150bd 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -86,7 +86,7 @@ PSI_stage_info MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]= {0, "Waiting for trigger metadata lock", 0}, {0, "Waiting for event metadata lock", 0}, {0, "Waiting for commit lock", 0}, - {0, "User lock"} /* Be compatible with old status. */ + {0, "User lock", 0} /* Be compatible with old status. */ }; #ifdef HAVE_PSI_INTERFACE diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 6d1b3aacf41..49d6b00d271 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -3434,12 +3434,23 @@ os_aio_array_create( if (!os_aio_linux_create_io_ctx(n/n_segments, &array->aio_ctx[i])) { /* If something bad happened during aio setup - we should call it a day and return right away. - We don't care about any leaks because a failure - to initialize the io subsystem means that the - server (or atleast the innodb storage engine) - is not going to startup. */ - return(NULL); + we disable linux native aio. + The disadvantage will be a small memory leak + at shutdown but that's ok compared to a crash + or a not working server. + This frequently happens when running the test suite + with many threads on a system with low fs.aio-max-nr! + */ + + fprintf(stderr, + " InnoDB: Warning: Linux Native AIO disabled " + "because os_aio_linux_create_io_ctx() " + "failed. To get rid of this warning you can " + "try increasing system " + "fs.aio-max-nr to 1048576 or larger or " + "setting innodb_use_native_aio = 0 in my.cnf\n"); + srv_use_native_aio = FALSE; + goto skip_native_aio; } } From 5cb486d159e45b9b8dc4d647b2df2492a286cf4d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Jun 2013 14:32:47 +0200 Subject: [PATCH 223/273] MDEV-26: Global transaction ID. Fix problems related to reconnect. When we need to reconnect (ie. explict stop/start of just the IO thread by user, or automatic reconnect due to loosing network connection with the master), it is a bit complex to correctly resume at the right point without causing duplicate or missing events in the relay log. The previous code had multiple problems in this regard. With this patch, the problem is solved as follows. The IO thread keeps track (in memory) of which GTID was last queued to the relay log. If it needs to reconnect, it resumes at that GTID position. It also counts number of events received within the last, possibly partial, event group, and skips the same number of events after a reconnect, so that events already enqueued before the reconnect are not duplicated. (There is no need to keep any persistent state; whenever we restart slave threads after both of them being stopped (such as after server restart), we erase the relay logs and start over from the last GTID applied by SQL thread. But while the SQL thread is running, this patch is needed to get correct relay log). --- .../include/kill_binlog_dump_threads.inc | 62 ++++ .../suite/rpl/r/rpl_gtid_reconnect.result | 169 ++++++++++ .../suite/rpl/t/rpl_gtid_reconnect.test | 201 ++++++++++++ sql/rpl_gtid.cc | 91 ++++-- sql/rpl_gtid.h | 4 + sql/rpl_mi.cc | 24 +- sql/rpl_mi.h | 37 ++- sql/share/errmsg-utf8.txt | 2 + sql/slave.cc | 290 +++++++++++++++--- sql/sql_parse.cc | 21 ++ sql/sql_repl.cc | 131 ++++++-- sql/sql_repl.h | 3 + 12 files changed, 936 insertions(+), 99 deletions(-) create mode 100644 mysql-test/include/kill_binlog_dump_threads.inc create mode 100644 mysql-test/suite/rpl/r/rpl_gtid_reconnect.result create mode 100644 mysql-test/suite/rpl/t/rpl_gtid_reconnect.test diff --git a/mysql-test/include/kill_binlog_dump_threads.inc b/mysql-test/include/kill_binlog_dump_threads.inc new file mode 100644 index 00000000000..38e3e2a7c98 --- /dev/null +++ b/mysql-test/include/kill_binlog_dump_threads.inc @@ -0,0 +1,62 @@ +# ==== Purpose ==== +# +# Terminate all binlog dump threads on a master. +# +# This is sometimes useful, as normally such dump threads can hang +# around for some time before they notice that the slave has disconnected. +# +# Note that if there are active slave connections, they might try to +# reconnect as their dump threads are killed, which may not lead to the +# desired results. +# +# +# ==== Usage ==== +# +# [--let $kill_timeout= NUMBER] +# --source include/stop_slavekill_binlog_dump_threads.inc +# +# Parameters: +# $kill_timeout +# Maximum number of seconds to wait for dump threads to disappear. + + +--let $include_filename= kill_binlog_dump_threads.inc +--source include/begin_include_file.inc + +--disable_query_log + +let $wait_counter= 300; +if ($kill_timeout) +{ + let $wait_counter= `SELECT $kill_timeout * 10`; +} + +let $success= 0; +while ($wait_counter) +{ + dec $wait_counter; + let $_tid= `SELECT id FROM information_schema.processlist WHERE command = 'Binlog Dump' LIMIT 1`; + if ($_tid) + { + eval KILL QUERY $_tid; + } + if (!$_tid) + { + let $wait_counter= 0; + let $success= 1; + } + if (!$success) + { + real_sleep 0.1; + } +} +if (!$success) +{ + SHOW FULL PROCESSLIST; + --die Timeout while waiting for binlog dump threads to disappear. +} + +--enable_query_log + +--let $include_filename= kill_binlog_dump_threads.inc +--source include/end_include_file.inc diff --git a/mysql-test/suite/rpl/r/rpl_gtid_reconnect.result b/mysql-test/suite/rpl/r/rpl_gtid_reconnect.result new file mode 100644 index 00000000000..e9f64628e12 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_reconnect.result @@ -0,0 +1,169 @@ +include/rpl_init.inc [topology=1->2] +include/stop_slave.inc +CHANGE MASTER TO master_use_gtid= current_pos; +include/start_slave.inc +CREATE TABLE t1 (a INT); +FLUSH LOGS; +SET gtid_domain_id=10; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +include/stop_slave.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +5 +include/kill_binlog_dump_threads.inc +INSERT INTO t1 VALUES (10); +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100"; +include/start_slave.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +5 +10 +include/stop_slave.inc +TRUNCATE t1; +RESET MASTER; +SET GLOBAL gtid_slave_pos= ""; +SET GLOBAL debug_dbug= @old_debug; +TRUNCATE t1; +RESET MASTER; +SET gtid_domain_id=10; +SET gtid_seq_no=50; +INSERT INTO t1 VALUES (1); +SET gtid_domain_id=11; +INSERT INTO t1 VALUES (11); +SET gtid_domain_id=10; +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (2); +SET gtid_domain_id=11; +INSERT INTO t1 VALUES (12); +SET gtid_domain_id=10; +INSERT INTO t1 VALUES (3); +SET gtid_domain_id=11; +SET gtid_seq_no=200; +INSERT INTO t1 VALUES (13); +START SLAVE UNTIL master_gtid_pos="10-1-50,11-1-200"; +include/wait_for_slave_to_stop.inc +SELECT * FROM t1 ORDER BY a; +a +1 +11 +12 +13 +include/kill_binlog_dump_threads.inc +INSERT INTO t1 VALUES (20); +SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100"; +include/start_slave.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +11 +12 +13 +20 +include/stop_slave.inc +TRUNCATE t1; +RESET MASTER; +SET GLOBAL gtid_slave_pos= ""; +SET GLOBAL debug_dbug= @old_debug; +TRUNCATE t1; +RESET MASTER; +include/kill_binlog_dump_threads.inc +SET gtid_domain_id= 9; +SET gtid_seq_no= 50; +INSERT INTO t1 VALUES (1); +SET gtid_domain_id= 10; +INSERT INTO t1 VALUES (11); +SET gtid_domain_id= 9; +INSERT INTO t1 VALUES (2); +SET gtid_domain_id= 10; +SET gtid_seq_no= 100; +INSERT INTO t1 VALUES (12); +SET gtid_domain_id= 9; +INSERT INTO t1 VALUES (3); +SET gtid_domain_id= 10; +SET gtid_seq_no= 200; +INSERT INTO t1 VALUES (13); +SET gtid_domain_id= 10; +SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100"; +START SLAVE UNTIL master_gtid_pos="9-1-50,10-1-200"; +include/wait_for_slave_to_stop.inc +SELECT * FROM t1 ORDER BY a; +a +1 +11 +12 +13 +SET GLOBAL debug_dbug= @old_debug; +INSERT INTO t1 VALUES (20); +include/start_slave.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +11 +12 +13 +20 +*** Test when slave IO thread needs to reconnect in the middle of an event group. *** +include/stop_slave.inc +TRUNCATE t1; +RESET MASTER; +SET GLOBAL gtid_slave_pos= ""; +SET GLOBAL debug_dbug= @old_debug; +TRUNCATE t1; +RESET MASTER; +include/kill_binlog_dump_threads.inc +SET GLOBAL debug_dbug="+d,binlog_force_reconnect_after_22_events"; +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1); +BEGIN; +INSERT INTO t2 VALUES (10); +INSERT INTO t2 VALUES (11); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (20); +INSERT INTO t2 VALUES (21); +INSERT INTO t2 VALUES (22); +INSERT INTO t2 VALUES (23); +INSERT INTO t2 VALUES (24); +INSERT INTO t2 VALUES (25); +INSERT INTO t2 VALUES (26); +INSERT INTO t2 VALUES (27); +INSERT INTO t2 VALUES (28); +INSERT INTO t2 VALUES (29); +COMMIT; +include/start_slave.inc +SELECT * FROM t2 ORDER BY a; +a +1 +10 +11 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +SET GLOBAL debug_dbug= @old_debug; +DROP TABLE t1, t2; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_reconnect.test b/mysql-test/suite/rpl/t/rpl_gtid_reconnect.test new file mode 100644 index 00000000000..153a04d8918 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_reconnect.test @@ -0,0 +1,201 @@ +--let $rpl_topology=1->2 +--source include/rpl_init.inc +--source include/have_innodb.inc +--source include/have_debug.inc + + +--connection server_2 +--source include/stop_slave.inc +CHANGE MASTER TO master_use_gtid= current_pos; +--source include/start_slave.inc + +--connection server_1 +CREATE TABLE t1 (a INT); +FLUSH LOGS; +--save_master_pos + +--connection server_2 +--sync_with_master + + +# Prepare a string of events and have the slave replicate all of it. +--connection server_1 +SET gtid_domain_id=10; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +--save_master_pos + +--connection server_2 +--sync_with_master +--source include/stop_slave.inc +SELECT * FROM t1 ORDER BY a; + +# Now start the slave again, but force a reconnect. There was a bug that this +# reconnect would cause duplicate events. + +--connection server_1 +# Make sure to get rid of any old binlog dump thread so it does not +# interfere with our DBUG error injection. +--source include/kill_binlog_dump_threads.inc +INSERT INTO t1 VALUES (10); +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100"; +--save_master_pos + +--connection server_2 +--source include/start_slave.inc +--sync_with_master +SELECT * FROM t1 ORDER BY a; + +--source include/stop_slave.inc +TRUNCATE t1; +RESET MASTER; +SET GLOBAL gtid_slave_pos= ""; + +--connection server_1 +SET GLOBAL debug_dbug= @old_debug; +TRUNCATE t1; +RESET MASTER; + +# A1 B1 A2 B2 A3 B3, slave reached A1 and B3 and stopped. Slave starts, +# reconnects at A2. There was a bug that B2 would be duplicated. + +SET gtid_domain_id=10; +SET gtid_seq_no=50; +INSERT INTO t1 VALUES (1); +SET gtid_domain_id=11; +INSERT INTO t1 VALUES (11); +SET gtid_domain_id=10; +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (2); +SET gtid_domain_id=11; +INSERT INTO t1 VALUES (12); +SET gtid_domain_id=10; +INSERT INTO t1 VALUES (3); +SET gtid_domain_id=11; +SET gtid_seq_no=200; +INSERT INTO t1 VALUES (13); + +--connection server_2 +START SLAVE UNTIL master_gtid_pos="10-1-50,11-1-200"; +--source include/wait_for_slave_to_stop.inc +SELECT * FROM t1 ORDER BY a; + +--connection server_1 +--source include/kill_binlog_dump_threads.inc +INSERT INTO t1 VALUES (20); +SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100"; +--save_master_pos + +--connection server_2 +--source include/start_slave.inc +--sync_with_master +SELECT * FROM t1 ORDER BY a; + +--source include/stop_slave.inc +TRUNCATE t1; +RESET MASTER; +SET GLOBAL gtid_slave_pos= ""; + +--connection server_1 +SET GLOBAL debug_dbug= @old_debug; +TRUNCATE t1; +RESET MASTER; + +# A1 B1 A2 B2 A3 B3. START SLAVE UNTIL A1,B3, gets reconnect at B2. +# There was a bug that the UNTIL would be ignored, and A2 would be lost. + +--source include/kill_binlog_dump_threads.inc +SET gtid_domain_id= 9; +SET gtid_seq_no= 50; +INSERT INTO t1 VALUES (1); +SET gtid_domain_id= 10; +INSERT INTO t1 VALUES (11); +SET gtid_domain_id= 9; +INSERT INTO t1 VALUES (2); +SET gtid_domain_id= 10; +SET gtid_seq_no= 100; +INSERT INTO t1 VALUES (12); +SET gtid_domain_id= 9; +INSERT INTO t1 VALUES (3); +SET gtid_domain_id= 10; +SET gtid_seq_no= 200; +INSERT INTO t1 VALUES (13); +SET gtid_domain_id= 10; + +SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100"; + +--connection server_2 +START SLAVE UNTIL master_gtid_pos="9-1-50,10-1-200"; +--source include/wait_for_slave_to_stop.inc +SELECT * FROM t1 ORDER BY a; + +--connection server_1 +SET GLOBAL debug_dbug= @old_debug; +INSERT INTO t1 VALUES (20); +--save_master_pos + +--connection server_2 +--source include/start_slave.inc +SELECT * FROM t1 ORDER BY a; + + +--echo *** Test when slave IO thread needs to reconnect in the middle of an event group. *** +--connection server_2 +--source include/stop_slave.inc + +TRUNCATE t1; +RESET MASTER; +SET GLOBAL gtid_slave_pos= ""; + +--connection server_1 +SET GLOBAL debug_dbug= @old_debug; +TRUNCATE t1; +RESET MASTER; + +--source include/kill_binlog_dump_threads.inc +SET GLOBAL debug_dbug="+d,binlog_force_reconnect_after_22_events"; + +# 4 events for FD, fake rotate, gtid list, binlog checkpoint. +# 2 events for GTID, create table +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; +# 3 events for BEGIN/query/COMMIT +INSERT INTO t2 VALUES (1); +# 4 events for BEGIN/query/query/COMMIT +BEGIN; +INSERT INTO t2 VALUES (10); +INSERT INTO t2 VALUES (11); +COMMIT; +# So this event group starts after 4+2+4+3=13 events. Or 16 in row-based. +BEGIN; +INSERT INTO t2 VALUES (20); +INSERT INTO t2 VALUES (21); +INSERT INTO t2 VALUES (22); +INSERT INTO t2 VALUES (23); +INSERT INTO t2 VALUES (24); +INSERT INTO t2 VALUES (25); +INSERT INTO t2 VALUES (26); +INSERT INTO t2 VALUES (27); +INSERT INTO t2 VALUES (28); +INSERT INTO t2 VALUES (29); +COMMIT; +--save_master_pos + +--connection server_2 +--source include/start_slave.inc +--sync_with_master +SELECT * FROM t2 ORDER BY a; + +--connection server_1 +SET GLOBAL debug_dbug= @old_debug; + + +# Clean up. +--connection server_1 +DROP TABLE t1, t2; + +--source include/rpl_end.inc diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index adaf9aa4e31..d5e9380296e 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -482,26 +482,10 @@ rpl_slave_state_tostring_helper(String *dest, const rpl_gtid *gtid, bool *first) } -/* - Prepare the current slave state as a string, suitable for sending to the - master to request to receive binlog events starting from that GTID state. - - The state consists of the most recently applied GTID for each domain_id, - ie. the one with the highest sub_id within each domain_id. - - Optinally, extra_gtids is a list of GTIDs from the binlog. This is used when - a server was previously a master and now needs to connect to a new master as - a slave. For each domain_id, if the GTID in the binlog was logged with our - own server_id _and_ has a higher seq_no than what is in the slave state, - then this should be used as the position to start replicating at. This - allows to promote a slave as new master, and connect the old master as a - slave with MASTER_GTID_POS=AUTO. -*/ - int -rpl_slave_state::tostring(String *dest, rpl_gtid *extra_gtids, uint32 num_extra) +rpl_slave_state::iterate(int (*cb)(rpl_gtid *, void *), void *data, + rpl_gtid *extra_gtids, uint32 num_extra) { - bool first= true; uint32 i; HASH gtid_hash; uchar *rec; @@ -555,7 +539,7 @@ rpl_slave_state::tostring(String *dest, rpl_gtid *extra_gtids, uint32 num_extra) } } - if (rpl_slave_state_tostring_helper(dest, &best_gtid, &first)) + if ((res= (*cb)(&best_gtid, data))) { unlock(); goto err; @@ -568,7 +552,7 @@ rpl_slave_state::tostring(String *dest, rpl_gtid *extra_gtids, uint32 num_extra) for (i= 0; i < gtid_hash.records; ++i) { gtid= (rpl_gtid *)my_hash_element(>id_hash, i); - if (rpl_slave_state_tostring_helper(dest, gtid, &first)) + if ((res= (*cb)(gtid, data))) goto err; } @@ -581,6 +565,44 @@ err: } +struct rpl_slave_state_tostring_data { + String *dest; + bool first; +}; +static int +rpl_slave_state_tostring_cb(rpl_gtid *gtid, void *data) +{ + rpl_slave_state_tostring_data *p= (rpl_slave_state_tostring_data *)data; + return rpl_slave_state_tostring_helper(p->dest, gtid, &p->first); +} + + +/* + Prepare the current slave state as a string, suitable for sending to the + master to request to receive binlog events starting from that GTID state. + + The state consists of the most recently applied GTID for each domain_id, + ie. the one with the highest sub_id within each domain_id. + + Optinally, extra_gtids is a list of GTIDs from the binlog. This is used when + a server was previously a master and now needs to connect to a new master as + a slave. For each domain_id, if the GTID in the binlog was logged with our + own server_id _and_ has a higher seq_no than what is in the slave state, + then this should be used as the position to start replicating at. This + allows to promote a slave as new master, and connect the old master as a + slave with MASTER_GTID_POS=AUTO. +*/ +int +rpl_slave_state::tostring(String *dest, rpl_gtid *extra_gtids, uint32 num_extra) +{ + struct rpl_slave_state_tostring_data data; + data.first= true; + data.dest= dest; + + return iterate(rpl_slave_state_tostring_cb, &data, extra_gtids, num_extra); +} + + /* Lookup a domain_id in the current replication slave state. @@ -626,9 +648,6 @@ rpl_slave_state::domain_to_gtid(uint32 domain_id, rpl_gtid *out_gtid) Parse a GTID at the start of a string, and update the pointer to point at the first character after the parsed GTID. - GTID can be in short form with domain_id=0 implied, SERVERID-SEQNO. - Or long form, DOMAINID-SERVERID-SEQNO. - Returns 0 on ok, non-zero on parse error. */ static int @@ -1217,7 +1236,7 @@ slave_connection_state::load(char *slave_request, size_t len) rpl_gtid *gtid; const rpl_gtid *gtid2; - my_hash_reset(&hash); + reset(); p= slave_request; end= slave_request + len; if (p == end) @@ -1270,7 +1289,7 @@ slave_connection_state::load(const rpl_gtid *gtid_list, uint32 count) { uint32 i; - my_hash_reset(&hash); + reset(); for (i= 0; i < count; ++i) if (update(>id_list[i])) return 1; @@ -1278,6 +1297,28 @@ slave_connection_state::load(const rpl_gtid *gtid_list, uint32 count) } +static int +slave_connection_state_load_cb(rpl_gtid *gtid, void *data) +{ + slave_connection_state *state= (slave_connection_state *)data; + return state->update(gtid); +} + + +/* + Same as rpl_slave_state::tostring(), but populates a slave_connection_state + instead. +*/ +int +slave_connection_state::load(rpl_slave_state *state, + rpl_gtid *extra_gtids, uint32 num_extra) +{ + reset(); + return state->iterate(slave_connection_state_load_cb, this, + extra_gtids, num_extra); +} + + rpl_gtid * slave_connection_state::find(uint32 domain_id) { diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index 40d51568357..4d5302020bf 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -93,6 +93,8 @@ struct rpl_slave_state int record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id, bool in_transaction, bool in_statement); uint64 next_subid(uint32 domain_id); + int iterate(int (*cb)(rpl_gtid *, void *), void *data, + rpl_gtid *extra_gtids, uint32 num_extra); int tostring(String *dest, rpl_gtid *extra_gtids, uint32 num_extra); bool domain_to_gtid(uint32 domain_id, rpl_gtid *out_gtid); int load(THD *thd, char *state_from_master, size_t len, bool reset, @@ -178,8 +180,10 @@ struct slave_connection_state slave_connection_state(); ~slave_connection_state(); + void reset() { my_hash_reset(&hash); } int load(char *slave_request, size_t len); int load(const rpl_gtid *gtid_list, uint32 count); + int load(rpl_slave_state *state, rpl_gtid *extra_gtids, uint32 num_extra); rpl_gtid *find(uint32 domain_id); int update(const rpl_gtid *in_gtid); void remove(const rpl_gtid *gtid); diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 4ffe4f37cac..4a69eb4a6ee 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -38,7 +38,8 @@ Master_info::Master_info(LEX_STRING *connection_name_arg, connect_retry(DEFAULT_CONNECT_RETRY), inited(0), abort_slave(0), slave_running(0), slave_run_id(0), sync_counter(0), heartbeat_period(0), received_heartbeats(0), master_id(0), - using_gtid(USE_GTID_NO) + using_gtid(USE_GTID_NO), events_queued_since_last_gtid(0), + gtid_reconnect_event_skip_count(0), gtid_event_seen(false) { host[0] = 0; user[0] = 0; password[0] = 0; ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0; @@ -147,6 +148,23 @@ void Master_info::clear_in_memory_info(bool all) } } + +const char * +Master_info::using_gtid_astext(enum enum_using_gtid arg) +{ + switch (arg) + { + case USE_GTID_NO: + return "No"; + case USE_GTID_SLAVE_POS: + return "Slave_Pos"; + default: + DBUG_ASSERT(arg == USE_GTID_CURRENT_POS); + return "Current_Pos"; + } +} + + void init_master_log_pos(Master_info* mi) { DBUG_ENTER("init_master_log_pos"); @@ -154,6 +172,10 @@ void init_master_log_pos(Master_info* mi) mi->master_log_name[0] = 0; mi->master_log_pos = BIN_LOG_HEADER_SIZE; // skip magic number mi->using_gtid= Master_info::USE_GTID_NO; + mi->gtid_current_pos.reset(); + mi->events_queued_since_last_gtid= 0; + mi->gtid_reconnect_event_skip_count= 0; + mi->gtid_event_seen= false; /* Intentionally init ssl_verify_server_cert to 0, no option available */ mi->ssl_verify_server_cert= 0; diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 916bd0dae02..38daed0e260 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -61,6 +61,10 @@ typedef struct st_mysql MYSQL; class Master_info : public Slave_reporting_capability { public: + enum enum_using_gtid { + USE_GTID_NO= 0, USE_GTID_CURRENT_POS= 1, USE_GTID_SLAVE_POS= 2 + }; + Master_info(LEX_STRING *connection_name, bool is_slave_recovery); ~Master_info(); bool shall_ignore_server_id(ulong s_id); @@ -70,6 +74,7 @@ class Master_info : public Slave_reporting_capability /* If malloc() in initialization failed */ return connection_name.str == 0; } + static const char *using_gtid_astext(enum enum_using_gtid arg); /* the variables below are needed because we can change masters on the fly */ char master_log_name[FN_REFLEN+6]; /* Room for multi-*/ @@ -135,9 +140,35 @@ class Master_info : public Slave_reporting_capability Note that you can not change the numeric values of these, they are used in master.info. */ - enum { - USE_GTID_NO= 0, USE_GTID_CURRENT_POS= 1, USE_GTID_SLAVE_POS= 2 - } using_gtid; + enum enum_using_gtid using_gtid; + + /* + This GTID position records how far we have fetched into the relay logs. + This is used to continue fetching when the IO thread reconnects to the + master. + + (Full slave stop/start does not use it, as it resets the relay logs). + */ + slave_connection_state gtid_current_pos; + /* + If events_queued_since_last_gtid is non-zero, it is the number of events + queued so far in the relaylog of a GTID-prefixed event group. + It is zero when no partial event group has been queued at the moment. + */ + uint64 events_queued_since_last_gtid; + /* + The GTID of the partially-queued event group, when + events_queued_since_last_gtid is non-zero. + */ + rpl_gtid last_queued_gtid; + /* + When slave IO thread needs to reconnect, gtid_reconnect_event_skip_count + counts number of events to skip from the first GTID-prefixed event group, + to avoid duplicating events in the relay log. + */ + uint64 gtid_reconnect_event_skip_count; + /* gtid_event_seen is false until we receive first GTID event from master. */ + bool gtid_event_seen; }; int init_master_info(Master_info* mi, const char* master_info_fname, const char* slave_info_fname, diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index a6a331eeb18..9acdda3b78b 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6549,3 +6549,5 @@ ER_GTID_STRICT_OUT_OF_ORDER eng "An attempt was made to binlog GTID %u-%u-%llu which would create an out-of-order sequence number with existing GTID %u-%u-%llu, and gtid strict mode is enabled." ER_GTID_START_FROM_BINLOG_HOLE eng "The binlog on the master is missing the GTID %u-%u-%llu requested by the slave (even though both a prior and a subsequent sequence number does exist), and GTID strict mode is enabled" +ER_SLAVE_UNEXPECTED_MASTER_SWITCH + eng "Unexpected GTID received from master after reconnect. This normally indicates that the master server was replaced without restarting the slave threads. %s" diff --git a/sql/slave.cc b/sql/slave.cc index 6b876c5e863..edd7a06d959 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -114,7 +114,7 @@ static const char *reconnect_messages[SLAVE_RECON_ACT_MAX][SLAVE_RECON_MSG_MAX]= registration on master", "Reconnecting after a failed registration on master", "failed registering on master, reconnecting to try again, \ -log '%s' at position %s", +log '%s' at position %s%s", "COM_REGISTER_SLAVE", "Slave I/O thread killed during or after reconnect" }, @@ -122,7 +122,7 @@ log '%s' at position %s", "Waiting to reconnect after a failed binlog dump request", "Slave I/O thread killed while retrying master dump", "Reconnecting after a failed binlog dump request", - "failed dump request, reconnecting to try again, log '%s' at position %s", + "failed dump request, reconnecting to try again, log '%s' at position %s%s", "COM_BINLOG_DUMP", "Slave I/O thread killed during or after reconnect" }, @@ -131,7 +131,7 @@ log '%s' at position %s", "Slave I/O thread killed while waiting to reconnect after a failed read", "Reconnecting after a failed master event read", "Slave I/O thread: Failed reading log event, reconnecting to retry, \ -log '%s' at position %s", +log '%s' at position %s%s", "", "Slave I/O thread killed during or after a reconnect done to recover from \ failed read" @@ -879,9 +879,13 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, purge_relay_logs(&mi->rli, NULL, 0, &errmsg); mi->master_log_name[0]= 0; mi->master_log_pos= 0; + error= rpl_load_gtid_state(&mi->gtid_current_pos, mi->using_gtid == + Master_info::USE_GTID_CURRENT_POS); + mi->events_queued_since_last_gtid= 0; + mi->gtid_reconnect_event_skip_count= 0; } - if (thread_mask & SLAVE_IO) + if (!error && (thread_mask & SLAVE_IO)) error= start_slave_thread( #ifdef HAVE_PSI_INTERFACE key_thread_slave_io, @@ -1873,18 +1877,9 @@ past_checksum: after_set_capability: #endif - /* - Request dump start from slave replication GTID state. - - Only request GTID position the first time we connect after CHANGE MASTER - or after starting both IO or SQL thread. - - Otherwise, if the IO thread was ahead of the SQL thread before the - restart or reconnect, we might end up re-fetching and hence re-applying - the same event(s) again. - */ - if (mi->using_gtid != Master_info::USE_GTID_NO && !mi->master_log_name[0]) + if (mi->using_gtid != Master_info::USE_GTID_NO) { + /* Request dump to start from slave replication GTID state. */ int rc; char str_buf[256]; String query_str(str_buf, sizeof(str_buf), system_charset_info); @@ -1913,9 +1908,7 @@ after_set_capability: query_str.append(STRING_WITH_LEN("SET @slave_connect_state='"), system_charset_info); - if (rpl_append_gtid_state(&query_str, - mi->using_gtid == - Master_info::USE_GTID_CURRENT_POS)) + if (mi->gtid_current_pos.append_to_string(&query_str)) { err_code= ER_OUTOFMEMORY; errmsg= "The slave I/O thread stops because a fatal out-of-memory " @@ -2016,7 +2009,7 @@ after_set_capability: } } } - if (mi->using_gtid == Master_info::USE_GTID_NO) + else { /* If we are not using GTID to connect this time, then instead request @@ -2588,10 +2581,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, } // Master_Server_id protocol->store((uint32) mi->master_id); - protocol->store((mi->using_gtid==Master_info::USE_GTID_NO ? "No" : - (mi->using_gtid==Master_info::USE_GTID_SLAVE_POS ? - "Slave_Pos" : "Current_Pos")), - &my_charset_bin); + protocol->store(mi->using_gtid_astext(mi->using_gtid), &my_charset_bin); if (full) { protocol->store((uint32) mi->rli.retried_trans); @@ -3424,8 +3414,22 @@ static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi, if (!suppress_warnings) { char buf[256], llbuff[22]; + String tmp; + if (mi->using_gtid != Master_info::USE_GTID_NO) + { + tmp.append(STRING_WITH_LEN("; GTID position '")); + mi->gtid_current_pos.append_to_string(&tmp); + if (mi->events_queued_since_last_gtid == 0) + tmp.append(STRING_WITH_LEN("'")); + else + { + tmp.append(STRING_WITH_LEN("', GTID event skip ")); + tmp.append_ulonglong((ulonglong)mi->events_queued_since_last_gtid); + } + } my_snprintf(buf, sizeof(buf), messages[SLAVE_RECON_MSG_FAILED], - IO_RPL_LOG_NAME, llstr(mi->master_log_pos, llbuff)); + IO_RPL_LOG_NAME, llstr(mi->master_log_pos, llbuff), + tmp.c_ptr_safe()); /* Raise a warining during registering on master/requesting dump. Log a message reading event. @@ -3545,11 +3549,21 @@ pthread_handler_t handle_slave_io(void *arg) // we can get killed during safe_connect if (!safe_connect(thd, mysql, mi)) { - sql_print_information("Slave I/O thread: connected to master '%s@%s:%d'," - "replication started in log '%s' at position %s", - mi->user, mi->host, mi->port, - IO_RPL_LOG_NAME, - llstr(mi->master_log_pos,llbuff)); + if (mi->using_gtid == Master_info::USE_GTID_NO) + sql_print_information("Slave I/O thread: connected to master '%s@%s:%d'," + "replication started in log '%s' at position %s", + mi->user, mi->host, mi->port, + IO_RPL_LOG_NAME, + llstr(mi->master_log_pos,llbuff)); + else + { + String tmp; + mi->gtid_current_pos.to_string(&tmp); + sql_print_information("Slave I/O thread: connected to master '%s@%s:%d'," + "replication starts at GTID position '%s'", + mi->user, mi->host, mi->port, tmp.c_ptr_safe()); + } + /* Adding MAX_LOG_EVENT_HEADER_LEN to the max_packet_size on the I/O thread, since a replication event can become this much larger than @@ -3566,6 +3580,25 @@ pthread_handler_t handle_slave_io(void *arg) connected: + if (mi->using_gtid != Master_info::USE_GTID_NO) + { + /* + When the IO thread (re)connects to the master using GTID, it will + connect at the start of an event group. But the IO thread may have + previously logged part of the following event group to the relay + log. + + When the IO and SQL thread are started together, we erase any previous + relay logs, but this is not possible/desirable while the SQL thread is + running. To avoid duplicating partial event groups in the relay logs in + this case, we remember the count of events in any partially logged event + group before the reconnect, and then here at connect we set up a counter + to skip the already-logged part of the group. + */ + mi->gtid_reconnect_event_skip_count= mi->events_queued_since_last_gtid; + mi->gtid_event_seen= false; + } + #ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("dbug.before_get_running_status_yes", { @@ -3791,8 +3824,19 @@ log space"); // error = 0; err: // print the current replication position - sql_print_information("Slave I/O thread exiting, read up to log '%s', position %s", - IO_RPL_LOG_NAME, llstr(mi->master_log_pos,llbuff)); + if (mi->using_gtid == Master_info::USE_GTID_NO) + sql_print_information("Slave I/O thread exiting, read up to log '%s', " + "position %s", + IO_RPL_LOG_NAME, llstr(mi->master_log_pos,llbuff)); + else + { + String tmp; + mi->gtid_current_pos.to_string(&tmp); + sql_print_information("Slave I/O thread exiting, read up to log '%s', " + "position %s; GTID position %s", + IO_RPL_LOG_NAME, llstr(mi->master_log_pos,llbuff), + tmp.c_ptr_safe()); + } RUN_HOOK(binlog_relay_io, thread_stop, (thd, mi)); thd->reset_query(); thd->reset_db(NULL, 0); @@ -4059,10 +4103,20 @@ pthread_handler_t handle_slave_sql(void *arg) rli->group_master_log_name, llstr(rli->group_master_log_pos,llbuff))); if (global_system_variables.log_warnings) + { + String tmp; + if (mi->using_gtid != Master_info::USE_GTID_NO) + { + tmp.append(STRING_WITH_LEN("; GTID position '")); + rpl_append_gtid_state(&tmp, + mi->using_gtid==Master_info::USE_GTID_CURRENT_POS); + tmp.append(STRING_WITH_LEN("'")); + } sql_print_information("Slave SQL thread initialized, starting replication in \ -log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, +log '%s' at position %s, relay log '%s' position: %s%s", RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff),rli->group_relay_log_name, - llstr(rli->group_relay_log_pos,llbuff1)); + llstr(rli->group_relay_log_pos,llbuff1), tmp.c_ptr_safe()); + } if (check_temp_dir(rli->slave_patternload_file)) { @@ -4196,16 +4250,35 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, sql_print_warning("Slave: %s Error_code: %d", err->get_message_text(), err->get_sql_errno()); } if (udf_error) + { + String tmp; + if (mi->using_gtid != Master_info::USE_GTID_NO) + { + tmp.append(STRING_WITH_LEN("; GTID position '")); + rpl_append_gtid_state(&tmp, false); + tmp.append(STRING_WITH_LEN("'")); + } sql_print_error("Error loading user-defined library, slave SQL " "thread aborted. Install the missing library, and restart the " "slave SQL thread with \"SLAVE START\". We stopped at log '%s' " - "position %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, - llbuff)); + "position %s%s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, + llbuff), tmp.c_ptr_safe()); + } else + { + String tmp; + if (mi->using_gtid != Master_info::USE_GTID_NO) + { + tmp.append(STRING_WITH_LEN("; GTID position '")); + rpl_append_gtid_state(&tmp, false); + tmp.append(STRING_WITH_LEN("'")); + } sql_print_error("\ Error running query, slave SQL thread aborted. Fix the problem, and restart \ the slave SQL thread with \"SLAVE START\". We stopped at log \ -'%s' position %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, llbuff)); +'%s' position %s%s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, llbuff), + tmp.c_ptr_safe()); + } } goto err; } @@ -4213,9 +4286,20 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ } /* Thread stopped. Print the current replication position to the log */ - sql_print_information("Slave SQL thread exiting, replication stopped in log " - "'%s' at position %s", - RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff)); + { + String tmp; + if (mi->using_gtid != Master_info::USE_GTID_NO) + { + tmp.append(STRING_WITH_LEN("; GTID position '")); + rpl_append_gtid_state(&tmp, false); + tmp.append(STRING_WITH_LEN("'")); + } + sql_print_information("Slave SQL thread exiting, replication stopped in " + "log '%s' at position %s%s", + RPL_LOG_NAME, + llstr(rli->group_master_log_pos,llbuff), + tmp.c_ptr_safe()); + } err: @@ -4690,6 +4774,8 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) mysql_mutex_t *log_lock= rli->relay_log.get_log_lock(); ulong s_id; bool unlock_data_lock= TRUE; + bool gtid_skip_enqueue= false; + /* FD_q must have been prepared for the first R_a event inside get_master_version_and_clock() @@ -4876,6 +4962,19 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) /* installing new value of checksum Alg for relay log */ mi->rli.relay_log.relay_log_checksum_alg= tmp->checksum_alg; + /* + Do not queue any format description event that we receive after a + reconnect where we are skipping over a partial event group received + before the reconnect. + + (If we queued such an event, and it was the first format_description + event after master restart, the slave SQL thread would think that + the partial event group before it in the relay log was from a + previous master crash and should be rolled back. + */ + if (unlikely(mi->gtid_reconnect_event_skip_count)) + gtid_skip_enqueue= true; + /* Though this does some conversion to the slave's format, this will preserve the master's binlog format version, and number of event types. @@ -4971,18 +5070,113 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) " UNTIL master_gtid_pos %s", str.c_ptr_safe()); mi->abort_slave= true; } + event_pos= glev->log_pos; delete glev; /* - Do not update position for fake Gtid_list event (which has a zero - end_log_pos). + We use fake Gtid_list events to update the old-style position (among + other things). + + Early code created fake Gtid_list events with zero log_pos, those should + not modify old-style position. */ - inc_pos= uint4korr(buf+LOG_POS_OFFSET) ? event_len : 0; + if (event_pos == 0 || event_pos <= mi->master_log_pos) + inc_pos= 0; + else + inc_pos= event_pos - mi->master_log_pos; + } + break; + + case GTID_EVENT: + { + uchar dummy_flag; + + if (mi->using_gtid == Master_info::USE_GTID_NO) + goto default_action; + if (unlikely(!mi->gtid_event_seen)) + { + mi->gtid_event_seen= true; + if (mi->gtid_reconnect_event_skip_count) + { + rpl_gtid gtid; + + /* + If we are reconnecting, and we need to skip a partial event group + already queued to the relay log before the reconnect, then we check + that we actually get the same event group (same GTID) as before, so + we do not end up with half of one group and half another. + + The only way we should be able to receive a different GTID than what + we expect is if the binlog on the master (or more likely the whole + master server) was replaced with a different one, one the same IP + address, _and_ the new master happens to have domains in a different + order so we get the GTID from a different domain first. Still, it is + best to protect against this case. + */ + if (Gtid_log_event::peek(buf, event_len, checksum_alg, + >id.domain_id, >id.server_id, + >id.seq_no, &dummy_flag)) + { + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + goto err; + } + if (gtid.domain_id != mi->last_queued_gtid.domain_id || + gtid.server_id != mi->last_queued_gtid.server_id || + gtid.seq_no != mi->last_queued_gtid.seq_no) + { + bool first; + error= ER_SLAVE_UNEXPECTED_MASTER_SWITCH; + error_msg.append(STRING_WITH_LEN("Expected: ")); + first= true; + rpl_slave_state_tostring_helper(&error_msg, &mi->last_queued_gtid, + &first); + error_msg.append(STRING_WITH_LEN(", received: ")); + first= true; + rpl_slave_state_tostring_helper(&error_msg, >id, &first); + goto err; + } + } + } + + if (unlikely(mi->gtid_reconnect_event_skip_count)) + { + goto default_action; + } + + /* + We have successfully queued to relay log everything before this GTID, so + in case of reconnect we can start from after any previous GTID. + */ + if (mi->events_queued_since_last_gtid) + { + mi->gtid_current_pos.update(&mi->last_queued_gtid); + mi->events_queued_since_last_gtid= 0; + } + if (Gtid_log_event::peek(buf, event_len, checksum_alg, + &mi->last_queued_gtid.domain_id, + &mi->last_queued_gtid.server_id, + &mi->last_queued_gtid.seq_no, &dummy_flag)) + { + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + goto err; + } + ++mi->events_queued_since_last_gtid; } break; default: default_action: + if (mi->using_gtid != Master_info::USE_GTID_NO && mi->gtid_event_seen) + { + if (unlikely(mi->gtid_reconnect_event_skip_count)) + { + --mi->gtid_reconnect_event_skip_count; + gtid_skip_enqueue= true; + } + else if (mi->events_queued_since_last_gtid) + ++mi->events_queued_since_last_gtid; + } + inc_pos= event_len; break; } @@ -5067,8 +5261,16 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) } else { - /* write the event to the relay log */ - if (likely(!(rli->relay_log.appendv(buf,event_len,0)))) + /* + Write the event to the relay log, unless we reconnected in the middle + of an event group and now need to skip the initial part of the group that + we already wrote before reconnecting. + */ + if (unlikely(gtid_skip_enqueue)) + { + mi->master_log_pos+= inc_pos; + } + else if (likely(!(rli->relay_log.appendv(buf,event_len,0)))) { mi->master_log_pos+= inc_pos; DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c6372099600..4625a61f22c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2776,13 +2776,34 @@ end_with_restore_list: { LEX_MASTER_INFO* lex_mi= &thd->lex->mi; Master_info *mi; + int load_error; + + load_error= rpl_load_gtid_slave_state(thd); + mysql_mutex_lock(&LOCK_active_mi); if ((mi= (master_info_index-> get_master_info(&lex_mi->connection_name, MYSQL_ERROR::WARN_LEVEL_ERROR)))) + { + if (load_error) + { + /* + We cannot start a slave using GTID if we cannot load the GTID position + from the mysql.gtid_slave_pos table. But we can allow non-GTID + replication (useful eg. during upgrade). + */ + if (mi->using_gtid != Master_info::USE_GTID_NO) + { + mysql_mutex_unlock(&LOCK_active_mi); + break; + } + else + thd->clear_error(); + } if (!start_slave(thd, mi, 1 /* net report*/)) my_ok(thd); + } mysql_mutex_unlock(&LOCK_active_mi); break; } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index fd9ead71472..d8aebbde8dc 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -50,7 +50,7 @@ extern TYPELIB binlog_checksum_typelib; static int fake_event_header(String* packet, Log_event_type event_type, ulong extra_len, my_bool *do_checksum, ha_checksum *crc, const char** errmsg, - uint8 checksum_alg_arg) + uint8 checksum_alg_arg, uint32 end_pos) { char header[LOG_EVENT_HEADER_LEN]; ulong event_len; @@ -70,7 +70,7 @@ fake_event_header(String* packet, Log_event_type event_type, ulong extra_len, int4store(header + EVENT_LEN_OFFSET, event_len); int2store(header + FLAGS_OFFSET, LOG_EVENT_ARTIFICIAL_F); // TODO: check what problems this may cause and fix them - int4store(header + LOG_POS_OFFSET, 0); + int4store(header + LOG_POS_OFFSET, end_pos); if (packet->append(header, sizeof(header))) { *errmsg= "Failed due to out-of-memory writing event"; @@ -146,7 +146,7 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, if ((err= fake_event_header(packet, ROTATE_EVENT, ident_len + ROTATE_HEADER_LEN, &do_checksum, &crc, - errmsg, checksum_alg_arg))) + errmsg, checksum_alg_arg, 0))) DBUG_RETURN(err); int8store(buf+R_POS_OFFSET,position); @@ -169,7 +169,7 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, static int fake_gtid_list_event(NET* net, String* packet, Gtid_list_log_event *glev, const char** errmsg, - uint8 checksum_alg_arg) + uint8 checksum_alg_arg, uint32 current_pos) { my_bool do_checksum; int err; @@ -185,7 +185,7 @@ static int fake_gtid_list_event(NET* net, String* packet, } if ((err= fake_event_header(packet, GTID_LIST_EVENT, str.length(), &do_checksum, &crc, - errmsg, checksum_alg_arg))) + errmsg, checksum_alg_arg, current_pos))) return err; packet->append(str); @@ -1406,7 +1406,7 @@ is_until_reached(THD *thd, NET *net, String *packet, ulong *ev_offset, enum_gtid_until_state gtid_until_group, Log_event_type event_type, uint8 current_checksum_alg, ushort flags, const char **errmsg, - rpl_binlog_state *until_binlog_state) + rpl_binlog_state *until_binlog_state, uint32 current_pos) { switch (gtid_until_group) { @@ -1437,7 +1437,8 @@ is_until_reached(THD *thd, NET *net, String *packet, ulong *ev_offset, return true; Gtid_list_log_event glev(until_binlog_state, Gtid_list_log_event::FLAG_UNTIL_REACHED); - if (fake_gtid_list_event(net, packet, &glev, errmsg, current_checksum_alg)) + if (fake_gtid_list_event(net, packet, &glev, errmsg, current_checksum_alg, + current_pos)) return true; *errmsg= NULL; return true; @@ -1508,6 +1509,19 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags, return "Failed to read Gtid_log_event: corrupt binlog"; } + DBUG_EXECUTE_IF("gtid_force_reconnect_at_10_1_100", + { + rpl_gtid *dbug_gtid; + if ((dbug_gtid= until_binlog_state->find(10,1)) && + dbug_gtid->seq_no == 100) + { + DBUG_SET("-d,gtid_force_reconnect_at_10_1_100"); + DBUG_SET_INITIAL("-d,gtid_force_reconnect_at_10_1_100"); + my_errno= ER_UNKNOWN_ERROR; + return "DBUG-injected forced reconnect"; + } + }); + if (until_binlog_state->update(&event_gtid, false)) { my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; @@ -1527,19 +1541,31 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags, if (event_gtid.server_id == gtid->server_id && event_gtid.seq_no >= gtid->seq_no) { - /* - In strict mode, it is an error if the slave requests to start in - a "hole" in the master's binlog: a GTID that does not exist, even - though both the prior and subsequent seq_no exists for same - domain_id and server_id. - */ - if (slave_gtid_strict_mode && event_gtid.seq_no > gtid->seq_no) + if (event_gtid.seq_no > gtid->seq_no) { - my_errno= ER_GTID_START_FROM_BINLOG_HOLE; - *error_gtid= *gtid; - return "The binlog on the master is missing the GTID requested " - "by the slave (even though both a prior and a subsequent " - "sequence number does exist), and GTID strict mode is enabled."; + /* + In strict mode, it is an error if the slave requests to start + in a "hole" in the master's binlog: a GTID that does not + exist, even though both the prior and subsequent seq_no exists + for same domain_id and server_id. + */ + if (slave_gtid_strict_mode) + { + my_errno= ER_GTID_START_FROM_BINLOG_HOLE; + *error_gtid= *gtid; + return "The binlog on the master is missing the GTID requested " + "by the slave (even though both a prior and a subsequent " + "sequence number does exist), and GTID strict mode is enabled."; + } + } + else + { + /* + Send a fake Gtid_list event to the slave. + This allows the slave to update its current binlog position + so MASTER_POS_WAIT() and MASTER_GTID_WAIT() can work. + */ +// send_fake_gtid_list_event(until_binlog_state); } /* Delete this entry if we have reached slave start position (so we @@ -1797,6 +1823,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, int old_max_allowed_packet= thd->variables.max_allowed_packet; #ifndef DBUG_OFF int left_events = max_binlog_dump_events; + uint dbug_reconnect_counter= 0; #endif DBUG_ENTER("mysql_binlog_send"); DBUG_PRINT("enter",("log_ident: '%s' pos: %ld", log_ident, (long) pos)); @@ -1830,6 +1857,13 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, until_gtid_state= &until_gtid_state_obj; } + DBUG_EXECUTE_IF("binlog_force_reconnect_after_22_events", + { + DBUG_SET("-d,binlog_force_reconnect_after_22_events"); + DBUG_SET_INITIAL("-d,binlog_force_reconnect_after_22_events"); + dbug_reconnect_counter= 22; + }); + /* We want to corrupt the first event, in Log_event::read_log_event(). But we do not want the corruption to happen early, eg. when client does @@ -2176,6 +2210,19 @@ impossible position"; (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F; } +#ifndef DBUG_OFF + if (dbug_reconnect_counter > 0) + { + --dbug_reconnect_counter; + if (dbug_reconnect_counter == 0) + { + errmsg= "DBUG-injected forced reconnect"; + my_errno= ER_UNKNOWN_ERROR; + goto err; + } + } +#endif + if ((tmp_msg= send_event_to_slave(thd, net, packet, flags, event_type, log_file_name, &log, mariadb_slave_capability, ev_offset, @@ -2191,7 +2238,7 @@ impossible position"; if (until_gtid_state && is_until_reached(thd, net, packet, &ev_offset, gtid_until_group, event_type, current_checksum_alg, flags, &errmsg, - &until_binlog_state)) + &until_binlog_state, my_b_tell(&log))) { if (errmsg) { @@ -2373,7 +2420,7 @@ impossible position"; until_gtid_state && is_until_reached(thd, net, packet, &ev_offset, gtid_until_group, event_type, current_checksum_alg, flags, &errmsg, - &until_binlog_state)) + &until_binlog_state, my_b_tell(&log))) { if (errmsg) { @@ -2970,6 +3017,7 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added) char saved_host[HOSTNAME_LENGTH + 1]; uint saved_port; char saved_log_name[FN_REFLEN]; + Master_info::enum_using_gtid saved_using_gtid; char master_info_file_tmp[FN_REFLEN]; char relay_log_info_file_tmp[FN_REFLEN]; my_off_t saved_log_pos; @@ -3059,6 +3107,7 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added) saved_port= mi->port; strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1); saved_log_pos= mi->master_log_pos; + saved_using_gtid= mi->using_gtid; /* If the user specified host or port without binlog or position, @@ -3291,6 +3340,11 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added) "master_log_pos='%ld'.", saved_host, saved_port, saved_log_name, (ulong) saved_log_pos, mi->host, mi->port, mi->master_log_name, (ulong) mi->master_log_pos); + if (saved_using_gtid != Master_info::USE_GTID_NO || + mi->using_gtid != Master_info::USE_GTID_NO) + sql_print_information("Previous Using_Gtid=%s. New Using_Gtid=%s", + mi->using_gtid_astext(saved_using_gtid), + mi->using_gtid_astext(mi->using_gtid)); /* If we don't write new coordinates to disk now, then old will remain in @@ -3753,11 +3807,11 @@ rpl_deinit_gtid_slave_state() /* - Format the current GTID state as a string, for use when connecting to a - master server with GTID, or for returning the value of @@global.gtid_state. + Format the current GTID state as a string, for returning the value of + @@global.gtid_slave_pos. If the flag use_binlog is true, then the contents of the binary log (if - enabled) is merged into the current GTID state. + enabled) is merged into the current GTID state (@@global.gtid_current_pos). */ int rpl_append_gtid_state(String *dest, bool use_binlog) @@ -3770,10 +3824,35 @@ rpl_append_gtid_state(String *dest, bool use_binlog) (err= mysql_bin_log.get_most_recent_gtid_list(>id_list, &num_gtids))) return err; - rpl_global_gtid_slave_state.tostring(dest, gtid_list, num_gtids); + err= rpl_global_gtid_slave_state.tostring(dest, gtid_list, num_gtids); my_free(gtid_list); - return 0; + return err; +} + + +/* + Load the current GITD position into a slave_connection_state, for use when + connecting to a master server with GTID. + + If the flag use_binlog is true, then the contents of the binary log (if + enabled) is merged into the current GTID state (master_use_gtid=current_pos). +*/ +int +rpl_load_gtid_state(slave_connection_state *state, bool use_binlog) +{ + int err; + rpl_gtid *gtid_list= NULL; + uint32 num_gtids= 0; + + if (use_binlog && opt_bin_log && + (err= mysql_bin_log.get_most_recent_gtid_list(>id_list, &num_gtids))) + return err; + + err= state->load(&rpl_global_gtid_slave_state, gtid_list, num_gtids); + my_free(gtid_list); + + return err; } diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 820ffed0928..a242fa4aeef 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -32,6 +32,8 @@ typedef struct st_slave_info THD* thd; } SLAVE_INFO; +class slave_connection_state; + extern my_bool opt_show_slave_auth_info; extern char *master_host, *master_info_file; extern bool server_id_supplied; @@ -70,6 +72,7 @@ void rpl_init_gtid_slave_state(); void rpl_deinit_gtid_slave_state(); int gtid_state_from_binlog_pos(const char *name, uint32 pos, String *out_str); int rpl_append_gtid_state(String *dest, bool use_binlog); +int rpl_load_gtid_state(slave_connection_state *state, bool use_binlog); bool rpl_gtid_pos_check(THD *thd, char *str, size_t len); bool rpl_gtid_pos_update(THD *thd, char *str, size_t len); From 64e53a0f816ec0ca4792fcefe5be18494691bfe7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Jun 2013 15:32:44 +0200 Subject: [PATCH 224/273] Fix two small problems in previous push. --- sql/slave.cc | 4 ++-- sql/sql_repl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index edd7a06d959..38ff94bcea0 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4970,9 +4970,9 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) (If we queued such an event, and it was the first format_description event after master restart, the slave SQL thread would think that the partial event group before it in the relay log was from a - previous master crash and should be rolled back. + previous master crash and should be rolled back). */ - if (unlikely(mi->gtid_reconnect_event_skip_count)) + if (unlikely(mi->gtid_reconnect_event_skip_count && !mi->gtid_event_seen)) gtid_skip_enqueue= true; /* diff --git a/sql/sql_repl.h b/sql/sql_repl.h index a242fa4aeef..917da9b598e 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -32,7 +32,7 @@ typedef struct st_slave_info THD* thd; } SLAVE_INFO; -class slave_connection_state; +struct slave_connection_state; extern my_bool opt_show_slave_auth_info; extern char *master_host, *master_info_file; From 5cf5a9a1e8660cbcc60362d90cc22b63b2c05ed7 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 6 Jun 2013 15:51:36 +0300 Subject: [PATCH 225/273] Fixed timing failure in myisam-metadata.test mysql-test/include/wait_show_condition.inc: Print failing statement if timeout mysql-test/r/myisam-metadata.result: Updated DBUG_SYNC mysql-test/t/myisam-metadata.test: Updated DBUG_SYNC. Removed wait_show_condtion, as this is not needed when we use DBUG_SYNC This should fix timing issues with the test mysys/thr_mutex.c: Added comments sql/sql_acl.cc: atoi -> atoll() (Safety) storage/myisam/ha_myisam.cc: Send signal before mi_repair_by_sort. --- mysql-test/include/wait_show_condition.inc | 1 + mysql-test/r/myisam-metadata.result | 2 +- mysql-test/t/myisam-metadata.test | 7 +------ mysys/thr_mutex.c | 10 +++++----- sql/sql_acl.cc | 2 +- storage/myisam/ha_myisam.cc | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/mysql-test/include/wait_show_condition.inc b/mysql-test/include/wait_show_condition.inc index ae1600a7e30..b8dd9bdf971 100644 --- a/mysql-test/include/wait_show_condition.inc +++ b/mysql-test/include/wait_show_condition.inc @@ -127,5 +127,6 @@ if (!$found) echo # field : $field; echo # condition : $condition; echo # max_run_time : $max_run_time; + eval $show_statement; } diff --git a/mysql-test/r/myisam-metadata.result b/mysql-test/r/myisam-metadata.result index 4d49bac9436..f13e4ac8b60 100644 --- a/mysql-test/r/myisam-metadata.result +++ b/mysql-test/r/myisam-metadata.result @@ -5,7 +5,7 @@ a VARCHAR(100), INDEX(a) ) ENGINE=MyISAM; ALTER TABLE t1 DISABLE KEYS; -SET debug_sync= 'myisam_after_repair_by_sort SIGNAL waiting WAIT_FOR go'; +SET debug_sync= 'myisam_before_repair_by_sort SIGNAL waiting WAIT_FOR go'; ALTER TABLE t1 ENABLE KEYS; SET debug_sync= 'now WAIT_FOR waiting'; SET debug_sync= 'now SIGNAL go'; diff --git a/mysql-test/t/myisam-metadata.test b/mysql-test/t/myisam-metadata.test index 2bbcc89a702..609cf5d8c5e 100644 --- a/mysql-test/t/myisam-metadata.test +++ b/mysql-test/t/myisam-metadata.test @@ -30,16 +30,11 @@ while ($1) --enable_query_log --connect(con1,localhost,root,,) -SET debug_sync= 'myisam_after_repair_by_sort SIGNAL waiting WAIT_FOR go'; +SET debug_sync= 'myisam_before_repair_by_sort SIGNAL waiting WAIT_FOR go'; send ALTER TABLE t1 ENABLE KEYS; --connection default ---let $wait_timeout=60 ---let $show_statement= SHOW PROCESSLIST ---let $field= State ---let $condition= = 'Repair by sorting' ---source include/wait_show_condition.inc SET debug_sync= 'now WAIT_FOR waiting'; SET debug_sync= 'now SIGNAL go'; diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 17cda782b30..c70aa342802 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -132,7 +132,7 @@ void safe_mutex_global_init(void) #ifdef SAFE_MUTEX_DETECT_DESTROY safe_mutex_create_root= 0; -#endif +#endif /* SAFE_MUTEX_DETECT_DESTROY */ } static inline void remove_from_active_list(safe_mutex_t *mp) @@ -553,7 +553,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, "on %s at %s, line %d\n", error, errno, mp->name, file, line); } -#endif +#endif /* EXTRA_DEBUG */ pthread_mutex_lock(&mp->global); /* Restore state as it was before */ mp->thread= save_state.thread; @@ -612,7 +612,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) error=1; if (pthread_mutex_destroy(&mp->mutex)) error=1; -#endif +#endif /* __WIN__ */ mp->file= 0; /* Mark destroyed */ #ifdef SAFE_MUTEX_DETECT_DESTROY @@ -838,7 +838,7 @@ static void print_deadlock_warning(safe_mutex_t *new_mutex, DBUG_VOID_RETURN; } -#elif defined(MY_PTHREAD_FASTMUTEX) +#elif defined(MY_PTHREAD_FASTMUTEX) /* !SAFE_MUTEX_DEFINED */ static ulong mutex_delay(ulong delayloops) { @@ -922,4 +922,4 @@ void fastmutex_global_init(void) #endif } -#endif /* defined(MY_PTHREAD_FASTMUTEX) */ +#endif /* defined(MY_PTHREAD_FASTMUTEX) && defined(SAFE_MUTEX_DEFINED) */ diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 69290a64a29..4fe99b24508 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -968,7 +968,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) { /* Starting from 5.0.3 we have max_user_connections field */ ptr= get_field(thd->mem_root, table->field[next_field++]); - user.user_resource.user_conn= ptr ? atoi(ptr) : 0; + user.user_resource.user_conn= ptr ? atoll(ptr) : 0; } if (table->s->fields >= 41) diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index c5d4f987c00..cb9ded167d9 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1126,9 +1126,9 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) else { thd_proc_info(thd, "Repair by sorting"); + DEBUG_SYNC(thd, "myisam_before_repair_by_sort"); error = mi_repair_by_sort(¶m, file, fixed_name, test(param.testflag & T_QUICK)); - DEBUG_SYNC(thd, "myisam_after_repair_by_sort"); } if (error && file->create_unique_index_by_sort && share->state.dupp_key != MAX_KEY) From 1ff1cb10fc236010b5969058cab934c2b306c931 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 6 Jun 2013 17:38:07 +0200 Subject: [PATCH 226/273] fix compile error --- sql/sql_acl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 4fe99b24508..69290a64a29 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -968,7 +968,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) { /* Starting from 5.0.3 we have max_user_connections field */ ptr= get_field(thd->mem_root, table->field[next_field++]); - user.user_resource.user_conn= ptr ? atoll(ptr) : 0; + user.user_resource.user_conn= ptr ? atoi(ptr) : 0; } if (table->s->fields >= 41) From ffa2eb43560faca9f7d05c79d4c54657d33c62a6 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 8 Jun 2013 00:24:27 +0400 Subject: [PATCH 227/273] Fixing a few compiler warnings modified: storage/connect/ha_connect.cc storage/connect/value.cpp --- storage/connect/ha_connect.cc | 6 +++--- storage/connect/value.cpp | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 10e415d2f6a..7d37b79bae8 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -228,8 +228,8 @@ ha_create_table_option connect_table_option_list[]= //HA_TOPTION_NUMBER("ESTIMATE", estimate, 0, 0, INT_MAX32, 1), HA_TOPTION_NUMBER("MULTIPLE", multiple, 0, 0, 2, 1), HA_TOPTION_NUMBER("HEADER", header, 0, 0, 3, 1), - HA_TOPTION_NUMBER("QUOTED", quoted, -1, 0, 3, 1), - HA_TOPTION_NUMBER("ENDING", ending, -1, 0, INT_MAX32, 1), + HA_TOPTION_NUMBER("QUOTED", quoted, (ulonglong) -1, 0, 3, 1), + HA_TOPTION_NUMBER("ENDING", ending, (ulonglong) -1, 0, INT_MAX32, 1), HA_TOPTION_NUMBER("COMPRESS", compressed, 0, 0, 2, 1), //HA_TOPTION_BOOL("COMPRESS", compressed, 0), HA_TOPTION_BOOL("MAPPED", mapped, 0), @@ -249,7 +249,7 @@ ha_create_table_option connect_table_option_list[]= */ ha_create_table_option connect_field_option_list[]= { - HA_FOPTION_NUMBER("FLAG", offset, -1, 0, INT_MAX32, 1), + HA_FOPTION_NUMBER("FLAG", offset, (ulonglong) -1, 0, INT_MAX32, 1), HA_FOPTION_NUMBER("FREQUENCY", freq, 0, 0, INT_MAX32, 1), // not used HA_FOPTION_NUMBER("OPT_VALUE", opt, 0, 0, 2, 1), // used for indexing HA_FOPTION_NUMBER("FIELD_LENGTH", fldlen, 0, 0, INT_MAX32, 1), diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index a770ac819c9..e60f3889ef5 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -88,6 +88,7 @@ PSZ strlwr(PSZ s); } #endif // !WIN32 +#ifdef NOT_USED /***********************************************************************/ /* Returns the bitmap representing the conditions that must not be */ /* met when returning from TestValue for a given operator. */ @@ -113,6 +114,7 @@ static BYTE OpBmp(PGLOBAL g, OPVAL opc) return bt; } // end of OpBmp +#endif /***********************************************************************/ /* GetTypeName: returns the PlugDB internal type name. */ From 76fc94af53f86deb5d284aba6c88897568dc0c87 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 8 Jun 2013 01:20:49 +0400 Subject: [PATCH 228/273] Enabling Connect tests modified: mysql-test/mysql-test-run.pl --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ed84175edae..45887f76794 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -377,7 +377,7 @@ sub main { # directly before it executes them, like "make test-force-pl" in RPM builds. mtr_report("Logging: $0 ", join(" ", @ARGV)); - $DEFAULT_SUITES.=",sequence,sql_discovery" if $source_dist; + $DEFAULT_SUITES.=",sequence,sql_discovery,connect" if $source_dist; command_line_setup(); From adeff67855cccea19bc3f2865459c0ad6705fcf4 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 8 Jun 2013 01:02:22 +0200 Subject: [PATCH 229/273] - Set timeout values in MYSQLC::Open modified: storage/connect/myconn.cpp --- storage/connect/myconn.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 9ebf77ff35a..41fdb1f5e98 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -311,6 +311,8 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, const char *user, const char *pwd, int pt) { + uint cto = 60, nrt = 120; + m_DB = mysql_init(NULL); if (!m_DB) { @@ -323,6 +325,9 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, // client's options, and vice versa. mysql_options(m_DB, MYSQL_READ_DEFAULT_GROUP, "PlugDB_CLIENT"); mysql_options(m_DB, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL); + mysql_options(m_DB, MYSQL_OPT_CONNECT_TIMEOUT, &cto); + mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt); +//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...); #if 0 if (pwd && !strcmp(pwd, "*")) { From fd3921df565b83c5f04e9d92795e52b3c7eeed1e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 9 Jun 2013 15:17:28 +0200 Subject: [PATCH 230/273] MDEV-4469 Fedora18 MariaDB-connect-engine packages are incorrectly asserting ownership of /usr/lib and /usr/lib64 connect/cassandra rpm settins were completely ignored --- storage/cassandra/CMakeLists.txt | 8 ++++---- storage/connect/CMakeLists.txt | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/cassandra/CMakeLists.txt b/storage/cassandra/CMakeLists.txt index 63e413ccb7b..78cb1f8b7e8 100644 --- a/storage/cassandra/CMakeLists.txt +++ b/storage/cassandra/CMakeLists.txt @@ -60,12 +60,12 @@ IF(CASSANDRASE_OK) IF(RPM) SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} cassandra-engine PARENT_SCOPE) - SET(CPACK_RPM_cassandra_engine_PACKAGE_REQUIRES "MariaDB-server" PARENT_SCOPE) + SET(CPACK_RPM_cassandra-engine_PACKAGE_REQUIRES "MariaDB-server" PARENT_SCOPE) # workarounds for cmake issues #13248 and #12864: - SET(CPACK_RPM_cassandra_engine_USER_FILELIST ${ignored} "%config(noreplace) /etc/my.cnf.d/*" PARENT_SCOPE) - SET(CPACK_RPM_cassandra_engine_PACKAGE_PROVIDES "cmake_bug_13248" PARENT_SCOPE) - SET(CPACK_RPM_cassandra_engine_PACKAGE_OBSOLETES "cmake_bug_13248" PARENT_SCOPE) + SET(CPACK_RPM_cassandra-engine_USER_FILELIST ${ignored} "%config(noreplace) /etc/my.cnf.d/*" PARENT_SCOPE) + SET(CPACK_RPM_cassandra-engine_PACKAGE_PROVIDES "cmake_bug_13248" PARENT_SCOPE) + SET(CPACK_RPM_cassandra-engine_PACKAGE_OBSOLETES "cmake_bug_13248" PARENT_SCOPE) ENDIF(RPM) ENDIF(CASSANDRASE_OK) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 34bf7fc2491..f25b33c7ccf 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -288,10 +288,10 @@ ENDIF(INSTALL_SYSCONFDIR) IF(RPM) SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} connect-engine PARENT_SCOPE) - SET(CPACK_RPM_connect_engine_PACKAGE_REQUIRES "MariaDB-server" PARENT_SCOPE) + SET(CPACK_RPM_connect-engine_PACKAGE_REQUIRES "MariaDB-server" PARENT_SCOPE) # workarounds for cmake issues #13248 and #12864: - SET(CPACK_RPM_connect_engine_USER_FILELIST ${ignored} "%config(noreplace) /etc/my.cnf.d/*" PARENT_SCOPE) - SET(CPACK_RPM_connect_engine_PACKAGE_PROVIDES "cmake_bug_13248" PARENT_SCOPE) - SET(CPACK_RPM_connect_engine_PACKAGE_OBSOLETES "cmake_bug_13248" PARENT_SCOPE) + SET(CPACK_RPM_connect-engine_USER_FILELIST ${ignored} "%config(noreplace) /etc/my.cnf.d/*" PARENT_SCOPE) + SET(CPACK_RPM_connect-engine_PACKAGE_PROVIDES "cmake_bug_13248" PARENT_SCOPE) + SET(CPACK_RPM_connect-engine_PACKAGE_OBSOLETES "cmake_bug_13248" PARENT_SCOPE) ENDIF(RPM) From 107acbb9e45a468b485311466b72a90330388fea Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 10 Jun 2013 08:40:25 +0200 Subject: [PATCH 231/273] remove .THIS file --- storage/perfschema/gen_pfs_lex_token.THIS | Bin 38168 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 storage/perfschema/gen_pfs_lex_token.THIS diff --git a/storage/perfschema/gen_pfs_lex_token.THIS b/storage/perfschema/gen_pfs_lex_token.THIS deleted file mode 100644 index b5165266759ab29a73f696a4d6de06f51d5a7014..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 38168 zcmeI5d3;pW{rAsI5}2@t)vzeTDj;NmD65c3GRX`~X2MJc2wE>8nJk*k%!I|dU{Py~ z3s$YRR-tOus#Sh2KeaC4O10J6*4?U9#YWK*RO--HEizlE2B|_dLrql!Kr-+t)IMa} zE@S68Z4YC+ST7BBIzDae-{vfYL~-VW z^|@MvymK81Y4)cbTpS>By@UXylPt z6@a;q!bkMOPX|9*Jh6UwS3i7XKm3AzICbw4YMk14#(KDV+eM*W+7b=zvFciCj67wn z*l2}g^^NgFti8CYIv$V3NhhADtvTTYQaMRkR(*48ixp2)whJu+X}-?)eA_-aSW)TUyJzRHLgm~0M3%Pp#)cNE?%SaF zkL}wj&%UmVEwkLpcj2Cdv*#t9OB zy1KfY;gc>v5h&cr>Ug9>=_W=#q!IGw+I>oCqHBpX17}8J$!Cvm-ldI#so-R z8Dn6c{8!ZSxfD@7M?}5Zj>tz5ZBItDnj-QZ_FdOfv^Oc^?&z3N;fC+OZn7xn*b-ouXb z&pAw49e(4U3-)w8X`)$a2gulY2lCSCJqWS$Ny^Q|S-ny9$!agw=^_QHB~GCSPCJF$ z_GWzkb2KBs;};`iyVs(3c5g!Y9>0XdQOHYo1Bo|~cp8aSB;H1%MdAt)?<4Vh6m|)T z50DrqaSn+Ol6WqO$CCIkiEoiOjKoJtJdvX6`4*xY4)JHmZTCSE_mb~a68}Qt3nZRR z;vY$Tjl_pYe2T<(Nqm{a`$^nS;y_C17bG4e@fZ?+OyXB0){^)`62B#J0%c<}iRsfJ zR+4Wci9<-7N51Pw%qH>Al+a2Nk0tRP5|@%Vi^MDnJD0?K65k;4I1&p<%%`Y^L)_~< zgvwV33cI3*e4Q`(9D96@m(cand>K12ANjgmNB8I|bon}8?A+V^{NbLSZQeuZIfvFD zjp0A0o^$Vih<0B?Khcs$GTJytyX~Aqlk7Mj=*oD0hg)IrcV;{RM_0xpFgr6|*-7r- z!_*CpEGcm57NqQM!8-qS8L^MTKODOj@Zg?e?u`B z8|B4Xxj-wg)5?{kyvA1ErIp7T<)K=6pjOV;$|sO=y{)`WD}Qt&7jPdOT^Vn}?96a! zWhW^&+sdo8@}oxiKCS#Kt^BS|dPZHde=*OkS_?78}n@;tMpcvvFk-Hv{+9J1;1^TjAfm0baW| zlWQ%x9wJweT-vvUTziNuCRaDP@{)Qp$Tbm1gYJps(v3KhTm{5j+B!o zY9RJ8T-~pu;<`V@(AUjMiymLT&ZcRv2Rdt~?ekqW_r6JP6}W8rU1WiG2Rake4hA~U zo`zZC)M;4FKUo-;GWd*uwr)3A=atFE+(`E*`&YqTsWqaXM!zXQ}Iq8eu ztmzyk_X}7?vym^~wnIIMagWe3j`sxzT-axHVZU&wr{go;0oZ$y?kgy7v}>aMBIYT& zB5l=)#_A?_Y;z*kl4xvgi7TIHwbzPNcq;v#fC^W($71d?Vq2JpE5lx|wbEM^Q8Q+! zrE2NPYUwgH`DAr6PR`39ELF>vfi6>?;$m+k;x7t#;jHwBg341;qCBOQ-mvnNdHlgh zCG4`Wx6D%sl|TTWvQXGx=_`jzYX#PLkd7zl2~@3vN)W+=RmuYtDW;F#57Qfr_$&RZ z;g9&DmA+6I{?W>imw zP=)dpdy0KzqL{_Vxu=8#ZI_UPq)HFswSt~<2tL#gnZYtGz=E336V?W*6Lm;p#9Im5 zi}bZw5u$u*XCzv#iv1NnQVe(^5eqd-WhxH%sYYzeid3SNBbEN*2uO%>5%L7Qkz#UC z4nu(eHI8jl6T%fOHx}nrBSfHWiyE1osD2KOFjk2-;I-o-$-5TmCIgjGIqdKOaJb8L z!;y`8wyjF4gHU+|imz=%XJ@IrB8;AGG+L^UVbTzS1>8B2mBA}7VE0QD{p(c%nBOzniSwtKjMMe?zCgX@`SE(O^ zP$xo$PN2k71yW`CLea2xl>3X3F)uP)!g4T*<{}+Kz39CmR1v7Rm_Gh;%n+~x9*mh1 zZ>c95s3hATL>|%Jo+>nowrR$&)?jdxp6&-F=w@(7icwbtBU;7IDf&sc+#l3EQ@?wB0Zvb^ihQCyKgE}#9P>+lf$odn30|N{UQP zTL`q8I-EA)hwf0NylatW5S8Oy>n)~g=HUPfnrkaO=%?tqa0O^0u;(tVPMz1D#7aGs z*-{UNi>~;HD)m;P45fZ=pacT7d8t24-u|@+TN(&qhSX+(Z7qZqjUWWFjt@pXO@98e zAnYhgTN)0PtI{Z@EHWyomzPFS)s(d|FWMM2YTGn4%eiEtPtj2%yuOKbR5iUB`}aNtVI4`neur9@b#DZtctLoR){L)3!z+O zL|~!^lVPQHVFtPnYd3dde+eqkk2)$*Xk(O>rhD5$KM$jIEI(?`UtSTyutnYbgC*Xz zw&?{YDRtWP2X#fGv(j>Dw~QYXP8h18D8pi9{&~LeP-)2Umwy zLSBJ2LSZ!0Cqjm$7ce{LEB(kx0IN>agM|m{Mx_cMa%u$FSYx#rfmKRAn8yO>& zx?iw6*ObLJv>@TG$TX*H+ zlmzs`!J0laQDqTUXR8AG=!F=Wm^#WmYfXKj2Sv!!ULeS06?&5&({vw*$(CvgLxT2I z5v;vfS!|0djDG~Hf%l1iG zx61t`m_c+>YZND zyG8|R&ZWR1YmEnkD~O!glVvc3B`6poWUs3hcD%eb4bqg2RSE4?tb(gOVI5znw3N1s zp+Je1?9<38#el?y7&T?v6a-d7F%@*b@=!NmW1lgwP4jg`SA1Hxc9KtAvU4j;mmX=~@>Cs0(rw#{}Z(3i&Uie}MgN);x zg_?zhU72lS;%b`-LJ#mP`Jz!q>e%r>8IRP zV0zIzC^!QiY%a*AJr^xbwl^$P1L~4$opKw&O00_-!G=#`EFRd~!3W(L7RCz&CX4b% zOPa#L#s?L>28FTbprf232lf=$SYUSu9c&8q_=aJ2BKjz+B3Rb!u0cEdk|=gfyv4UI zdv|TSBZ{XB+v+o)07doIB!Y@UmV1}|2z4zF3IrCWGqr8`*Xi1cpbt@v=x#?U2#OsL za^XXsBfe;535Jp4njs5Ymk9PJl+ggK$q}r6DiZWm=ph`zo*aW1v0w?M$U<1EBiNe3 z&}|i=y&Xz|9TOVGobw|U7z(ABFEC@#$Gf)JtA{)ZbWDWmDxAl|K^lK>VzR*j8tsBD zzZUJDm_qC$FZp4;FGj5+U3-!xhIy-3L1#KOHtuw!SQ+t~6NnLcRyU&F0UCi0HpY$9 z`^uzXPvFMO3`QeY(WZr#ZWMUCYk`7?#LQ6BuqaRWDHw-2x-&qiQ35=jfW<*Jt>ED z0>V+=2FWS5(o36Jn#ahcJ>jAQ7Fx9gPOLGN*nGpljIXz3y}Plbi_Y~)0ZU^kq+pd^ zvB^O_j%+)&kfO6Sx?vePf)Ty}l;XxPz|bzEO)cBVcNiN27(sn7tE|Eqij0T?(KiAp zyXZvvfT>-5CqQ`F6CgRD=+`$fU}Jc}#Jme@Wsrtb6!&m2OMvqBJBkyR9$HZx4+6^G z#lXTg0-J#-?KfcRPnaBG>aBVRA$ugI)IVgaG+Yi&6%ef~wh#E^(6wtE2!eyXy${l6 z1VWf^Gnr+ZZTp@N1V7ChS`l?#rdIns_+YEB+8?f@Bd*>j@HmYqJp$HHyTZVvvc^Zp zLUb;l!lrhmS`+qEQ17!>o3$tAEmCVSQLXi;wdDb&2L&0HJ$Tl6_4*c2XP-?s^Yk4B z+y}Gh&K%hYNfyO`ds=i)1hq*wE3_tTU3?PsZ6fW!SfKN5nC|N6tqtuH(E(_Sh~-JKA)Z`^^9pzwPO%s$W)e;V70a_t3nS^B36Xz7YXR(VPlMvm>jC*DpD1( zJ*%+uDz~FVe=Mhl@O!Xul0!#HwvMl;y4Ia&JtNlQu50aRsU4(mqk3vHtDZhfOjyLd^Ptj<=;)#8)YOsl4$x;-9C%u+KqG$N9jwXvGU=ISQ6>Y7@si8sVH zli3^qpX1KS$x$I=v!yE)-+RD! zBkJ9~pt`-iddn%_J6U}ndWe)}PIvxdH)XoI24ByxTO*!B3BiAQ-uzlP-R|$Zr<}TZ zdfvRvQ|7qy&zUnQ8F=1eH`N9=<52@nk0a3ZS`LNVM&(r$C!z$;J4c2-}Ysku;UYHh5pu_fk4Lt7Q45li1D@fTZqm?L7l*L;VbMSDtHS;j}(7@A!I*fi5Q z%0&5HdMQ!retR^1`ykUd=I_?)jalm2jjVH+J6or!RB>zDmiET_hJ<@&%`Er4y!`w* zWX_x84xv$-VsqT(tu2Wy?uz!-`u6H(w`YU9x~10LnrMi%$8!cLG_}6m?#hP7xVx^g zDdvV2j5L{NAMU!tHl$o?bY?M+_qSIUA(3t)?A&7 zU{+gQ+)8%3oSK>(g`U_^lSt`_cGpB)HF!*t&>he{ySY!lT>@Wxwa0BJzTQ)xXjq~W zTiRmi67GKDJR*@LD4k`iDI|b6}4KqswttSUEOlIVKDl=-LiG4UE3%wdc=0J#C~gEUR=_ z_KM+yH@UW|<>QykoT-`PV!%MX~snZtYL+v z+Xi0Yygco)bZ2-N@J zRI9H%w&^=_bYR7gCur0%Xr;KmX>5FX#+oRc@%=R3%WqeDS59bP8&)<(-&U^wlsNo(HkKiTD>Fa59 z8U3<;_zLDbMY;jzFA5%H{*>UWn7=L3tz`a=;A@!wT*Pw<^EAQhnA4sowOq~2GXy`A z`9Q%pG1p(wOsSvqm}d(8PUeFJzl`}H!LMaLMDQD!4;B0t=EDTPi+PsdyO@s<{C?&m z1%HtFD8V0LK3ec6n2!u%Lae{xyJX`QDnNJY>Yv$tx&&(>+{a~Wt zShTILG` zzk&He!Ea%{NbtLuFA@B|`r(f-r@vN6t>>qhFBAMZ=1T>Cnfb|rzs-EP;2$tA6#O&h z9>EVWFA{vvh(ew3V!^YRmk2(NxmWPxn3oDZgL#?YdCWtCFJN9FcrkOI;47K?1z*j4 zh2XW!R|?+FJRta1=H-HSF%JrUE%Q}^?_eGg{8r{+!FMsQ6#OCPQNf>LzFP1XnXeK2 z4d!bFf1i1k;D2MjPVj#*KSl8Lk#@g2Rq$h&e^2n^nV%;3BIcIhMaWqm*7t_zf|zw_QPLeewomJi}@9Tzr*}; z!S^%YF8IgHuN3_6%zq^KA?8;J?i_9R+p7g1#QYk;hco}N;G>yeEBFNF*9ks_`A-Bt zf%#7b&t-nS;04TY6nqKu8w4+AzC&;y^P2<@GQU~yDDz(kek$`@1g~X&o8YH2zg6%v zncpt>Cg#5sd@J)i1izU1oq}J%{4T+-X8tR|Z)7gV>8;G~7W(%vzen&#nE#jHPcXk% z@MoFdC-@7@?-%?}%;i4qP38{>{dbxFx8VDkKPdPC<_`=0SwH*`b2+YinEzVDlQG5~ zkB_d=c}f1@|z2M(~x)_X=Lg z{8_>4ng2%ccIM9szJ>Yof}h9yw}M~9{C9$1%KZ0&U(Ng_!GFU14}#yw{EveFg882W zzk~TJf*%=}%!dzkMNe85<{ z|NlksZ07F?K8g9~f=^-of#5Tlzb|+m^ZkN*n13j^kNIB(k23ET{1oON30}?oW5Ju5 z9}qmj{1d@{!2DCeFJXRA@XMJ`;~V$p{>)X(KNS1?>zFSR{Dywwzlph9qVeSz1Ih%Q!;CalQf-hj6F8EUB z8G?J54-mYJxl8Z>^Gw0R%m)cx#eA^f7V{y3pU!-!;H}Ju37%j+T=27)%X9Pv{qU=p zj}-A-$9#m~H!>e3_^r%G3w|f_Y{7RiA0zm~%*P7;B=d2C?`1w-@Rym-5&SLY69qrW z{8+&cGe1u7A=&o0m?ZcF=5E1HU_M#!1$%2DtMgvbiubVpCR}) z%#RoR7Ut&tQD#1Wkohd3|19$p1pk2fT)_`A&k@`;&aUTN!G|$7?;|t$Ii7jG&|k`Y zp5R{Q^92twKT+@+<|hfhnfU_2&u6|w@Qax*6#OdYN34U)7YqH{nJ*Rm9_A+t{s8l3 zfrx zOz`)Z*9m@rdA;DDGuLnIQoYYBdzd#0edh$b|DPfF0OqF)KAd^8;A5FL2|j^&i{NhN zt%A>D-X?fH^D_ls$h=+fV&)qKFJ+z(JivU5;1$d_3BH>7X2DNmewN_1%)c*q3-hxD zk260<@bj6UC-}w8w+en8^YaDY$@~Jr?_mA|!5?J4P4Fj~Unux*nO`LMtIU5W_@9|~ z3jRLxiv>Tx{1U-GW8NkBznEVt_`jK7F1Tx=Jua>gJd62u!N)PbQt;!L|48r|%&!tW zpZV2-FJXR-;Kj^;EO?0dwSuoU;MXv}N${P_cL;tf^P2^~lld)z-^ctHfbGT$xu zZOr!wemCmyhKP&h?=6eP2X8ye3pD_Q8 z;GZ#nPVmFbe=E52IJ=+!PVgbjUl4o@^A>TxXd?3$h5k(DtwKMK`Ab570rTGrzJmE5 z1dlNPqu}e9|4Hy#<}VB0!u(aiJD9&B_z#%BCio@HUl;sJ=5Gpq4f8(>em(Pd1>ebh zpWwe_{ujY_F@I0+2bsSw_~Xn!5d3N8`vrfF`CkS9Bl8ahe~Wpy;O{a2NbtWhA0hhB zC(J(<`d=_VAo$nJKM~x4cj(desoyr{IK9Nng3hxT;>i@ zt^(#x!Iv^m6MO~pbir3K&k($t`9Q%NnP&>Vk-1Co3z!cP{1WCv1^*HAVS-=Be7N90 zXFf*o+n66C_`S?W2>vkhk%B+Xe6--NFdr-U2h6ht{~Pmhf*)c&UhuTZc0ZgbxQqF* zf)8bWoZuswPZ9hW=92`U%-k(_4)e)^FJ(Sea4&QD+_0SabfLeR`3%9Um>)0r2Ieyb zZ(%-5@UxkpAovB$XA6EA^SOfmh6-ot#c;F(kGe!g7rk<1GP&t~osd=m2_ z!H;KNEcjgJWrF83FA@AC=8rj*zRbGdW$qRFQRbzBe~-CO@EYcR!JC+`6ug7^3c(%!7jelzB+-oBHARFs~5$4>J!7{si+%!JlCs75sVTs|Eif^EHCM#(b^d z`ELC#{@r)d4u3nnb!-R!@N=O10A7C!a`*}b7F!RA89yP5{ceE_Q zUCd>9M>C%z^v5w@CHRzn_-y78plUTYe7SG}6`> zo12$Ykh5Tx?W2xRE+EakBQy)t92C;7S^E#7M-Q}%{lx%X`Xh`h97g|1Xnc!I;MK>rlbNf`*brP-=)Z|!Ka5DdRSqyl|leXO-v zZRmsA6L^WcdIgLU!n;yx`K2ZL-8$+3JesSMFW`ycCy7QNoAiPmlY!$Q=S&~?GlH&x z*J{535$%`p4WzX647~pZei^q?qz{t%Wv9U-{TJlCoSYf10j_O!$aM&relCUkQxVJo zuIphA)Sj+^KO!Ah#?KLvYY`M*PaomQPN8hL zS@dPTNMR?lSdn=qg`L9U+RWjU?li|U$iH*y`b?T=(q}m6ey4M4L*_js&g2rcWqwTJ z92OIqLnx{oM+}y8>gG)PvS#``M*+mNsaqYHqbMKq9eyqUz>!IlXL^By?nS0e-R8)A zne-Pr=-yk})QcUNSrnbe(WdpcJ2E>+e}&`wTE5Pac{a%_S>EZ$q)9zJ!1C>m%uezz zXL*++b34gF$0a)aLypYPNv_bjPn){Okx7T&^ss~O!KF=o+MxzjP=^0|Fx~vgPJi@a zSVOjv&ST_6iw>C&JN@z9T5=7cFF~e1X}5M3`UpMD9N?msOLY(320&#TRs;w6QD4!N z?iy)2N~OO6uZ*88ftkJ>*+{#FdZaTw{c0rQbfv$Kd<@4AlHph8==XrK2F!PAtAI*} zap2TbS$YOdT36hTP%Jqn#2uV3sodQJ@@YBJCI`n#&G=q%9%FQj5sq<8qjFSIJ2Jg0C5&ebmaQvQb|C(s&r^V>ngAc6-qyNd#*06^i{U11brN%mb3021z1WaHv zsnPd;r)J=NAJj)|73Y;r$7E`WJe25no zO{9ZMW|#9utwq0*MAy)lL1|gjas4$-jk}(5IrnKGWRHIBi>`5}BYTb9_ zY<9XZLdL4JVT%VZ8SEd0u|FItm>tL>dEg91mTQzFZP?(!(8_Q?%p7V5$?%U_hVrh}6SR|4olkA(_-5Epm=3rV$+-=!&9U5gti3+hv*C=~ z<}L9vn{xB>a`NV4ua?-7d*u7)RBlJSJ-4x?rm3Sgmb;-5KM<)2eg`raKO~up9|^Ti zDwx|=!#^5Y-_nswd)WdLrcVTYgxolOxaa>YvfTO;PMEu~Kz(O9&TLZZXm8G=TA=sc z#d8{HhlRxiZ@z;Y!wV&9Y=sk(h|xe@*VrobgQWBZKJ0Hdv^GHtFCT)B2>>sfE#1)3 z*p!&t*s=^Yjw{n?rtq}Ij{Oa;=YD?oRnNn8)w}lRUxKyG`6Du1RoaZgbPQNAAT9IN zq}P6O{Yrb+Ycm3ql-{{{|Hu37>j2yP_kV6OB;08{zqI>`uR-G zzi`KnoylOXT8`;0&8{I2=fa^3zuvKP2g;Q4FMmHm?=aWSs&!RPC%U4AUxnDvQD?>tWlI;yn16yrxQi`ijc~(tFI}U+O9nCGu zYHPJiXxF8#o$B`bjf!4%+NXSdW3~%o#nEAO1?e})i}Pr*(dbBsAE<4suAQ%ke)5Hx z{MuH96l;=+^{ECsoui&VzjLNJqFB$6ew$Bq8b6rOhB4?z-mpCp#8E^g}SM2)H$)E*YQ&K zqr9%mFX-DjHl}n+_|W|bbJ2=Oms4$W88>EreSu{e_v1;nG0V7jC)po32GiUhUQ$?-EEnThlRsIt4c~oiIt{ z0Yyhm67}3b=QlkO)4{N}uh3Dfch03vJ`W5!nAslO7wJIIJLl0Bo^}yOOeIJYKRb`{ zhn@>N(Qexf#)VNDYj0CIc*}1r$5Z5=o2af=IoKQJG*rhMR8H-d76i6!jCSp_5z7F6 z>GGwFC_yP z>Ck1yh>0g3>`T0h(&Yc3vk-*d!>KL(eq?gV@V2i~bZ*DtCYgSATA}vJMsKF;pl#8X zR@akBpKdbJRg4d*n)J>4K3$waI=QD_vi?@Wlisaq!rz--sMYV~@S{1f$-mJv_FDMU zyE=_*-q-mX4)5mhGXIQKJshNJ!khPlc60bVRy66$^6Q&}DdElgMzcA<_LT5+_fLlZ zJ{Z*r<&Q4&zSY|~ys2l~*UqbPlf4n2)bM-wy`OtHd|RqA+*vFe`+N~TZ$P2e$m0w> zWHKzmv8a9sM{4@!{jl9Qxzoj#Ex_bzP0E+SMd3~T9~xGu{SI-!o5pD|X^8A7x{s9_ z{%11_weHVm+CfTeD{0E~Z-!55_B3J(`WKVVDO>vOf0tZ!TD zZGR)*4@YYFZVuo5zZw1!5&jT|Kg8i>ex!?ov|L0Qv1%(mfE-6wvFjF4z}NeP5I~KlD;N9-RnxdxH@$h;s@|C zELCqolP$@3rS8}Lgs6OiPh^=D4oAiynq@VQlEo?-w)hKcXgs4jU3IEEuc7W$O zoUvs15%4g5&*+f7<2+khEdmHpx1E_gQ^RkjJu$B9Xmf&VIzF@UG2_OpE16(NOFxUA z+2L{tPno{0b#yZgxodM49^sjW+5Xa_^0egp#8U&MVbwTzRQ-(P`^5X|4^U<9YtLCN=u_vM3=>vvy1M45HDFCVJRdfS%|Q)V6Q%ZDqoKKA8V z%B*{R`3Pm!v%Y*}a-HhSM=7)Z^yQr;_-r>XHrFal|6LO*JuENM;bzdBSm&dZv9g9>=Mdd4Hfq7^iB-k-Qb$p^j`{npWLN zSGLzS@R2&MzQ(nh4^=yd6>1MNSKY>3_W!%VM;Tc_*M_P`j@e?LG&b;@NZO zdXp7x=WG4m`N6Df^nEsp-#jwiy37tn-%lZaJI7;TQO1%O+M$oiA(*7=0~nC^!Gayk9nYL;yL;Q zEo)t1fw>V3cmDjocY`haH_a{k7j`ZC=NECGjqV`fh7Nwd%zhM;3gU_CcHB-a;a{Jp z8$!5;PE6m{t}84o3;2tQt$8`~a&YSych5J}ST*qu+$_eeC{{(D_?uw%(+|t4$Ng8^ z)3TJcVxtv~)#GbevG(Go>UbRYk?=LMc;C4H!$XJI=Eg){Wlml`020qZIJ>$$xQE!- zA|j!?&v>xcV(D*V;cgY~JPQ>orACgt*`Ip<{b;wOEvq)(YBk^|!{{ctRf1oxv+(1Z zR42VPsc-OE7Vg4vb*9!t>i5*_M;E=7&9}Mjr(ODqPT$Pa4e}$tWY=Hh|LJK-oqk-< nH*zbcZyuWH_&Hf`=JbOh<9p Date: Wed, 12 Jun 2013 01:02:04 +0200 Subject: [PATCH 232/273] - Fix MDEV-4638 modified: storage/connect/ha_connect.cc storage/connect/valblk.cpp - Add trace in tabmul modified: storage/connect/tabmul.cpp --- storage/connect/ha_connect.cc | 8 +++++ storage/connect/tabmul.cpp | 65 ++++++++++++++++++++++------------- storage/connect/valblk.cpp | 2 +- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 7d37b79bae8..672bad023a5 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -4027,6 +4027,14 @@ int ha_connect::create(const char *name, TABLE *table_arg, DBUG_RETURN(rc); } // endif flags + if (fp->flags & (BLOB_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG)) { + sprintf(g->Message, "Unsupported type for column %s", + fp->field_name); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + rc= HA_ERR_INTERNAL_ERROR; + DBUG_RETURN(rc); + } // endif flags + switch (fp->type()) { case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 5fe18ef5b1d..f339fcc9a39 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -68,6 +68,8 @@ #include "tabdos.h" // TDBDOS and DOSCOL class dcls #include "tabmul.h" // TDBMUL and MULCOL classes dcls +extern "C" int trace; + /* ------------------------- Class TDBMUL ---------------------------- */ /***********************************************************************/ @@ -123,14 +125,19 @@ PTDB TDBMUL::Duplicate(PGLOBAL g) bool TDBMUL::InitFileNames(PGLOBAL g) { #define PFNZ 8192 - char *pfn[PFNZ], filename[_MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT]; - int rc, n = 0; + char* *pfn, filename[_MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT]; + int rc, n = 0; + + pfn = (char**)PlugSubAlloc(g, NULL, PFNZ * sizeof(char*)); // The sub table may need to refer to the Table original block Tdbp->SetTable(To_Table); // Was not set at construction PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath()); + if (trace) + htrc("InitFileName: fn='%s'\n", filename); + if (Mul == 1) { /*******************************************************************/ /* To_File is a multiple name with special characters */ @@ -194,15 +201,28 @@ bool TDBMUL::InitFileNames(PGLOBAL g) _splitpath(filename, NULL, direc, pattern, ftype); strcat(pattern, ftype); + if (trace) + htrc("direc=%s pattern=%s ftype=%s\n", direc, pattern, ftype); + // Start searching files in the target directory. if (!(dir = opendir(direc))) { sprintf(g->Message, MSG(BAD_DIRECTORY), direc, strerror(errno)); + + if (trace) + htrc("%s\n", g->Message); + return true; } // endif dir + if (trace) + htrc("dir opened: reading files\n"); + while ((entry = readdir(dir)) && n < PFNZ) { strcat(strcpy(fn, direc), entry->d_name); + if (trace) + htrc("%s read\n", fn); + if (lstat(fn, &fileinfo) < 0) { sprintf(g->Message, "%s: %s", fn, strerror(errno)); return true; @@ -218,6 +238,10 @@ bool TDBMUL::InitFileNames(PGLOBAL g) strcat(strcpy(filename, direc), entry->d_name); pfn[n] = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); strcpy(pfn[n++], filename); + + if (trace) + htrc("Adding pfn[%d] %s\n", n, filename); + } // endwhile readdir // Close the dir handle. @@ -420,10 +444,9 @@ int TDBMUL::RowNumber(PGLOBAL g, bool b) /***********************************************************************/ bool TDBMUL::OpenDB(PGLOBAL g) { -#ifdef DEBTRACE - htrc("MUL OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", - this, Tdb_No, Use, To_Key_Col, Mode); -#endif + if (trace) + htrc("MUL OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", + this, Tdb_No, Use, To_Key_Col, Mode); if (Use == USE_OPEN) { /*******************************************************************/ @@ -735,10 +758,9 @@ int TDBDIR::GetMaxSize(PGLOBAL g) /***********************************************************************/ bool TDBDIR::OpenDB(PGLOBAL g) { -#ifdef DEBTRACE - htrc("DIR OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", - this, Tdb_No, Use, Mode); -#endif + if (trace) + htrc("DIR OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", + this, Tdb_No, Use, Mode); if (Use == USE_OPEN) { /*******************************************************************/ @@ -898,11 +920,9 @@ void DIRCOL::ReadColumn(PGLOBAL g) { PTDBDIR tdbp = (PTDBDIR)To_Tdb; -#ifdef DEBTRACE - fprintf(debug, - "DIR ReadColumn: col %s R%d use=%.4X status=%.4X type=%d N=%d\n", - Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type, N); -#endif + if (trace) + htrc("DIR ReadColumn: col %s R%d use=%.4X status=%.4X type=%d N=%d\n", + Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type, N); /*********************************************************************/ /* Retrieve the information corresponding to the column number. */ @@ -1304,10 +1324,9 @@ int TDBDHR::GetMaxSize(PGLOBAL g) /***********************************************************************/ bool TDBDHR::OpenDB(PGLOBAL g) { -#ifdef DEBTRACE - htrc("DHR OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", - this, Tdb_No, Use, Mode); -#endif + if (trace) + htrc("DHR OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", + this, Tdb_No, Use, Mode); if (Use == USE_OPEN) { /*******************************************************************/ @@ -1442,11 +1461,9 @@ void DHRCOL::ReadColumn(PGLOBAL g) int rc; PTDBDHR tdbp = (PTDBDHR)To_Tdb; -#ifdef DEBTRACE - fprintf(debug, - "DHR ReadColumn: col %s R%d use=%.4X status=%.4X type=%d N=%d\n", - Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type, N); -#endif + if (trace) + htrc("DHR ReadColumn: col %s R%d use=%.4X status=%.4X type=%d N=%d\n", + Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type, N); /*********************************************************************/ /* Retrieve the information corresponding to the column number. */ diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index a96dec2565c..575d88a56fc 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -592,7 +592,7 @@ void CHRBLK::SetValue(char *sp, uint len, int n) #endif if (sp) - memcpy(p, sp, len); + memcpy(p, sp, Long); if (Blanks) { // Suppress eventual ending zero and right fill with blanks From 1784618e7030bd83d33d0f857c6fed0860fe4487 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 12 Jun 2013 11:39:57 +0200 Subject: [PATCH 233/273] - Add trace in TDBMUL::GetMaxSize. modified: storage/connect/tabmul.cpp --- storage/connect/tabmul.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index f339fcc9a39..50e48dc2e93 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -391,6 +391,9 @@ int TDBMUL::GetMaxSize(PGLOBAL g) int i; int mxsz; + if (trace) + htrc("TDBMUL::GetMaxSize: Filenames=%p\n", Filenames); + if (!Filenames && InitFileNames(g)) return -1; From 36b718766317f410df045788eef423967332d880 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 12 Jun 2013 16:51:12 +0200 Subject: [PATCH 234/273] - Suballocate filename in TDBMUL::InitFileNames. This fix the bug MDEV-4524 but I still don't know why it happened with a stack variable. (and only on Linux) modified: storage/connect/tabmul.cpp --- storage/connect/tabmul.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 50e48dc2e93..42cae1d6748 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -124,11 +124,17 @@ PTDB TDBMUL::Duplicate(PGLOBAL g) /***********************************************************************/ bool TDBMUL::InitFileNames(PGLOBAL g) { -#define PFNZ 8192 - char* *pfn, filename[_MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT]; +#define PFNZ 4096 + char *pfn[PFNZ]/*, filename[_MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT]*/; +// char* *pfn; + char *filename; int rc, n = 0; - pfn = (char**)PlugSubAlloc(g, NULL, PFNZ * sizeof(char*)); + if (trace) + htrc("in InitFileName: fn[]=%d\n", _MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT); + +// pfn = (char**)PlugSubAlloc(g, NULL, PFNZ * sizeof(char*)); + filename = (char*)PlugSubAlloc(g, NULL, _MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT); // The sub table may need to refer to the Table original block Tdbp->SetTable(To_Table); // Was not set at construction @@ -388,12 +394,12 @@ int TDBMUL::Cardinality(PGLOBAL g) int TDBMUL::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { - int i; + int i; int mxsz; if (trace) htrc("TDBMUL::GetMaxSize: Filenames=%p\n", Filenames); - + if (!Filenames && InitFileNames(g)) return -1; @@ -477,7 +483,7 @@ bool TDBMUL::OpenDB(PGLOBAL g) /*********************************************************************/ /* Open the first table file of the list. */ /*********************************************************************/ -//if (!Filenames && InitFileNames(g)) done in GetMaxSize +//if (!Filenames && InitFileNames(g)) // was done in GetMaxSize // return true; if (Filenames[iFile = 0]) { From a8428e3ac88a1d202f41d1b0cbbef247f7fd7c21 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 12 Jun 2013 20:48:55 +0200 Subject: [PATCH 235/273] - To avoid crashing in debug mode, the error message concerning the making of the index is changed to a warning. modified: storage/connect/ha_connect.cc storage/connect/tabmul.cpp* --- storage/connect/ha_connect.cc | 11 ++++++++++- storage/connect/tabmul.cpp | 8 +++----- 2 files changed, 13 insertions(+), 6 deletions(-) mode change 100644 => 100755 storage/connect/tabmul.cpp diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 672bad023a5..2e4e86ab6c9 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -2920,8 +2920,17 @@ int ha_connect::external_lock(THD *thd, int lock_type) } // endelse Xchk - if (CloseTable(g)) + if (CloseTable(g)) { + // This is an error while builing index +#if defined(_DEBUG) + // Make it a warning to avoid crash + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + rc= 0; +#else // !_DEBUG + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); rc= HA_ERR_INTERNAL_ERROR; +#endif // !DEBUG + } // endif Close DBUG_RETURN(rc); } // endif MODE_ANY diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp old mode 100644 new mode 100755 index 42cae1d6748..0561638daa8 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -125,15 +125,13 @@ PTDB TDBMUL::Duplicate(PGLOBAL g) bool TDBMUL::InitFileNames(PGLOBAL g) { #define PFNZ 4096 - char *pfn[PFNZ]/*, filename[_MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT]*/; -// char* *pfn; - char *filename; - int rc, n = 0; + char *pfn[PFNZ]; + char *filename; + int rc, n = 0; if (trace) htrc("in InitFileName: fn[]=%d\n", _MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT); -// pfn = (char**)PlugSubAlloc(g, NULL, PFNZ * sizeof(char*)); filename = (char*)PlugSubAlloc(g, NULL, _MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT); // The sub table may need to refer to the Table original block From d861b6170ad504de50d0c40e23e9eb46ee137137 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 14 Jun 2013 20:52:46 +0200 Subject: [PATCH 236/273] - Fix regression error for multiple 2 tables. modified: storage/connect/tabmul.cpp - Fix regression error on field types. Cannot eliminate BINARY_FLAG that is on for DATE columns. Update result from dbf.test case. modified: storage/connect/ha_connect.cc storage/connect/mysql-test/connect/r/dbf.result --- storage/connect/ha_connect.cc | 2 +- storage/connect/mysql-test/connect/r/dbf.result | 8 ++++---- storage/connect/tabmul.cpp | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 2e4e86ab6c9..e28ac90a9ce 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -4036,7 +4036,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, DBUG_RETURN(rc); } // endif flags - if (fp->flags & (BLOB_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG)) { + if (fp->flags & (BLOB_FLAG | ENUM_FLAG | SET_FLAG)) { sprintf(g->Message, "Unsupported type for column %s", fp->field_name); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); diff --git a/storage/connect/mysql-test/connect/r/dbf.result b/storage/connect/mysql-test/connect/r/dbf.result index 2e84c5b3090..cbe4f4db620 100644 --- a/storage/connect/mysql-test/connect/r/dbf.result +++ b/storage/connect/mysql-test/connect/r/dbf.result @@ -394,22 +394,22 @@ CREATE TABLE t1 ( a BLOB ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; -ERROR HY000: Unsupported type for column 'a' +ERROR HY000: Unsupported type for column a CREATE TABLE t1 ( a TINYBLOB ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; -ERROR HY000: Unsupported type for column 'a' +ERROR HY000: Unsupported type for column a CREATE TABLE t1 ( a MEDIUMBLOB ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; -ERROR HY000: Unsupported type for column 'a' +ERROR HY000: Unsupported type for column a CREATE TABLE t1 ( a LONGBLOB ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; -ERROR HY000: Unsupported type for column 'a' +ERROR HY000: Unsupported type for column a # # Testing DATE # diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 0561638daa8..146e2891ec7 100755 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -125,14 +125,15 @@ PTDB TDBMUL::Duplicate(PGLOBAL g) bool TDBMUL::InitFileNames(PGLOBAL g) { #define PFNZ 4096 +#define FNSZ _MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT char *pfn[PFNZ]; char *filename; int rc, n = 0; if (trace) - htrc("in InitFileName: fn[]=%d\n", _MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT); + htrc("in InitFileName: fn[]=%d\n", FNSZ); - filename = (char*)PlugSubAlloc(g, NULL, _MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT); + filename = (char*)PlugSubAlloc(g, NULL, FNSZ); // The sub table may need to refer to the Table original block Tdbp->SetTable(To_Table); // Was not set at construction @@ -263,7 +264,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) return true; while (n < PFNZ) { - if (!fgets(filename, sizeof(filename), stream)) { + if (!fgets(filename, FNSZ, stream)) { fclose(stream); break; } // endif fgets From b0c378b4502c893e55930d4258d9e4ffd8e32f98 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 14 Jun 2013 21:00:12 +0200 Subject: [PATCH 237/273] - Add a test case for multiple tables added: storage/connect/mysql-test/connect/r/mul.result storage/connect/mysql-test/connect/t/mul.test --- .../connect/mysql-test/connect/r/mul.result | 57 +++++++++++++++++++ storage/connect/mysql-test/connect/t/mul.test | 43 ++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 storage/connect/mysql-test/connect/r/mul.result create mode 100644 storage/connect/mysql-test/connect/t/mul.test diff --git a/storage/connect/mysql-test/connect/r/mul.result b/storage/connect/mysql-test/connect/r/mul.result new file mode 100644 index 00000000000..46500f6e3ca --- /dev/null +++ b/storage/connect/mysql-test/connect/r/mul.result @@ -0,0 +1,57 @@ +# +# Testing multiple 1 +# +CREATE TABLE `t1` ( +`a` char(10) DEFAULT NULL, +`b` char(10) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `sep_char`=';'; +Warnings: +Warning 1105 No file name. Table will use t1.csv +INSERT INTO t1 VALUES('test1','bla'); +SELECT * FROM t1; +a b +test1 bla +CREATE TABLE `t2` ( +`a` char(10) DEFAULT NULL, +`b` char(10) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `sep_char`=';'; +Warnings: +Warning 1105 No file name. Table will use t2.csv +INSERT INTO t2 VALUES('test2','blub'); +SELECT * FROM t2; +a b +test2 blub +CREATE TABLE `t_all` ( +`a` char(10) DEFAULT NULL, +`b` char(10) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `file_name`='t*.csv' `sep_char`=';' `multiple`=1; +SELECT * FROM t_all; +a b +test1 bla +test2 blub +# +# Testing multiple 2 +# +CREATE table fnlist ( +fn char(8) not null +) ENGINE=CONNECT DEFAULT CHARSET=latin1 table_type=DOS; +Warnings: +Warning 1105 No file name. Table will use fnlist.dos +INSERT INTO fnlist VALUES('t1.csv'),('t2.csv'); +SELECT fn FROM fnlist; +fn +t1.csv +t2.csv +CREATE TABLE `tblist` ( +`a` char(10) DEFAULT NULL, +`b` char(10) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `file_name`='fnlist.dos' `sep_char`=';' `multiple`=2; +SELECT * FROM tblist; +a b +test1 bla +test2 blub +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t_all; +DROP TABLE fnlist; +DROP TABLE tblist; diff --git a/storage/connect/mysql-test/connect/t/mul.test b/storage/connect/mysql-test/connect/t/mul.test new file mode 100644 index 00000000000..c28e2d140fc --- /dev/null +++ b/storage/connect/mysql-test/connect/t/mul.test @@ -0,0 +1,43 @@ +--echo # +--echo # Testing multiple 1 +--echo # +CREATE TABLE `t1` ( + `a` char(10) DEFAULT NULL, + `b` char(10) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `sep_char`=';'; +INSERT INTO t1 VALUES('test1','bla'); +SELECT * FROM t1; + +CREATE TABLE `t2` ( + `a` char(10) DEFAULT NULL, + `b` char(10) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `sep_char`=';'; +INSERT INTO t2 VALUES('test2','blub'); +SELECT * FROM t2; + +CREATE TABLE `t_all` ( + `a` char(10) DEFAULT NULL, + `b` char(10) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `file_name`='t*.csv' `sep_char`=';' `multiple`=1; +SELECT * FROM t_all; + +--echo # +--echo # Testing multiple 2 +--echo # +CREATE table fnlist ( +fn char(8) not null +) ENGINE=CONNECT DEFAULT CHARSET=latin1 table_type=DOS; +INSERT INTO fnlist VALUES('t1.csv'),('t2.csv'); +SELECT fn FROM fnlist; + +CREATE TABLE `tblist` ( + `a` char(10) DEFAULT NULL, + `b` char(10) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `file_name`='fnlist.dos' `sep_char`=';' `multiple`=2; +SELECT * FROM tblist; + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t_all; +DROP TABLE fnlist; +DROP TABLE tblist; From b5130b5bd26eeb8b2bcfe1b38b10fbbbd9b68743 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 16 Jun 2013 19:07:27 +0200 Subject: [PATCH 238/273] - Implemented: The use of Federated servers. modified: storage/connect/global.h storage/connect/ha_connect.cc storage/connect/plugutil.c storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabtbl.cpp --- storage/connect/global.h | 1 + storage/connect/ha_connect.cc | 3 +- storage/connect/plugutil.c | 17 +++++ storage/connect/tabmysql.cpp | 136 ++++++++++++++++++++-------------- storage/connect/tabmysql.h | 1 + storage/connect/tabtbl.cpp | 20 ++++- 6 files changed, 119 insertions(+), 59 deletions(-) diff --git a/storage/connect/global.h b/storage/connect/global.h index 303078f5a18..3702f050501 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -244,6 +244,7 @@ DllExport BOOL PlugIsAbsolutePath(LPCSTR path); DllExport void *PlugAllocMem(PGLOBAL, uint); DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); +DllExport char *PlugDup(PGLOBAL g, const char *str); DllExport void *MakePtr(void *, OFFSET); DllExport void htrc(char const *fmt, ...); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index e28ac90a9ce..ab002488620 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -666,8 +666,7 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) else if (!stricmp(opname, "Separator")) opval= (char*)options->separator; else if (!stricmp(opname, "Connect")) -// opval= (char*)options->connect; - opval= table->s->connect_string.str; + opval= (tshp) ? tshp->connect_string.str : table->s->connect_string.str; else if (!stricmp(opname, "Qchar")) opval= (char*)options->qchar; else if (!stricmp(opname, "Module")) diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index e8098bb2512..7910f1ea318 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -511,6 +511,23 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) return (memp); } /* end of PlugSubAlloc */ +/***********************************************************************/ +/* This routine suballocate a copy of the passed string. */ +/***********************************************************************/ +char *PlugDup(PGLOBAL g, const char *str) + { + char *buf; + size_t len; + + if (str && (len = strlen(str))) { + buf = (char*)PlugSubAlloc(g, NULL, len + 1); + strcpy(buf, str); + } else + buf = NULL; + + return(buf); + } /* end of PlugDup */ + /***********************************************************************/ /* This routine makes a pointer from an offset to a memory pointer. */ /***********************************************************************/ diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 1a19b4cbf33..3af5904eee4 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -31,7 +31,10 @@ /* IBM, Borland, GNU or Microsoft C++ Compiler and Linker */ /* */ /************************************************************************/ +#define MYSQL_SERVER 1 #include "my_global.h" +#include "sql_class.h" +#include "sql_servers.h" #if defined(WIN32) //#include #else // !WIN32 @@ -64,7 +67,6 @@ void PrintResult(PGLOBAL, PSEM, PQRYRES); #endif // _CONSOLE extern "C" int trace; -extern MYSQL_PLUGIN_IMPORT uint mysqld_port; /* -------------- Implementation of the MYSQLDEF class --------------- */ @@ -86,6 +88,45 @@ MYSQLDEF::MYSQLDEF(void) Delayed = FALSE; } // end of MYSQLDEF constructor +/***********************************************************************/ +/* Get connection info from the declared server. */ +/***********************************************************************/ +bool MYSQLDEF::GetServerInfo(PGLOBAL g, const char *server_name) +{ + THD *thd= current_thd; + MEM_ROOT *mem= thd->mem_root; + FOREIGN_SERVER *server, server_buffer; + DBUG_ENTER("GetServerInfo"); + DBUG_PRINT("info", ("server_name %s", server_name)); + + if (!server_name || !strlen(server_name)) { + DBUG_PRINT("info", ("server_name not defined!")); + strcpy(g->Message, "server_name not defined!"); + DBUG_RETURN(true); + } // endif server_name + + // get_server_by_name() clones the server if exists and allocates + // copies of strings in the supplied mem_root + if (!(server= get_server_by_name(mem, server_name, &server_buffer))) { + DBUG_PRINT("info", ("get_server_by_name returned > 0 error condition!")); + /* need to come up with error handling */ + strcpy(g->Message, "get_server_by_name returned > 0 error condition!"); + DBUG_RETURN(true); + } // endif server + + DBUG_PRINT("info", ("get_server_by_name returned server at %lx", + (long unsigned int) server)); + + // TODO: We need to examine which of these can really be NULL + Hostname = PlugDup(g, server->host); + Database = PlugDup(g, server->db); + Username = PlugDup(g, server->username); + Password = PlugDup(g, server->password); + Portnumber = (server->port) ? server->port : GetDefaultPort(); + + DBUG_RETURN(false); +} // end of GetServerInfo + /***********************************************************************/ /* Parse connection string */ /* */ @@ -135,54 +176,25 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url) if ((!strstr(url, "://") && (!strchr(url, '@')))) { // No :// or @ in connection string. Must be a straight // connection name of either "server" or "server/table" - strcpy(g->Message, "Using Federated server not implemented yet"); - return true; -#if 0 - /* ok, so we do a little parsing, but not completely! */ - share->parsed= FALSE; - /* - If there is a single '/' in the connection string, this means the user is - specifying a table name - */ + // ok, so we do a little parsing, but not completely! + if ((Tabname= strchr(url, '/'))) { + // If there is a single '/' in the connection string, + // this means the user is specifying a table name + *Tabname++= '\0'; - if ((share->table_name= strchr(share->connection_string, '/'))) - { - *share->table_name++= '\0'; - share->table_name_length= strlen(share->table_name); + // there better not be any more '/'s ! + if (strchr(Tabname, '/')) + return true; - DBUG_PRINT("info", - ("internal format, parsed table_name " - "share->connection_string: %s share->table_name: %s", - share->connection_string, share->table_name)); + } else + // Otherwise, straight server name, + // use tablename of federatedx table as remote table name + Tabname= Name; - /* - there better not be any more '/'s ! - */ - if (strchr(share->table_name, '/')) - goto error; - } - /* - Otherwise, straight server name, use tablename of federatedx table - as remote table name - */ - else - { - /* - Connection specifies everything but, resort to - expecting remote and foreign table names to match - */ - share->table_name= strmake_root(mem_root, table->s->table_name.str, - (share->table_name_length= - table->s->table_name.length)); - DBUG_PRINT("info", - ("internal format, default table_name " - "share->connection_string: %s share->table_name: %s", - share->connection_string, share->table_name)); - } + if (trace) + htrc("server: %s Tabname: %s", url, Tabname); - if ((error_num= get_connection(mem_root, share))) - goto error; -#endif // 0 + return GetServerInfo(g, url); } else { // URL, parse it char *sport, *scheme = url; @@ -247,7 +259,7 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url) if ((sport = strchr(Hostname, ':'))) *sport++ = 0; - Portnumber = (sport && sport[0]) ? atoi(sport) : mysqld_port; + Portnumber = (sport && sport[0]) ? atoi(sport) : GetDefaultPort(); if (Username[0] == 0) Username = Cat->GetStringCatInfo(g, "User", "*"); @@ -279,12 +291,14 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url) /***********************************************************************/ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - char *url = Cat->GetStringCatInfo(g, "Connect", NULL); + char *url; Desc = "MySQL Table"; if (stricmp(am, "MYPRX")) { // Normal case of specific MYSQL table + url = Cat->GetStringCatInfo(g, "Connect", NULL); + if (!url || !*url) { // Not using the connection URL Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); @@ -293,24 +307,36 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); Username = Cat->GetStringCatInfo(g, "User", "*"); Password = Cat->GetStringCatInfo(g, "Password", NULL); - Portnumber = Cat->GetIntCatInfo("Port", mysqld_port); + Portnumber = Cat->GetIntCatInfo("Port", GetDefaultPort()); } else if (ParseURL(g, url)) return TRUE; Bind = !!Cat->GetIntCatInfo("Bind", 0); Delayed = !!Cat->GetIntCatInfo("Delayed", 0); } else { - // MYSQL access from a PROXY table, not using URL + // MYSQL access from a PROXY table Database = Cat->GetStringCatInfo(g, "Database", "*"); - Tabname = Name; Isview = Cat->GetBoolCatInfo("View", FALSE); - // We must get connection parms from the calling table + // We must get other connection parms from the calling table Remove_tshp(Cat); - Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); - Username = Cat->GetStringCatInfo(g, "User", "*"); - Password = Cat->GetStringCatInfo(g, "Password", NULL); - Portnumber = Cat->GetIntCatInfo("Port", mysqld_port); + url = Cat->GetStringCatInfo(g, "Connect", NULL); + + if (!url || !*url) { + Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); + Username = Cat->GetStringCatInfo(g, "User", "*"); + Password = Cat->GetStringCatInfo(g, "Password", NULL); + Portnumber = Cat->GetIntCatInfo("Port", GetDefaultPort()); + } else { + char *locdb = Database; + + if (ParseURL(g, url)) + return TRUE; + + Database = locdb; + } // endif url + + Tabname = Name; } // endif am if ((Srcdef = Cat->GetStringCatInfo(g, "Srcdef", NULL))) diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h index 24f8c4cdef2..16e2d650229 100644 --- a/storage/connect/tabmysql.h +++ b/storage/connect/tabmysql.h @@ -39,6 +39,7 @@ class MYSQLDEF : public TABDEF {/* Logical table description */ virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual PTDB GetTable(PGLOBAL g, MODE m); bool ParseURL(PGLOBAL g, char *url); + bool GetServerInfo(PGLOBAL g, const char *server_name); protected: // Members diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 89acc53fd4a..6b90b3861aa 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -109,11 +109,12 @@ TBLDEF::TBLDEF(void) /**************************************************************************/ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - char *tablist, *dbname; + char *tablist, *dbname, *def = NULL; Desc = "Table list table"; tablist = Cat->GetStringCatInfo(g, "Tablist", ""); dbname = Cat->GetStringCatInfo(g, "Dbname", "*"); + def = Cat->GetStringCatInfo(g, "Srcdef", NULL); Ntables = 0; if (*tablist) { @@ -134,7 +135,7 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) } // endif p // Allocate the TBLIST block for that table - tbl = new(g) XTAB(pn); + tbl = new(g) XTAB(pn, def); tbl->SetQualifier(pdb); if (trace) @@ -231,16 +232,28 @@ PCOL TDBTBL::InsertSpecialColumn(PGLOBAL g, PCOL scp) bool TDBTBL::InitTableList(PGLOBAL g) { int n; + uint sln; + char *scs; PTABLE tp, tabp; PCOL colp; PTBLDEF tdp = (PTBLDEF)To_Def; + PCATLG cat = To_Def->GetCat(); + PHC hc = ((MYCAT*)cat)->GetHandler(); + scs = hc->get_table()->s->connect_string.str; + sln = hc->get_table()->s->connect_string.length; // PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath()); for (n = 0, tp = tdp->Tablep; tp; tp = tp->GetNext()) { if (TestFil(g, To_Filter, tp)) { tabp = new(g) XTAB(tp); + if (tabp->GetSrc()) { + // Table list is a list of connections + hc->get_table()->s->connect_string.str = (char*)tabp->GetName(); + hc->get_table()->s->connect_string.length = strlen(tabp->GetName()); + } // endif Src + // Get the table description block of this table if (!(Tdbp = GetSubTable(g, tabp))) { if (++Nbc > Maxerr) @@ -269,6 +282,9 @@ bool TDBTBL::InitTableList(PGLOBAL g) } // endfor tp + hc->get_table()->s->connect_string.str = scs; + hc->get_table()->s->connect_string.length = sln; + //NumTables = n; To_Filter = NULL; // To avoid doing it several times return FALSE; From c6c1a6e2e88eb73ee4d491fd552ba1cb7b6a7154 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 26 Jun 2013 19:42:28 +0200 Subject: [PATCH 239/273] - Fix potential bug in MYSQLCOL::WriteColumn: ShowValue was call with *Bind->length instead of Bind->buffer_length modified: storage/connect/tabmysql.cpp --- storage/connect/tabmysql.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 3af5904eee4..030f5760601 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -767,11 +767,6 @@ int TDBMYSQL::BindColumns(PGLOBAL g) } // endif prep #endif // MYSQL_PREPARED_STATEMENTS - for (PMYCOL colp = (PMYCOL)Columns; colp; colp = (PMYCOL)colp->Next) - if (colp->Buf_Type == TYPE_DATE) - // Format must match DATETIME MySQL type - ((DTVAL*)colp->GetValue())->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19); - return RC_OK; } // end of BindColumns @@ -801,6 +796,14 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) } // endif Connected + /*********************************************************************/ + /* Take care of DATE columns. */ + /*********************************************************************/ + for (PMYCOL colp = (PMYCOL)Columns; colp; colp = (PMYCOL)colp->Next) + if (colp->Buf_Type == TYPE_DATE) + // Format must match DATETIME MySQL type + ((DTVAL*)colp->GetValue())->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19); + /*********************************************************************/ /* Allocate whatever is used for getting results. */ /*********************************************************************/ @@ -1191,10 +1194,6 @@ void MYSQLCOL::InitBind(PGLOBAL g) memset(Bind, 0, sizeof(MYSQL_BIND)); if (Buf_Type == TYPE_DATE) { - // Default format must match DATETIME MySQL type -// if (!((DTVAL*)Value)->IsFormatted()) - ((DTVAL*)Value)->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19); - Bind->buffer_type = PLGtoMYSQL(TYPE_STRING, false); Bind->buffer = (char *)PlugSubAlloc(g,NULL, 20); Bind->buffer_length = 20; @@ -1257,7 +1256,7 @@ void MYSQLCOL::WriteColumn(PGLOBAL g) #if defined(MYSQL_PREPARED_STATEMENTS) if (((PTDBMY)To_Tdb)->Prep) { if (Buf_Type == TYPE_DATE) { - Value->ShowValue((char *)Bind->buffer, (int)*Bind->length); + Value->ShowValue((char *)Bind->buffer, (int)Bind->buffer_length); Slen = strlen((char *)Bind->buffer); } else if (IsTypeChar(Buf_Type)) Slen = strlen(Value->GetCharValue()); From d662c48a6870bc0c203a24595d2ca943d089bc6f Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 26 Jun 2013 19:52:38 +0200 Subject: [PATCH 240/273] - In connect_assisted_discovery the test on topt->quoted must be done on its signed value modified: storage/connect/ha_connect.cc --- storage/connect/ha_connect.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index ab002488620..897827474a6 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3440,7 +3440,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, fnc= GetFuncID(fncn); sep= topt->separator; spc= (!sep || !strcmp(sep, "\\t")) ? '\t' : *sep; - qch= topt->qchar ? *topt->qchar : topt->quoted >= 0 ? '"' : 0; + qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0; hdr= (int)topt->header; tbl= topt->tablist; col= topt->colist; From 2662ae4b2b48bc41ff187115c88e2860e872131c Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 26 Jun 2013 20:00:15 +0200 Subject: [PATCH 241/273] - Trying to remove those warnings about non virtual destructor modified: storage/connect/block.h --- storage/connect/block.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/connect/block.h b/storage/connect/block.h index 963cfa42f32..fae4dffa68f 100644 --- a/storage/connect/block.h +++ b/storage/connect/block.h @@ -52,6 +52,9 @@ if (debug != NULL) // Avoid warning C4291 by defining a matching dummy delete operator void operator delete(void *, PGLOBAL, void *) {} #endif + + protected: + ~BLOCK(void) {} }; // end of class BLOCK #endif // !BLOCK_DEFINED From 0b116de7c58db3e483964d00e6a3803947bfaf4f Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 27 Jun 2013 15:18:48 +0400 Subject: [PATCH 242/273] MDEV-4438 - Spider storage engine --- .../dist/Debian/mariadb-server-10.0.files.in | 1 + .../dist/Ubuntu/mariadb-server-10.0.files.in | 1 + mysql-test/mysql-test-run.pl | 2 +- storage/spider/CMakeLists.txt | 45 + storage/spider/Makefile.am | 89 + storage/spider/configure.in | 95 + storage/spider/ha_spider.cc | 13545 ++++++++++++++++ storage/spider/ha_spider.h | 1014 ++ storage/spider/hs_client/allocator.hpp | 43 + storage/spider/hs_client/auto_addrinfo.hpp | 49 + storage/spider/hs_client/auto_file.hpp | 67 + .../spider/hs_client/auto_ptrcontainer.hpp | 70 + storage/spider/hs_client/config.cpp | 291 + storage/spider/hs_client/config.hpp | 81 + storage/spider/hs_client/escape.cpp | 127 + storage/spider/hs_client/escape.hpp | 64 + storage/spider/hs_client/fatal.cpp | 68 + storage/spider/hs_client/fatal.hpp | 33 + storage/spider/hs_client/hs_compat.h | 31 + storage/spider/hs_client/hstcpcli.cpp | 643 + storage/spider/hs_client/hstcpcli.hpp | 93 + storage/spider/hs_client/mutex.hpp | 48 + storage/spider/hs_client/socket.cpp | 310 + storage/spider/hs_client/socket.hpp | 62 + storage/spider/hs_client/string_buffer.hpp | 146 + storage/spider/hs_client/string_ref.hpp | 106 + storage/spider/hs_client/string_util.cpp | 206 + storage/spider/hs_client/string_util.hpp | 51 + storage/spider/hs_client/thread.hpp | 84 + storage/spider/hs_client/util.hpp | 25 + .../spider/bg/include/deinit_child2_1.inc | 0 .../spider/bg/include/deinit_child2_2.inc | 0 .../spider/bg/include/deinit_child2_3.inc | 0 .../spider/bg/include/deinit_child3_1.inc | 0 .../spider/bg/include/deinit_child3_2.inc | 0 .../spider/bg/include/deinit_child3_3.inc | 0 .../spider/bg/include/deinit_master_1.inc | 1 + .../spider/bg/include/deinit_slave1_1.inc | 0 .../spider/bg/include/ha_deinit_child2_1.inc | 0 .../spider/bg/include/ha_deinit_child2_2.inc | 0 .../spider/bg/include/ha_deinit_child2_3.inc | 0 .../spider/bg/include/ha_deinit_child3_1.inc | 1 + .../spider/bg/include/ha_deinit_child3_2.inc | 1 + .../spider/bg/include/ha_deinit_child3_3.inc | 1 + .../spider/bg/include/ha_deinit_master_1.inc | 0 .../spider/bg/include/ha_init_child2_1.inc | 8 + .../spider/bg/include/ha_init_child2_2.inc | 4 + .../spider/bg/include/ha_init_child2_3.inc | 4 + .../spider/bg/include/ha_init_child3_1.inc | 140 + .../spider/bg/include/ha_init_child3_2.inc | 140 + .../spider/bg/include/ha_init_child3_3.inc | 140 + .../spider/bg/include/ha_init_master_1.inc | 105 + .../spider/bg/include/hs_deinit_child2_1.inc | 0 .../spider/bg/include/hs_deinit_child2_2.inc | 0 .../spider/bg/include/hs_deinit_child2_3.inc | 0 .../spider/bg/include/hs_deinit_master_1.inc | 0 .../spider/bg/include/hs_init_child2_1.inc | 24 + .../spider/bg/include/hs_init_child2_2.inc | 12 + .../spider/bg/include/hs_init_child2_3.inc | 0 .../spider/bg/include/hs_init_master_1.inc | 12 + .../spider/bg/include/init_child2_1.inc | 175 + .../spider/bg/include/init_child2_2.inc | 80 + .../spider/bg/include/init_child2_3.inc | 11 + .../spider/bg/include/init_child3_1.inc | 0 .../spider/bg/include/init_child3_2.inc | 0 .../spider/bg/include/init_child3_3.inc | 0 .../spider/bg/include/init_master_1.inc | 194 + .../spider/bg/include/init_slave1_1.inc | 10 + storage/spider/mysql-test/spider/bg/my.cnf | 176 + .../mysql-test/spider/bg/r/basic_sql.result | 701 + .../spider/bg/r/direct_aggregate.result | 132 + .../spider/bg/r/direct_update.result | 226 + .../mysql-test/spider/bg/r/function.result | 149 + .../spider/mysql-test/spider/bg/r/ha.result | 431 + .../spider/bg/r/spider3_fixes.result | 371 + .../spider/bg/r/spider_fixes.result | 692 + .../mysql-test/spider/bg/r/vp_fixes.result | 80 + storage/spider/mysql-test/spider/bg/suite.opt | 1 + storage/spider/mysql-test/spider/bg/suite.pm | 9 + .../mysql-test/spider/bg/t/basic_sql.test | 3189 ++++ .../spider/bg/t/connect_child2_1.inc | 1 + .../spider/bg/t/connect_child2_2.inc | 1 + .../spider/bg/t/connect_child2_3.inc | 1 + .../spider/bg/t/connect_child3_1.inc | 1 + .../spider/bg/t/connect_child3_2.inc | 1 + .../spider/bg/t/connect_child3_3.inc | 1 + .../spider/bg/t/connect_master_1.inc | 1 + .../spider/bg/t/connect_slave1_1.inc | 1 + .../spider/bg/t/direct_aggregate.test | 316 + .../mysql-test/spider/bg/t/direct_update.test | 354 + .../mysql-test/spider/bg/t/function.test | 276 + storage/spider/mysql-test/spider/bg/t/ha.test | 1794 ++ .../mysql-test/spider/bg/t/ha_test_deinit.inc | 30 + .../mysql-test/spider/bg/t/ha_test_init.inc | 30 + .../mysql-test/spider/bg/t/have_engine.inc | 7 + .../mysql-test/spider/bg/t/have_func.inc | 5 + .../mysql-test/spider/bg/t/have_partition.inc | 7 + .../mysql-test/spider/bg/t/have_trigger.inc | 2 + .../mysql-test/spider/bg/t/hs_test_deinit.inc | 17 + .../mysql-test/spider/bg/t/hs_test_init.inc | 17 + .../spider/bg/t/slave_test_deinit.inc | 6 + .../spider/bg/t/slave_test_init.inc | 44 + .../mysql-test/spider/bg/t/spider3_fixes.test | 570 + .../mysql-test/spider/bg/t/spider_fixes.test | 1967 +++ .../mysql-test/spider/bg/t/test_deinit.inc | 37 + .../mysql-test/spider/bg/t/test_init.inc | 74 + .../mysql-test/spider/bg/t/vp_fixes.test | 358 + .../handler/include/deinit_child2_1.inc | 0 .../handler/include/deinit_child2_2.inc | 0 .../handler/include/deinit_child2_3.inc | 0 .../handler/include/deinit_child3_1.inc | 0 .../handler/include/deinit_child3_2.inc | 0 .../handler/include/deinit_child3_3.inc | 0 .../handler/include/deinit_master_1.inc | 1 + .../handler/include/deinit_slave1_1.inc | 0 .../handler/include/ha_deinit_child2_1.inc | 0 .../handler/include/ha_deinit_child2_2.inc | 0 .../handler/include/ha_deinit_child2_3.inc | 0 .../handler/include/ha_deinit_child3_1.inc | 1 + .../handler/include/ha_deinit_child3_2.inc | 1 + .../handler/include/ha_deinit_child3_3.inc | 1 + .../handler/include/ha_deinit_master_1.inc | 0 .../handler/include/ha_init_child2_1.inc | 8 + .../handler/include/ha_init_child2_2.inc | 4 + .../handler/include/ha_init_child2_3.inc | 4 + .../handler/include/ha_init_child3_1.inc | 140 + .../handler/include/ha_init_child3_2.inc | 140 + .../handler/include/ha_init_child3_3.inc | 140 + .../handler/include/ha_init_master_1.inc | 105 + .../handler/include/hs_deinit_child2_1.inc | 0 .../handler/include/hs_deinit_child2_2.inc | 0 .../handler/include/hs_deinit_child2_3.inc | 0 .../handler/include/hs_deinit_master_1.inc | 0 .../handler/include/hs_init_child2_1.inc | 24 + .../handler/include/hs_init_child2_2.inc | 12 + .../handler/include/hs_init_child2_3.inc | 0 .../handler/include/hs_init_master_1.inc | 12 + .../spider/handler/include/init_child2_1.inc | 176 + .../spider/handler/include/init_child2_2.inc | 80 + .../spider/handler/include/init_child2_3.inc | 11 + .../spider/handler/include/init_child3_1.inc | 0 .../spider/handler/include/init_child3_2.inc | 0 .../spider/handler/include/init_child3_3.inc | 0 .../spider/handler/include/init_master_1.inc | 186 + .../spider/handler/include/init_slave1_1.inc | 10 + .../spider/mysql-test/spider/handler/my.cnf | 176 + .../spider/handler/r/basic_sql.result | 693 + .../spider/handler/r/direct_aggregate.result | 132 + .../spider/handler/r/direct_update.result | 242 + .../spider/handler/r/function.result | 149 + .../mysql-test/spider/handler/r/ha.result | 431 + .../spider/handler/r/spider3_fixes.result | 403 + .../spider/handler/r/spider_fixes.result | 699 + .../spider/handler/r/vp_fixes.result | 80 + .../spider/handler/t/basic_sql.test | 3189 ++++ .../spider/handler/t/connect_child2_1.inc | 1 + .../spider/handler/t/connect_child2_2.inc | 1 + .../spider/handler/t/connect_child2_3.inc | 1 + .../spider/handler/t/connect_child3_1.inc | 1 + .../spider/handler/t/connect_child3_2.inc | 1 + .../spider/handler/t/connect_child3_3.inc | 1 + .../spider/handler/t/connect_master_1.inc | 1 + .../spider/handler/t/connect_slave1_1.inc | 1 + .../spider/handler/t/direct_aggregate.test | 316 + .../spider/handler/t/direct_update.test | 354 + .../mysql-test/spider/handler/t/function.test | 276 + .../mysql-test/spider/handler/t/ha.test | 1794 ++ .../spider/handler/t/ha_test_deinit.inc | 30 + .../spider/handler/t/ha_test_init.inc | 30 + .../spider/handler/t/have_engine.inc | 7 + .../mysql-test/spider/handler/t/have_func.inc | 5 + .../spider/handler/t/have_partition.inc | 7 + .../spider/handler/t/have_trigger.inc | 2 + .../spider/handler/t/hs_test_deinit.inc | 17 + .../spider/handler/t/hs_test_init.inc | 17 + .../spider/handler/t/slave_test_deinit.inc | 6 + .../spider/handler/t/slave_test_init.inc | 44 + .../spider/handler/t/spider3_fixes.test | 570 + .../spider/handler/t/spider_fixes.test | 1967 +++ .../spider/handler/t/test_deinit.inc | 37 + .../mysql-test/spider/handler/t/test_init.inc | 74 + .../mysql-test/spider/handler/t/vp_fixes.test | 358 + .../spider/include/deinit_child2_1.inc | 3 + .../spider/include/deinit_child2_2.inc | 3 + .../spider/include/deinit_child2_3.inc | 3 + .../spider/include/deinit_child3_1.inc | 3 + .../spider/include/deinit_child3_2.inc | 3 + .../spider/include/deinit_child3_3.inc | 3 + .../spider/include/deinit_engine.inc | 4 + .../spider/include/deinit_handlersocket.inc | 1 + .../spider/include/deinit_innodb_plugin.inc | 1 + .../spider/include/deinit_master_1.inc | 1 + .../spider/include/deinit_slave1_1.inc | 0 .../spider/include/deinit_spider.inc | 17 + .../spider/include/ha_deinit_child2_1.inc | 0 .../spider/include/ha_deinit_child2_2.inc | 0 .../spider/include/ha_deinit_child2_3.inc | 0 .../spider/include/ha_deinit_child3_1.inc | 1 + .../spider/include/ha_deinit_child3_2.inc | 1 + .../spider/include/ha_deinit_child3_3.inc | 1 + .../spider/include/ha_deinit_master_1.inc | 0 .../spider/include/ha_init_child2_1.inc | 8 + .../spider/include/ha_init_child2_2.inc | 4 + .../spider/include/ha_init_child2_3.inc | 4 + .../spider/include/ha_init_child3_1.inc | 140 + .../spider/include/ha_init_child3_2.inc | 140 + .../spider/include/ha_init_child3_3.inc | 140 + .../spider/include/ha_init_master_1.inc | 105 + .../spider/include/hs_deinit_child2_1.inc | 0 .../spider/include/hs_deinit_child2_2.inc | 0 .../spider/include/hs_deinit_child2_3.inc | 0 .../spider/include/hs_deinit_master_1.inc | 0 .../spider/include/hs_init_child2_1.inc | 24 + .../spider/include/hs_init_child2_2.inc | 12 + .../spider/include/hs_init_child2_3.inc | 0 .../spider/include/hs_init_master_1.inc | 12 + .../spider/include/init_child2_1.inc | 178 + .../spider/include/init_child2_2.inc | 83 + .../spider/include/init_child2_3.inc | 14 + .../spider/include/init_child3_1.inc | 3 + .../spider/include/init_child3_2.inc | 3 + .../spider/include/init_child3_3.inc | 3 + .../mysql-test/spider/include/init_engine.inc | 10 + .../spider/include/init_master_1.inc | 186 + .../spider/include/init_slave1_1.inc | 10 + .../mysql-test/spider/include/init_spider.inc | 339 + storage/spider/mysql-test/spider/my.cnf | 177 + .../spider/oracle/include/deinit_child2_1.inc | 0 .../spider/oracle/include/deinit_child2_2.inc | 0 .../spider/oracle/include/deinit_child2_3.inc | 0 .../spider/oracle/include/deinit_child3_1.inc | 3 + .../spider/oracle/include/deinit_child3_2.inc | 3 + .../spider/oracle/include/deinit_child3_3.inc | 3 + .../spider/oracle/include/deinit_master_1.inc | 1 + .../spider/oracle/include/deinit_slave1_1.inc | 0 .../oracle/include/ha_deinit_child2_1.inc | 0 .../oracle/include/ha_deinit_child2_2.inc | 0 .../oracle/include/ha_deinit_child2_3.inc | 0 .../oracle/include/ha_deinit_child3_1.inc | 1 + .../oracle/include/ha_deinit_child3_2.inc | 1 + .../oracle/include/ha_deinit_child3_3.inc | 1 + .../oracle/include/ha_deinit_master_1.inc | 0 .../oracle/include/ha_init_child2_1.inc | 8 + .../oracle/include/ha_init_child2_2.inc | 4 + .../oracle/include/ha_init_child2_3.inc | 4 + .../oracle/include/ha_init_child3_1.inc | 140 + .../oracle/include/ha_init_child3_2.inc | 140 + .../oracle/include/ha_init_child3_3.inc | 140 + .../oracle/include/ha_init_master_1.inc | 109 + .../oracle/include/hs_deinit_child2_1.inc | 0 .../oracle/include/hs_deinit_child2_2.inc | 0 .../oracle/include/hs_deinit_child2_3.inc | 0 .../oracle/include/hs_deinit_master_1.inc | 0 .../oracle/include/hs_init_child2_1.inc | 24 + .../oracle/include/hs_init_child2_2.inc | 12 + .../oracle/include/hs_init_child2_3.inc | 0 .../oracle/include/hs_init_master_1.inc | 12 + .../spider/oracle/include/init_child2_1.inc | 192 + .../spider/oracle/include/init_child2_2.inc | 94 + .../spider/oracle/include/init_child2_3.inc | 15 + .../spider/oracle/include/init_child3_1.inc | 3 + .../spider/oracle/include/init_child3_2.inc | 3 + .../spider/oracle/include/init_child3_3.inc | 3 + .../spider/oracle/include/init_master_1.inc | 149 + .../spider/oracle/include/init_slave1_1.inc | 10 + .../spider/oracle/include/init_spider.inc | 105 + .../spider/mysql-test/spider/oracle/my.cnf | 146 + .../spider/oracle/r/basic_sql.result | 701 + .../spider/oracle/r/direct_aggregate.result | 132 + .../spider/oracle/r/direct_update.result | 226 + .../spider/oracle/r/function.result | 149 + .../mysql-test/spider/oracle/r/ha.result | 431 + .../spider/oracle/r/spider3_fixes.result | 343 + .../spider/oracle/r/spider_fixes.result | 670 + .../spider/oracle/r/vp_fixes.result | 80 + .../mysql-test/spider/oracle/t/basic_sql.test | 3189 ++++ .../spider/oracle/t/connect_child2_1.inc | 1 + .../spider/oracle/t/connect_child2_2.inc | 1 + .../spider/oracle/t/connect_child2_3.inc | 1 + .../spider/oracle/t/connect_child3_1.inc | 1 + .../spider/oracle/t/connect_child3_2.inc | 1 + .../spider/oracle/t/connect_child3_3.inc | 1 + .../spider/oracle/t/connect_master_1.inc | 1 + .../spider/oracle/t/connect_slave1_1.inc | 1 + .../spider/oracle/t/direct_aggregate.test | 316 + .../spider/oracle/t/direct_update.test | 354 + .../mysql-test/spider/oracle/t/function.test | 276 + .../spider/mysql-test/spider/oracle/t/ha.test | 1794 ++ .../spider/oracle/t/ha_test_deinit.inc | 30 + .../spider/oracle/t/ha_test_init.inc | 30 + .../spider/oracle/t/have_engine.inc | 7 + .../mysql-test/spider/oracle/t/have_func.inc | 5 + .../spider/oracle/t/have_partition.inc | 7 + .../spider/oracle/t/have_trigger.inc | 2 + .../spider/oracle/t/hs_test_deinit.inc | 17 + .../spider/oracle/t/hs_test_init.inc | 17 + .../spider/oracle/t/slave_test_deinit.inc | 6 + .../spider/oracle/t/slave_test_init.inc | 44 + .../spider/oracle/t/spider3_fixes.test | 570 + .../spider/oracle/t/spider_fixes.test | 1967 +++ .../spider/oracle/t/test_deinit.inc | 37 + .../mysql-test/spider/oracle/t/test_init.inc | 74 + .../mysql-test/spider/oracle/t/vp_fixes.test | 358 + .../oracle2/include/deinit_child2_1.inc | 0 .../oracle2/include/deinit_child2_2.inc | 0 .../oracle2/include/deinit_child2_3.inc | 0 .../oracle2/include/deinit_child3_1.inc | 3 + .../oracle2/include/deinit_child3_2.inc | 3 + .../oracle2/include/deinit_child3_3.inc | 3 + .../oracle2/include/deinit_master_1.inc | 1 + .../oracle2/include/deinit_slave1_1.inc | 0 .../oracle2/include/ha_deinit_child2_1.inc | 0 .../oracle2/include/ha_deinit_child2_2.inc | 0 .../oracle2/include/ha_deinit_child2_3.inc | 0 .../oracle2/include/ha_deinit_child3_1.inc | 1 + .../oracle2/include/ha_deinit_child3_2.inc | 1 + .../oracle2/include/ha_deinit_child3_3.inc | 1 + .../oracle2/include/ha_deinit_master_1.inc | 0 .../oracle2/include/ha_init_child2_1.inc | 8 + .../oracle2/include/ha_init_child2_2.inc | 4 + .../oracle2/include/ha_init_child2_3.inc | 4 + .../oracle2/include/ha_init_child3_1.inc | 140 + .../oracle2/include/ha_init_child3_2.inc | 140 + .../oracle2/include/ha_init_child3_3.inc | 140 + .../oracle2/include/ha_init_master_1.inc | 109 + .../oracle2/include/hs_deinit_child2_1.inc | 0 .../oracle2/include/hs_deinit_child2_2.inc | 0 .../oracle2/include/hs_deinit_child2_3.inc | 0 .../oracle2/include/hs_deinit_master_1.inc | 0 .../oracle2/include/hs_init_child2_1.inc | 24 + .../oracle2/include/hs_init_child2_2.inc | 12 + .../oracle2/include/hs_init_child2_3.inc | 0 .../oracle2/include/hs_init_master_1.inc | 12 + .../spider/oracle2/include/init_child2_1.inc | 192 + .../spider/oracle2/include/init_child2_2.inc | 94 + .../spider/oracle2/include/init_child2_3.inc | 15 + .../spider/oracle2/include/init_child3_1.inc | 3 + .../spider/oracle2/include/init_child3_2.inc | 3 + .../spider/oracle2/include/init_child3_3.inc | 3 + .../spider/oracle2/include/init_master_1.inc | 150 + .../spider/oracle2/include/init_slave1_1.inc | 10 + .../spider/oracle2/include/init_spider.inc | 105 + .../spider/mysql-test/spider/oracle2/my.cnf | 146 + .../spider/oracle2/r/basic_sql.result | 701 + .../spider/oracle2/r/direct_aggregate.result | 132 + .../spider/oracle2/r/direct_update.result | 226 + .../spider/oracle2/r/function.result | 149 + .../mysql-test/spider/oracle2/r/ha.result | 431 + .../spider/oracle2/r/spider3_fixes.result | 375 + .../spider/oracle2/r/spider_fixes.result | 678 + .../spider/oracle2/r/vp_fixes.result | 80 + .../spider/oracle2/t/basic_sql.test | 3189 ++++ .../spider/oracle2/t/connect_child2_1.inc | 1 + .../spider/oracle2/t/connect_child2_2.inc | 1 + .../spider/oracle2/t/connect_child2_3.inc | 1 + .../spider/oracle2/t/connect_child3_1.inc | 1 + .../spider/oracle2/t/connect_child3_2.inc | 1 + .../spider/oracle2/t/connect_child3_3.inc | 1 + .../spider/oracle2/t/connect_master_1.inc | 1 + .../spider/oracle2/t/connect_slave1_1.inc | 1 + .../spider/oracle2/t/direct_aggregate.test | 316 + .../spider/oracle2/t/direct_update.test | 354 + .../mysql-test/spider/oracle2/t/function.test | 276 + .../mysql-test/spider/oracle2/t/ha.test | 1794 ++ .../spider/oracle2/t/ha_test_deinit.inc | 30 + .../spider/oracle2/t/ha_test_init.inc | 30 + .../spider/oracle2/t/have_engine.inc | 7 + .../mysql-test/spider/oracle2/t/have_func.inc | 5 + .../spider/oracle2/t/have_partition.inc | 7 + .../spider/oracle2/t/have_trigger.inc | 2 + .../spider/oracle2/t/hs_test_deinit.inc | 17 + .../spider/oracle2/t/hs_test_init.inc | 17 + .../spider/oracle2/t/slave_test_deinit.inc | 6 + .../spider/oracle2/t/slave_test_init.inc | 44 + .../spider/oracle2/t/spider3_fixes.test | 570 + .../spider/oracle2/t/spider_fixes.test | 1967 +++ .../spider/oracle2/t/test_deinit.inc | 37 + .../mysql-test/spider/oracle2/t/test_init.inc | 74 + .../mysql-test/spider/oracle2/t/vp_fixes.test | 358 + .../mysql-test/spider/r/basic_sql.result | 701 + .../spider/r/direct_aggregate.result | 132 + .../mysql-test/spider/r/direct_update.result | 226 + .../mysql-test/spider/r/function.result | 149 + storage/spider/mysql-test/spider/r/ha.result | 431 + .../mysql-test/spider/r/spider3_fixes.result | 371 + .../mysql-test/spider/r/spider_fixes.result | 692 + .../mysql-test/spider/r/vp_fixes.result | 80 + storage/spider/mysql-test/spider/suite.opt | 1 + storage/spider/mysql-test/spider/suite.pm | 9 + .../spider/mysql-test/spider/t/basic_sql.test | 3189 ++++ .../mysql-test/spider/t/connect_child2_1.inc | 1 + .../mysql-test/spider/t/connect_child2_2.inc | 1 + .../mysql-test/spider/t/connect_child2_3.inc | 1 + .../mysql-test/spider/t/connect_child3_1.inc | 1 + .../mysql-test/spider/t/connect_child3_2.inc | 1 + .../mysql-test/spider/t/connect_child3_3.inc | 1 + .../mysql-test/spider/t/connect_master_1.inc | 1 + .../mysql-test/spider/t/connect_slave1_1.inc | 1 + .../mysql-test/spider/t/direct_aggregate.test | 316 + .../mysql-test/spider/t/direct_update.test | 354 + .../spider/mysql-test/spider/t/function.test | 276 + storage/spider/mysql-test/spider/t/ha.test | 1794 ++ .../mysql-test/spider/t/ha_test_deinit.inc | 30 + .../mysql-test/spider/t/ha_test_init.inc | 30 + .../mysql-test/spider/t/have_engine.inc | 7 + .../spider/mysql-test/spider/t/have_func.inc | 5 + .../mysql-test/spider/t/have_partition.inc | 7 + .../mysql-test/spider/t/have_plugin.inc | 5 + .../mysql-test/spider/t/have_trigger.inc | 2 + .../mysql-test/spider/t/hs_test_deinit.inc | 17 + .../mysql-test/spider/t/hs_test_init.inc | 17 + .../mysql-test/spider/t/slave_test_deinit.inc | 6 + .../mysql-test/spider/t/slave_test_init.inc | 44 + .../mysql-test/spider/t/spider3_fixes.test | 570 + .../mysql-test/spider/t/spider_fixes.test | 1967 +++ .../mysql-test/spider/t/test_deinit.inc | 37 + .../spider/mysql-test/spider/t/test_init.inc | 74 + .../spider/mysql-test/spider/t/vp_fixes.test | 358 + storage/spider/plug.in | 6 + storage/spider/spd_conn.cc | 3988 +++++ storage/spider/spd_conn.h | 313 + storage/spider/spd_copy_tables.cc | 1343 ++ storage/spider/spd_copy_tables.h | 55 + storage/spider/spd_db_conn.cc | 9729 +++++++++++ storage/spider/spd_db_conn.h | 1022 ++ storage/spider/spd_db_handlersocket.cc | 5308 ++++++ storage/spider/spd_db_handlersocket.h | 893 + storage/spider/spd_db_include.h | 1579 ++ storage/spider/spd_db_mysql.cc | 10839 +++++++++++++ storage/spider/spd_db_mysql.h | 1295 ++ storage/spider/spd_db_oracle.cc | 11764 ++++++++++++++ storage/spider/spd_db_oracle.h | 1389 ++ storage/spider/spd_direct_sql.cc | 1877 +++ storage/spider/spd_direct_sql.h | 67 + storage/spider/spd_err.h | 119 + storage/spider/spd_i_s.cc | 148 + storage/spider/spd_include.h | 1123 ++ storage/spider/spd_malloc.cc | 1267 ++ storage/spider/spd_malloc.h | 79 + storage/spider/spd_param.cc | 2933 ++++ storage/spider/spd_param.h | 370 + storage/spider/spd_ping_table.cc | 1460 ++ storage/spider/spd_ping_table.h | 102 + storage/spider/spd_sys_table.cc | 2417 +++ storage/spider/spd_sys_table.h | 427 + storage/spider/spd_table.cc | 7837 +++++++++ storage/spider/spd_table.h | 412 + storage/spider/spd_trx.cc | 4049 +++++ storage/spider/spd_trx.h | 260 + storage/spider/spd_udf.cc | 154 + storage/spider/spd_udf.def | 20 + storage/spider/spd_udf.h | 79 + 452 files changed, 158438 insertions(+), 1 deletion(-) create mode 100644 storage/spider/CMakeLists.txt create mode 100644 storage/spider/Makefile.am create mode 100644 storage/spider/configure.in create mode 100644 storage/spider/ha_spider.cc create mode 100644 storage/spider/ha_spider.h create mode 100644 storage/spider/hs_client/allocator.hpp create mode 100644 storage/spider/hs_client/auto_addrinfo.hpp create mode 100644 storage/spider/hs_client/auto_file.hpp create mode 100644 storage/spider/hs_client/auto_ptrcontainer.hpp create mode 100644 storage/spider/hs_client/config.cpp create mode 100644 storage/spider/hs_client/config.hpp create mode 100644 storage/spider/hs_client/escape.cpp create mode 100644 storage/spider/hs_client/escape.hpp create mode 100644 storage/spider/hs_client/fatal.cpp create mode 100644 storage/spider/hs_client/fatal.hpp create mode 100644 storage/spider/hs_client/hs_compat.h create mode 100644 storage/spider/hs_client/hstcpcli.cpp create mode 100644 storage/spider/hs_client/hstcpcli.hpp create mode 100644 storage/spider/hs_client/mutex.hpp create mode 100644 storage/spider/hs_client/socket.cpp create mode 100644 storage/spider/hs_client/socket.hpp create mode 100644 storage/spider/hs_client/string_buffer.hpp create mode 100644 storage/spider/hs_client/string_ref.hpp create mode 100644 storage/spider/hs_client/string_util.cpp create mode 100644 storage/spider/hs_client/string_util.hpp create mode 100644 storage/spider/hs_client/thread.hpp create mode 100644 storage/spider/hs_client/util.hpp create mode 100644 storage/spider/mysql-test/spider/bg/include/deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/deinit_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/ha_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/hs_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/hs_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/hs_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/hs_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/hs_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/include/init_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/my.cnf create mode 100644 storage/spider/mysql-test/spider/bg/r/basic_sql.result create mode 100644 storage/spider/mysql-test/spider/bg/r/direct_aggregate.result create mode 100644 storage/spider/mysql-test/spider/bg/r/direct_update.result create mode 100644 storage/spider/mysql-test/spider/bg/r/function.result create mode 100644 storage/spider/mysql-test/spider/bg/r/ha.result create mode 100644 storage/spider/mysql-test/spider/bg/r/spider3_fixes.result create mode 100644 storage/spider/mysql-test/spider/bg/r/spider_fixes.result create mode 100644 storage/spider/mysql-test/spider/bg/r/vp_fixes.result create mode 100644 storage/spider/mysql-test/spider/bg/suite.opt create mode 100644 storage/spider/mysql-test/spider/bg/suite.pm create mode 100644 storage/spider/mysql-test/spider/bg/t/basic_sql.test create mode 100644 storage/spider/mysql-test/spider/bg/t/connect_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/connect_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/connect_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/connect_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/connect_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/connect_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/connect_master_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/connect_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/direct_aggregate.test create mode 100644 storage/spider/mysql-test/spider/bg/t/direct_update.test create mode 100644 storage/spider/mysql-test/spider/bg/t/function.test create mode 100644 storage/spider/mysql-test/spider/bg/t/ha.test create mode 100644 storage/spider/mysql-test/spider/bg/t/ha_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/ha_test_init.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/have_engine.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/have_func.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/have_partition.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/have_trigger.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/hs_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/hs_test_init.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/slave_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/slave_test_init.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/spider3_fixes.test create mode 100644 storage/spider/mysql-test/spider/bg/t/spider_fixes.test create mode 100644 storage/spider/mysql-test/spider/bg/t/test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/test_init.inc create mode 100644 storage/spider/mysql-test/spider/bg/t/vp_fixes.test create mode 100644 storage/spider/mysql-test/spider/handler/include/deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/deinit_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/ha_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/hs_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/hs_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/hs_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/hs_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/hs_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/include/init_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/my.cnf create mode 100644 storage/spider/mysql-test/spider/handler/r/basic_sql.result create mode 100644 storage/spider/mysql-test/spider/handler/r/direct_aggregate.result create mode 100644 storage/spider/mysql-test/spider/handler/r/direct_update.result create mode 100644 storage/spider/mysql-test/spider/handler/r/function.result create mode 100644 storage/spider/mysql-test/spider/handler/r/ha.result create mode 100644 storage/spider/mysql-test/spider/handler/r/spider3_fixes.result create mode 100644 storage/spider/mysql-test/spider/handler/r/spider_fixes.result create mode 100644 storage/spider/mysql-test/spider/handler/r/vp_fixes.result create mode 100644 storage/spider/mysql-test/spider/handler/t/basic_sql.test create mode 100644 storage/spider/mysql-test/spider/handler/t/connect_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/connect_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/connect_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/connect_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/connect_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/connect_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/connect_master_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/connect_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/direct_aggregate.test create mode 100644 storage/spider/mysql-test/spider/handler/t/direct_update.test create mode 100644 storage/spider/mysql-test/spider/handler/t/function.test create mode 100644 storage/spider/mysql-test/spider/handler/t/ha.test create mode 100644 storage/spider/mysql-test/spider/handler/t/ha_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/ha_test_init.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/have_engine.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/have_func.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/have_partition.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/have_trigger.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/hs_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/hs_test_init.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/slave_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/slave_test_init.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/spider3_fixes.test create mode 100644 storage/spider/mysql-test/spider/handler/t/spider_fixes.test create mode 100644 storage/spider/mysql-test/spider/handler/t/test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/test_init.inc create mode 100644 storage/spider/mysql-test/spider/handler/t/vp_fixes.test create mode 100644 storage/spider/mysql-test/spider/include/deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_engine.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_handlersocket.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_innodb_plugin.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/include/deinit_spider.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/include/ha_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/include/hs_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/include/hs_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/include/hs_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/include/hs_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/include/hs_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/include/hs_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/include/hs_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/include/hs_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/include/init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/include/init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/include/init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/include/init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/include/init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/include/init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/include/init_engine.inc create mode 100644 storage/spider/mysql-test/spider/include/init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/include/init_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/include/init_spider.inc create mode 100644 storage/spider/mysql-test/spider/my.cnf create mode 100644 storage/spider/mysql-test/spider/oracle/include/deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/deinit_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/ha_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/hs_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/hs_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/hs_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/hs_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/hs_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/include/init_spider.inc create mode 100644 storage/spider/mysql-test/spider/oracle/my.cnf create mode 100644 storage/spider/mysql-test/spider/oracle/r/basic_sql.result create mode 100644 storage/spider/mysql-test/spider/oracle/r/direct_aggregate.result create mode 100644 storage/spider/mysql-test/spider/oracle/r/direct_update.result create mode 100644 storage/spider/mysql-test/spider/oracle/r/function.result create mode 100644 storage/spider/mysql-test/spider/oracle/r/ha.result create mode 100644 storage/spider/mysql-test/spider/oracle/r/spider3_fixes.result create mode 100644 storage/spider/mysql-test/spider/oracle/r/spider_fixes.result create mode 100644 storage/spider/mysql-test/spider/oracle/r/vp_fixes.result create mode 100644 storage/spider/mysql-test/spider/oracle/t/basic_sql.test create mode 100644 storage/spider/mysql-test/spider/oracle/t/connect_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/connect_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/connect_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/connect_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/connect_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/connect_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/connect_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/connect_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/direct_aggregate.test create mode 100644 storage/spider/mysql-test/spider/oracle/t/direct_update.test create mode 100644 storage/spider/mysql-test/spider/oracle/t/function.test create mode 100644 storage/spider/mysql-test/spider/oracle/t/ha.test create mode 100644 storage/spider/mysql-test/spider/oracle/t/ha_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/ha_test_init.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/have_engine.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/have_func.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/have_partition.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/have_trigger.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/hs_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/hs_test_init.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/slave_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/slave_test_init.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/spider3_fixes.test create mode 100644 storage/spider/mysql-test/spider/oracle/t/spider_fixes.test create mode 100644 storage/spider/mysql-test/spider/oracle/t/test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/test_init.inc create mode 100644 storage/spider/mysql-test/spider/oracle/t/vp_fixes.test create mode 100644 storage/spider/mysql-test/spider/oracle2/include/deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/deinit_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/ha_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/hs_deinit_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/hs_init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/include/init_spider.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/my.cnf create mode 100644 storage/spider/mysql-test/spider/oracle2/r/basic_sql.result create mode 100644 storage/spider/mysql-test/spider/oracle2/r/direct_aggregate.result create mode 100644 storage/spider/mysql-test/spider/oracle2/r/direct_update.result create mode 100644 storage/spider/mysql-test/spider/oracle2/r/function.result create mode 100644 storage/spider/mysql-test/spider/oracle2/r/ha.result create mode 100644 storage/spider/mysql-test/spider/oracle2/r/spider3_fixes.result create mode 100644 storage/spider/mysql-test/spider/oracle2/r/spider_fixes.result create mode 100644 storage/spider/mysql-test/spider/oracle2/r/vp_fixes.result create mode 100644 storage/spider/mysql-test/spider/oracle2/t/basic_sql.test create mode 100644 storage/spider/mysql-test/spider/oracle2/t/connect_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/connect_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/connect_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/connect_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/connect_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/connect_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/connect_master_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/connect_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/direct_aggregate.test create mode 100644 storage/spider/mysql-test/spider/oracle2/t/direct_update.test create mode 100644 storage/spider/mysql-test/spider/oracle2/t/function.test create mode 100644 storage/spider/mysql-test/spider/oracle2/t/ha.test create mode 100644 storage/spider/mysql-test/spider/oracle2/t/ha_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/ha_test_init.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/have_engine.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/have_func.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/have_partition.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/have_trigger.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/hs_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/hs_test_init.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/slave_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/slave_test_init.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/spider3_fixes.test create mode 100644 storage/spider/mysql-test/spider/oracle2/t/spider_fixes.test create mode 100644 storage/spider/mysql-test/spider/oracle2/t/test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/test_init.inc create mode 100644 storage/spider/mysql-test/spider/oracle2/t/vp_fixes.test create mode 100644 storage/spider/mysql-test/spider/r/basic_sql.result create mode 100644 storage/spider/mysql-test/spider/r/direct_aggregate.result create mode 100644 storage/spider/mysql-test/spider/r/direct_update.result create mode 100644 storage/spider/mysql-test/spider/r/function.result create mode 100644 storage/spider/mysql-test/spider/r/ha.result create mode 100644 storage/spider/mysql-test/spider/r/spider3_fixes.result create mode 100644 storage/spider/mysql-test/spider/r/spider_fixes.result create mode 100644 storage/spider/mysql-test/spider/r/vp_fixes.result create mode 100644 storage/spider/mysql-test/spider/suite.opt create mode 100644 storage/spider/mysql-test/spider/suite.pm create mode 100644 storage/spider/mysql-test/spider/t/basic_sql.test create mode 100644 storage/spider/mysql-test/spider/t/connect_child2_1.inc create mode 100644 storage/spider/mysql-test/spider/t/connect_child2_2.inc create mode 100644 storage/spider/mysql-test/spider/t/connect_child2_3.inc create mode 100644 storage/spider/mysql-test/spider/t/connect_child3_1.inc create mode 100644 storage/spider/mysql-test/spider/t/connect_child3_2.inc create mode 100644 storage/spider/mysql-test/spider/t/connect_child3_3.inc create mode 100644 storage/spider/mysql-test/spider/t/connect_master_1.inc create mode 100644 storage/spider/mysql-test/spider/t/connect_slave1_1.inc create mode 100644 storage/spider/mysql-test/spider/t/direct_aggregate.test create mode 100644 storage/spider/mysql-test/spider/t/direct_update.test create mode 100644 storage/spider/mysql-test/spider/t/function.test create mode 100644 storage/spider/mysql-test/spider/t/ha.test create mode 100644 storage/spider/mysql-test/spider/t/ha_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/t/ha_test_init.inc create mode 100644 storage/spider/mysql-test/spider/t/have_engine.inc create mode 100644 storage/spider/mysql-test/spider/t/have_func.inc create mode 100644 storage/spider/mysql-test/spider/t/have_partition.inc create mode 100644 storage/spider/mysql-test/spider/t/have_plugin.inc create mode 100644 storage/spider/mysql-test/spider/t/have_trigger.inc create mode 100644 storage/spider/mysql-test/spider/t/hs_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/t/hs_test_init.inc create mode 100644 storage/spider/mysql-test/spider/t/slave_test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/t/slave_test_init.inc create mode 100644 storage/spider/mysql-test/spider/t/spider3_fixes.test create mode 100644 storage/spider/mysql-test/spider/t/spider_fixes.test create mode 100644 storage/spider/mysql-test/spider/t/test_deinit.inc create mode 100644 storage/spider/mysql-test/spider/t/test_init.inc create mode 100644 storage/spider/mysql-test/spider/t/vp_fixes.test create mode 100644 storage/spider/plug.in create mode 100644 storage/spider/spd_conn.cc create mode 100644 storage/spider/spd_conn.h create mode 100644 storage/spider/spd_copy_tables.cc create mode 100644 storage/spider/spd_copy_tables.h create mode 100644 storage/spider/spd_db_conn.cc create mode 100644 storage/spider/spd_db_conn.h create mode 100644 storage/spider/spd_db_handlersocket.cc create mode 100644 storage/spider/spd_db_handlersocket.h create mode 100644 storage/spider/spd_db_include.h create mode 100644 storage/spider/spd_db_mysql.cc create mode 100644 storage/spider/spd_db_mysql.h create mode 100644 storage/spider/spd_db_oracle.cc create mode 100644 storage/spider/spd_db_oracle.h create mode 100644 storage/spider/spd_direct_sql.cc create mode 100644 storage/spider/spd_direct_sql.h create mode 100644 storage/spider/spd_err.h create mode 100644 storage/spider/spd_i_s.cc create mode 100644 storage/spider/spd_include.h create mode 100644 storage/spider/spd_malloc.cc create mode 100644 storage/spider/spd_malloc.h create mode 100644 storage/spider/spd_param.cc create mode 100644 storage/spider/spd_param.h create mode 100644 storage/spider/spd_ping_table.cc create mode 100644 storage/spider/spd_ping_table.h create mode 100644 storage/spider/spd_sys_table.cc create mode 100644 storage/spider/spd_sys_table.h create mode 100644 storage/spider/spd_table.cc create mode 100644 storage/spider/spd_table.h create mode 100644 storage/spider/spd_trx.cc create mode 100644 storage/spider/spd_trx.h create mode 100644 storage/spider/spd_udf.cc create mode 100644 storage/spider/spd_udf.def create mode 100644 storage/spider/spd_udf.h diff --git a/debian/dist/Debian/mariadb-server-10.0.files.in b/debian/dist/Debian/mariadb-server-10.0.files.in index 1f1132ea4fa..e56a5894b3f 100644 --- a/debian/dist/Debian/mariadb-server-10.0.files.in +++ b/debian/dist/Debian/mariadb-server-10.0.files.in @@ -81,3 +81,4 @@ usr/share/mysql/mysql_performance_tables.sql usr/share/mysql/mysql_test_data_timezone.sql @CASSANDRA_DEB_FILES@ @OQGRAPH_DEB_FILES@ +@SPIDER_DEB_FILES@ diff --git a/debian/dist/Ubuntu/mariadb-server-10.0.files.in b/debian/dist/Ubuntu/mariadb-server-10.0.files.in index 565405adb6f..c0e67d617d9 100644 --- a/debian/dist/Ubuntu/mariadb-server-10.0.files.in +++ b/debian/dist/Ubuntu/mariadb-server-10.0.files.in @@ -83,3 +83,4 @@ usr/share/mysql/mysql_performance_tables.sql usr/share/mysql/mysql_test_data_timezone.sql @CASSANDRA_DEB_FILES@ @OQGRAPH_DEB_FILES@ +@SPIDER_DEB_FILES@ diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ed84175edae..90988c73c66 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -377,7 +377,7 @@ sub main { # directly before it executes them, like "make test-force-pl" in RPM builds. mtr_report("Logging: $0 ", join(" ", @ARGV)); - $DEFAULT_SUITES.=",sequence,sql_discovery" if $source_dist; + $DEFAULT_SUITES.=",sequence,sql_discovery,spider,spider/bg" if $source_dist; command_line_setup(); diff --git a/storage/spider/CMakeLists.txt b/storage/spider/CMakeLists.txt new file mode 100644 index 00000000000..2e6046f6a29 --- /dev/null +++ b/storage/spider/CMakeLists.txt @@ -0,0 +1,45 @@ +SET(SPIDER_SOURCES + spd_param.cc spd_sys_table.cc spd_trx.cc spd_db_conn.cc spd_conn.cc + spd_table.cc spd_direct_sql.cc spd_udf.cc spd_ping_table.cc + spd_copy_tables.cc spd_i_s.cc spd_malloc.cc ha_spider.cc spd_udf.def + spd_db_mysql.cc spd_db_handlersocket.cc spd_db_oracle.cc + hs_client/config.cpp hs_client/escape.cpp hs_client/fatal.cpp + hs_client/hstcpcli.cpp hs_client/socket.cpp hs_client/string_util.cpp +) + +IF(DEFINED ENV{ORACLE_HOME}) + SET(ORACLE_HOME $ENV{ORACLE_HOME}) + FIND_PATH(ORACLE_INCLUDE_DIR oci.h PATHS ${ORACLE_HOME}/rdbms/public) + SET(ORACLE_OCI_LIB_NAME clntsh) + SET(ORACLE_LIB_DIR ${ORACLE_HOME}/lib) + FIND_LIBRARY(ORACLE_OCI_LIBRARY NAMES ${ORACLE_OCI_LIB_NAME} PATHS ${ORACLE_LIB_DIR}) +ENDIF() + +IF(EXISTS ${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake) + SET(CMAKE_CXX_FLAGS_DEBUG + "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi") + SET(CMAKE_C_FLAGS_DEBUG + "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi") + SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS") + INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake") + + INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/regex) + + MYSQL_STORAGE_ENGINE(SPIDER) +ELSE() + INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/storage/spider/hs_client + ${ORACLE_INCLUDE_DIR}) + + SET(SPIDER_DEB_FILES "usr/lib/mysql/plugin/ha_spider.so" PARENT_SCOPE) + MYSQL_ADD_PLUGIN(spider ${SPIDER_SOURCES} STORAGE_ENGINE MODULE_ONLY MODULE_OUTPUT_NAME "ha_spider") +ENDIF() + +IF(ORACLE_INCLUDE_DIR AND ORACLE_OCI_LIBRARY) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT") + TARGET_LINK_LIBRARIES (spider ${ORACLE_OCI_LIBRARY}) +ENDIF() diff --git a/storage/spider/Makefile.am b/storage/spider/Makefile.am new file mode 100644 index 00000000000..3847b3f2332 --- /dev/null +++ b/storage/spider/Makefile.am @@ -0,0 +1,89 @@ +HAVE_HANDLERSOCKET = "-DHAVE_HANDLERSOCKET" + +pkgplugindir = $(pkglibdir)/plugin +INCLUDES = -I$(SPD_MYSQL_INC)$(top_srcdir)/include \ + -I$(SPD_MYSQL_INC)$(top_srcdir)/regex \ + -I$(SPD_MYSQL_INC)$(top_srcdir)/sql \ + -I$(SPD_MYSQL_INC)$(top_srcdir)/extra/yassl/include \ + -I./hs_client \ + $(MYSQL_INCLUDE_PATH) \ + $(HANDLERSOCKET_INCLUDE_PATH) + +noinst_HEADERS = ha_spider.h spd_conn.h spd_db_conn.h \ + spd_db_include.h spd_err.h spd_sys_table.h \ + spd_table.h spd_trx.h spd_include.h spd_param.h \ + spd_direct_sql.h spd_udf.h spd_ping_table.h \ + spd_copy_tables.h spd_malloc.h \ + spd_db_mysql.h spd_db_handlersocket.h \ + hs_client/allocator.hpp hs_client/config.hpp \ + hs_client/mutex.hpp hs_client/string_util.hpp \ + hs_client/auto_addrinfo.hpp hs_client/escape.hpp \ + hs_client/socket.hpp hs_client/thread.hpp \ + hs_client/auto_file.hpp hs_client/fatal.hpp \ + hs_client/string_buffer.hpp hs_client/util.hpp \ + hs_client/auto_ptrcontainer.hpp \ + hs_client/hstcpcli.hpp hs_client/string_ref.hpp \ + hs_client/hs_compat.h + +lib_LTLIBRARIES = $(PLUGIN_SPIDER_LTLIBRARIES_TARGET) +EXTRA_LTLIBRARIES = ha_spider.la +pkgplugin_LTLIBRARIES = @plugin_spider_shared_target@ +ha_spider_la_LDFLAGS = -shared -module -rpath $(pkgplugindir) +ha_spider_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN \ + $(HAVE_HANDLERSOCKET) +ha_spider_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN \ + $(HAVE_HANDLERSOCKET) +ha_spider_la_SOURCES = \ + spd_param.cc \ + spd_sys_table.cc \ + spd_trx.cc \ + spd_db_conn.cc \ + spd_conn.cc \ + spd_table.cc \ + spd_direct_sql.cc \ + spd_udf.cc \ + spd_ping_table.cc \ + spd_copy_tables.cc \ + spd_i_s.cc \ + spd_malloc.cc \ + ha_spider.cc \ + spd_db_mysql.cc \ + spd_db_handlersocket.cc \ + hs_client/config.cpp \ + hs_client/escape.cpp \ + hs_client/fatal.cpp \ + hs_client/hstcpcli.cpp \ + hs_client/socket.cpp \ + hs_client/string_util.cpp + +lib_LIBRARIES = $(PLUGIN_SPIDER_LIBRARIES_TARGET) +EXTRA_LIBRARIES = libspider.a +noinst_LIBRARIES = @plugin_spider_static_target@ +libspider_a_CXXFLAGS = $(AM_CXXFLAGS) $(HAVE_HANDLERSOCKET) +libspider_a_CFLAGS = $(AM_CFLAGS) $(HAVE_HANDLERSOCKET) +libspider_a_SOURCES = \ + spd_param.cc \ + spd_sys_table.cc \ + spd_trx.cc \ + spd_db_conn.cc \ + spd_conn.cc \ + spd_table.cc \ + spd_direct_sql.cc \ + spd_udf.cc \ + spd_ping_table.cc \ + spd_copy_tables.cc \ + spd_i_s.cc \ + spd_malloc.cc \ + ha_spider.cc \ + spd_db_mysql.cc \ + spd_db_handlersocket.cc \ + hs_client/config.cpp \ + hs_client/escape.cpp \ + hs_client/fatal.cpp \ + hs_client/hstcpcli.cpp \ + hs_client/socket.cpp \ + hs_client/string_util.cpp + +EXTRA_DIST = plug.in +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/storage/spider/configure.in b/storage/spider/configure.in new file mode 100644 index 00000000000..6f103aed871 --- /dev/null +++ b/storage/spider/configure.in @@ -0,0 +1,95 @@ +AC_INIT([spider_engine], [1.0], [kentokushiba@gmail.com]) +AC_CONFIG_HEADERS([config.h]) +AM_INIT_AUTOMAKE + +AC_PROG_CC +AC_PROG_CXX +AC_PROG_LIBTOOL + +AC_TYPE_SIZE_T + +AC_DEFUN([MYSQL_PATH_TEST],[ + AC_MSG_CHECKING([mysql source path]) + AC_ARG_WITH([mysql], + [AS_HELP_STRING([--with-mysql=PATH],[mysql source directory PATH])], + [ + if test \ + -f $withval/include/mysql/plugin.h -a \ + -f $withval/include/mysql.h -a \ + -f $withval/include/errmsg.h -a \ + \( -f $withval/sql/mysql_priv.h -o -f $withval/sql/sql_priv.h \) ; + then + SPD_MYSQL_INC="$withval/" + AC_MSG_RESULT([yes]) + plugin_spider_shared_target="" + AC_SUBST(plugin_spider_shared_target) + plugin_spider_static_target="" + AC_SUBST(plugin_spider_static_target) + PLUGIN_SPIDER_LTLIBRARIES_TARGET="ha_spider.la" + AC_SUBST(PLUGIN_SPIDER_LTLIBRARIES_TARGET) + PLUGIN_SPIDER_LIBRARIES_TARGET="libspider.a" + AC_SUBST(PLUGIN_SPIDER_LIBRARIES_TARGET) + LIBTOOL="$LIBTOOL --preserve-dup-deps" + AC_SUBST(LIBTOOL) + else + AC_MSG_ERROR([Can't find header files. Please check --with-mysql=PATH option]) + fi + ], + [ + if test \ + -f ../../include/mysql/plugin.h -a \ + -f ../../include/mysql.h -a \ + -f ../../include/errmsg.h -a \ + \( -f ../../sql/mysql_priv.h -o ../../sql/sql_priv.h \) ; + then + SPD_MYSQL_INC="../../" + AC_MSG_RESULT([no]) + else + AC_MSG_ERROR([Can't find header files. Please set --with-mysql=PATH option]) + fi + ] + ) +]) + +MYSQL_PATH_TEST +AC_SUBST(SPD_MYSQL_INC) + +AC_DEFUN([MYSQL_INCLUDE_PATH_TEST],[ + AC_MSG_CHECKING([mysql include path]) + AC_ARG_WITH([mysql-include], + [AS_HELP_STRING([--with-mysql-include=PATH],[mysql include directory PATH])], + [ + if test \ + -f $withval/mysql_version.h -a \ + -f $withval/my_config.h ; + then + MYSQL_INCLUDE_PATH="-I $withval/" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR([Can't find "my_config.h". Please check --with-mysql-include=PATH option]) + fi + ], + [ + if test \ + -f ../../include/mysql_version.h -a \ + -f ../../include/my_config.h ; + then + MYSQL_INCLUDE_PATH="-I ../../include/" + AC_MSG_RESULT([no]) + else + AC_MSG_ERROR([Can't find "my_config.h". Please set --with-mysql-include=PATH option]) + fi + ] + ) +]) + +MYSQL_INCLUDE_PATH_TEST +AC_SUBST(MYSQL_INCLUDE_PATH) + +CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti" + + +AC_CHECK_FUNCS([memset strchr strncasecmp]) + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc new file mode 100644 index 00000000000..f2b79424ba0 --- /dev/null +++ b/storage/spider/ha_spider.cc @@ -0,0 +1,13545 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifdef USE_PRAGMA_IMPLEMENTATION +#pragma implementation +#endif + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "key.h" +#endif +#include "ha_partition.h" +#include "spd_param.h" +#include "spd_err.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "ha_spider.h" +#include "spd_table.h" +#include "spd_sys_table.h" +#include "spd_trx.h" +#include "spd_conn.h" +#include "spd_db_conn.h" +#include "spd_ping_table.h" +#include "spd_malloc.h" + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 +#define SPIDER_CAN_BG_SEARCH (1LL << 37) +#define SPIDER_CAN_BG_INSERT (1LL << 38) +#define SPIDER_CAN_BG_UPDATE (1LL << 39) +#else +#define SPIDER_CAN_BG_SEARCH (LL(1) << 37) +#define SPIDER_CAN_BG_INSERT (LL(1) << 38) +#define SPIDER_CAN_BG_UPDATE (LL(1) << 39) +#endif + +extern handlerton *spider_hton_ptr; +extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; + +ha_spider::ha_spider( +) : handler(spider_hton_ptr, NULL) +{ + DBUG_ENTER("ha_spider::ha_spider"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_alloc_calc_mem_init(mem_calc, 139); + spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); + share = NULL; + trx = NULL; + conns = NULL; + need_mons = NULL; + condition = NULL; + blob_buff = NULL; + conn_keys = NULL; + spider_thread_id = 0; + trx_conn_adjustment = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + trx_hs_r_conn_adjustment = 0; + trx_hs_w_conn_adjustment = 0; +#endif + search_link_query_id = 0; + searched_bitmap = NULL; +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_handler_share = NULL; + pt_handler_share_creator = NULL; +#endif +#ifdef HA_MRR_USE_DEFAULT_IMPL + multi_range_keys = NULL; +#endif + append_tblnm_alias = NULL; + is_clone = FALSE; + clone_bitmap_init = FALSE; + pt_clone_source_handler = NULL; + pt_clone_last_searcher = NULL; + ft_handler = NULL; + ft_first = NULL; + ft_current = NULL; + ft_count = 0; + ft_init_without_index_init = FALSE; + sql_kinds = 0; + error_mode = 0; + use_spatial_index = FALSE; + use_pre_call = FALSE; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + hs_pushed_ret_fields_num = MAX_FIELDS; + hs_pushed_ret_fields = NULL; + hs_pushed_ret_fields_size = 0; + hs_increment = FALSE; + hs_decrement = FALSE; + hs_pushed_strref_num = 0; +#endif + direct_update_fields = NULL; +#endif +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + info_limit = 9223372036854775807LL; +#endif +#ifdef HA_CAN_BULK_ACCESS + is_bulk_access_clone = FALSE; + synced_from_clone_source = FALSE; + bulk_access_started = FALSE; + bulk_access_executing = FALSE; + bulk_access_pre_called = FALSE; + bulk_access_link_first = NULL; +/* + init_ha_mem_root = FALSE; +*/ +#endif + result_link_idx = 0; + result_list.have_sql_kind_backup = FALSE; + result_list.sqls = NULL; + result_list.insert_sqls = NULL; + result_list.update_sqls = NULL; + result_list.tmp_sqls = NULL; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + result_list.hs_result_buf = NULL; +#endif + result_list.tmp_tables_created = FALSE; + result_list.bgs_working = FALSE; + result_list.direct_order_limit = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + result_list.hs_has_result = FALSE; +#endif + result_list.set_split_read = FALSE; + result_list.insert_dup_update_pushdown = FALSE; + result_list.tmp_pos_row_first = NULL; + DBUG_VOID_RETURN; +} + +ha_spider::ha_spider( + handlerton *hton, + TABLE_SHARE *table_arg +) : handler(hton, table_arg) +{ + DBUG_ENTER("ha_spider::ha_spider"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_alloc_calc_mem_init(mem_calc, 0); + spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); + share = NULL; + trx = NULL; + conns = NULL; + need_mons = NULL; + condition = NULL; + blob_buff = NULL; + conn_keys = NULL; + spider_thread_id = 0; + trx_conn_adjustment = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + trx_hs_r_conn_adjustment = 0; + trx_hs_w_conn_adjustment = 0; +#endif + search_link_query_id = 0; + searched_bitmap = NULL; +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_handler_share = NULL; + pt_handler_share_creator = NULL; +#endif +#ifdef HA_MRR_USE_DEFAULT_IMPL + multi_range_keys = NULL; +#endif + append_tblnm_alias = NULL; + is_clone = FALSE; + clone_bitmap_init = FALSE; + pt_clone_source_handler = NULL; + pt_clone_last_searcher = NULL; + ft_handler = NULL; + ft_first = NULL; + ft_current = NULL; + ft_count = 0; + ft_init_without_index_init = FALSE; + sql_kinds = 0; + error_mode = 0; + use_spatial_index = FALSE; + use_pre_call = FALSE; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + hs_pushed_ret_fields_num = MAX_FIELDS; + hs_pushed_ret_fields = NULL; + hs_pushed_ret_fields_size = 0; + hs_increment = FALSE; + hs_decrement = FALSE; + hs_pushed_strref_num = 0; +#endif + direct_update_fields = NULL; +#endif +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + info_limit = 9223372036854775807LL; +#endif +#ifdef HA_CAN_BULK_ACCESS + is_bulk_access_clone = FALSE; + synced_from_clone_source = FALSE; + bulk_access_started = FALSE; + bulk_access_executing = FALSE; + bulk_access_pre_called = FALSE; + bulk_access_link_first = NULL; +/* + init_ha_mem_root = FALSE; +*/ +#endif + result_link_idx = 0; + result_list.have_sql_kind_backup = FALSE; + result_list.sqls = NULL; + result_list.insert_sqls = NULL; + result_list.update_sqls = NULL; + result_list.tmp_sqls = NULL; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + result_list.hs_result_buf = NULL; +#endif + result_list.tmp_tables_created = FALSE; + result_list.bgs_working = FALSE; + result_list.direct_order_limit = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + result_list.hs_has_result = FALSE; +#endif + result_list.set_split_read = FALSE; + result_list.insert_dup_update_pushdown = FALSE; + result_list.tmp_pos_row_first = NULL; + ref_length = sizeof(SPIDER_POSITION); + DBUG_VOID_RETURN; +} + +ha_spider::~ha_spider() +{ + DBUG_ENTER("ha_spider::~ha_spider"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); + DBUG_VOID_RETURN; +} + +handler *ha_spider::clone( + const char *name, + MEM_ROOT *mem_root +) { + ha_spider *spider; + DBUG_ENTER("ha_spider::clone"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + !(spider = (ha_spider *) + get_new_handler(table->s, mem_root, spider_hton_ptr)) || + !(spider->ref = (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length) * 2)) + ) + DBUG_RETURN(NULL); + spider->is_clone = TRUE; + spider->pt_clone_source_handler = this; + if (spider->ha_open(table, name, table->db_stat, + HA_OPEN_IGNORE_IF_LOCKED)) + DBUG_RETURN(NULL); + spider->sync_from_clone_source_base(this); + + DBUG_RETURN((handler *) spider); +} + +static const char *ha_spider_exts[] = { + NullS +}; + +const char **ha_spider::bas_ext() const +{ + return ha_spider_exts; +} + +int ha_spider::open( + const char* name, + int mode, + uint test_if_locked +) { + THD *thd = ha_thd(); + int error_num, roop_count; + int init_sql_alloc_size; +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARTITION_SHARE *partition_share; + uchar *idx_read_bitmap, *idx_write_bitmap, + *rnd_read_bitmap, *rnd_write_bitmap; + uint part_num; + bool create_pt_handler_share = FALSE, pt_handler_mutex = FALSE, + may_be_clone = FALSE; + ha_spider **pt_handler_share_handlers; +#endif +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value; +#endif + DBUG_ENTER("ha_spider::open"); + DBUG_PRINT("info",("spider this=%p", this)); + + dup_key_idx = (uint) -1; + conn_kinds = SPIDER_CONN_KIND_MYSQL; + if (!spider_get_share(name, table, thd, this, &error_num)) + goto error_get_share; + thr_lock_data_init(&share->lock,&lock,NULL); + +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_share = share->partition_share; + table->file->get_no_parts("", &part_num); + if (partition_share) + { + pt_handler_mutex = TRUE; + pthread_mutex_lock(&partition_share->pt_handler_mutex); +/* + if ( + !partition_share->partition_handler_share || + partition_share->partition_handler_share->table != table + ) + create_pt_handler_share = TRUE; +*/ +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + hash_value = my_calc_hash(&partition_share->pt_handler_hash, + (uchar*) &table, sizeof(TABLE *)); + if (!(partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE*) + my_hash_search_using_hash_value(&partition_share->pt_handler_hash, + hash_value, (uchar*) &table, sizeof(TABLE *)))) +#else + if (!(partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE*) + my_hash_search(&partition_share->pt_handler_hash, (uchar*) &table, + sizeof(TABLE *)))) +#endif + { + create_pt_handler_share = TRUE; + } + } + + if (create_pt_handler_share) + { + if (!(searched_bitmap = (uchar *) + spider_bulk_malloc(spider_current_trx, 15, MYF(MY_WME), + &searched_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), + &position_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), + &partition_handler_share, sizeof(SPIDER_PARTITION_HANDLER_SHARE), + &idx_read_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), + &idx_write_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), + &rnd_read_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), + &rnd_write_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), + &pt_handler_share_handlers, sizeof(ha_spider *) * part_num, + NullS)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_searched_bitmap_alloc; + } + DBUG_PRINT("info",("spider create partition_handler_share")); + partition_handler_share->use_count = 1; +/* + if (partition_handler_share->use_count < part_num) + partition_share->partition_handler_share = partition_handler_share; +*/ + DBUG_PRINT("info",("spider table=%p", table)); + partition_handler_share->table = table; + partition_handler_share->searched_bitmap = NULL; + partition_handler_share->idx_read_bitmap = idx_read_bitmap; + partition_handler_share->idx_write_bitmap = idx_write_bitmap; + partition_handler_share->rnd_read_bitmap = rnd_read_bitmap; + partition_handler_share->rnd_write_bitmap = rnd_write_bitmap; + partition_handler_share->between_flg = FALSE; + partition_handler_share->idx_bitmap_is_set = FALSE; + partition_handler_share->rnd_bitmap_is_set = FALSE; + partition_handler_share->table_hash_value = hash_value; + partition_handler_share->creator = this; + pt_handler_share_creator = this; + if (part_num) + { + partition_handler_share->handlers = (void **) pt_handler_share_handlers; + partition_handler_share->handlers[0] = this; + } else + partition_handler_share->handlers = NULL; + uint old_elements = partition_share->pt_handler_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&partition_share->pt_handler_hash, + hash_value, (uchar*) partition_handler_share)) +#else + if (my_hash_insert(&partition_share->pt_handler_hash, + (uchar*) partition_handler_share)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_hash_insert; + } + if (partition_share->pt_handler_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + partition_share->pt_handler_hash, + (partition_share->pt_handler_hash.array.max_element - old_elements) * + partition_share->pt_handler_hash.array.size_of_element); + } + pthread_mutex_unlock(&partition_share->pt_handler_mutex); + pt_handler_mutex = FALSE; + } else { +#endif + if (!(searched_bitmap = (uchar *) + spider_bulk_malloc(spider_current_trx, 16, MYF(MY_WME), + &searched_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), + &position_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set), + NullS)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_searched_bitmap_alloc; + } +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (partition_share) + { + DBUG_PRINT("info",("spider copy partition_handler_share")); +/* + partition_handler_share = (SPIDER_PARTITION_HANDLER_SHARE *) + partition_share->partition_handler_share; +*/ + if (part_num) + { + if (partition_handler_share->use_count >= part_num) + may_be_clone = TRUE; + else { + partition_handler_share->handlers[ + partition_handler_share->use_count] = this; + partition_handler_share->use_count++; + } + } +/* + if (partition_handler_share->use_count == part_num) + partition_share->partition_handler_share = NULL; +*/ + pthread_mutex_unlock(&partition_share->pt_handler_mutex); + pt_handler_mutex = FALSE; + } + } +#endif + + init_sql_alloc_size = + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); + + result_list.table = table; + result_list.first = NULL; + result_list.last = NULL; + result_list.current = NULL; + result_list.record_num = 0; + if ( + !(result_list.sqls = new spider_string[share->link_count]) || + !(result_list.insert_sqls = new spider_string[share->link_count]) || + !(result_list.update_sqls = new spider_string[share->link_count]) || + !(result_list.tmp_sqls = new spider_string[share->link_count]) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_result_list; + } + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + result_list.sqls[roop_count].init_calc_mem(80); + result_list.insert_sqls[roop_count].init_calc_mem(81); + result_list.update_sqls[roop_count].init_calc_mem(82); + result_list.tmp_sqls[roop_count].init_calc_mem(83); + uint all_link_idx = conn_link_idx[roop_count]; + uint dbton_id = share->sql_dbton_ids[all_link_idx]; + if (share->dbton_share[dbton_id]->need_change_db_table_name()) + { + if ( + result_list.sqls[roop_count].real_alloc(init_sql_alloc_size) || + result_list.insert_sqls[roop_count].real_alloc(init_sql_alloc_size) || + result_list.update_sqls[roop_count].real_alloc(init_sql_alloc_size) || + result_list.tmp_sqls[roop_count].real_alloc(init_sql_alloc_size) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_result_list; + } + } + result_list.sqls[roop_count].set_charset(share->access_charset); + result_list.insert_sqls[roop_count].set_charset(share->access_charset); + result_list.update_sqls[roop_count].set_charset(share->access_charset); + result_list.tmp_sqls[roop_count].set_charset(share->access_charset); + } + + DBUG_PRINT("info",("spider blob_fields=%d", table_share->blob_fields)); + if (table_share->blob_fields) + { + if (!(blob_buff = new spider_string[table_share->fields])) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_blob_buff; + } + for (roop_count = 0; roop_count < (int) table_share->fields; roop_count++) + { + blob_buff[roop_count].init_calc_mem(84); + blob_buff[roop_count].set_charset(table->field[roop_count]->charset()); + } + } + +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (may_be_clone && thd_sql_command(thd) != SQLCOM_ALTER_TABLE) + is_clone = TRUE; +#endif + if (is_clone) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (part_num) + { + for (roop_count = 0; roop_count < (int) part_num; roop_count++) + { + if (((ha_spider *) partition_handler_share->handlers[roop_count])-> + share == share) + { + pt_clone_source_handler = + (ha_spider *) partition_handler_share->handlers[roop_count]; + break; + } + } + } +#endif + + sql_command = pt_clone_source_handler->sql_command; + result_list.lock_type = pt_clone_source_handler->result_list.lock_type; + lock_mode = pt_clone_source_handler->lock_mode; + + if (!pt_clone_source_handler->clone_bitmap_init) + { + pt_clone_source_handler->set_select_column_mode(); + pt_clone_source_handler->clone_bitmap_init = TRUE; + } + set_clone_searched_bitmap(); + position_bitmap_init = FALSE; + } +#ifdef HA_CAN_BULK_ACCESS + external_lock_cnt = 0; +#endif + + if (reset()) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_reset; + } + + DBUG_RETURN(0); + +error_reset: + delete [] blob_buff; + blob_buff = NULL; +error_init_blob_buff: +error_init_result_list: +#ifdef WITH_PARTITION_STORAGE_ENGINE + if ( + partition_handler_share && + pt_handler_share_creator == this + ) { + partition_share = share->partition_share; + if (!pt_handler_mutex) + pthread_mutex_lock(&partition_share->pt_handler_mutex); +/* + if (partition_share->partition_handler_share == partition_handler_share) + partition_share->partition_handler_share = NULL; +*/ +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&partition_share->pt_handler_hash, + partition_handler_share->table_hash_value, + (uchar*) partition_handler_share); +#else + my_hash_delete(&partition_share->pt_handler_hash, + (uchar*) partition_handler_share); +#endif + pthread_mutex_unlock(&partition_share->pt_handler_mutex); + pt_handler_mutex = FALSE; + } +error_hash_insert: + partition_handler_share = NULL; + pt_handler_share_creator = NULL; +#endif + if (searched_bitmap) + { + spider_free(spider_current_trx, searched_bitmap, MYF(0)); + searched_bitmap = NULL; + } +error_searched_bitmap_alloc: + if (pt_handler_mutex) + pthread_mutex_unlock(&partition_share->pt_handler_mutex); + spider_free_share(share); + share = NULL; +error_get_share: + if (conn_keys) + { + spider_free(spider_current_trx, conn_keys, MYF(0)); + conn_keys = NULL; + } + DBUG_RETURN(error_num); +} + +int ha_spider::close() +{ + int error_num = 0, roop_count, error_num2; + THD *thd = ha_thd(); +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARTITION_SHARE *partition_share; +#endif + backup_error_status(); + DBUG_ENTER("ha_spider::close"); + DBUG_PRINT("info",("spider this=%p", this)); + +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (multi_range_keys) + { + DBUG_PRINT("info",("spider free multi_range_keys=%p", multi_range_keys)); + spider_free(spider_current_trx, multi_range_keys, MYF(0)); + multi_range_keys = NULL; + } +#endif +#ifdef HA_CAN_BULK_ACCESS + if (bulk_access_link_first) + { + do { + DBUG_PRINT("info",("spider bulk_access_link->spider=%p", + bulk_access_link_first->spider)); + DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", + bulk_access_link_first->spider->dbton_handler)); + DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", + &bulk_access_link_first->spider->dbton_handler)); + bulk_access_link_current = bulk_access_link_first->next; + delete_bulk_access_link(bulk_access_link_first); + bulk_access_link_first = bulk_access_link_current; + } while (bulk_access_link_first); + } +#endif + if (is_clone) + { + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + if ((error_num2 = close_opened_handler(roop_count, FALSE))) + { + if (check_error_mode(error_num2)) + error_num = error_num2; + } + } + } + for (roop_count = share->use_dbton_count - 1; roop_count >= 0; roop_count--) + { + uint dbton_id = share->use_dbton_ids[roop_count]; + if (dbton_handler[dbton_id]) + { + delete dbton_handler[dbton_id]; + dbton_handler[dbton_id] = NULL; + } + } + + if (!thd || !*thd_ha_data(thd, spider_hton_ptr)) + { + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + conns[roop_count] = NULL; + } + + if (ft_first) + { + st_spider_ft_info *tmp_ft_info; + do { + tmp_ft_info = ft_first->next; + spider_free(spider_current_trx, ft_first, MYF(0)); + ft_first = tmp_ft_info; + } while (ft_first); + } + + spider_db_free_result(this, TRUE); + if (conn_keys) + { + spider_free(spider_current_trx, conn_keys, MYF(0)); + conn_keys = NULL; + } +#ifdef WITH_PARTITION_STORAGE_ENGINE + if ( + partition_handler_share && + pt_handler_share_creator == this + ) { + partition_share = share->partition_share; + pthread_mutex_lock(&partition_share->pt_handler_mutex); +/* + if (partition_share->partition_handler_share == partition_handler_share) + partition_share->partition_handler_share = NULL; +*/ +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&partition_share->pt_handler_hash, + partition_handler_share->table_hash_value, + (uchar*) partition_handler_share); +#else + my_hash_delete(&partition_share->pt_handler_hash, + (uchar*) partition_handler_share); +#endif + pthread_mutex_unlock(&partition_share->pt_handler_mutex); + } + partition_handler_share = NULL; + pt_handler_share_creator = NULL; +#endif + if (searched_bitmap) + { + spider_free(spider_current_trx, searched_bitmap, MYF(0)); + searched_bitmap = NULL; + } + if (blob_buff) + { + delete [] blob_buff; + blob_buff = NULL; + } + if (result_list.sqls) + { + delete [] result_list.sqls; + result_list.sqls = NULL; + } + if (result_list.insert_sqls) + { + delete [] result_list.insert_sqls; + result_list.insert_sqls = NULL; + } + if (result_list.update_sqls) + { + delete [] result_list.update_sqls; + result_list.update_sqls = NULL; + } + if (result_list.tmp_sqls) + { + delete [] result_list.tmp_sqls; + result_list.tmp_sqls = NULL; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (result_list.hs_result_buf) + { + delete result_list.hs_result_buf; + result_list.hs_result_buf = NULL; + } +#endif + + spider_free_share(share); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if (hs_pushed_ret_fields) + { + spider_free(spider_current_trx, hs_pushed_ret_fields, MYF(0)); + hs_pushed_ret_fields = NULL; + hs_pushed_ret_fields_size = 0; + } +#endif +#endif +#ifdef HA_CAN_BULK_ACCESS +/* + if (init_ha_mem_root) + { + free_root(&ha_mem_root, MYF(0)); + init_ha_mem_root = FALSE; + } +*/ +#endif + is_clone = FALSE; + pt_clone_source_handler = NULL; + share = NULL; + trx = NULL; + conns = NULL; + + DBUG_RETURN(error_num); +} + +int ha_spider::check_access_kind( + THD *thd, + bool write_request +) { + int error_num, roop_count; + DBUG_ENTER("ha_spider::check_access_kind"); + DBUG_PRINT("info",("spider this=%p", this)); + sql_command = thd_sql_command(thd); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = FALSE; + maybe_do_hs_direct_update = FALSE; +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + memset(do_hs_direct_update, 0, share->link_bitmap_size); +#endif +#endif + conn_kinds = 0; + switch (sql_command) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + case SQLCOM_HS_READ: + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + if (!write_request) + { + DBUG_PRINT("info",("spider spider_use_hs_read=%d", + spider_param_use_hs_read(thd, share->use_hs_reads[roop_count]))); + DBUG_PRINT("info",("spider use_hs_reads[%d]=%ld", roop_count, + share->use_hs_reads[roop_count])); + if (spider_param_use_hs_read(thd, share->use_hs_reads[roop_count])) + { + DBUG_PRINT("info",("spider set %d to HS_READ", roop_count)); + conn_kinds |= SPIDER_CONN_KIND_HS_READ; + conn_kind[roop_count] = SPIDER_CONN_KIND_HS_READ; + } else { + conn_kinds |= SPIDER_CONN_KIND_MYSQL; + conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + } + } else if (share->hs_write_to_reads[roop_count]) + { + DBUG_PRINT("info",("spider spider_use_hs_write=%d", + spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); + DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, + share->use_hs_writes[roop_count])); + if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) + { + DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); + conn_kinds |= SPIDER_CONN_KIND_HS_READ; + conn_kind[roop_count] = SPIDER_CONN_KIND_HS_READ; + } else { + conn_kinds |= SPIDER_CONN_KIND_MYSQL; + conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + } + } else { + DBUG_PRINT("info",("spider spider_use_hs_write=%d", + spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); + DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, + share->use_hs_writes[roop_count])); + if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) + { + DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); + conn_kinds |= SPIDER_CONN_KIND_HS_WRITE; + conn_kind[roop_count] = SPIDER_CONN_KIND_HS_WRITE; + } else { + conn_kinds |= SPIDER_CONN_KIND_MYSQL; + conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + } + } + } + break; + case SQLCOM_HS_UPDATE: + case SQLCOM_HS_DELETE: +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = TRUE; + maybe_do_hs_direct_update = TRUE; +#endif + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + conn_kinds |= SPIDER_CONN_KIND_MYSQL; + conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) + { + DBUG_PRINT("info",("spider do_hs_direct_update[%d]=TRUE", + roop_count)); + spider_set_bit(do_hs_direct_update, roop_count); + } else { + maybe_do_hs_direct_update = FALSE; + } +#endif + } + break; + case SQLCOM_HS_INSERT: + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + DBUG_PRINT("info",("spider spider_use_hs_write=%d", + spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); + DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, + share->use_hs_writes[roop_count])); + if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) + { + DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); + conn_kinds |= SPIDER_CONN_KIND_HS_WRITE; + conn_kind[roop_count] = SPIDER_CONN_KIND_HS_WRITE; + } else { + conn_kinds |= SPIDER_CONN_KIND_MYSQL; + conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + } + } + break; +#endif + case SQLCOM_UPDATE: + case SQLCOM_UPDATE_MULTI: + case SQLCOM_DELETE: + case SQLCOM_DELETE_MULTI: +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = TRUE; +#endif + default: + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + conn_kinds |= SPIDER_CONN_KIND_MYSQL; + conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + } + break; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = reset_hs_strs_pos(SPIDER_SQL_TYPE_UPDATE_HS))) + { + DBUG_RETURN(error_num); + } +#endif + if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE))) + { + DBUG_RETURN(error_num); + } + DBUG_PRINT("info",("spider sql_command=%u", sql_command)); + DBUG_PRINT("info",("spider thd->query_id=%lld", thd->query_id)); + if ( +#ifdef HS_HAS_SQLCOM + sql_command == SQLCOM_HS_UPDATE || +#endif + sql_command == SQLCOM_UPDATE || + sql_command == SQLCOM_UPDATE_MULTI + ) + update_request = TRUE; + else + update_request = FALSE; + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::additional_lock( + THD *thd, + enum thr_lock_type lock_type +) { + DBUG_ENTER("ha_spider::additional_lock"); + DBUG_PRINT("info",("spider this=%p", this)); + if (bulk_access_executing) + { + if (is_bulk_access_clone) + { + DBUG_RETURN(check_access_kind(thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); + } else if (bulk_access_link_exec_tgt->called) + { + DBUG_RETURN(bulk_access_link_exec_tgt->spider->check_access_kind( + thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); + } + } + DBUG_RETURN(check_access_kind(thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); +} +#endif + +THR_LOCK_DATA **ha_spider::store_lock( + THD *thd, + THR_LOCK_DATA **to, + enum thr_lock_type lock_type +) { + int error_num, roop_count; + DBUG_ENTER("ha_spider::store_lock"); + DBUG_PRINT("info",("spider this=%p", this)); + if (lock_type == TL_IGNORE) + { + *to++ = &lock; + DBUG_RETURN(to); + } + if ((error_num = check_access_kind(thd, + (lock_type >= TL_WRITE_ALLOW_WRITE)))) + { + store_error_num = error_num; + DBUG_RETURN(to); + } + DBUG_PRINT("info",("spider sql_command=%u", sql_command)); + DBUG_PRINT("info",("spider lock_type=%d", lock_type)); + DBUG_PRINT("info",("spider thd->query_id=%lld", thd->query_id)); + if (sql_command == SQLCOM_ALTER_TABLE) + { + if (trx->query_id != thd->query_id) + { + spider_free_trx_alter_table(trx); + trx->query_id = thd->query_id; + trx->tmp_flg = FALSE; + } + if (!(SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, + (uchar*) share->table_name, share->table_name_length)) + { + if (spider_create_trx_alter_table(trx, share, FALSE)) + { + store_error_num = HA_ERR_OUT_OF_MEM; + DBUG_RETURN(to); + } + } + } + + this->lock_type = lock_type; + selupd_lock_mode = spider_param_selupd_lock_mode(thd, + share->selupd_lock_mode); + if ( + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE + ) { + SPIDER_SET_CONNS_PARAM(semi_trx_chk, FALSE, conns, share->link_statuses, + conn_link_idx, (int) share->link_count, SPIDER_LINK_STATUS_RECOVERY); + } + switch (sql_command) + { + case SQLCOM_SELECT: + case SQLCOM_HA_READ: +#ifdef HS_HAS_SQLCOM + case SQLCOM_HS_READ: +#endif + if (lock_type == TL_READ_WITH_SHARED_LOCKS) + lock_mode = 1; + else if (lock_type <= TL_READ_NO_INSERT) + { + lock_mode = 0; + SPIDER_SET_CONNS_PARAM(semi_trx_isolation_chk, TRUE, conns, + share->link_statuses, conn_link_idx, (int) share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + } else + lock_mode = -1; + SPIDER_SET_CONNS_PARAM(semi_trx_chk, TRUE, conns, share->link_statuses, + conn_link_idx, (int) share->link_count, SPIDER_LINK_STATUS_RECOVERY); + break; + case SQLCOM_UPDATE: + case SQLCOM_UPDATE_MULTI: +#ifdef HS_HAS_SQLCOM + case SQLCOM_HS_UPDATE: +#endif + case SQLCOM_CREATE_TABLE: + case SQLCOM_INSERT: + case SQLCOM_INSERT_SELECT: + case SQLCOM_DELETE: + case SQLCOM_LOAD: + case SQLCOM_REPLACE: + case SQLCOM_REPLACE_SELECT: + case SQLCOM_DELETE_MULTI: +#ifdef HS_HAS_SQLCOM + case SQLCOM_HS_INSERT: + case SQLCOM_HS_DELETE: +#endif + if (lock_type >= TL_READ && lock_type <= TL_READ_NO_INSERT) + { + lock_mode = selupd_lock_mode; + SPIDER_SET_CONNS_PARAM(semi_trx_isolation_chk, TRUE, conns, + share->link_statuses, conn_link_idx, (int) share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + } else + lock_mode = -1; + SPIDER_SET_CONNS_PARAM(semi_trx_chk, TRUE, conns, share->link_statuses, + conn_link_idx, (int) share->link_count, SPIDER_LINK_STATUS_RECOVERY); + break; + default: + lock_mode = -1; + } + switch (lock_type) + { + case TL_READ_HIGH_PRIORITY: + high_priority = TRUE; + break; + case TL_WRITE_DELAYED: + insert_delayed = TRUE; + break; + case TL_WRITE_LOW_PRIORITY: + low_priority = TRUE; + break; + default: + break; + } + + if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) + { + if ( + sql_command == SQLCOM_DROP_TABLE || + sql_command == SQLCOM_ALTER_TABLE || + sql_command == SQLCOM_SHOW_CREATE + ) { + if ( + lock_type == TL_READ_NO_INSERT && + !thd->in_lock_tables + ) + lock_type = TL_READ; + if ( + lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE && + !thd->in_lock_tables && !thd_tablespace_op(thd) + ) + lock_type = TL_WRITE_ALLOW_WRITE; + } else if ( + sql_command == SQLCOM_LOCK_TABLES || + (spider_param_lock_exchange(thd) == 1 && share->semi_table_lock)) + { + if ( + ( + this->lock_type == TL_READ || + this->lock_type == TL_READ_NO_INSERT || + this->lock_type == TL_WRITE_LOW_PRIORITY || + this->lock_type == TL_WRITE + ) && + !spider_param_local_lock_table(thd) + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + SPIDER_CONN *conn = conns[roop_count]; + int appended = 0; + if ((error_num = dbton_handler[conn->dbton_id]-> + append_lock_tables_list(conn, roop_count, &appended))) + { + store_error_num = error_num; + DBUG_RETURN(to); + } + if (appended) + { + conn->table_lock = 2; + } + } + } + } else { + if ( + this->lock_type == TL_READ || + this->lock_type == TL_READ_NO_INSERT || + this->lock_type == TL_WRITE_LOW_PRIORITY || + this->lock_type == TL_WRITE + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if ( + conns[roop_count] && + conns[roop_count]->table_lock != 1 && + spider_param_semi_table_lock(thd, share->semi_table_lock) && + !spider_param_local_lock_table(thd) + ) { + SPIDER_CONN *conn = conns[roop_count]; + int appended = 0; + if ((error_num = dbton_handler[conn->dbton_id]-> + append_lock_tables_list(conn, roop_count, &appended))) + { + store_error_num = error_num; + DBUG_RETURN(to); + } + if (appended) + { + conn->table_lock = 3; + } + } + } + } + if ( + lock_type == TL_READ_NO_INSERT && + !thd->in_lock_tables + ) + lock_type = TL_READ; + if ( + lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE && + !thd->in_lock_tables && !thd_tablespace_op(thd) + ) + lock_type = TL_WRITE_ALLOW_WRITE; + } + lock.type = lock_type; + } + *to++ = &lock; + DBUG_RETURN(to); +} + +int ha_spider::external_lock( + THD *thd, + int lock_type +) { + int error_num, roop_count; + bool sync_trx_isolation = spider_param_sync_trx_isolation(thd); + backup_error_status(); + DBUG_ENTER("ha_spider::external_lock"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider lock_type=%x", lock_type)); +#if MYSQL_VERSION_ID < 50500 + DBUG_PRINT("info",("spider thd->options=%x", (int) thd->options)); +#endif +#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC + info_auto_called = FALSE; +#endif + + sql_command = thd_sql_command(thd); + if (sql_command == SQLCOM_BEGIN) + sql_command = SQLCOM_UNLOCK_TABLES; + if ( + sql_command == SQLCOM_UNLOCK_TABLES && + (error_num = spider_check_trx_and_get_conn(thd, this, + FALSE)) + ) { + DBUG_RETURN(error_num); + } + + DBUG_PRINT("info",("spider sql_command=%d", sql_command)); + DBUG_ASSERT(trx == spider_get_trx(thd, TRUE, &error_num)); +#ifdef HA_CAN_BULK_ACCESS + external_lock_cnt++; +#endif + if (store_error_num) + DBUG_RETURN(store_error_num); + if ( + lock_type == F_UNLCK && + sql_command != SQLCOM_UNLOCK_TABLES + ) + DBUG_RETURN(0); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((conn_kinds & SPIDER_CONN_KIND_MYSQL)) + { +#endif + if ( + /* SQLCOM_RENAME_TABLE and SQLCOM_DROP_DB don't come here */ + sql_command == SQLCOM_DROP_TABLE || + sql_command == SQLCOM_ALTER_TABLE + ) { + if (trx->locked_connections) + { + my_message(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM, + ER_SPIDER_ALTER_BEFORE_UNLOCK_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM); + } + DBUG_RETURN(0); + } + if (!conns[search_link_idx]) + { + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if (sql_command == SQLCOM_TRUNCATE) + DBUG_RETURN(0); + else if (sql_command != SQLCOM_UNLOCK_TABLES) + { + if ( + (!conns[roop_count]->join_trx && + (error_num = spider_internal_start_trx(this, conns[roop_count], + roop_count))) + ) { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode(error_num)); + } + result_list.lock_type = lock_type; + reset_first_link_idx(); + if ( + conns[roop_count]->semi_trx_isolation == -2 && + conns[roop_count]->semi_trx_isolation_chk == TRUE && + sync_trx_isolation && + spider_param_semi_trx_isolation(trx->thd) >= 0 + ) { +/* + if (conns[roop_count]->trx_isolation != + spider_param_semi_trx_isolation(trx->thd)) + { +*/ + spider_conn_queue_semi_trx_isolation(conns[roop_count], + spider_param_semi_trx_isolation(trx->thd)); +/* + } + conns[roop_count]->semi_trx_isolation = + spider_param_semi_trx_isolation(trx->thd); + conns[roop_count]->trx_isolation = + thd_tx_isolation(conns[roop_count]->thd); + DBUG_PRINT("info",("spider conn=%p", conns[roop_count])); + DBUG_PRINT("info",("spider conn->trx_isolation=%d", + conns[roop_count]->trx_isolation)); +*/ + } else { + if (sync_trx_isolation) + { + if ((error_num = spider_check_and_set_trx_isolation( + conns[roop_count], &need_mons[roop_count]))) + { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode(error_num)); + } + } + conns[roop_count]->semi_trx_isolation = -1; + } + } + if (conns[roop_count]->table_lock >= 2) + { + if ( + conns[roop_count]->db_conn->have_lock_table_list() && + (error_num = spider_db_lock_tables(this, roop_count)) + ) { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + conns[roop_count]->table_lock = 0; + DBUG_RETURN(check_error_mode(error_num)); + } + if (conns[roop_count]->table_lock == 2) + conns[roop_count]->table_lock = 1; + } else if (sql_command == SQLCOM_UNLOCK_TABLES || + spider_param_internal_unlock(thd) == 1) + { + if (conns[roop_count]->table_lock == 1) + { + conns[roop_count]->table_lock = 0; + if (!conns[roop_count]->trx_start) + conns[roop_count]->disable_reconnect = FALSE; + if ((error_num = spider_db_unlock_tables(this, roop_count))) + { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode(error_num)); + } + } + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + result_list.lock_type = lock_type; + reset_first_link_idx(); + trans_register_ha(trx->thd, FALSE, spider_hton_ptr); + if (thd_test_options(trx->thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + trans_register_ha(trx->thd, TRUE, spider_hton_ptr); + } + if ((conn_kinds & SPIDER_CONN_KIND_HS_READ)) + { + SPIDER_CONN *hs_conn; + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + hs_conn = hs_r_conns[roop_count]; + if ( + hs_conn && + hs_conn->hsc_query_id != thd->query_id && + hs_conn->hs_pre_age == hs_conn->hs_age + ) { + double interval = spider_param_hs_ping_interval(thd); + time_t tmp_time = (time_t) time((time_t*) 0); + DBUG_PRINT("info", + ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); + DBUG_PRINT("info", ("spider interval=%f", interval)); + if ( + hs_conn->server_lost || + difftime(tmp_time, hs_conn->ping_time) >= interval + ) { + DBUG_PRINT("info", ("spider hsr[%d] need reconnect", roop_count)); + hs_conn->hs_pre_age++; + hs_conn->ping_time = tmp_time; + } + hs_conn->hsc_query_id = thd->query_id; + } + } + } + if ( +#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) + ( +#endif + conn_kinds & SPIDER_CONN_KIND_HS_WRITE +#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) + ) || + ( + do_direct_update && + ( + sql_command == SQLCOM_HS_UPDATE || + sql_command == SQLCOM_HS_DELETE + ) + ) +#endif + ) { + SPIDER_CONN *hs_conn; + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + hs_conn = hs_w_conns[roop_count]; + if ( + hs_conn && + hs_conn->hsc_query_id != thd->query_id && + hs_conn->hs_pre_age == hs_conn->hs_age + ) { + double interval = spider_param_hs_ping_interval(thd); + time_t tmp_time = (time_t) time((time_t*) 0); + DBUG_PRINT("info", + ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); + DBUG_PRINT("info", ("spider interval=%f", interval)); + if ( + hs_conn->server_lost || + difftime(tmp_time, hs_conn->ping_time) >= interval + ) { + DBUG_PRINT("info", ("spider hsw[%d] need reconnect", roop_count)); + hs_conn->hs_pre_age++; + hs_conn->ping_time = tmp_time; + } + hs_conn->hsc_query_id = thd->query_id; + } + } + } +#endif + DBUG_RETURN(0); +} + +int ha_spider::reset() +{ + int error_num = 0, error_num2, roop_count; + THD *thd = ha_thd(); + SPIDER_TRX *tmp_trx, *trx_bak; + SPIDER_CONDITION *tmp_cond; +/* + char first_byte, first_byte_bak; +*/ + backup_error_status(); + DBUG_ENTER("ha_spider::reset"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef HA_CAN_BULK_ACCESS + SPIDER_BULK_ACCESS_LINK *tmp_bulk_access_link = bulk_access_link_first; + while (tmp_bulk_access_link) + { + DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", + tmp_bulk_access_link->spider->dbton_handler)); + DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", + &tmp_bulk_access_link->spider->dbton_handler)); + if (!tmp_bulk_access_link->used) + break; + if ((error_num2 = tmp_bulk_access_link->spider->ha_reset())) + error_num = error_num2; + tmp_bulk_access_link->used = FALSE; + tmp_bulk_access_link = tmp_bulk_access_link->next; + } + synced_from_clone_source = FALSE; + bulk_access_started = FALSE; + bulk_access_executing = FALSE; + bulk_access_pre_called = FALSE; + if ( + bulk_access_link_first && + !spider_param_bulk_access_free(share->bulk_access_free) + ) { + do { + DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", + bulk_access_link_first->spider->dbton_handler)); + DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", + &bulk_access_link_first->spider->dbton_handler)); + bulk_access_link_current = bulk_access_link_first->next; + delete_bulk_access_link(bulk_access_link_first); + bulk_access_link_first = bulk_access_link_current; + } while (bulk_access_link_first); + } +#endif + store_error_num = 0; +#ifdef WITH_PARTITION_STORAGE_ENGINE + if ( + partition_handler_share && + partition_handler_share->searched_bitmap + ) { + if (!is_clone) + partition_handler_share->searched_bitmap = NULL; + partition_handler_share->between_flg = FALSE; + partition_handler_share->idx_bitmap_is_set = FALSE; + partition_handler_share->rnd_bitmap_is_set = FALSE; + } +#endif + if (!(tmp_trx = spider_get_trx(thd, TRUE, &error_num2))) + { + DBUG_PRINT("info",("spider get trx error")); + if (check_error_mode(error_num2)) + error_num = error_num2; + } + if (share) + { + trx_bak = trx; + trx = tmp_trx; + if ((error_num2 = spider_db_free_result(this, FALSE))) + error_num = error_num2; + trx = trx_bak; +/* + int semi_table_lock_conn = spider_param_semi_table_lock_connection(thd, + share->semi_table_lock_conn); + if (semi_table_lock_conn) + first_byte = '0' + + spider_param_semi_table_lock(thd, share->semi_table_lock); + else + first_byte = '0'; + DBUG_PRINT("info",("spider semi_table_lock_conn = %d", + semi_table_lock_conn)); + DBUG_PRINT("info",("spider semi_table_lock = %d", + spider_param_semi_table_lock(thd, share->semi_table_lock))); + DBUG_PRINT("info",("spider first_byte = %d", first_byte)); + if (tmp_trx->spider_thread_id != spider_thread_id || + (tmp_trx->trx_conn_adjustment != trx_conn_adjustment && + tmp_trx->trx_conn_adjustment - 1 != trx_conn_adjustment) || + first_byte != *conn_keys[0] + ) { + DBUG_PRINT("info",(first_byte != *conn_keys[0] ? + "spider change conn type" : tmp_trx != trx ? "spider change thd" : + "spider next trx")); + trx = tmp_trx; + spider_thread_id = tmp_trx->spider_thread_id; + trx_conn_adjustment = tmp_trx->trx_conn_adjustment; + + first_byte_bak = *conn_keys[0]; + *conn_keys[0] = first_byte; + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + *conn_keys[roop_count] = first_byte; + if ( + !(conns[roop_count] = + spider_get_conn(share, roop_count, conn_keys[roop_count], trx, + this, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL, &error_num)) + ) { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_PRINT("info",("spider get conn error")); + *conn_keys[0] = first_byte_bak; + conns[0] = NULL; + DBUG_RETURN(error_num); + } + } + } +*/ + memset(need_mons, 0, sizeof(int) * share->link_count); + rm_bulk_tmp_table(); + for (roop_count = share->link_count - 1; roop_count >= 0; roop_count--) + { + result_list.update_sqls[roop_count].length(0); + + if ((error_num2 = close_opened_handler(roop_count, TRUE))) + { + if (check_error_mode(error_num2)) + error_num = error_num2; + } + + conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + } + result_list.bulk_update_mode = 0; + result_list.bulk_update_size = 0; + result_list.bulk_update_start = SPD_BU_NOT_START; + for (roop_count = 0; roop_count < (int) share->use_dbton_count; + roop_count++) + { + uint dbton_id = share->use_dbton_ids[roop_count]; + if ((error_num2 = dbton_handler[dbton_id]->reset())) + { + if (check_error_mode(error_num2)) + error_num = error_num2; + } + } + } + quick_mode = FALSE; + keyread = FALSE; + ignore_dup_key = FALSE; + write_can_replace = FALSE; + insert_with_update = FALSE; + low_priority = FALSE; + high_priority = FALSE; + insert_delayed = FALSE; + use_pre_call = FALSE; + bulk_insert = FALSE; + clone_bitmap_init = FALSE; + result_list.tmp_table_join = FALSE; + result_list.use_union = FALSE; + pt_clone_last_searcher = NULL; + conn_kinds = SPIDER_CONN_KIND_MYSQL; + while (condition) + { + tmp_cond = condition->next; + spider_free(spider_current_trx, condition, MYF(0)); + condition = tmp_cond; + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (multi_range_keys) + { + DBUG_PRINT("info",("spider free multi_range_keys=%p", multi_range_keys)); + spider_free(spider_current_trx, multi_range_keys, MYF(0)); + multi_range_keys = NULL; + } +#endif + ft_handler = NULL; + ft_current = NULL; + ft_count = 0; + ft_init_without_index_init = FALSE; + sql_kinds = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + hs_pushed_ret_fields_num = MAX_FIELDS; + hs_increment = FALSE; + hs_decrement = FALSE; +#endif +#endif +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + direct_update_fields = NULL; +#endif +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + info_limit = 9223372036854775807LL; +#endif + result_list.have_sql_kind_backup = FALSE; + result_list.direct_order_limit = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num2 = reset_hs_strs(SPIDER_SQL_TYPE_UPDATE_HS))) + error_num = error_num2; +#endif + result_list.set_split_read = FALSE; + result_list.insert_dup_update_pushdown = FALSE; + use_spatial_index = FALSE; + error_mode = 0; +#ifdef HA_CAN_BULK_ACCESS +#ifndef DBUG_OFF + if (bulk_access_link_first) + { + DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", + bulk_access_link_first->spider->dbton_handler)); + DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", + &bulk_access_link_first->spider->dbton_handler)); + } +#endif +#endif + DBUG_RETURN(error_num); +} + +int ha_spider::extra( + enum ha_extra_function operation +) { + int error_num; + DBUG_ENTER("ha_spider::extra"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider operation=%d", (int) operation)); + switch (operation) + { + case HA_EXTRA_QUICK: + quick_mode = TRUE; + break; + case HA_EXTRA_KEYREAD: + if (!is_clone) + { + keyread = TRUE; +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (update_request) + { + if (check_partitioned()) + keyread = FALSE; + } +#endif + } + break; + case HA_EXTRA_NO_KEYREAD: + keyread = FALSE; + break; + case HA_EXTRA_IGNORE_DUP_KEY: + ignore_dup_key = TRUE; + break; + case HA_EXTRA_NO_IGNORE_DUP_KEY: + ignore_dup_key = FALSE; + break; + case HA_EXTRA_WRITE_CAN_REPLACE: + write_can_replace = TRUE; + break; + case HA_EXTRA_WRITE_CANNOT_REPLACE: + write_can_replace = FALSE; + break; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + case HA_EXTRA_INSERT_WITH_UPDATE: + insert_with_update = TRUE; + check_insert_dup_update_pushdown(); + break; +#endif + case HA_EXTRA_ATTACH_CHILDREN: + DBUG_PRINT("info",("spider HA_EXTRA_ATTACH_CHILDREN")); + if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num))) + DBUG_RETURN(error_num); + break; +#if MYSQL_VERSION_ID < 50500 +#else + case HA_EXTRA_ADD_CHILDREN_LIST: + DBUG_PRINT("info",("spider HA_EXTRA_ADD_CHILDREN_LIST")); + if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num))) + DBUG_RETURN(error_num); + break; +#endif + default: + break; + } + DBUG_RETURN(0); +} + +int ha_spider::index_init( + uint idx, + bool sorted +) { + int error_num; + DBUG_ENTER("ha_spider::index_init"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider idx=%u", idx)); +#ifdef HA_CAN_BULK_ACCESS + DBUG_ASSERT(!bulk_access_started); + if (bulk_access_executing) + { + if ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) { + DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_index_init( + idx, sorted)); + } + } +#endif + pushed_pos = NULL; + active_index = idx; + result_list.sorted = sorted; + spider_set_result_list_param(this); + mrr_with_cnt = FALSE; + init_index_handler = FALSE; + use_spatial_index = FALSE; + + if (result_list.lock_type == F_WRLCK) + { + pk_update = FALSE; + check_and_start_bulk_update(SPD_BU_START_BY_INDEX_OR_RND_INIT); + + if ( + update_request && + share->have_recovery_link && + (pk_update = spider_check_pk_update(table)) + ) { + bitmap_set_all(table->read_set); + if (is_clone) + memset(searched_bitmap, 0xFF, no_bytes_in_map(table->read_set)); + } + } + + if (!is_clone) + set_select_column_mode(); + + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = reset_hs_sql(SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); + if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); +#endif + result_list.check_direct_order_limit = FALSE; + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_index_init( + uint idx, + bool sorted +) { + DBUG_ENTER("ha_spider::pre_index_init"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(bulk_access_link_current->spider->ha_index_init(idx, sorted)); +} +#endif + +int ha_spider::index_end() +{ + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::index_end"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef HA_CAN_BULK_ACCESS + DBUG_ASSERT(!bulk_access_started); + if (bulk_access_executing) + { + if ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) { + error_num = bulk_access_link_exec_tgt->spider->ha_index_end(); + if (error_num) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); + } + } +#endif + active_index = MAX_KEY; +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + info_limit = 9223372036854775807LL; +#endif + if ( + (error_num = drop_tmp_tables()) || + (error_num = check_and_end_bulk_update( + SPD_BU_START_BY_INDEX_OR_RND_INIT)) || + (error_num = spider_trx_check_link_idx_failed(this)) + ) + DBUG_RETURN(check_error_mode(error_num)); + result_list.use_union = FALSE; + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_index_end() +{ + DBUG_ENTER("ha_spider::pre_index_end"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(bulk_access_link_current->spider->ha_index_end()); +} +#endif + +int ha_spider::index_read_map_internal( + uchar *buf, + const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag +) { + int error_num, roop_count; + key_range start_key; + SPIDER_CONN *conn; + backup_error_status(); + DBUG_ENTER("ha_spider::index_read_map_internal"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if (do_direct_update) + { + direct_update_kinds = SPIDER_SQL_KIND_SQL; + memset(do_hs_direct_update, 0, share->link_bitmap_size); + } +#endif +#endif + if ( + find_flag >= HA_READ_MBR_CONTAIN && + find_flag <= HA_READ_MBR_EQUAL + ) + use_spatial_index = TRUE; + + if ((error_num = index_handler_init())) + DBUG_RETURN(check_error_mode_eof(error_num)); + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + spider_db_free_one_result_for_start_next(this); + spider_set_result_list_param(this); + check_direct_order_limit(); + start_key.key = key; + start_key.keypart_map = keypart_map; + start_key.flag = find_flag; + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + check_select_column(FALSE); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (keyread) + result_list.keyread = TRUE; + else + result_list.keyread = FALSE; + if ( + (error_num = spider_db_append_select(this)) || + (error_num = spider_db_append_select_columns(this)) + ) + DBUG_RETURN(error_num); + if ( + share->key_hint && + (error_num = append_hint_after_table_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + result_list.desc_flg = FALSE; + result_list.sorted = TRUE; + result_list.key_info = &table->key_info[active_index]; + result_list.limit_num = + result_list.internal_limit >= result_list.split_read ? + result_list.split_read : result_list.internal_limit; + DBUG_PRINT("info",("spider result_list.internal_limit=%lld", + result_list.internal_limit)); + DBUG_PRINT("info",("spider result_list.split_read=%lld", + result_list.split_read)); + DBUG_PRINT("info",("spider result_list.limit_num=%lld", + result_list.limit_num)); + if ( + (error_num = spider_db_append_key_where( + &start_key, NULL, this)) + ) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider result_list.internal_limit=%lld", + result_list.internal_limit)); + DBUG_PRINT("info",("spider result_list.split_read=%lld", + result_list.split_read)); + DBUG_PRINT("info",("spider result_list.limit_num=%lld", + result_list.limit_num)); + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (sql_kinds & SPIDER_SQL_KIND_HS) + { + if ((error_num = append_limit_hs_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_HS))) + { + DBUG_RETURN(error_num); + } + } +#endif + + int roop_start, roop_end, lock_mode, link_ok; + lock_mode = spider_conn_lock_mode(this); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if ( + is_bulk_access_clone && + !bulk_access_executing && + conn_kind[roop_count] != SPIDER_CONN_KIND_MYSQL + ) { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + if (buf && (error_num = spider_db_fetch(buf, this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::pre_index_read_map( + const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag, + bool use_parallel +) { +#ifdef HA_CAN_BULK_ACCESS + int error_num; +#endif + DBUG_ENTER("ha_spider::pre_index_read_map"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef HA_CAN_BULK_ACCESS + if (bulk_access_started) + { + error_num = bulk_access_link_current->spider->pre_index_read_map(key, + keypart_map, find_flag, TRUE); + bulk_access_link_current->spider->bulk_access_pre_called = TRUE; + bulk_access_link_current->called = TRUE; + DBUG_RETURN(error_num); + } else if ( + bulk_access_executing && !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) { + DBUG_RETURN(bulk_access_link_exec_tgt->spider->pre_index_read_map(key, + keypart_map, find_flag, TRUE)); + } +#endif + check_pre_call(use_parallel); + if (use_pre_call) + { + store_error_num = + index_read_map_internal(NULL, key, keypart_map, find_flag); +#ifdef HA_CAN_BULK_ACCESS + if ( + !store_error_num && + bulk_access_executing && + is_bulk_access_clone && + !bulk_access_pre_called + ) { + bulk_req_exec(); + } +#endif + DBUG_RETURN(store_error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::index_read_map( + uchar *buf, + const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag +) { + int error_num; + DBUG_ENTER("ha_spider::index_read_map"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef HA_CAN_BULK_ACCESS + DBUG_ASSERT(!bulk_access_started); + if (bulk_access_executing) + { + if (is_bulk_access_clone) + { + if (bulk_access_pre_called) + { + SPIDER_CONN *conn; + int roop_count, roop_start, roop_end, tmp_lock_mode, link_ok, + tmp_error_num; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + } +#endif + if ((tmp_error_num = spider_db_bulk_store_result(this, conn, + roop_count, (roop_count != link_ok)))) + { + store_error_num = tmp_error_num; + } else { + result_link_idx = link_ok; + } + } + use_pre_call = TRUE; + bulk_access_pre_called = FALSE; + } else { + /* do access normally */ + } + } else if (bulk_access_link_exec_tgt->called) + { + DBUG_RETURN(bulk_access_link_exec_tgt->spider->index_read_map(buf, key, + keypart_map, find_flag)); + } + } +#endif + if (use_pre_call) + { + if (store_error_num) + { + if (store_error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(store_error_num); + } + if ((error_num = spider_bg_all_conn_pre_next(this, search_link_idx))) + DBUG_RETURN(error_num); + use_pre_call = FALSE; + if ( + result_list.sorted && + result_list.desc_flg + ) { + DBUG_RETURN(index_prev(buf)); + } + DBUG_RETURN(index_next(buf)); + } + DBUG_RETURN(index_read_map_internal(buf, key, keypart_map, find_flag)); +} + +int ha_spider::index_read_last_map_internal( + uchar *buf, + const uchar *key, + key_part_map keypart_map +) { + int error_num; + key_range start_key; + SPIDER_CONN *conn; + backup_error_status(); + DBUG_ENTER("ha_spider::index_read_last_map_internal"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + if ((error_num = index_handler_init())) + DBUG_RETURN(check_error_mode_eof(error_num)); + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } +/* + spider_db_free_one_result_for_start_next(this); +*/ + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ( + result_list.hs_has_result || +#endif + result_list.current +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) +#endif + && + (error_num = spider_db_free_result(this, FALSE)) + ) + DBUG_RETURN(error_num); + + check_direct_order_limit(); + start_key.key = key; + start_key.keypart_map = keypart_map; + start_key.flag = HA_READ_KEY_EXACT; + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + check_select_column(FALSE); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (keyread) + result_list.keyread = TRUE; + else + result_list.keyread = FALSE; + if ( + (error_num = spider_db_append_select(this)) || + (error_num = spider_db_append_select_columns(this)) + ) + DBUG_RETURN(error_num); + if ( + share->key_hint && + (error_num = append_hint_after_table_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + result_list.desc_flg = TRUE; + result_list.sorted = TRUE; + result_list.key_info = &table->key_info[active_index]; + result_list.limit_num = + result_list.internal_limit >= result_list.split_read ? + result_list.split_read : result_list.internal_limit; + if ( + (error_num = spider_db_append_key_where( + &start_key, NULL, this)) + ) + DBUG_RETURN(error_num); + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + if (buf && (error_num = spider_db_fetch(buf, this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::pre_index_read_last_map( + const uchar *key, + key_part_map keypart_map, + bool use_parallel +) { + DBUG_ENTER("ha_spider::pre_index_read_last_map"); + DBUG_PRINT("info",("spider this=%p", this)); + check_pre_call(use_parallel); + if (use_pre_call) + { + store_error_num = + index_read_last_map_internal(NULL, key, keypart_map); + DBUG_RETURN(store_error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::index_read_last_map( + uchar *buf, + const uchar *key, + key_part_map keypart_map +) { + int error_num; + DBUG_ENTER("ha_spider::index_read_last_map"); + DBUG_PRINT("info",("spider this=%p", this)); + if (use_pre_call) + { + if (store_error_num) + { + if (store_error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(store_error_num); + } + if ((error_num = spider_bg_all_conn_pre_next(this, search_link_idx))) + DBUG_RETURN(error_num); + use_pre_call = FALSE; + DBUG_RETURN(index_prev(buf)); + } + DBUG_RETURN(index_read_last_map_internal(buf, key, keypart_map)); +} + +int ha_spider::index_next( + uchar *buf +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::index_next"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } +#ifdef HA_CAN_BULK_ACCESS + DBUG_ASSERT(!bulk_access_started); + if (bulk_access_executing) + { + if ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) { + error_num = bulk_access_link_exec_tgt->spider->index_next(buf); + if (error_num) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); + } + } +#endif + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + if ( + result_list.sorted && + result_list.desc_flg + ) { + if ((error_num = spider_db_seek_prev(buf, this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); + } + if ((error_num = spider_db_seek_next(buf, this, search_link_idx, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::index_prev( + uchar *buf +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::index_prev"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } +#ifdef HA_CAN_BULK_ACCESS + DBUG_ASSERT(!bulk_access_started); + if (bulk_access_executing) + { + if ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) { + error_num = bulk_access_link_exec_tgt->spider->index_prev(buf); + if (error_num) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); + } + } +#endif + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + if ( + result_list.sorted && + result_list.desc_flg + ) { + if ((error_num = spider_db_seek_next(buf, this, search_link_idx, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); + } + if ((error_num = spider_db_seek_prev(buf, this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::index_first_internal( + uchar *buf +) { + int error_num; + SPIDER_CONN *conn; + backup_error_status(); + DBUG_ENTER("ha_spider::index_first_internal"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + if ((error_num = index_handler_init())) + DBUG_RETURN(check_error_mode_eof(error_num)); + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + result_list.hs_has_result || +#endif + sql_is_empty(SPIDER_SQL_TYPE_HANDLER) || + sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL) + ) { +/* + spider_db_free_one_result_for_start_next(this); +*/ + if ((error_num = spider_db_free_result(this, FALSE))) + DBUG_RETURN(error_num); + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); + + check_direct_order_limit(); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + check_select_column(FALSE); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (keyread) + result_list.keyread = TRUE; + else + result_list.keyread = FALSE; + if ( + (error_num = spider_db_append_select(this)) || + (error_num = spider_db_append_select_columns(this)) + ) + DBUG_RETURN(error_num); + if ( + share->key_hint && + (error_num = append_hint_after_table_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + result_list.desc_flg = FALSE; + result_list.sorted = TRUE; + result_list.key_info = &table->key_info[active_index]; + result_list.key_order = 0; + result_list.limit_num = + result_list.internal_limit >= result_list.split_read ? + result_list.split_read : result_list.internal_limit; + if ( + (error_num = spider_db_append_key_where( + NULL, NULL, this)) + ) + DBUG_RETURN(error_num); + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = + dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + } + + if (buf) + { + if ( + result_list.sorted && + result_list.desc_flg + ) { + if ((error_num = spider_db_seek_last(buf, this, search_link_idx, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); + } + if ((error_num = spider_db_seek_first(buf, this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + } + DBUG_RETURN(0); +} + +int ha_spider::pre_index_first( + bool use_parallel +) { + DBUG_ENTER("ha_spider::pre_index_first"); + DBUG_PRINT("info",("spider this=%p", this)); + check_pre_call(use_parallel); + if (use_pre_call) + { + store_error_num = + index_first_internal(NULL); + DBUG_RETURN(store_error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::index_first( + uchar *buf +) { + int error_num; + DBUG_ENTER("ha_spider::index_first"); + DBUG_PRINT("info",("spider this=%p", this)); + if (use_pre_call) + { + if (store_error_num) + { + if (store_error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(store_error_num); + } + if ((error_num = spider_bg_all_conn_pre_next(this, search_link_idx))) + DBUG_RETURN(error_num); + use_pre_call = FALSE; + DBUG_RETURN(index_next(buf)); + } + DBUG_RETURN(index_first_internal(buf)); +} + +int ha_spider::index_last_internal( + uchar *buf +) { + int error_num; + SPIDER_CONN *conn; + backup_error_status(); + DBUG_ENTER("ha_spider::index_last_internal"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + if ((error_num = index_handler_init())) + DBUG_RETURN(check_error_mode_eof(error_num)); + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + result_list.hs_has_result || +#endif + sql_is_empty(SPIDER_SQL_TYPE_HANDLER) || + sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL) + ) { +/* + spider_db_free_one_result_for_start_next(this); +*/ + if ((error_num = spider_db_free_result(this, FALSE))) + DBUG_RETURN(error_num); + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); + + check_direct_order_limit(); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + check_select_column(FALSE); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (keyread) + result_list.keyread = TRUE; + else + result_list.keyread = FALSE; + if ( + (error_num = spider_db_append_select(this)) || + (error_num = spider_db_append_select_columns(this)) + ) + DBUG_RETURN(error_num); + if ( + share->key_hint && + (error_num = append_hint_after_table_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + result_list.desc_flg = TRUE; + result_list.sorted = TRUE; + result_list.key_info = &table->key_info[active_index]; + result_list.key_order = 0; + result_list.limit_num = + result_list.internal_limit >= result_list.split_read ? + result_list.split_read : result_list.internal_limit; + if ( + (error_num = spider_db_append_key_where( + NULL, NULL, this)) + ) + DBUG_RETURN(error_num); + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = + dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + } + + if (buf) + { + if ( + result_list.sorted && + result_list.desc_flg + ) { + if ((error_num = spider_db_seek_first(buf, this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); + } + if ((error_num = spider_db_seek_last(buf, this, search_link_idx, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + } + DBUG_RETURN(0); +} + +int ha_spider::pre_index_last( + bool use_parallel +) { + DBUG_ENTER("ha_spider::pre_index_last"); + DBUG_PRINT("info",("spider this=%p", this)); + check_pre_call(use_parallel); + if (use_pre_call) + { + store_error_num = + index_last_internal(NULL); + DBUG_RETURN(store_error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::index_last( + uchar *buf +) { + int error_num; + DBUG_ENTER("ha_spider::index_last"); + DBUG_PRINT("info",("spider this=%p", this)); + if (use_pre_call) + { + if (store_error_num) + { + if (store_error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(store_error_num); + } + if ((error_num = spider_bg_all_conn_pre_next(this, search_link_idx))) + DBUG_RETURN(error_num); + use_pre_call = FALSE; + DBUG_RETURN(index_prev(buf)); + } + DBUG_RETURN(index_last_internal(buf)); +} + +int ha_spider::index_next_same( + uchar *buf, + const uchar *key, + uint keylen +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::index_next_same"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } +#ifdef HA_CAN_BULK_ACCESS + DBUG_ASSERT(!bulk_access_started); + if (bulk_access_executing) + { + if ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) { + error_num = bulk_access_link_exec_tgt->spider->index_next_same(buf, key, + keylen); + if (error_num) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); + } + } +#endif + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + if ( + result_list.sorted && + result_list.desc_flg + ) { + if ((error_num = spider_db_seek_prev(buf, this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); + } + if ((error_num = spider_db_seek_next(buf, this, search_link_idx, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::read_range_first_internal( + uchar *buf, + const key_range *start_key, + const key_range *end_key, + bool eq_range, + bool sorted +) { + int error_num; + SPIDER_CONN *conn; + backup_error_status(); + DBUG_ENTER("ha_spider::read_range_first_internal"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + if ( + start_key && + start_key->flag >= HA_READ_MBR_CONTAIN && + start_key->flag <= HA_READ_MBR_EQUAL + ) + use_spatial_index = TRUE; + + if (end_key) + { + key_compare_result_on_equal = + ((end_key->flag == HA_READ_BEFORE_KEY) ? 1 : + (end_key->flag == HA_READ_AFTER_KEY) ? -1 : 0); + } + range_key_part = table->key_info[active_index].key_part; + + if ((error_num = index_handler_init())) + DBUG_RETURN(check_error_mode_eof(error_num)); + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + spider_db_free_one_result_for_start_next(this); + check_direct_order_limit(); + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + check_select_column(FALSE); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (keyread) + result_list.keyread = TRUE; + else + result_list.keyread = FALSE; + if ( + (error_num = spider_db_append_select(this)) || + (error_num = spider_db_append_select_columns(this)) + ) + DBUG_RETURN(error_num); + if ( + share->key_hint && + (error_num = append_hint_after_table_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + result_list.desc_flg = FALSE; + result_list.sorted = sorted; + result_list.key_info = &table->key_info[active_index]; + result_list.limit_num = + result_list.internal_limit >= result_list.split_read ? + result_list.split_read : result_list.internal_limit; + if ( + (error_num = spider_db_append_key_where( + start_key, eq_range ? NULL : end_key, this)) + ) + DBUG_RETURN(error_num); + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + if (buf && (error_num = spider_db_fetch(buf, this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::pre_read_range_first( + const key_range *start_key, + const key_range *end_key, + bool eq_range, + bool sorted, + bool use_parallel +) { + DBUG_ENTER("ha_spider::pre_read_range_first"); + DBUG_PRINT("info",("spider this=%p", this)); + check_pre_call(use_parallel); + if (use_pre_call) + { + store_error_num = + read_range_first_internal(NULL, start_key, end_key, eq_range, sorted); + DBUG_RETURN(store_error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::read_range_first( + const key_range *start_key, + const key_range *end_key, + bool eq_range, + bool sorted +) { + int error_num; + DBUG_ENTER("ha_spider::read_range_first"); + DBUG_PRINT("info",("spider this=%p", this)); + if (use_pre_call) + { + if (store_error_num) + { + if (store_error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(store_error_num); + } + if ((error_num = spider_bg_all_conn_pre_next(this, search_link_idx))) + DBUG_RETURN(error_num); + use_pre_call = FALSE; + DBUG_RETURN(read_range_next()); + } + DBUG_RETURN(read_range_first_internal(table->record[0], start_key, end_key, + eq_range, sorted)); +} + +int ha_spider::read_range_next() +{ + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::read_range_next"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + if ( + result_list.sorted && + result_list.desc_flg + ) { + if ((error_num = spider_db_seek_prev(table->record[0], this, table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); + } + if ((error_num = spider_db_seek_next(table->record[0], this, search_link_idx, + table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +#ifdef HA_MRR_USE_DEFAULT_IMPL +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +ha_rows ha_spider::multi_range_read_info_const( + uint keyno, + RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, + uint *bufsz, + uint *flags, + Cost_estimate *cost +) +#else +ha_rows ha_spider::multi_range_read_info_const( + uint keyno, + RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, + uint *bufsz, + uint *flags, + COST_VECT *cost +) +#endif +{ + DBUG_ENTER("ha_spider::multi_range_read_info_const"); + DBUG_PRINT("info",("spider this=%p", this)); + ha_rows rows = + handler::multi_range_read_info_const( + keyno, + seq, + seq_init_param, + n_ranges, + bufsz, + flags, + cost + ); + *flags &= ~HA_MRR_USE_DEFAULT_IMPL; + DBUG_PRINT("info",("spider rows=%llu", rows)); + DBUG_RETURN(rows); +} + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +ha_rows ha_spider::multi_range_read_info( + uint keyno, + uint n_ranges, + uint keys, + uint key_parts, + uint *bufsz, + uint *flags, + Cost_estimate *cost +) +#else +ha_rows ha_spider::multi_range_read_info( + uint keyno, + uint n_ranges, + uint keys, + uint key_parts, + uint *bufsz, + uint *flags, + COST_VECT *cost +) +#endif +{ + DBUG_ENTER("ha_spider::multi_range_read_info"); + DBUG_PRINT("info",("spider this=%p", this)); + ha_rows rows = + handler::multi_range_read_info( + keyno, + n_ranges, + keys, + key_parts, + bufsz, + flags, + cost + ); + *flags &= ~HA_MRR_USE_DEFAULT_IMPL; + DBUG_PRINT("info",("spider rows=%llu", rows)); + DBUG_RETURN(rows); +} + +int ha_spider::multi_range_read_init( + RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, + uint mode, + HANDLER_BUFFER *buf +) { + bka_mode = spider_param_bka_mode(trx->thd, share->bka_mode); + backup_error_status(); + DBUG_ENTER("ha_spider::multi_range_read_init"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider n_ranges=%u", n_ranges)); + multi_range_num = n_ranges; + DBUG_RETURN( + handler::multi_range_read_init( + seq, + seq_init_param, + n_ranges, + mode, + buf + ) + ); +} + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +int ha_spider::multi_range_read_next( + range_id_t *range_info +) +#else +int ha_spider::multi_range_read_next( + char **range_info +) +#endif +{ + int error_num; + DBUG_ENTER("ha_spider::multi_range_read_next"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!mrr_have_range) + { + error_num = multi_range_read_next_first(range_info); + mrr_have_range = TRUE; + } else + error_num = multi_range_read_next_next(range_info); + DBUG_RETURN(error_num); +} +#endif + +#ifdef HA_MRR_USE_DEFAULT_IMPL +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +int ha_spider::multi_range_read_next_first( + range_id_t *range_info +) +#else +int ha_spider::multi_range_read_next_first( + char **range_info +) +#endif +#else +int ha_spider::read_multi_range_first_internal( + uchar *buf, + KEY_MULTI_RANGE **found_range_p, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + HANDLER_BUFFER *buffer +) +#endif +{ + int error_num, roop_count; + SPIDER_CONN *conn; +#ifdef HA_MRR_USE_DEFAULT_IMPL + int range_res; + backup_error_status(); + DBUG_ENTER("ha_spider::multi_range_read_next_first"); +#else + bka_mode = spider_param_bka_mode(trx->thd, share->bka_mode); + backup_error_status(); + DBUG_ENTER("ha_spider::read_multi_range_first_internal"); +#endif + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + if ((error_num = index_handler_init())) + DBUG_RETURN(check_error_mode_eof(error_num)); + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } +#ifdef HA_MRR_USE_DEFAULT_IMPL +#else + multi_range_sorted = sorted; + multi_range_buffer = buffer; +#endif + + spider_db_free_one_result_for_start_next(this); + check_direct_order_limit(); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + check_select_column(FALSE); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); +#endif + result_list.desc_flg = FALSE; +#ifdef HA_MRR_USE_DEFAULT_IMPL + result_list.sorted = mrr_is_output_sorted; +#else + result_list.sorted = sorted; +#endif + result_list.key_info = &table->key_info[active_index]; + if ( + result_list.multi_split_read <= 1 || + (sql_kinds & SPIDER_SQL_KIND_HANDLER) + ) { + if (keyread) + result_list.keyread = TRUE; + else + result_list.keyread = FALSE; + if ( + (error_num = spider_db_append_select(this)) || + (error_num = spider_db_append_select_columns(this)) + ) + DBUG_RETURN(error_num); + if ( + share->key_hint && + (error_num = append_hint_after_table_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); +#ifdef HA_MRR_USE_DEFAULT_IMPL + while (!(range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range))) +#else + for ( + multi_range_curr = ranges, + multi_range_end = ranges + range_count; + multi_range_curr < multi_range_end; + multi_range_curr++ + ) +#endif + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + DBUG_PRINT("info",("spider range_res1=%d", range_res)); +#endif + result_list.limit_num = + result_list.internal_limit - result_list.record_num >= + result_list.split_read ? + result_list.split_read : + result_list.internal_limit - result_list.record_num; + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + (error_num = spider_db_append_key_where( + &mrr_cur_range.start_key, + test(mrr_cur_range.range_flag & EQ_RANGE) ? + NULL : &mrr_cur_range.end_key, this)) +#else + (error_num = spider_db_append_key_where( + &multi_range_curr->start_key, + test(multi_range_curr->range_flag & EQ_RANGE) ? + NULL : &multi_range_curr->end_key, this)) +#endif + ) + DBUG_RETURN(error_num); + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset + result_list.record_num, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset + result_list.record_num, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)); + if ( + error_num && + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = + dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = (char *) mrr_cur_range.ptr; +#else + *found_range_p = multi_range_curr; +#endif + DBUG_RETURN(0); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + } + if (!error_num) + { + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + } + } + if (!error_num) + { + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + error_num = spider_db_store_result(this, roop_count, table); + if ( + error_num && + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + if (error_num) + { + if ( + error_num != HA_ERR_END_OF_FILE && + check_error_mode(error_num) + ) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (result_list.current) + { + DBUG_PRINT("info", + ("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + if (result_list.current == result_list.first) + result_list.current = NULL; + else + result_list.current = result_list.current->prev; + } + } else { +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (!(error_num = spider_db_fetch(table->record[0], this, table))) +#else + if (!buf || !(error_num = spider_db_fetch(buf, this, table))) +#endif + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = (char *) mrr_cur_range.ptr; +#else + *found_range_p = multi_range_curr; +#endif + DBUG_RETURN(0); + } + if ( + error_num != HA_ERR_END_OF_FILE && + check_error_mode(error_num) + ) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (result_list.current) + { + DBUG_PRINT("info", + ("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + if (result_list.current == result_list.first) + result_list.current = NULL; + else + result_list.current = result_list.current->prev; + } + } + set_where_to_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + set_where_to_pos_sql(SPIDER_SQL_TYPE_HANDLER); + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + DBUG_PRINT("info",("spider range_res2=%d", range_res)); +#endif + if (error_num) + DBUG_RETURN(check_error_mode_eof(error_num)); + } else { + bool tmp_high_priority = high_priority; + bool have_multi_range; +#ifdef HA_MRR_USE_DEFAULT_IMPL + have_second_range = FALSE; +#endif + if (keyread) + result_list.keyread = TRUE; + else + result_list.keyread = FALSE; + mrr_with_cnt = TRUE; + multi_range_cnt = 0; + multi_range_hit_point = 0; +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (multi_range_keys) + { + DBUG_PRINT("info",("spider free multi_range_keys=%p", multi_range_keys)); + spider_free(spider_current_trx, multi_range_keys, MYF(0)); + } +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + if (!(multi_range_keys = (range_id_t *) + spider_malloc(spider_current_trx, 1, sizeof(range_id_t) * + (multi_range_num < result_list.multi_split_read ? + multi_range_num : result_list.multi_split_read), MYF(MY_WME))) + ) +#else + if (!(multi_range_keys = (char **) + spider_malloc(spider_current_trx, 1, sizeof(char *) * + (multi_range_num < result_list.multi_split_read ? + multi_range_num : result_list.multi_split_read), MYF(MY_WME))) + ) +#endif + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_PRINT("info",("spider alloc multi_range_keys=%p", multi_range_keys)); +#else + multi_range_ranges = ranges; +#endif + error_num = 0; +#ifdef HA_MRR_USE_DEFAULT_IMPL + if ((range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range))) + { + DBUG_PRINT("info",("spider range_res3=%d", range_res)); + DBUG_PRINT("info",("spider result_list.finish_flg = TRUE")); + result_list.finish_flg = TRUE; + if (result_list.current) + { + DBUG_PRINT("info",("spider result_list.current->finish_flg = TRUE")); + result_list.current->finish_flg = TRUE; + } + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + DBUG_PRINT("info",("spider range_res4=%d", range_res)); +#else + multi_range_curr = ranges; + multi_range_end = ranges + range_count; +#endif + result_list.tmp_table_join = FALSE; + memset(result_list.tmp_table_join_first, 0, share->link_bitmap_size); + do + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + if ((range_res = mrr_funcs.next(mrr_iter, &mrr_second_range))) +#else + if (multi_range_curr + 1 >= multi_range_end) +#endif + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + have_second_range = FALSE; +#endif + have_multi_range = FALSE; + } else { +#ifdef HA_MRR_USE_DEFAULT_IMPL + have_second_range = TRUE; +#endif + have_multi_range = TRUE; + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + DBUG_PRINT("info",("spider range_res5=%d", range_res)); +#endif + result_list.tmp_reuse_sql = FALSE; + if (bka_mode && + have_multi_range && +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + !(sql_kinds & SPIDER_SQL_KIND_HS) && +#endif +#ifdef HA_MRR_USE_DEFAULT_IMPL + test(mrr_cur_range.range_flag & EQ_RANGE) +#else + test(multi_range_curr->range_flag & EQ_RANGE) +#endif + ) { + if ( + result_list.tmp_table_join && +#ifdef HA_MRR_USE_DEFAULT_IMPL + result_list.tmp_table_join_key_part_map == + mrr_cur_range.start_key.keypart_map +#else + result_list.tmp_table_join_key_part_map == + multi_range_curr->start_key.keypart_map +#endif + ) { + /* reuse tmp_sql */ + result_list.tmp_reuse_sql = TRUE; + } else { + /* create tmp_sql */ + result_list.tmp_table_join = TRUE; +#ifdef HA_MRR_USE_DEFAULT_IMPL + result_list.tmp_table_join_key_part_map = + mrr_cur_range.start_key.keypart_map; +#else + result_list.tmp_table_join_key_part_map = + multi_range_curr->start_key.keypart_map; +#endif + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL))) + DBUG_RETURN(error_num); + if ((sql_kinds & SPIDER_SQL_KIND_SQL)) + { + for (roop_count = 0; roop_count < (int) share->link_count; + roop_count++) + { + result_list.sql_kind_backup[roop_count] = sql_kind[roop_count]; + sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; + } + result_list.sql_kinds_backup = sql_kinds; + sql_kinds = SPIDER_SQL_KIND_SQL; + result_list.have_sql_kind_backup = TRUE; + } + } + memset(result_list.tmp_table_join_first, 0xFF, + share->link_bitmap_size); + } else { + result_list.tmp_table_join = FALSE; + if (result_list.have_sql_kind_backup) + { + for (roop_count = 0; roop_count < (int) share->link_count; + roop_count++) + { + sql_kind[roop_count] = + result_list.sql_kind_backup[roop_count]; + } + sql_kinds = result_list.sql_kinds_backup; + result_list.have_sql_kind_backup = FALSE; + } + } + result_list.tmp_table_join_break_after_get_next = FALSE; + + if (result_list.tmp_table_join) + { + result_list.limit_num = + result_list.internal_limit >= result_list.split_read ? + result_list.split_read : result_list.internal_limit; + if (!result_list.tmp_reuse_sql) + { + if ((error_num = append_tmp_table_and_sql_for_bka( +#ifdef HA_MRR_USE_DEFAULT_IMPL + &mrr_cur_range.start_key +#else + &multi_range_curr->start_key +#endif + ))) { + DBUG_RETURN(error_num); + } + } else { + if ((error_num = reuse_tmp_table_and_sql_for_bka())) + { + DBUG_RETURN(error_num); + } + } + +#ifdef HA_MRR_USE_DEFAULT_IMPL + do +#else + for ( + ; + multi_range_curr < multi_range_end; + multi_range_curr++ + ) +#endif + { + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + !test(mrr_cur_range.range_flag & EQ_RANGE) || + result_list.tmp_table_join_key_part_map != + mrr_cur_range.start_key.keypart_map +#else + !test(multi_range_curr->range_flag & EQ_RANGE) || + result_list.tmp_table_join_key_part_map != + multi_range_curr->start_key.keypart_map +#endif + ) { + result_list.tmp_table_join_break_after_get_next = TRUE; + break; + } + +#ifdef HA_MRR_USE_DEFAULT_IMPL +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + multi_range_keys[multi_range_cnt] = mrr_cur_range.ptr; +#else + multi_range_keys[multi_range_cnt] = (char *) mrr_cur_range.ptr; +#endif +#endif + if ((error_num = append_multi_range_cnt_sql_part( + SPIDER_SQL_TYPE_TMP_SQL, multi_range_cnt, TRUE))) + DBUG_RETURN(error_num); + if ((error_num = append_key_column_values_sql_part( +#ifdef HA_MRR_USE_DEFAULT_IMPL + &mrr_cur_range.start_key, +#else + &multi_range_curr->start_key, +#endif + SPIDER_SQL_TYPE_TMP_SQL))) + DBUG_RETURN(error_num); + + if ((error_num = + append_values_connector_sql_part(SPIDER_SQL_TYPE_TMP_SQL))) + DBUG_RETURN(error_num); + multi_range_cnt++; + if (multi_range_cnt >= (uint) result_list.multi_split_read) + break; +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (multi_range_cnt == 1) + { + if (have_multi_range) + { + memcpy(&mrr_cur_range, &mrr_second_range, + sizeof(KEY_MULTI_RANGE)); + have_second_range = FALSE; + range_res = 0; + } else { + range_res = 1; + } + } else { + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res6=%d", range_res)); + } +#endif + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + while (!range_res); +#endif + if ((error_num = + append_values_terminator_sql_part(SPIDER_SQL_TYPE_TMP_SQL))) + DBUG_RETURN(error_num); + result_list.use_union = FALSE; + + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } else { + result_list.limit_num = result_list.internal_limit; + if ((error_num = append_union_all_start_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + +#ifdef HA_MRR_USE_DEFAULT_IMPL + do +#else + for ( + ; + multi_range_curr < multi_range_end; + multi_range_curr++ + ) +#endif + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + DBUG_PRINT("info",("spider range_res7=%d", range_res)); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + multi_range_keys[multi_range_cnt] = mrr_cur_range.ptr; +#else + multi_range_keys[multi_range_cnt] = (char *) mrr_cur_range.ptr; +#endif +#endif + if ((error_num = spider_db_append_select(this))) + DBUG_RETURN(error_num); + if ((error_num = append_multi_range_cnt_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL, multi_range_cnt, TRUE))) + DBUG_RETURN(error_num); + if ((error_num = spider_db_append_select_columns(this))) + DBUG_RETURN(error_num); + high_priority = FALSE; + if ( + share->key_hint && + (error_num = append_hint_after_table_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + (error_num = spider_db_append_key_where( + &mrr_cur_range.start_key, + test(mrr_cur_range.range_flag & EQ_RANGE) ? + NULL : &mrr_cur_range.end_key, this)) +#else + (error_num = spider_db_append_key_where( + &multi_range_curr->start_key, + test(multi_range_curr->range_flag & EQ_RANGE) ? + NULL : &multi_range_curr->end_key, this)) +#endif + ) + DBUG_RETURN(error_num); + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + 0, + result_list.internal_offset + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + if ((error_num = append_union_all_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + multi_range_cnt++; + if (multi_range_cnt >= (uint) result_list.multi_split_read) + break; +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (multi_range_cnt == 1) + { + if (have_multi_range) + { + memcpy(&mrr_cur_range, &mrr_second_range, + sizeof(KEY_MULTI_RANGE)); + have_second_range = FALSE; + range_res = 0; + } else { + range_res = 1; + } + } else { + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res8=%d", range_res)); + } +#endif + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + while (!range_res); +#endif + high_priority = tmp_high_priority; + if ((error_num = append_union_all_end_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + result_list.use_union = TRUE; + + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = + dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = multi_range_keys[multi_range_hit_point]; +#else + *found_range_p = &multi_range_ranges[multi_range_hit_point]; +#endif + DBUG_RETURN(0); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + if ( + result_list.tmp_table_join && + spider_bit_is_set(result_list.tmp_table_join_first, roop_count) + ) { + spider_clear_bit(result_list.tmp_table_join_first, roop_count); + spider_set_bit(result_list.tmp_table_created, roop_count); + result_list.tmp_tables_created = TRUE; + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_TMP_SQL, + conn, + -1, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + spider_db_discard_multiple_result(this, roop_count, conn); + } + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + if (error_num) + { + if ( + error_num != HA_ERR_END_OF_FILE && + !check_error_mode(error_num) + ) + error_num = HA_ERR_END_OF_FILE; + if (error_num == HA_ERR_END_OF_FILE) + { + if (multi_range_cnt >= (uint) result_list.multi_split_read) + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res9=%d", range_res)); +#else + multi_range_curr++; +#endif + } + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res +#else + multi_range_curr == multi_range_end +#endif + ) { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(error_num); + } + + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (result_list.current) + { + DBUG_PRINT("info", + ("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + if (result_list.current == result_list.first) + result_list.current = NULL; + else + result_list.current = result_list.current->prev; + } + error_num = 0; + } else + DBUG_RETURN(error_num); + } else { +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (!(error_num = spider_db_fetch(table->record[0], this, table))) +#else + if (!buf || !(error_num = spider_db_fetch(buf, this, table))) +#endif + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = multi_range_keys[multi_range_hit_point]; +#else + *found_range_p = &multi_range_ranges[multi_range_hit_point]; +#endif + DBUG_RETURN(0); + } + if ( + error_num != HA_ERR_END_OF_FILE && + !check_error_mode(error_num) + ) + error_num = HA_ERR_END_OF_FILE; + if (error_num == HA_ERR_END_OF_FILE) + { + if (multi_range_cnt >= (uint) result_list.multi_split_read) + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res10=%d", range_res)); +#else + multi_range_curr++; +#endif + } + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res +#else + multi_range_curr == multi_range_end +#endif + ) { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(error_num); + } + + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (result_list.current) + { + DBUG_PRINT("info", + ("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + if (result_list.current == result_list.first) + result_list.current = NULL; + else + result_list.current = result_list.current->prev; + } + error_num = 0; + } else + DBUG_RETURN(error_num); + } + multi_range_cnt = 0; + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); +#endif +#ifdef HA_MRR_USE_DEFAULT_IMPL +#else + multi_range_ranges = multi_range_curr; +#endif + } while (!error_num); + } + DBUG_RETURN(0); +} + +#ifdef HA_MRR_USE_DEFAULT_IMPL +#else +int ha_spider::pre_read_multi_range_first( + KEY_MULTI_RANGE **found_range_p, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + HANDLER_BUFFER *buffer, + bool use_parallel +) { + DBUG_ENTER("ha_spider::pre_read_multi_range_first"); + DBUG_PRINT("info",("spider this=%p", this)); + check_pre_call(use_parallel); + if (use_pre_call) + { + store_error_num = + read_multi_range_first_internal(NULL, found_range_p, ranges, + range_count, sorted, buffer); + DBUG_RETURN(store_error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::read_multi_range_first( + KEY_MULTI_RANGE **found_range_p, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + HANDLER_BUFFER *buffer +) { + int error_num; + DBUG_ENTER("ha_spider::read_multi_range_first"); + DBUG_PRINT("info",("spider this=%p", this)); + if (use_pre_call) + { + if (store_error_num) + { + if (store_error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(store_error_num); + } + if ((error_num = spider_bg_all_conn_pre_next(this, search_link_idx))) + DBUG_RETURN(error_num); + use_pre_call = FALSE; + DBUG_RETURN(read_multi_range_next(found_range_p)); + } + DBUG_RETURN(read_multi_range_first_internal(table->record[0], found_range_p, + ranges, range_count, sorted, buffer)); +} +#endif + +#ifdef HA_MRR_USE_DEFAULT_IMPL +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +int ha_spider::multi_range_read_next_next( + range_id_t *range_info +) +#else +int ha_spider::multi_range_read_next_next( + char **range_info +) +#endif +#else +int ha_spider::read_multi_range_next( + KEY_MULTI_RANGE **found_range_p +) +#endif +{ + int error_num, roop_count; + SPIDER_CONN *conn; +#ifdef HA_MRR_USE_DEFAULT_IMPL + int range_res; + backup_error_status(); + DBUG_ENTER("ha_spider::multi_range_read_next_next"); +#else + backup_error_status(); + DBUG_ENTER("ha_spider::read_multi_range_next"); +#endif + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + if ( + result_list.multi_split_read <= 1 || + (sql_kinds & SPIDER_SQL_KIND_HANDLER) + ) { + if (!(error_num = spider_db_seek_next(table->record[0], this, + search_link_idx, table))) + DBUG_RETURN(0); +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res1=%d", range_res)); +#else + multi_range_curr++; +#endif + if ( + error_num != HA_ERR_END_OF_FILE && + !check_error_mode(error_num) + ) + error_num = HA_ERR_END_OF_FILE; + if ( + error_num != HA_ERR_END_OF_FILE || +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res +#else + multi_range_curr == multi_range_end +#endif + ) + DBUG_RETURN(error_num); + spider_db_free_one_result_for_start_next(this); + spider_first_split_read_param(this); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + if (result_list.current) + { + DBUG_PRINT("info",("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + } + result_list.record_num = 0; +#ifdef HA_MRR_USE_DEFAULT_IMPL + do +#else + for ( + ; + multi_range_curr < multi_range_end; + multi_range_curr++ + ) +#endif + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + DBUG_PRINT("info",("spider range_res2=%d", range_res)); +#endif + set_where_to_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + set_where_to_pos_sql(SPIDER_SQL_TYPE_HANDLER); + result_list.limit_num = + result_list.internal_limit - result_list.record_num >= + result_list.split_read ? + result_list.split_read : + result_list.internal_limit - result_list.record_num; + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + (error_num = spider_db_append_key_where( + &mrr_cur_range.start_key, + test(mrr_cur_range.range_flag & EQ_RANGE) ? + NULL : &mrr_cur_range.end_key, this)) +#else + (error_num = spider_db_append_key_where( + &multi_range_curr->start_key, + test(multi_range_curr->range_flag & EQ_RANGE) ? + NULL : &multi_range_curr->end_key, this)) +#endif + ) + DBUG_RETURN(error_num); + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset + result_list.record_num, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset + result_list.record_num, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)); + if ( + error_num && + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = + dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = multi_range_keys[multi_range_hit_point]; +#else + *found_range_p = &multi_range_ranges[multi_range_hit_point]; +#endif + DBUG_RETURN(0); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + } + if (!error_num) + { + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + } + } + if (!error_num) + { + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + error_num = spider_db_store_result(this, roop_count, table); + if ( + error_num && + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + if (error_num) + { + if ( + error_num != HA_ERR_END_OF_FILE && + !check_error_mode(error_num) + ) + error_num = HA_ERR_END_OF_FILE; + if (error_num == HA_ERR_END_OF_FILE) + { + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (result_list.current) + { + DBUG_PRINT("info", + ("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + result_list.current = result_list.current->prev; + } + } else + DBUG_RETURN(error_num); + } else { + if (!(error_num = spider_db_fetch(table->record[0], this, table))) + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = (char *) mrr_cur_range.ptr; +#else + *found_range_p = multi_range_curr; +#endif + DBUG_RETURN(0); + } + if ( + error_num != HA_ERR_END_OF_FILE && + !check_error_mode(error_num) + ) + error_num = HA_ERR_END_OF_FILE; + if (error_num == HA_ERR_END_OF_FILE) + { + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (result_list.current) + { + DBUG_PRINT("info", + ("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + result_list.current = result_list.current->prev; + } + } else + DBUG_RETURN(error_num); + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res3=%d", range_res)); +#endif + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + while (!range_res); +#endif + if (error_num) + DBUG_RETURN(check_error_mode_eof(error_num)); + } else { + if (!(error_num = spider_db_seek_next(table->record[0], this, + search_link_idx, table))) + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = multi_range_keys[multi_range_hit_point]; +#else + *found_range_p = &multi_range_ranges[multi_range_hit_point]; +#endif + DBUG_RETURN(0); + } + + if (!result_list.tmp_table_join_break_after_get_next) + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res4=%d", range_res)); +#else + if (multi_range_curr < multi_range_end) + multi_range_curr++; +#endif + } else { + result_list.tmp_table_join_break_after_get_next = FALSE; +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res = 0; +#endif + } + + if ( + error_num != HA_ERR_END_OF_FILE && + !check_error_mode(error_num) + ) + error_num = HA_ERR_END_OF_FILE; + if ( + error_num != HA_ERR_END_OF_FILE || +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res +#else + multi_range_curr == multi_range_end +#endif + ) + DBUG_RETURN(error_num); + spider_db_free_one_result_for_start_next(this); + spider_first_split_read_param(this); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + if (result_list.current) + { + DBUG_PRINT("info",("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + } + result_list.record_num = 0; + + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); +#endif +#ifdef HA_MRR_USE_DEFAULT_IMPL +#else + multi_range_ranges = multi_range_curr; +#endif + + bool tmp_high_priority = high_priority; + bool have_multi_range; + multi_range_cnt = 0; + error_num = 0; + do + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + if ( + !have_second_range && + (range_res = mrr_funcs.next(mrr_iter, &mrr_second_range)) + ) +#else + if (multi_range_curr + 1 >= multi_range_end) +#endif + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + have_second_range = FALSE; +#endif + have_multi_range = FALSE; + } else { +#ifdef HA_MRR_USE_DEFAULT_IMPL + have_second_range = TRUE; +#endif + have_multi_range = TRUE; + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + DBUG_PRINT("info",("spider range_res5=%d", range_res)); +#endif + result_list.tmp_reuse_sql = FALSE; + if (bka_mode && + have_multi_range && +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + !(sql_kinds & SPIDER_SQL_KIND_HS) && +#endif +#ifdef HA_MRR_USE_DEFAULT_IMPL + test(mrr_cur_range.range_flag & EQ_RANGE) +#else + test(multi_range_curr->range_flag & EQ_RANGE) +#endif + ) { + if ( + result_list.tmp_table_join && +#ifdef HA_MRR_USE_DEFAULT_IMPL + result_list.tmp_table_join_key_part_map == + mrr_cur_range.start_key.keypart_map +#else + result_list.tmp_table_join_key_part_map == + multi_range_curr->start_key.keypart_map +#endif + ) { + /* reuse tmp_sql */ + result_list.tmp_reuse_sql = TRUE; + } else { + /* create tmp_sql */ + result_list.tmp_table_join = TRUE; +#ifdef HA_MRR_USE_DEFAULT_IMPL + result_list.tmp_table_join_key_part_map = + mrr_cur_range.start_key.keypart_map; +#else + result_list.tmp_table_join_key_part_map = + multi_range_curr->start_key.keypart_map; +#endif + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL))) + DBUG_RETURN(error_num); + if ((sql_kinds & SPIDER_SQL_KIND_SQL)) + { + for (roop_count = 0; roop_count < (int) share->link_count; + roop_count++) + { + result_list.sql_kind_backup[roop_count] = sql_kind[roop_count]; + sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; + } + result_list.sql_kinds_backup = sql_kinds; + sql_kinds = SPIDER_SQL_KIND_SQL; + result_list.have_sql_kind_backup = TRUE; + } + } + memset(result_list.tmp_table_join_first, 0xFF, + share->link_bitmap_size); + } else { + result_list.tmp_table_join = FALSE; + if (result_list.have_sql_kind_backup) + { + for (roop_count = 0; roop_count < (int) share->link_count; + roop_count++) + { + sql_kind[roop_count] = + result_list.sql_kind_backup[roop_count]; + } + sql_kinds = result_list.sql_kinds_backup; + result_list.have_sql_kind_backup = FALSE; + } + } + + if (result_list.tmp_table_join) + { + result_list.limit_num = + result_list.internal_limit - result_list.record_num >= + result_list.split_read ? + result_list.split_read : + result_list.internal_limit - result_list.record_num; + if (!result_list.tmp_reuse_sql) + { + if ((error_num = append_tmp_table_and_sql_for_bka( +#ifdef HA_MRR_USE_DEFAULT_IMPL + &mrr_cur_range.start_key +#else + &multi_range_curr->start_key +#endif + ))) { + DBUG_RETURN(error_num); + } + } else { + if ((error_num = reuse_tmp_table_and_sql_for_bka())) + { + DBUG_RETURN(error_num); + } + } + +#ifdef HA_MRR_USE_DEFAULT_IMPL + do +#else + for ( + ; + multi_range_curr < multi_range_end; + multi_range_curr++ + ) +#endif + { + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + !test(mrr_cur_range.range_flag & EQ_RANGE) || + result_list.tmp_table_join_key_part_map != + mrr_cur_range.start_key.keypart_map +#else + !test(multi_range_curr->range_flag & EQ_RANGE) || + result_list.tmp_table_join_key_part_map != + multi_range_curr->start_key.keypart_map +#endif + ) { + result_list.tmp_table_join_break_after_get_next = TRUE; + break; + } + +#ifdef HA_MRR_USE_DEFAULT_IMPL +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + multi_range_keys[multi_range_cnt] = mrr_cur_range.ptr; +#else + multi_range_keys[multi_range_cnt] = (char *) mrr_cur_range.ptr; +#endif +#endif + if ((error_num = append_multi_range_cnt_sql_part( + SPIDER_SQL_TYPE_TMP_SQL, multi_range_cnt, TRUE))) + DBUG_RETURN(error_num); + if ((error_num = append_key_column_values_sql_part( +#ifdef HA_MRR_USE_DEFAULT_IMPL + &mrr_cur_range.start_key, +#else + &multi_range_curr->start_key, +#endif + SPIDER_SQL_TYPE_TMP_SQL))) + DBUG_RETURN(error_num); + + if ((error_num = + append_values_connector_sql_part(SPIDER_SQL_TYPE_TMP_SQL))) + DBUG_RETURN(error_num); + multi_range_cnt++; + if (multi_range_cnt >= (uint) result_list.multi_split_read) + break; +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (multi_range_cnt == 1) + { + if (have_multi_range) + { + memcpy(&mrr_cur_range, &mrr_second_range, + sizeof(KEY_MULTI_RANGE)); + have_second_range = FALSE; + range_res = 0; + } else { + range_res = 1; + } + } else { + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res6=%d", range_res)); + } +#endif + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + while (!range_res); +#endif + if ((error_num = + append_values_terminator_sql_part(SPIDER_SQL_TYPE_TMP_SQL))) + DBUG_RETURN(error_num); + result_list.use_union = FALSE; + + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } else { + result_list.limit_num = + result_list.internal_limit - result_list.record_num; + if ((error_num = + append_union_all_start_sql_part(SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); +#ifdef HA_MRR_USE_DEFAULT_IMPL + do +#else + for ( + ; + multi_range_curr < multi_range_end; + multi_range_curr++ + ) +#endif + { +#ifdef HA_MRR_USE_DEFAULT_IMPL +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + multi_range_keys[multi_range_cnt] = mrr_cur_range.ptr; +#else + multi_range_keys[multi_range_cnt] = (char *) mrr_cur_range.ptr; +#endif +#endif + if ((error_num = spider_db_append_select(this))) + DBUG_RETURN(error_num); + if ((error_num = append_multi_range_cnt_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL, multi_range_cnt, TRUE))) + DBUG_RETURN(error_num); + if ((error_num = spider_db_append_select_columns(this))) + DBUG_RETURN(error_num); + high_priority = FALSE; + if ( + share->key_hint && + (error_num = append_hint_after_table_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + (error_num = spider_db_append_key_where( + &mrr_cur_range.start_key, + test(mrr_cur_range.range_flag & EQ_RANGE) ? + NULL : &mrr_cur_range.end_key, this)) +#else + (error_num = spider_db_append_key_where( + &multi_range_curr->start_key, + test(multi_range_curr->range_flag & EQ_RANGE) ? + NULL : &multi_range_curr->end_key, this)) +#endif + ) + DBUG_RETURN(error_num); + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + 0, + result_list.internal_offset + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ((error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + if ((error_num = + append_union_all_sql_part(SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + multi_range_cnt++; + if (multi_range_cnt >= (uint) result_list.multi_split_read) + break; +#ifdef HA_MRR_USE_DEFAULT_IMPL + if (multi_range_cnt == 1) + { + if (have_multi_range) + { + memcpy(&mrr_cur_range, &mrr_second_range, + sizeof(KEY_MULTI_RANGE)); + have_second_range = FALSE; + range_res = 0; + } else { + range_res = 1; + } + } else { + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res7=%d", range_res)); + } +#endif + } +#ifdef HA_MRR_USE_DEFAULT_IMPL + while (!range_res); +#endif + high_priority = tmp_high_priority; + if ((error_num = + append_union_all_end_sql_part(SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + result_list.use_union = TRUE; + + if (result_list.direct_order_limit) + { + if ((error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } else { + if ((error_num = append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + } else { +#endif + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = conns[roop_count]; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + conn = hs_r_conns[roop_count]; + else + conn = hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = + dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(trx, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = multi_range_keys[multi_range_hit_point]; +#else + *found_range_p = &multi_range_ranges[multi_range_hit_point]; +#endif + DBUG_RETURN(0); + } else { +#endif + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + if ( + result_list.tmp_table_join && + spider_bit_is_set(result_list.tmp_table_join_first, roop_count) + ) { + spider_clear_bit(result_list.tmp_table_join_first, roop_count); + spider_set_bit(result_list.tmp_table_created, roop_count); + result_list.tmp_tables_created = TRUE; + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_TMP_SQL, + conn, + -1, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + spider_db_discard_multiple_result(this, roop_count, conn); + } + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + break; + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + if (error_num) + { + if ( + error_num != HA_ERR_END_OF_FILE && + !check_error_mode(error_num) + ) + error_num = HA_ERR_END_OF_FILE; + if (error_num == HA_ERR_END_OF_FILE) + { + if (multi_range_cnt >= (uint) result_list.multi_split_read) + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res8=%d", range_res)); +#else + multi_range_curr++; +#endif + } + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res +#else + multi_range_curr == multi_range_end +#endif + ) { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(error_num); + } + + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (result_list.current) + { + DBUG_PRINT("info", + ("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + if (result_list.current == result_list.first) + result_list.current = NULL; + else + result_list.current = result_list.current->prev; + } + error_num = 0; + } else + DBUG_RETURN(error_num); + } else { + if (!(error_num = spider_db_fetch(table->record[0], this, table))) + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + *range_info = multi_range_keys[multi_range_hit_point]; +#else + *found_range_p = &multi_range_ranges[multi_range_hit_point]; +#endif + DBUG_RETURN(0); + } + if ( + error_num != HA_ERR_END_OF_FILE && + !check_error_mode(error_num) + ) + error_num = HA_ERR_END_OF_FILE; + if (error_num == HA_ERR_END_OF_FILE) + { + if (multi_range_cnt >= (uint) result_list.multi_split_read) + { +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range); + DBUG_PRINT("info",("spider range_res9=%d", range_res)); +#else + multi_range_curr++; +#endif + } + if ( +#ifdef HA_MRR_USE_DEFAULT_IMPL + range_res +#else + multi_range_curr == multi_range_end +#endif + ) { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(error_num); + } + + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (result_list.current) + { + DBUG_PRINT("info", + ("spider result_list.current->finish_flg = FALSE")); + result_list.current->finish_flg = FALSE; + if (result_list.current == result_list.first) + result_list.current = NULL; + else + result_list.current = result_list.current->prev; + } + error_num = 0; + } else + DBUG_RETURN(error_num); + } + multi_range_cnt = 0; + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ( + (error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS)) + ) + DBUG_RETURN(error_num); +#endif +#ifdef HA_MRR_USE_DEFAULT_IMPL +#else + multi_range_ranges = multi_range_curr; +#endif + } while (!error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::rnd_init( + bool scan +) { + int error_num; + DBUG_ENTER("ha_spider::rnd_init"); + DBUG_PRINT("info",("spider this=%p", this)); + pushed_pos = NULL; + if (result_list.lock_type == F_WRLCK) + check_and_start_bulk_update(SPD_BU_START_BY_INDEX_OR_RND_INIT); + + rnd_scan_and_first = scan; + if ( + scan && + sql_command != SQLCOM_ALTER_TABLE + ) { + spider_set_result_list_param(this); + pk_update = FALSE; + if ( + result_list.current && + !result_list.low_mem_read + ) { + result_list.current = result_list.first; + spider_db_set_pos_to_first_row(&result_list); + rnd_scan_and_first = FALSE; + } else { + spider_db_free_one_result_for_start_next(this); + if ( + result_list.current && + result_list.low_mem_read + ) { + int roop_start, roop_end, roop_count, tmp_lock_mode; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (conns[roop_count] && result_list.bgs_working) + spider_bg_conn_break(conns[roop_count], this); +#endif + if (quick_targets[roop_count]) + { + DBUG_ASSERT(quick_targets[roop_count] == + conns[roop_count]->quick_target); + DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", + conns[roop_count])); + conns[roop_count]->quick_target = NULL; + quick_targets[roop_count] = NULL; + } + } + result_list.record_num = 0; + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.quick_phase = 0; +#ifndef WITHOUT_SPIDER_BG_SEARCH + result_list.bgs_phase = 0; +#endif + } + + mrr_with_cnt = FALSE; + use_spatial_index = FALSE; + + if ( + update_request && + share->have_recovery_link && + result_list.lock_type == F_WRLCK && + (pk_update = spider_check_pk_update(table)) + ) { + bitmap_set_all(table->read_set); + if (is_clone) + memset(searched_bitmap, 0xFF, no_bytes_in_map(table->read_set)); + } + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif + set_select_column_mode(); + result_list.keyread = FALSE; + + init_rnd_handler = FALSE; + if ((error_num = reset_sql_sql( + SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ( + (error_num = reset_hs_sql(SPIDER_SQL_TYPE_SELECT_HS)) || + (error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS)) + ) + DBUG_RETURN(error_num); +#endif + result_list.check_direct_order_limit = FALSE; + } + } + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_rnd_init( + bool scan +) { + DBUG_ENTER("ha_spider::pre_rnd_init"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(bulk_access_link_current->spider->ha_rnd_init(scan)); +} +#endif + +int ha_spider::rnd_end() +{ + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::rnd_end"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + info_limit = 9223372036854775807LL; +#endif + if ( + (error_num = check_and_end_bulk_update( + SPD_BU_START_BY_INDEX_OR_RND_INIT)) || + (error_num = spider_trx_check_link_idx_failed(this)) + ) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_rnd_end() +{ + DBUG_ENTER("ha_spider::pre_rnd_end"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(bulk_access_link_current->spider->ha_rnd_end()); +} +#endif + +int ha_spider::rnd_next_internal( + uchar *buf +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::rnd_next_internal"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + /* do not copy table data at alter table */ + if (sql_command == SQLCOM_ALTER_TABLE) + DBUG_RETURN(HA_ERR_END_OF_FILE); + + if (rnd_scan_and_first) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (sql_kinds & SPIDER_SQL_KIND_HS) + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +#endif + if ((error_num = rnd_handler_init())) + DBUG_RETURN(check_error_mode_eof(error_num)); + check_direct_order_limit(); +#ifdef WITH_PARTITION_STORAGE_ENGINE + check_select_column(TRUE); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if ( + (error_num = spider_db_append_select(this)) || + (error_num = spider_db_append_select_columns(this)) + ) + DBUG_RETURN(error_num); + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + + /* append condition pushdown */ + if (spider_db_append_condition(this, NULL, 0, FALSE)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + set_order_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + if ( + result_list.direct_order_limit && + (error_num = append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + result_list.desc_flg = FALSE; + result_list.sorted = FALSE; + result_list.key_info = NULL; + result_list.limit_num = + result_list.internal_limit >= result_list.split_read ? + result_list.split_read : result_list.internal_limit; + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + } else { +#endif + SPIDER_CONN *conn = conns[roop_count]; + ulong sql_type; + if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } + spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = + dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, + roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + rnd_scan_and_first = FALSE; + } + if (buf && (error_num = spider_db_seek_next(buf, this, search_link_idx, + table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::pre_rnd_next( + bool use_parallel +) { + DBUG_ENTER("ha_spider::pre_rnd_next"); + DBUG_PRINT("info",("spider this=%p", this)); + check_pre_call(use_parallel); + if (use_pre_call) + { + store_error_num = + rnd_next_internal(NULL); + DBUG_RETURN(store_error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::rnd_next( + uchar *buf +) { + int error_num; + DBUG_ENTER("ha_spider::rnd_next"); + DBUG_PRINT("info",("spider this=%p", this)); + if (use_pre_call) + { + if (store_error_num) + { + if (store_error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(store_error_num); + } + if ((error_num = spider_bg_all_conn_pre_next(this, search_link_idx))) + DBUG_RETURN(error_num); + use_pre_call = FALSE; + } + DBUG_RETURN(rnd_next_internal(buf)); +} + +void ha_spider::position( + const uchar *record +) { + DBUG_ENTER("ha_spider::position"); + DBUG_PRINT("info",("spider this=%p", this)); + if (pushed_pos) + { + DBUG_PRINT("info",("spider pushed_pos=%p", pushed_pos)); + memcpy(ref, pushed_pos, ref_length); + DBUG_VOID_RETURN; + } + if (pt_clone_last_searcher) + { + /* sercher is cloned handler */ + DBUG_PRINT("info",("spider cloned handler access")); + pt_clone_last_searcher->position(record); + memcpy(ref, pt_clone_last_searcher->ref, ref_length); + } else { + memset(ref, '0', sizeof(SPIDER_POSITION)); + DBUG_PRINT("info",("spider self position")); + DBUG_PRINT("info", + ("spider current_row_num=%lld", result_list.current_row_num)); + if (!position_bitmap_init) + { + if (select_column_mode) + { + int roop_count; + for (roop_count = 0; + roop_count < (int) ((table_share->fields + 7) / 8); + roop_count++) + { + position_bitmap[roop_count] = + searched_bitmap[roop_count] | + ((uchar *) table->read_set->bitmap)[roop_count] | + ((uchar *) table->write_set->bitmap)[roop_count]; + DBUG_PRINT("info",("spider roop_count=%d", roop_count)); + DBUG_PRINT("info",("spider position_bitmap=%d", + position_bitmap[roop_count])); + DBUG_PRINT("info",("spider searched_bitmap=%d", + searched_bitmap[roop_count])); + DBUG_PRINT("info",("spider read_set=%d", + ((uchar *) table->read_set->bitmap)[roop_count])); + DBUG_PRINT("info",("spider write_set=%d", + ((uchar *) table->write_set->bitmap)[roop_count])); + } + } + position_bitmap_init = TRUE; + } + spider_db_create_position(this, (SPIDER_POSITION *) ref); + } + DBUG_VOID_RETURN; +} + +int ha_spider::rnd_pos( + uchar *buf, + uchar *pos +) { + DBUG_ENTER("ha_spider::rnd_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + DBUG_PRINT("info",("spider pos=%p", pos)); + DBUG_PRINT("info",("spider buf=%p", buf)); + pushed_pos_buf = *((SPIDER_POSITION *) pos); + pushed_pos = &pushed_pos_buf; + DBUG_RETURN(spider_db_seek_tmp(buf, &pushed_pos_buf, this, table)); +} + +int ha_spider::cmp_ref( + const uchar *ref1, + const uchar *ref2 +) { + int ret = 0; + DBUG_ENTER("ha_spider::cmp_ref"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider ref1=%p", ref1)); + DBUG_PRINT("info",("spider ref2=%p", ref2)); + if (table_share->primary_key < MAX_KEY) + { + uchar table_key[MAX_KEY_LENGTH]; + KEY *key_info = &table->key_info[table_share->primary_key]; + DBUG_PRINT("info",("spider cmp by primary key")); + rnd_pos(table->record[0], (uchar *) ref2); + key_copy( + table_key, + table->record[0], + key_info, + key_info->key_length); + rnd_pos(table->record[0], (uchar *) ref1); + ret = key_cmp(key_info->key_part, table_key, key_info->key_length); + } else { + Field **field; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(table->record[1], table->record[0]); + DBUG_PRINT("info",("spider cmp by all rows")); + rnd_pos(table->record[1], (uchar *) ref2); + rnd_pos(table->record[0], (uchar *) ref1); + for ( + field = table->field; + *field; + field++ + ) { + if ((ret = (*field)->cmp_binary_offset(ptr_diff))) + { + DBUG_PRINT("info",("spider different at %s", (*field)->field_name)); + break; + } + } + } + DBUG_PRINT("info",("spider ret=%d", ret)); + DBUG_RETURN(ret); +} + +float spider_ft_find_relevance( + FT_INFO *handler, + uchar *record, + uint length +) { + DBUG_ENTER("spider_ft_find_relevance"); + st_spider_ft_info *info = (st_spider_ft_info*) handler; + DBUG_PRINT("info",("spider info=%p", info)); + DBUG_PRINT("info",("spider score=%f", info->score)); + DBUG_RETURN(info->score); +} + +float spider_ft_get_relevance( + FT_INFO *handler +) { + DBUG_ENTER("spider_ft_get_relevance"); + st_spider_ft_info *info = (st_spider_ft_info*) handler; + DBUG_PRINT("info",("spider info=%p", info)); + DBUG_PRINT("info",("spider score=%f", info->score)); + DBUG_RETURN(info->score); +} + +void spider_ft_close_search( + FT_INFO *handler +) { + DBUG_ENTER("spider_ft_close_search"); + DBUG_VOID_RETURN; +} + +_ft_vft spider_ft_vft = { + NULL, // spider_ft_read_next + spider_ft_find_relevance, + spider_ft_close_search, + spider_ft_get_relevance, + NULL // spider_ft_reinit_search +}; + +int ha_spider::ft_init() +{ + int roop_count, error_num; + DBUG_ENTER("ha_spider::ft_init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (store_error_num) + DBUG_RETURN(store_error_num); + if (active_index == MAX_KEY && inited == NONE) + { + st_spider_ft_info *ft_info = ft_first; + ft_init_without_index_init = TRUE; + ft_init_idx = MAX_KEY; + while (TRUE) + { + if (ft_info->used_in_where) + { + ft_init_idx = ft_info->inx; + if ((error_num = index_init(ft_init_idx, FALSE))) + DBUG_RETURN(error_num); + active_index = MAX_KEY; + break; + } + if (ft_info == ft_current) + break; + ft_info = ft_info->next; + } + if (ft_init_idx == MAX_KEY) + { + if ((error_num = rnd_init(TRUE))) + DBUG_RETURN(error_num); + } + } else { + ft_init_idx = active_index; + ft_init_without_index_init = FALSE; + } + + ft_init_and_first = TRUE; + + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; + sql_kinds = SPIDER_SQL_KIND_SQL; + DBUG_RETURN(0); +} + +void ha_spider::ft_end() +{ + DBUG_ENTER("ha_spider::ft_end"); + DBUG_PRINT("info",("spider this=%p", this)); + ft_handler = NULL; + ft_current = NULL; + ft_count = 0; + if (ft_init_without_index_init) + { + if (ft_init_idx == MAX_KEY) + store_error_num = rnd_end(); + else + store_error_num = index_end(); + } + ft_init_without_index_init = FALSE; + DBUG_VOID_RETURN; +} + +FT_INFO *ha_spider::ft_init_ext( + uint flags, + uint inx, + String *key +) { + st_spider_ft_info *tmp_ft_info; + backup_error_status(); + DBUG_ENTER("ha_spider::ft_init_ext"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider flags=%u", flags)); + DBUG_PRINT("info",("spider inx=%u", inx)); + DBUG_PRINT("info",("spider key=%s", key->c_ptr_safe())); + tmp_ft_info = ft_current; + if (ft_current) + ft_current = ft_current->next; + else + ft_current = ft_first; + + if (!ft_current) + { + if (!(ft_current = (st_spider_ft_info *) + spider_malloc(spider_current_trx, 2, sizeof(st_spider_ft_info), + MYF(MY_WME | MY_ZEROFILL)))) + { + store_error_num = HA_ERR_OUT_OF_MEM; + DBUG_RETURN(NULL); + } + if (tmp_ft_info) + tmp_ft_info->next = ft_current; + else + ft_first = ft_current; + } + + ft_current->please = &spider_ft_vft; + ft_current->file = this; + ft_current->used_in_where = (flags & FT_SORTED); + ft_current->target = ft_count; + ft_current->flags = flags; + ft_current->inx = inx; + ft_current->key = key; + + ft_count++; + DBUG_RETURN((FT_INFO *) ft_current); +} + +int ha_spider::ft_read_internal( + uchar *buf +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::ft_read_internal"); + DBUG_PRINT("info",("spider this=%p", this)); + if (trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + DBUG_RETURN(ER_QUERY_INTERRUPTED); + } + if (ft_init_and_first) + { + ft_init_and_first = FALSE; + spider_db_free_one_result_for_start_next(this); + check_direct_order_limit(); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_set_conn_bg_param(this))) + DBUG_RETURN(error_num); +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + check_select_column(FALSE); +#endif + DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); + result_list.finish_flg = FALSE; + result_list.record_num = 0; + if (keyread) + result_list.keyread = TRUE; + else + result_list.keyread = FALSE; + if ( + (error_num = spider_db_append_select(this)) || + (error_num = spider_db_append_select_columns(this)) + ) + DBUG_RETURN(error_num); + uint tmp_active_index = active_index; + active_index = ft_init_idx; + if ( + ft_init_idx < MAX_KEY && + share->key_hint && + (error_num = + append_hint_after_table_sql_part(SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + active_index = tmp_active_index; + DBUG_RETURN(error_num); + } + active_index = tmp_active_index; + set_where_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + result_list.desc_flg = FALSE; + result_list.sorted = TRUE; + if (ft_init_idx == MAX_KEY) + result_list.key_info = NULL; + else + result_list.key_info = &table->key_info[ft_init_idx]; + result_list.key_order = 0; + result_list.limit_num = + result_list.internal_limit >= result_list.split_read ? + result_list.split_read : result_list.internal_limit; + if ( + (error_num = spider_db_append_match_where(this)) || + ( + result_list.direct_order_limit && + (error_num = + append_key_order_for_direct_order_limit_with_alias_sql_part(NULL, 0, + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + ) + DBUG_RETURN(error_num); + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + if ( + (error_num = append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = append_limit_sql_part( + result_list.internal_offset, + result_list.limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_RETURN(error_num); + } + } + + int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + link_ok = search_link_idx; + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list.bgs_phase > 0) + { + if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + } else { +#endif + uint dbton_id = share->use_sql_dbton_ids[roop_count]; + spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; + SPIDER_CONN *conn = conns[roop_count]; + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_SELECT_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec( + SPIDER_SQL_TYPE_SELECT_SQL, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_SELECT_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + conn->need_mon = &need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(this, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + spider_conn_set_timeout_from_share(conn, roop_count, trx->thd, share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_SELECT_SQL, + conn, + result_list.quick_mode, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(this, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(check_error_mode_eof(error_num)); + } + result_link_idx = link_ok; + } else { + spider_db_discard_result(this, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + } + + if (is_clone) + { + DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", + pt_clone_source_handler)); + pt_clone_source_handler->pt_clone_last_searcher = this; + } + if (buf && (error_num = spider_db_seek_next(buf, this, search_link_idx, + table))) + DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::pre_ft_read( + bool use_parallel +) { + DBUG_ENTER("ha_spider::pre_ft_read"); + DBUG_PRINT("info",("spider this=%p", this)); + check_pre_call(use_parallel); + if (use_pre_call) + { + store_error_num = + ft_read_internal(NULL); + DBUG_RETURN(store_error_num); + } + DBUG_RETURN(0); +} + +int ha_spider::ft_read( + uchar *buf +) { + int error_num; + DBUG_ENTER("ha_spider::ft_read"); + DBUG_PRINT("info",("spider this=%p", this)); + if (use_pre_call) + { + if (store_error_num) + { + if (store_error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(store_error_num); + } + if ((error_num = spider_bg_all_conn_pre_next(this, search_link_idx))) + DBUG_RETURN(error_num); + use_pre_call = FALSE; + } + DBUG_RETURN(ft_read_internal(buf)); +} + +int ha_spider::info( + uint flag +) { + int error_num; + THD *thd = ha_thd(); + double sts_interval = spider_param_sts_interval(thd, share->sts_interval); + int sts_mode = spider_param_sts_mode(thd, share->sts_mode); +#ifdef WITH_PARTITION_STORAGE_ENGINE + int sts_sync = spider_param_sts_sync(thd, share->sts_sync); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + int sts_bg_mode = spider_param_sts_bg_mode(thd, share->sts_bg_mode); +#endif + SPIDER_INIT_ERROR_TABLE *spider_init_error_table = NULL; + set_error_mode(); + backup_error_status(); + DBUG_ENTER("ha_spider::info"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider flag=%x", flag)); + sql_command = thd_sql_command(thd); + if ( + sql_command == SQLCOM_DROP_TABLE || + sql_command == SQLCOM_ALTER_TABLE || + sql_command == SQLCOM_SHOW_CREATE + ) { + if (flag & HA_STATUS_AUTO) + { + if (share->auto_increment_value) + stats.auto_increment_value = share->auto_increment_value; + else + stats.auto_increment_value = 1; + } + DBUG_RETURN(0); + } + + if (flag & + (HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE | HA_STATUS_AUTO)) + { + time_t tmp_time = (time_t) time((time_t*) 0); + DBUG_PRINT("info", + ("spider difftime=%f", difftime(tmp_time, share->sts_get_time))); + DBUG_PRINT("info", + ("spider sts_interval=%f", sts_interval)); + int tmp_auto_increment_mode = 0; + if (flag & HA_STATUS_AUTO) + { + tmp_auto_increment_mode = spider_param_auto_increment_mode(thd, + share->auto_increment_mode); +#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC + info_auto_called = TRUE; +#endif + } + if (!share->sts_init) + { + pthread_mutex_lock(&share->sts_mutex); + if (share->sts_init) + pthread_mutex_unlock(&share->sts_mutex); + else { + if ((spider_init_error_table = + spider_get_init_error_table(trx, share, FALSE))) + { + DBUG_PRINT("info",("spider diff=%f", + difftime(tmp_time, spider_init_error_table->init_error_time))); + if (difftime(tmp_time, + spider_init_error_table->init_error_time) < + spider_param_table_init_error_interval()) + { + pthread_mutex_unlock(&share->sts_mutex); + if (spider_init_error_table->init_error_with_message) + my_message(spider_init_error_table->init_error, + spider_init_error_table->init_error_msg, MYF(0)); + DBUG_RETURN(check_error_mode(spider_init_error_table->init_error)); + } + } + pthread_mutex_unlock(&share->sts_mutex); + sts_interval = 0; +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (tmp_auto_increment_mode == 1) + sts_sync = 0; +#endif + } + } + if (flag & HA_STATUS_AUTO) + { + if ( + share->partition_share && + tmp_auto_increment_mode == 1 && + !share->auto_increment_init + ) { + sts_interval = 0; +#ifdef WITH_PARTITION_STORAGE_ENGINE + sts_sync = 0; +#endif + } + } + if (difftime(tmp_time, share->sts_get_time) >= sts_interval) + { + if ( + sts_interval == 0 || + !pthread_mutex_trylock(&share->sts_mutex) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (sts_interval == 0 || sts_bg_mode == 0) + { +#endif + if (sts_interval == 0) + pthread_mutex_lock(&share->sts_mutex); + if (difftime(tmp_time, share->sts_get_time) >= sts_interval) + { + if ( + (error_num = spider_check_trx_and_get_conn(ha_thd(), this, + FALSE)) || + (error_num = spider_get_sts(share, search_link_idx, tmp_time, + this, sts_interval, sts_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + sts_sync, +#endif + share->sts_init ? 2 : 1, + flag | (share->sts_init ? 0 : HA_STATUS_AUTO))) + ) { + pthread_mutex_unlock(&share->sts_mutex); + if ( + share->monitoring_kind[search_link_idx] && + need_mons[search_link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[search_link_idx], + share->table_name, + share->table_name_length, + conn_link_idx[search_link_idx], + NULL, + 0, + share->monitoring_kind[search_link_idx], + share->monitoring_limit[search_link_idx], + TRUE + ); + } + if (!share->sts_init) + { + if ( + spider_init_error_table || + (spider_init_error_table = + spider_get_init_error_table(trx, share, TRUE)) + ) { + spider_init_error_table->init_error = error_num; +/* + if (!thd->is_error()) + my_error(error_num, MYF(0), ""); +*/ + if ((spider_init_error_table->init_error_with_message = + thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(spider_init_error_table->init_error_msg, + thd->main_da.message()); +#else + strmov(spider_init_error_table->init_error_msg, + thd->stmt_da->message()); +#endif + spider_init_error_table->init_error_time = + (time_t) time((time_t*) 0); + } + share->init_error = TRUE; + share->init = TRUE; + } + DBUG_RETURN(check_error_mode(error_num)); + } + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + } else { + /* background */ + if (!share->bg_sts_init || share->bg_sts_thd_wait) + { + share->bg_sts_thd_wait = FALSE; + share->bg_sts_try_time = tmp_time; + share->bg_sts_interval = sts_interval; + share->bg_sts_mode = sts_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + share->bg_sts_sync = sts_sync; +#endif + if (!share->bg_sts_init) + { + if ((error_num = spider_create_sts_thread(share))) + { + pthread_mutex_unlock(&share->sts_mutex); + DBUG_RETURN(error_num); + } + } else + pthread_cond_signal(&share->bg_sts_cond); + } + } +#endif + pthread_mutex_unlock(&share->sts_mutex); + } + } + if (flag & HA_STATUS_CONST) + { + if ((error_num = check_crd())) + DBUG_RETURN(error_num); + spider_db_set_cardinarity(this, table); + } + + if (flag & HA_STATUS_TIME) + stats.update_time = (ulong) share->update_time; + if (flag & (HA_STATUS_CONST | HA_STATUS_VARIABLE)) + { + stats.max_data_file_length = share->max_data_file_length; + stats.create_time = (ulong) share->create_time; + stats.block_size = spider_param_block_size(thd); + } + if (flag & HA_STATUS_VARIABLE) + { + stats.data_file_length = share->data_file_length; + stats.index_file_length = share->index_file_length; + stats.records = share->records; + stats.mean_rec_length = share->mean_rec_length; + stats.check_time = (ulong) share->check_time; + if (stats.records <= 1 /* && (flag & HA_STATUS_NO_LOCK) */ ) + stats.records = 2; + } + if (flag & HA_STATUS_AUTO) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (share->partition_share && table->next_number_field) + { + ulonglong first_value, nb_reserved_values; + if ( + tmp_auto_increment_mode == 0 && + !( + table->next_number_field->val_int() != 0 || + (table->auto_increment_field_not_null && + thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) + ) + ) { + get_auto_increment(0, 0, 0, &first_value, &nb_reserved_values); + share->auto_increment_value = first_value; + share->auto_increment_lclval = first_value; + share->auto_increment_init = TRUE; + DBUG_PRINT("info",("spider init auto_increment_lclval=%llu", + share->auto_increment_lclval)); + stats.auto_increment_value = first_value; + } else if (tmp_auto_increment_mode == 1 && !share->auto_increment_init) + { + share->auto_increment_lclval = share->auto_increment_value; + share->auto_increment_init = TRUE; + stats.auto_increment_value = share->auto_increment_value; + } else { + stats.auto_increment_value = share->auto_increment_value; + } + } else { +#endif + stats.auto_increment_value = share->auto_increment_value; +#ifdef WITH_PARTITION_STORAGE_ENGINE + } +#endif + } + } + if (flag & HA_STATUS_ERRKEY) + errkey = dup_key_idx; + DBUG_RETURN(0); +} + +ha_rows ha_spider::records_in_range( + uint inx, + key_range *start_key, + key_range *end_key +) { + int error_num; + THD *thd = ha_thd(); + double crd_interval = spider_param_crd_interval(thd, share->crd_interval); + int crd_mode = spider_param_crd_mode(thd, share->crd_mode); + int crd_type = spider_param_crd_type(thd, share->crd_type); +#ifdef WITH_PARTITION_STORAGE_ENGINE + int crd_sync = spider_param_crd_sync(thd, share->crd_sync); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + int crd_bg_mode = spider_param_crd_bg_mode(thd, share->crd_bg_mode); +#endif + SPIDER_INIT_ERROR_TABLE *spider_init_error_table = NULL; + uint dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::records_in_range"); + DBUG_PRINT("info",("spider this=%p", this)); + time_t tmp_time = (time_t) time((time_t*) 0); + if (!share->crd_init) + { + pthread_mutex_lock(&share->crd_mutex); + if (share->crd_init) + pthread_mutex_unlock(&share->crd_mutex); + else { + if ((spider_init_error_table = + spider_get_init_error_table(trx, share, FALSE))) + { + DBUG_PRINT("info",("spider diff=%f", + difftime(tmp_time, spider_init_error_table->init_error_time))); + if (difftime(tmp_time, + spider_init_error_table->init_error_time) < + spider_param_table_init_error_interval()) + { + pthread_mutex_unlock(&share->crd_mutex); + if (spider_init_error_table->init_error_with_message) + my_message(spider_init_error_table->init_error, + spider_init_error_table->init_error_msg, MYF(0)); + if (check_error_mode(spider_init_error_table->init_error)) + my_errno = spider_init_error_table->init_error; + DBUG_RETURN(HA_POS_ERROR); + } + } + pthread_mutex_unlock(&share->crd_mutex); + if (crd_mode == 3) + crd_mode = 1; + crd_interval = 0; + } + } + dbton_id = share->sql_dbton_ids[search_link_idx]; + dbton_hdl = dbton_handler[dbton_id]; + crd_mode = dbton_hdl->crd_mode_exchange(crd_mode); + if (crd_mode == 1 || crd_mode == 2) + { + DBUG_PRINT("info", + ("spider difftime=%f", difftime(tmp_time, share->crd_get_time))); + DBUG_PRINT("info", + ("spider crd_interval=%f", crd_interval)); + if (difftime(tmp_time, share->crd_get_time) >= crd_interval) + { + if ( + crd_interval == 0 || + !pthread_mutex_trylock(&share->crd_mutex) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (crd_interval == 0 || crd_bg_mode == 0) + { +#endif + if (crd_interval == 0) + pthread_mutex_lock(&share->crd_mutex); + if (difftime(tmp_time, share->crd_get_time) >= crd_interval) + { + if ((error_num = spider_get_crd(share, search_link_idx, tmp_time, + this, table, crd_interval, crd_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + crd_sync, +#endif + share->crd_init ? 2 : 1))) + { + pthread_mutex_unlock(&share->crd_mutex); + if ( + share->monitoring_kind[search_link_idx] && + need_mons[search_link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[search_link_idx], + share->table_name, + share->table_name_length, + conn_link_idx[search_link_idx], + NULL, + 0, + share->monitoring_kind[search_link_idx], + share->monitoring_limit[search_link_idx], + TRUE + ); + } + if (!share->crd_init) + { + if ( + spider_init_error_table || + (spider_init_error_table = + spider_get_init_error_table(trx, share, TRUE)) + ) { + spider_init_error_table->init_error = error_num; +/* + if (!thd->is_error()) + my_error(error_num, MYF(0), ""); +*/ + if ((spider_init_error_table->init_error_with_message = + thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(spider_init_error_table->init_error_msg, + thd->main_da.message()); +#else + strmov(spider_init_error_table->init_error_msg, + thd->stmt_da->message()); +#endif + spider_init_error_table->init_error_time = + (time_t) time((time_t*) 0); + } + share->init_error = TRUE; + share->init = TRUE; + } + if (check_error_mode(error_num)) + my_errno = error_num; + DBUG_RETURN(HA_POS_ERROR); + } + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + } else { + /* background */ + if (!share->bg_crd_init || share->bg_crd_thd_wait) + { + share->bg_crd_thd_wait = FALSE; + share->bg_crd_try_time = tmp_time; + share->bg_crd_interval = crd_interval; + share->bg_crd_mode = crd_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + share->bg_crd_sync = crd_sync; +#endif + if (!share->bg_crd_init) + { + if ((error_num = spider_create_crd_thread(share))) + { + pthread_mutex_unlock(&share->crd_mutex); + my_errno = error_num; + DBUG_RETURN(HA_POS_ERROR); + } + } else + pthread_cond_signal(&share->bg_crd_cond); + } + } +#endif + pthread_mutex_unlock(&share->crd_mutex); + } + } + + KEY *key_info = &table->key_info[inx]; + key_part_map full_key_part_map = + make_prev_keypart_map(key_info->key_parts); + key_part_map start_key_part_map; + key_part_map end_key_part_map; + key_part_map tgt_key_part_map; + KEY_PART_INFO *key_part; + Field *field; + double rows = (double) share->records; + double weight, rate; + DBUG_PRINT("info",("spider rows1=%f", rows)); + if (start_key) + start_key_part_map = start_key->keypart_map & full_key_part_map; + else + start_key_part_map = 0; + if (end_key) + end_key_part_map = end_key->keypart_map & full_key_part_map; + else + end_key_part_map = 0; + + if (!start_key_part_map && !end_key_part_map) + { + DBUG_RETURN(HA_POS_ERROR); + } + else if (start_key_part_map >= end_key_part_map) + { + tgt_key_part_map = start_key_part_map; + } else { + tgt_key_part_map = end_key_part_map; + } + + if (crd_type == 0) + weight = spider_param_crd_weight(thd, share->crd_weight); + else + weight = 1; + + for ( + key_part = key_info->key_part; + tgt_key_part_map > 1; + tgt_key_part_map >>= 1, + key_part++ + ) { + field = key_part->field; + if ((rate = + ((double) share->cardinality[field->field_index]) / weight) >= 1 + ) { + if ((rows = rows / rate) < 2) + { + DBUG_PRINT("info",("spider rows2=%f then ret 2", rows)); + DBUG_RETURN((ha_rows) 2); + } + } + if (crd_type == 1) + weight += spider_param_crd_weight(thd, share->crd_weight); + else if (crd_type == 2) + weight *= spider_param_crd_weight(thd, share->crd_weight); + } + field = key_part->field; + if ( + start_key_part_map >= end_key_part_map && + start_key->flag == HA_READ_KEY_EXACT + ) { + if ((rate = + ((double) share->cardinality[field->field_index]) / weight) >= 1) + rows = rows / rate; + } else if (start_key_part_map == end_key_part_map) + { + if ((rate = + ((double) share->cardinality[field->field_index]) / weight / 4) >= 1) + rows = rows / rate; + } else { + if ((rate = + ((double) share->cardinality[field->field_index]) / weight / 16) >= 1) + rows = rows / rate; + } + if (rows < 2) + { + DBUG_PRINT("info",("spider rows3=%f then ret 2", rows)); + DBUG_RETURN((ha_rows) 2); + } + DBUG_PRINT("info",("spider rows4=%f", rows)); + DBUG_RETURN((ha_rows) rows); + } else if (crd_mode == 3) + { + result_list.key_info = &table->key_info[inx]; + DBUG_RETURN(spider_db_explain_select(start_key, end_key, this, + search_link_idx)); + } + DBUG_RETURN((ha_rows) spider_param_crd_weight(thd, share->crd_weight)); +} + +int ha_spider::check_crd() +{ + int error_num; + THD *thd = ha_thd(); + double crd_interval = spider_param_crd_interval(thd, share->crd_interval); + int crd_mode = spider_param_crd_mode(thd, share->crd_mode); +#ifdef WITH_PARTITION_STORAGE_ENGINE + int crd_sync = spider_param_crd_sync(thd, share->crd_sync); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + int crd_bg_mode = spider_param_crd_bg_mode(thd, share->crd_bg_mode); +#endif + SPIDER_INIT_ERROR_TABLE *spider_init_error_table = NULL; + uint dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::check_crd"); + DBUG_PRINT("info",("spider this=%p", this)); + time_t tmp_time = (time_t) time((time_t*) 0); + if (!share->crd_init) + { + pthread_mutex_lock(&share->crd_mutex); + if (share->crd_init) + pthread_mutex_unlock(&share->crd_mutex); + else { + if ((spider_init_error_table = + spider_get_init_error_table(trx, share, FALSE))) + { + DBUG_PRINT("info",("spider diff=%f", + difftime(tmp_time, spider_init_error_table->init_error_time))); + if (difftime(tmp_time, + spider_init_error_table->init_error_time) < + spider_param_table_init_error_interval()) + { + pthread_mutex_unlock(&share->crd_mutex); + if (spider_init_error_table->init_error_with_message) + my_message(spider_init_error_table->init_error, + spider_init_error_table->init_error_msg, MYF(0)); + DBUG_RETURN(check_error_mode(spider_init_error_table->init_error)); + } + } + pthread_mutex_unlock(&share->crd_mutex); + crd_interval = 0; + } + } + if (crd_mode == 3) + crd_mode = 1; + dbton_id = share->sql_dbton_ids[search_link_idx]; + dbton_hdl = dbton_handler[dbton_id]; + crd_mode = dbton_hdl->crd_mode_exchange(crd_mode); + DBUG_PRINT("info", + ("spider difftime=%f", difftime(tmp_time, share->crd_get_time))); + DBUG_PRINT("info", + ("spider crd_interval=%f", crd_interval)); + if (difftime(tmp_time, share->crd_get_time) >= crd_interval) + { + if ( + crd_interval == 0 || + !pthread_mutex_trylock(&share->crd_mutex) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (crd_interval == 0 || crd_bg_mode == 0) + { +#endif + if (crd_interval == 0) + pthread_mutex_lock(&share->crd_mutex); + if (difftime(tmp_time, share->crd_get_time) >= crd_interval) + { + if ((error_num = spider_get_crd(share, search_link_idx, tmp_time, + this, table, crd_interval, crd_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + crd_sync, +#endif + share->crd_init ? 2 : 1))) + { + pthread_mutex_unlock(&share->crd_mutex); + if ( + share->monitoring_kind[search_link_idx] && + need_mons[search_link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[search_link_idx], + share->table_name, + share->table_name_length, + conn_link_idx[search_link_idx], + NULL, + 0, + share->monitoring_kind[search_link_idx], + share->monitoring_limit[search_link_idx], + TRUE + ); + } + if (!share->crd_init) + { + if ( + spider_init_error_table || + (spider_init_error_table = + spider_get_init_error_table(trx, share, TRUE)) + ) { + spider_init_error_table->init_error = error_num; + if ((spider_init_error_table->init_error_with_message = + thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(spider_init_error_table->init_error_msg, + thd->main_da.message()); +#else + strmov(spider_init_error_table->init_error_msg, + thd->stmt_da->message()); +#endif + spider_init_error_table->init_error_time = + (time_t) time((time_t*) 0); + } + share->init_error = TRUE; + share->init = TRUE; + } + DBUG_RETURN(check_error_mode(error_num)); + } + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + } else { + /* background */ + if (!share->bg_crd_init || share->bg_crd_thd_wait) + { + share->bg_crd_thd_wait = FALSE; + share->bg_crd_try_time = tmp_time; + share->bg_crd_interval = crd_interval; + share->bg_crd_mode = crd_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + share->bg_crd_sync = crd_sync; +#endif + if (!share->bg_crd_init) + { + if ((error_num = spider_create_crd_thread(share))) + { + pthread_mutex_unlock(&share->crd_mutex); + DBUG_RETURN(error_num); + } + } else + pthread_cond_signal(&share->bg_crd_cond); + } + } +#endif + pthread_mutex_unlock(&share->crd_mutex); + } + } + DBUG_RETURN(0); +} + +ha_rows ha_spider::records() +{ + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::records"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_show_records(this, search_link_idx))) + { + check_error_mode(error_num); + DBUG_RETURN(HA_POS_ERROR); + } + DBUG_RETURN(share->records); +} + +const char *ha_spider::table_type() const +{ + DBUG_ENTER("ha_spider::table_type"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN("SPIDER"); +} + +ulonglong ha_spider::table_flags() const +{ + DBUG_ENTER("ha_spider::table_flags"); + DBUG_PRINT("info",("spider this=%p", this)); + ulonglong flags = + HA_REC_NOT_IN_SEQ | + HA_CAN_GEOMETRY | + HA_NULL_IN_KEY | + HA_CAN_INDEX_BLOBS | + HA_AUTO_PART_KEY | + HA_CAN_RTREEKEYS | + HA_PRIMARY_KEY_REQUIRED_FOR_DELETE | + /* HA_NO_PREFIX_CHAR_KEYS | */ + HA_CAN_FULLTEXT | + HA_CAN_SQL_HANDLER | + HA_FILE_BASED | + HA_CAN_INSERT_DELAYED | + HA_CAN_BIT_FIELD | + HA_NO_COPY_ON_ALTER | + HA_BINLOG_ROW_CAPABLE | + HA_BINLOG_STMT_CAPABLE | + HA_HAS_RECORDS | + HA_PARTIAL_COLUMN_READ | +#ifdef HA_CAN_BULK_ACCESS + (support_bulk_access_hs() ? HA_CAN_BULK_ACCESS : 0) | +#endif + SPIDER_CAN_BG_SEARCH | + SPIDER_CAN_BG_INSERT | + SPIDER_CAN_BG_UPDATE | + (share ? share->additional_table_flags : 0) + ; + DBUG_RETURN(flags); +} + +const char *ha_spider::index_type( + uint key_number +) { + KEY *key_info = &table->s->key_info[key_number]; + DBUG_ENTER("ha_spider::index_type"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider flags=%ld", key_info->flags)); + DBUG_PRINT("info",("spider algorithm=%d", key_info->algorithm)); + DBUG_RETURN( + (key_info->flags & HA_FULLTEXT) ? "FULLTEXT" : + (key_info->flags & HA_SPATIAL) ? "SPATIAL" : + (key_info->algorithm == HA_KEY_ALG_HASH) ? "HASH" : + (key_info->algorithm == HA_KEY_ALG_RTREE) ? "RTREE" : + "BTREE" + ); +} + +ulong ha_spider::index_flags( + uint idx, + uint part, + bool all_parts +) const { + DBUG_ENTER("ha_spider::index_flags"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN( + (table_share->key_info[idx].algorithm == HA_KEY_ALG_FULLTEXT) ? + 0 : + (table_share->key_info[idx].algorithm == HA_KEY_ALG_HASH) ? + HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR : + HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE | + HA_KEYREAD_ONLY + ); +} + +uint ha_spider::max_supported_record_length() const +{ + DBUG_ENTER("ha_spider::max_supported_record_length"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_MAX_REC_LENGTH); +} + +uint ha_spider::max_supported_keys() const +{ + DBUG_ENTER("ha_spider::max_supported_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(MAX_KEY); +} + +uint ha_spider::max_supported_key_parts() const +{ + DBUG_ENTER("ha_spider::max_supported_key_parts"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(MAX_REF_PARTS); +} + +uint ha_spider::max_supported_key_length() const +{ + DBUG_ENTER("ha_spider::max_supported_key_length"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(SPIDER_MAX_KEY_LENGTH); +} + +uint ha_spider::max_supported_key_part_length() const +{ + DBUG_ENTER("ha_spider::max_supported_key_part_length"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(SPIDER_MAX_KEY_LENGTH); +} + +uint8 ha_spider::table_cache_type() +{ + DBUG_ENTER("ha_spider::table_cache_type"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_CACHE_TBL_NOCACHE); +} + +#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC +bool ha_spider::need_info_for_auto_inc() +{ + THD *thd = ha_thd(); + DBUG_ENTER("ha_spider::need_info_for_auto_inc"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider return=%s", ( + !spider_param_auto_increment_mode(thd, share->auto_increment_mode) && + !info_auto_called + ) ? "TRUE" : "FALSE")); + DBUG_RETURN(( + !spider_param_auto_increment_mode(thd, share->auto_increment_mode) && + !info_auto_called + )); +} +#endif + + +int ha_spider::update_auto_increment() +{ + int error_num; + THD *thd = ha_thd(); + int auto_increment_mode = spider_param_auto_increment_mode(thd, + share->auto_increment_mode); + bool lock_here = FALSE; + backup_error_status(); + DBUG_ENTER("ha_spider::update_auto_increment"); + DBUG_PRINT("info",("spider this=%p", this)); + force_auto_increment = TRUE; +/* + if ( + next_insert_id >= auto_inc_interval_for_cur_row.maximum() && + trx->thd->auto_inc_intervals_forced.get_current() + ) { + force_auto_increment = TRUE; + DBUG_PRINT("info",("spider force_auto_increment=TRUE")); + } else { + force_auto_increment = FALSE; + DBUG_PRINT("info",("spider force_auto_increment=FALSE")); + } +*/ + if ( + auto_increment_mode == 1 && + !( + table->next_number_field->val_int() != 0 || + (table->auto_increment_field_not_null && + thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) + ) + ) { + lock_here = TRUE; + pthread_mutex_lock(&share->auto_increment_mutex); + next_insert_id = share->auto_increment_value; + } + if ((error_num = handler::update_auto_increment())) + { + if (lock_here) + pthread_mutex_unlock(&share->auto_increment_mutex); + DBUG_RETURN(check_error_mode(error_num)); + } + if (lock_here) + { + if (insert_id_for_cur_row) + { + share->auto_increment_lclval = insert_id_for_cur_row + 1; + share->auto_increment_value = next_insert_id; + DBUG_PRINT("info",("spider after auto_increment_lclval=%llu", + share->auto_increment_lclval)); + } + pthread_mutex_unlock(&share->auto_increment_mutex); + } + if (!store_last_insert_id) + { + store_last_insert_id = table->next_number_field->val_int(); + } + DBUG_RETURN(0); +} + +void ha_spider::get_auto_increment( + ulonglong offset, + ulonglong increment, + ulonglong nb_desired_values, + ulonglong *first_value, + ulonglong *nb_reserved_values +) { + THD *thd = ha_thd(); + int auto_increment_mode = spider_param_auto_increment_mode(thd, + share->auto_increment_mode); + DBUG_ENTER("ha_spider::get_auto_increment"); + DBUG_PRINT("info",("spider this=%p", this)); + *nb_reserved_values = ULONGLONG_MAX; + if (auto_increment_mode == 0) + { + /* strict mode */ + int error_num; + extra(HA_EXTRA_KEYREAD); + if (index_init(table_share->next_number_index, TRUE)) + goto error_index_init; + result_list.internal_limit = 1; + if (table_share->next_number_keypart) + { + uchar key[MAX_KEY_LENGTH]; + key_copy(key, table->record[0], + &table->key_info[table_share->next_number_index], + table_share->next_number_key_offset); + error_num = index_read_last_map(table->record[1], key, + make_prev_keypart_map(table_share->next_number_keypart)); + } else + error_num = index_last(table->record[1]); + + if (error_num) + *first_value = 1; + else + *first_value = ((ulonglong) table->next_number_field-> + val_int_offset(table_share->rec_buff_length) + 1); + index_end(); + extra(HA_EXTRA_NO_KEYREAD); + DBUG_VOID_RETURN; + +error_index_init: + extra(HA_EXTRA_NO_KEYREAD); + *first_value = ~(ulonglong)0; + DBUG_VOID_RETURN; + } else { + if (auto_increment_mode != 1) + pthread_mutex_lock(&share->auto_increment_mutex); + DBUG_PRINT("info",("spider before auto_increment_lclval=%llu", + share->auto_increment_lclval)); + *first_value = share->auto_increment_lclval; + share->auto_increment_lclval += nb_desired_values * increment; + DBUG_PRINT("info",("spider after auto_increment_lclval=%llu", + share->auto_increment_lclval)); + if (auto_increment_mode != 1) + pthread_mutex_unlock(&share->auto_increment_mutex); + } + DBUG_VOID_RETURN; +} + +int ha_spider::reset_auto_increment( + ulonglong value +) { + DBUG_ENTER("ha_spider::reset_auto_increment"); + DBUG_PRINT("info",("spider this=%p", this)); + if (table->next_number_field) + { + pthread_mutex_lock(&share->auto_increment_mutex); + share->auto_increment_lclval = value; + share->auto_increment_init = TRUE; + DBUG_PRINT("info",("spider init auto_increment_lclval=%llu", + share->auto_increment_lclval)); + pthread_mutex_unlock(&share->auto_increment_mutex); + } + DBUG_RETURN(0); +} + +void ha_spider::release_auto_increment() +{ + DBUG_ENTER("ha_spider::release_auto_increment"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +void ha_spider::start_bulk_insert( + ha_rows rows +) { + DBUG_ENTER("ha_spider::start_bulk_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + bulk_insert = TRUE; + bulk_size = -1; + store_last_insert_id = 0; + DBUG_VOID_RETURN; +} + +int ha_spider::end_bulk_insert() +{ + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::end_bulk_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + bulk_insert = FALSE; + if (bulk_size == -1) + DBUG_RETURN(0); + if ((error_num = spider_db_bulk_insert(this, table, TRUE))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::write_row( + uchar *buf +) { + int error_num; + THD *thd = ha_thd(); + int auto_increment_mode = spider_param_auto_increment_mode(thd, + share->auto_increment_mode); + bool auto_increment_flag = + table->next_number_field && buf == table->record[0]; + backup_error_status(); + DBUG_ENTER("ha_spider::write_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_param_read_only_mode(thd, share->read_only_mode)) + { + my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), + table_share->db.str, table_share->table_name.str); + DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); + } +#ifdef HA_CAN_BULK_ACCESS + if ( + bulk_access_executing && + ( + ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) || + bulk_access_pre_called + ) + ) { + ulonglong option_backup = 0; + if (is_bulk_access_clone) + { + bulk_access_pre_called = FALSE; + DBUG_RETURN(spider_db_bulk_bulk_insert(this)); + } +#if MYSQL_VERSION_ID < 50500 + option_backup = thd->options; + thd->options &= ~OPTION_BIN_LOG; +#else + option_backup = thd->variables.option_bits; + thd->variables.option_bits &= ~OPTION_BIN_LOG; +#endif + error_num = bulk_access_link_exec_tgt->spider->ha_write_row(buf); +#if MYSQL_VERSION_ID < 50500 + thd->options = option_backup; +#else + thd->variables.option_bits = option_backup; +#endif + DBUG_RETURN(error_num); + } +#endif + ha_statistic_increment(&SSV::ha_write_count); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +#else + if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) + table->timestamp_field->set_time(); +#endif + if (!bulk_insert) + store_last_insert_id = 0; + if (auto_increment_flag) + { + if (auto_increment_mode == 3) + { + if (!table->auto_increment_field_not_null) + { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + table->next_number_field->store((longlong) 0, TRUE); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + force_auto_increment = FALSE; + table->file->insert_id_for_cur_row = 0; + } + } else if (auto_increment_mode == 2) + { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + table->next_number_field->store((longlong) 0, TRUE); + table->auto_increment_field_not_null = FALSE; +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + force_auto_increment = FALSE; + table->file->insert_id_for_cur_row = 0; + } else { + if (!share->auto_increment_init) + { + pthread_mutex_lock(&share->auto_increment_mutex); + if (!share->auto_increment_init) + { + info(HA_STATUS_AUTO); + share->auto_increment_lclval = stats.auto_increment_value; + share->auto_increment_init = TRUE; + DBUG_PRINT("info",("spider init auto_increment_lclval=%llu", + share->auto_increment_lclval)); + } + pthread_mutex_unlock(&share->auto_increment_mutex); + } + if ((error_num = update_auto_increment())) + DBUG_RETURN(error_num); + } + } + if (!bulk_insert || bulk_size < 0) + { + direct_dup_insert = + spider_param_direct_dup_insert(trx->thd, share->direct_dup_insert); + DBUG_PRINT("info",("spider direct_dup_insert=%d", direct_dup_insert)); + if ((error_num = spider_db_bulk_insert_init(this, table))) + DBUG_RETURN(check_error_mode(error_num)); + if (bulk_insert) + bulk_size = + insert_with_update || (!direct_dup_insert && ignore_dup_key) ? + 0 : spider_param_bulk_size(trx->thd, share->bulk_size); + else + bulk_size = 0; + } + if ((error_num = spider_db_bulk_insert(this, table, FALSE))) + DBUG_RETURN(check_error_mode(error_num)); + +#ifdef HA_CAN_BULK_ACCESS + /* bulk access disabled case (like using partitioning) */ + if (bulk_access_executing && is_bulk_access_clone) + { + bulk_req_exec(); + DBUG_RETURN(spider_db_bulk_bulk_insert(this)); + } +#endif + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_write_row( + uchar *buf +) { + int error_num; + ulonglong option_backup = 0; + THD *thd = trx->thd; + DBUG_ENTER("ha_spider::pre_write_row"); + DBUG_PRINT("info",("spider this=%p", this)); +#if MYSQL_VERSION_ID < 50500 + option_backup = thd->options; + thd->options &= ~OPTION_BIN_LOG; +#else + option_backup = thd->variables.option_bits; + thd->variables.option_bits &= ~OPTION_BIN_LOG; +#endif + error_num = bulk_access_link_current->spider->ha_write_row(buf); + bulk_access_link_current->spider->bulk_access_pre_called = TRUE; + bulk_access_link_current->called = TRUE; +#if MYSQL_VERSION_ID < 50500 + thd->options = option_backup; +#else + thd->variables.option_bits = option_backup; +#endif + DBUG_RETURN(error_num); +} +#endif + +bool ha_spider::start_bulk_update( +) { + DBUG_ENTER("ha_spider::start_bulk_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(check_and_start_bulk_update(SPD_BU_START_BY_BULK_INIT)); +} + +int ha_spider::exec_bulk_update( + uint *dup_key_found +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::exec_bulk_update"); + DBUG_PRINT("info",("spider this=%p", this)); + *dup_key_found = 0; + if ((error_num = spider_db_bulk_update_end(this, dup_key_found))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +void ha_spider::end_bulk_update( +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::end_bulk_update"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = check_and_end_bulk_update(SPD_BU_START_BY_BULK_INIT))) + { + if (check_error_mode(error_num)) + my_errno = error_num; + } + DBUG_VOID_RETURN; +} + +int ha_spider::bulk_update_row( + const uchar *old_data, + uchar *new_data, + uint *dup_key_found +) { + DBUG_ENTER("ha_spider::bulk_update_row"); + DBUG_PRINT("info",("spider this=%p", this)); + *dup_key_found = 0; + DBUG_RETURN(update_row(old_data, new_data)); +} + +int ha_spider::update_row( + const uchar *old_data, + uchar *new_data +) { + int error_num; + THD *thd = ha_thd(); + backup_error_status(); + DBUG_ENTER("ha_spider::update_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_param_read_only_mode(thd, share->read_only_mode)) + { + my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), + table_share->db.str, table_share->table_name.str); + DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); + } +#ifdef HA_CAN_BULK_ACCESS + if ( + bulk_access_executing && !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) { + ulonglong option_backup = 0; +#if MYSQL_VERSION_ID < 50500 + option_backup = thd->options; + thd->options &= ~OPTION_BIN_LOG; +#else + option_backup = thd->variables.option_bits; + thd->variables.option_bits &= ~OPTION_BIN_LOG; +#endif + error_num = bulk_access_link_exec_tgt->spider->ha_update_row( + old_data, new_data); +#if MYSQL_VERSION_ID < 50500 + thd->options = option_backup; +#else + thd->variables.option_bits = option_backup; +#endif + DBUG_RETURN(error_num); + } +#endif + ha_statistic_increment(&SSV::ha_update_count); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = FALSE; +#endif +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +#else + if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) + table->timestamp_field->set_time(); +#endif + if ((error_num = spider_db_update(this, table, old_data))) + DBUG_RETURN(check_error_mode(error_num)); + if (table->found_next_number_field && + new_data == table->record[0] && + !table->s->next_number_keypart + ) { + pthread_mutex_lock(&share->auto_increment_mutex); + if (!share->auto_increment_init) + { + info(HA_STATUS_AUTO); + share->auto_increment_lclval = stats.auto_increment_value; + share->auto_increment_init = TRUE; + DBUG_PRINT("info",("spider init auto_increment_lclval=%llu", + share->auto_increment_lclval)); + } + ulonglong tmp_auto_increment; + if (((Field_num *) table->found_next_number_field)->unsigned_flag) + { + tmp_auto_increment = + (ulonglong) table->found_next_number_field->val_int(); + } else { + longlong tmp_auto_increment2 = + table->found_next_number_field->val_int(); + if (tmp_auto_increment2 > 0) + tmp_auto_increment = tmp_auto_increment2; + else + tmp_auto_increment = 0; + } + if (tmp_auto_increment >= share->auto_increment_lclval) + { + share->auto_increment_lclval = tmp_auto_increment + 1; + share->auto_increment_value = tmp_auto_increment + 1; + DBUG_PRINT("info",("spider after auto_increment_lclval=%llu", + share->auto_increment_lclval)); + } + pthread_mutex_unlock(&share->auto_increment_mutex); + } + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int ha_spider::direct_update_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data +) { + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + THD *thd = trx->thd; + DBUG_ENTER("ha_spider::direct_update_rows_init"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef HA_CAN_BULK_ACCESS + if ( + bulk_access_executing && + ( + ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) || + bulk_access_pre_called + ) + ) { + if (is_bulk_access_clone) + { + DBUG_PRINT("info",("spider return pre_direct_init_result %d", + pre_direct_init_result)); + DBUG_RETURN(pre_direct_init_result); + } + DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( + mode, ranges, range_count, sorted, new_data)); + } +#endif + if (!condition) + cond_check = FALSE; + spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); + if ( + !range_count && + direct_update_fields + ) { + if ( +#if MYSQL_VERSION_ID < 50500 + !thd->variables.engine_condition_pushdown || +#else + !(thd->variables.optimizer_switch & + OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || +#endif + !select_lex || + select_lex->table_list.elements != 1 || + check_update_columns_sql_part() || + spider_db_append_condition(this, NULL, 0, TRUE) + ) { + DBUG_PRINT("info",("spider FALSE by condition")); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); + } + if (select_lex->order_list.elements) + { + ORDER *order; + for (order = (ORDER *) select_lex->order_list.first; order; + order = order->next) + { + if (check_item_type_sql((*order->item))) + { + DBUG_PRINT("info",("spider FALSE by order")); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); + } + } + result_list.direct_order_limit = TRUE; + } + + trx->direct_update_count++; + DBUG_PRINT("info",("spider OK")); + DBUG_RETURN(0); + } + + DBUG_PRINT("info",("spider offset_limit=%lld", offset_limit)); + DBUG_PRINT("info",("spider mode=%u", mode)); + DBUG_PRINT("info",("spider maybe_do_hs_direct_update=%s", + maybe_do_hs_direct_update ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider sql_command=%u", sql_command)); + DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", + hs_pushed_ret_fields_num)); + DBUG_PRINT("info",("spider do_direct_update=%s", + do_direct_update ? "TRUE" : "FALSE")); + if ( + ( + !offset_limit +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + || (mode == 2 && maybe_do_hs_direct_update) +#endif + ) && +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + sql_command == SQLCOM_HS_UPDATE && + hs_pushed_ret_fields_num < MAX_FIELDS && +#endif + do_direct_update + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + DBUG_PRINT("info",("spider pk_update=%s", pk_update ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider start_key=%p", &ranges->start_key)); + if (pk_update && spider_check_hs_pk_update(this, &ranges->start_key)) + { + DBUG_PRINT("info",("spider FALSE by pk_update")); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); + } +#endif + trx->direct_update_count++; + DBUG_PRINT("info",("spider OK")); + DBUG_RETURN(0); + } + DBUG_PRINT("info",("spider FALSE by default")); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_direct_update_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data +) { + int error_num; + DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (bulk_access_started) + { + error_num = bulk_access_link_current->spider-> + ha_pre_direct_update_rows_init( + mode, ranges, range_count, sorted, new_data); + bulk_access_link_current->spider->bulk_access_pre_called = TRUE; + bulk_access_link_current->called = TRUE; + DBUG_RETURN(error_num); + } + pre_direct_init_result = direct_update_rows_init( + mode, ranges, range_count, sorted, new_data); + DBUG_RETURN(pre_direct_init_result); +} +#endif + +int ha_spider::direct_update_rows( + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data, + uint *update_rows +) { + int error_num; + THD *thd = ha_thd(); + backup_error_status(); + DBUG_ENTER("ha_spider::direct_update_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_param_read_only_mode(thd, share->read_only_mode)) + { + my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), + table_share->db.str, table_share->table_name.str); + DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); + } +#ifdef HA_CAN_BULK_ACCESS + if ( + bulk_access_executing && + ( + ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) || + bulk_access_pre_called + ) + ) { + if (is_bulk_access_clone) + { + bulk_access_pre_called = FALSE; + DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows)); + } + DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_update_rows( + ranges, range_count, sorted, new_data, update_rows)); + } +#endif + if ( + (active_index != MAX_KEY && (error_num = index_handler_init())) || + (active_index == MAX_KEY && (error_num = rnd_handler_init())) || + (error_num = spider_db_direct_update(this, table, ranges, range_count, + update_rows)) + ) + DBUG_RETURN(check_error_mode(error_num)); + +#ifdef HA_CAN_BULK_ACCESS + if (bulk_access_executing && is_bulk_access_clone) + { + bulk_req_exec(); + DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows)); + } +#endif + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_direct_update_rows( + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data, + uint *update_rows +) { + DBUG_ENTER("ha_spider::pre_direct_update_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(bulk_access_link_current->spider->ha_direct_update_rows(ranges, + range_count, sorted, new_data, update_rows)); +} +#endif +#endif + +bool ha_spider::start_bulk_delete( +) { + DBUG_ENTER("ha_spider::start_bulk_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(check_and_start_bulk_update(SPD_BU_START_BY_BULK_INIT)); +} + +int ha_spider::end_bulk_delete( +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::end_bulk_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = check_and_end_bulk_update(SPD_BU_START_BY_BULK_INIT))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::delete_row( + const uchar *buf +) { + THD *thd = ha_thd(); + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::delete_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_param_read_only_mode(thd, share->read_only_mode)) + { + my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), + table_share->db.str, table_share->table_name.str); + DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); + } +#ifdef HA_CAN_BULK_ACCESS + if ( + bulk_access_executing && !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) { + ulonglong option_backup = 0; +#if MYSQL_VERSION_ID < 50500 + option_backup = thd->options; + thd->options &= ~OPTION_BIN_LOG; +#else + option_backup = thd->variables.option_bits; + thd->variables.option_bits &= ~OPTION_BIN_LOG; +#endif + error_num = bulk_access_link_exec_tgt->spider->ha_delete_row(buf); +#if MYSQL_VERSION_ID < 50500 + thd->options = option_backup; +#else + thd->variables.option_bits = option_backup; +#endif + DBUG_RETURN(error_num); + } +#endif + ha_statistic_increment(&SSV::ha_delete_count); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = FALSE; +#endif + if ((error_num = spider_db_delete(this, table, buf))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int ha_spider::direct_delete_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted +) { + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + THD *thd = trx->thd; + DBUG_ENTER("ha_spider::direct_delete_rows_init"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef HA_CAN_BULK_ACCESS + if ( + bulk_access_executing && + ( + ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) || + bulk_access_pre_called + ) + ) { + if (is_bulk_access_clone) + { + DBUG_RETURN(pre_direct_init_result); + } + DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_delete_rows_init( + mode, ranges, range_count, sorted)); + } +#endif + if (!condition) + cond_check = FALSE; + spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); + if (!range_count) + { + if ( +#if MYSQL_VERSION_ID < 50500 + !thd->variables.engine_condition_pushdown || +#else + !(thd->variables.optimizer_switch & + OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || +#endif + !select_lex || + select_lex->table_list.elements != 1 || + spider_db_append_condition(this, NULL, 0, TRUE) + ) { + DBUG_PRINT("info",("spider FALSE by condition")); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); + } + if (select_lex->order_list.elements) + { + ORDER *order; + for (order = (ORDER *) select_lex->order_list.first; order; + order = order->next) + { + if (check_item_type_sql((*order->item))) + { + DBUG_PRINT("info",("spider FALSE by order")); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); + } + } + result_list.direct_order_limit = TRUE; + } + + trx->direct_delete_count++; + DBUG_PRINT("info",("spider OK")); + DBUG_RETURN(0); + } + + if ( + ( + !offset_limit +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + || (mode == 2 && maybe_do_hs_direct_update) +#endif + ) && +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + sql_command == SQLCOM_HS_DELETE && +#endif + do_direct_update + ) { + trx->direct_delete_count++; + DBUG_PRINT("info",("spider OK")); + DBUG_RETURN(0); + } + DBUG_PRINT("info",("spider FALSE by default")); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_direct_delete_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted +) { + int error_num; + DBUG_ENTER("ha_spider::pre_direct_delete_rows_init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (bulk_access_started) + { + error_num = bulk_access_link_current->spider-> + ha_pre_direct_delete_rows_init( + mode, ranges, range_count, sorted); + bulk_access_link_current->spider->bulk_access_pre_called = TRUE; + bulk_access_link_current->called = TRUE; + DBUG_RETURN(error_num); + } + pre_direct_init_result = direct_delete_rows_init( + mode, ranges, range_count, sorted); + DBUG_RETURN(pre_direct_init_result); +} +#endif + +int ha_spider::direct_delete_rows( + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uint *delete_rows +) { + int error_num; + THD *thd = ha_thd(); + backup_error_status(); + DBUG_ENTER("ha_spider::direct_delete_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_param_read_only_mode(thd, share->read_only_mode)) + { + my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), + table_share->db.str, table_share->table_name.str); + DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); + } +#ifdef HA_CAN_BULK_ACCESS + if ( + bulk_access_executing && + ( + ( + !is_bulk_access_clone && + bulk_access_link_exec_tgt->called + ) || + bulk_access_pre_called + ) + ) { + if (is_bulk_access_clone) + { + bulk_access_pre_called = FALSE; + DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); + } + DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_delete_rows( + ranges, range_count, sorted, delete_rows)); + } +#endif + if ( + (active_index != MAX_KEY && (error_num = index_handler_init())) || + (active_index == MAX_KEY && (error_num = rnd_handler_init())) || + (error_num = spider_db_direct_delete(this, table, ranges, range_count, + delete_rows)) + ) + DBUG_RETURN(check_error_mode(error_num)); + +#ifdef HA_CAN_BULK_ACCESS + if (bulk_access_executing && is_bulk_access_clone) + { + bulk_req_exec(); + DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); + } +#endif + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int ha_spider::pre_direct_delete_rows( + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uint *delete_rows +) { + DBUG_ENTER("ha_spider::pre_direct_delete_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(bulk_access_link_current->spider->ha_direct_delete_rows( + ranges, range_count, sorted, delete_rows)); +} +#endif +#endif + +int ha_spider::delete_all_rows() +{ + int error_num, roop_count; + THD *thd = ha_thd(); + backup_error_status(); + DBUG_ENTER("ha_spider::delete_all_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_param_read_only_mode(thd, share->read_only_mode)) + { + my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), + table_share->db.str, table_share->table_name.str); + DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); + } +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = FALSE; +#endif + sql_kinds = SPIDER_SQL_KIND_SQL; + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; + if ((error_num = spider_db_delete_all_rows(this))) + DBUG_RETURN(check_error_mode(error_num)); + if (sql_command == SQLCOM_TRUNCATE && table->found_next_number_field) + { + DBUG_PRINT("info",("spider reset auto increment")); + pthread_mutex_lock(&share->auto_increment_mutex); + share->auto_increment_lclval = 1; + share->auto_increment_init = FALSE; + share->auto_increment_value = 1; + DBUG_PRINT("info",("spider init auto_increment_lclval=%llu", + share->auto_increment_lclval)); + pthread_mutex_unlock(&share->auto_increment_mutex); + } + DBUG_RETURN(0); +} + +int ha_spider::truncate() +{ + int error_num, roop_count; + THD *thd = ha_thd(); + backup_error_status(); + DBUG_ENTER("ha_spider::truncate"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_param_read_only_mode(thd, share->read_only_mode)) + { + my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), + table_share->db.str, table_share->table_name.str); + DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); + } + sql_command = SQLCOM_TRUNCATE; + if ((error_num = spider_check_trx_and_get_conn(thd, this, FALSE))) + { + DBUG_RETURN(error_num); + } +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = FALSE; +#endif + sql_kinds = SPIDER_SQL_KIND_SQL; + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; + if ((error_num = spider_db_delete_all_rows(this))) + DBUG_RETURN(check_error_mode(error_num)); + if (sql_command == SQLCOM_TRUNCATE && table->found_next_number_field) + { + DBUG_PRINT("info",("spider reset auto increment")); + pthread_mutex_lock(&share->auto_increment_mutex); + share->auto_increment_lclval = 1; + share->auto_increment_init = FALSE; + share->auto_increment_value = 1; + DBUG_PRINT("info",("spider init auto_increment_lclval=%llu", + share->auto_increment_lclval)); + pthread_mutex_unlock(&share->auto_increment_mutex); + } + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +void ha_spider::bulk_req_exec() +{ + int need_mon; + SPIDER_CONN *conn = trx->bulk_access_conn_first; + DBUG_ENTER("ha_spider::bulk_req_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider trx=%p", trx)); + DBUG_PRINT("info",("spider first_conn=%p", conn)); + while (conn) + { + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", + conn->bulk_access_requests)); + if (conn->bulk_access_requests) + { + spider_bg_conn_wait(conn); + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &need_mon; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + /* currently only used for HS */ + conn->bulk_access_error_num = 0; + if (spider_db_query( + conn, + NULL, + 0, + -1, + &need_mon) + ) { + conn->bulk_access_error_num = spider_db_errorno(conn); + } +/* + conn->bulk_access_sended += conn->bulk_access_requests; +*/ + conn->bulk_access_requests = 0; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + conn = conn->bulk_access_next; + } + trx->bulk_access_conn_first = NULL; + DBUG_VOID_RETURN; +} +#endif + +double ha_spider::scan_time() +{ + DBUG_ENTER("ha_spider::scan_time"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider scan_time = %.6f", + share->scan_rate * share->records * share->mean_rec_length + 2)); + DBUG_RETURN(share->scan_rate * share->records * share->mean_rec_length + 2); +} + +double ha_spider::read_time( + uint index, + uint ranges, + ha_rows rows +) { + DBUG_ENTER("ha_spider::read_time"); + DBUG_PRINT("info",("spider this=%p", this)); + if (keyread) + { + DBUG_PRINT("info",("spider read_time(keyread) = %.6f", + share->read_rate * table->s->key_info[index].key_length * + rows / 2 + 2)); + DBUG_RETURN(share->read_rate * table->s->key_info[index].key_length * + rows / 2 + 2); + } else { + DBUG_PRINT("info",("spider read_time = %.6f", + share->read_rate * share->mean_rec_length * rows + 2)); + DBUG_RETURN(share->read_rate * share->mean_rec_length * rows + 2); + } +} + +const key_map *ha_spider::keys_to_use_for_scanning() +{ + DBUG_ENTER("ha_spider::keys_to_use_for_scanning"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(&key_map_full); +} + +ha_rows ha_spider::estimate_rows_upper_bound() +{ + DBUG_ENTER("ha_spider::estimate_rows_upper_bound"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_POS_ERROR); +} + +bool ha_spider::get_error_message( + int error, + String *buf +) { + DBUG_ENTER("ha_spider::get_error_message"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (error) + { + case ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM: + if (buf->reserve(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_LEN)) + DBUG_RETURN(TRUE); + buf->q_append(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_LEN); + break; + default: + if (buf->reserve(ER_SPIDER_UNKNOWN_LEN)) + DBUG_RETURN(TRUE); + buf->q_append(ER_SPIDER_UNKNOWN_STR, ER_SPIDER_UNKNOWN_LEN); + break; + } + DBUG_RETURN(FALSE); +} + +int ha_spider::create( + const char *name, + TABLE *form, + HA_CREATE_INFO *info +) { + int error_num; + SPIDER_SHARE tmp_share; + THD *thd = ha_thd(); + uint sql_command = thd_sql_command(thd), roop_count; + SPIDER_TRX *trx; + TABLE *table_tables = NULL; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + bool need_lock = FALSE; + DBUG_ENTER("ha_spider::create"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider name=%s", name)); + DBUG_PRINT("info", + ("spider form->s->connect_string=%s", form->s->connect_string.str)); + DBUG_PRINT("info", + ("spider info->connect_string=%s", info->connect_string.str)); + if ( + sql_command == SQLCOM_CREATE_INDEX || + sql_command == SQLCOM_DROP_INDEX + ) + DBUG_RETURN(0); + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + goto error_get_trx; + if ( + trx->locked_connections && + sql_command == SQLCOM_ALTER_TABLE + ) { + my_message(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM, + ER_SPIDER_ALTER_BEFORE_UNLOCK_STR, MYF(0)); + error_num = ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM; + goto error_alter_before_unlock; + } + memset(&tmp_share, 0, sizeof(SPIDER_SHARE)); + tmp_share.table_name = (char*) name; + tmp_share.table_name_length = strlen(name); + if (form->s->keys > 0 && + !(tmp_share.key_hint = new spider_string[form->s->keys]) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + for (roop_count = 0; roop_count < form->s->keys; roop_count++) + tmp_share.key_hint[roop_count].init_calc_mem(85); + DBUG_PRINT("info",("spider tmp_share.key_hint=%p", tmp_share.key_hint)); + if ((error_num = spider_parse_connect_info(&tmp_share, form->s, +#ifdef WITH_PARTITION_STORAGE_ENGINE + form->part_info, +#endif + 1))) + goto error; + DBUG_PRINT("info",("spider tmp_table=%d", form->s->tmp_table)); + if ( + (sql_command == SQLCOM_CREATE_TABLE && + !(info->options & HA_LEX_CREATE_TMP_TABLE)) + ) { + if ( + !(table_tables = spider_open_sys_table( + current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, FALSE, + &error_num)) + ) { + goto error; + } + if ( + (error_num = spider_insert_tables(table_tables, &tmp_share)) + ) { + goto error; + } + spider_close_sys_table(current_thd, table_tables, + &open_tables_backup, FALSE); + table_tables = NULL; + } else if ( + sql_command == SQLCOM_ALTER_TABLE + ) { + SPIDER_ALTER_TABLE *alter_table; + if (trx->query_id != thd->query_id) + { + spider_free_trx_alter_table(trx); + trx->query_id = thd->query_id; + } +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + tmp_share.table_name_hash_value = my_calc_hash(&trx->trx_alter_table_hash, + (uchar*) tmp_share.table_name, tmp_share.table_name_length);; + if (!(alter_table = + (SPIDER_ALTER_TABLE*) my_hash_search_using_hash_value( + &trx->trx_alter_table_hash, tmp_share.table_name_hash_value, + (uchar*) tmp_share.table_name, tmp_share.table_name_length))) +#else + if (!(alter_table = + (SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, + (uchar*) tmp_share.table_name, tmp_share.table_name_length))) +#endif + { + if ((error_num = spider_create_trx_alter_table(trx, &tmp_share, TRUE))) + goto error; + } + trx->tmp_flg = TRUE; + + DBUG_PRINT("info", + ("spider alter_info.flags=%u", thd->lex->alter_info.flags)); + if ( + (thd->lex->alter_info.flags & + ( + ALTER_ADD_PARTITION | ALTER_DROP_PARTITION | + ALTER_COALESCE_PARTITION | ALTER_REORGANIZE_PARTITION | + ALTER_TABLE_REORG | ALTER_REBUILD_PARTITION + ) + ) && + memcmp(name + strlen(name) - 5, "#TMP#", 5) + ) { + need_lock = TRUE; + if ( + !(table_tables = spider_open_sys_table( + current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE, + &error_num)) + ) { + goto error; + } + if ( + (error_num = spider_insert_tables(table_tables, &tmp_share)) + ) { + goto error; + } + spider_close_sys_table(current_thd, table_tables, + &open_tables_backup, TRUE); + table_tables = NULL; + } + } + + spider_free_share_alloc(&tmp_share); + DBUG_RETURN(0); + +error: + if (table_tables) + spider_close_sys_table(current_thd, table_tables, + &open_tables_backup, need_lock); + spider_free_share_alloc(&tmp_share); +error_alter_before_unlock: +error_get_trx: + DBUG_RETURN(error_num); +} + +void ha_spider::update_create_info( + HA_CREATE_INFO* create_info +) { + DBUG_ENTER("ha_spider::update_create_info"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!create_info->connect_string.str) + { + create_info->connect_string.str = table->s->connect_string.str; + create_info->connect_string.length = table->s->connect_string.length; + } + DBUG_PRINT("info", + ("spider create_info->connect_string=%s", + create_info->connect_string.str)); + DBUG_VOID_RETURN; +} + +int ha_spider::rename_table( + const char *from, + const char *to +) { + int error_num, roop_count, old_link_count, from_len = strlen(from); + THD *thd = ha_thd(); + uint sql_command = thd_sql_command(thd); + SPIDER_TRX *trx; + TABLE *table_tables = NULL; + SPIDER_ALTER_TABLE *alter_table_from, *alter_table_to; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + bool need_lock = FALSE; + DBUG_ENTER("ha_spider::rename_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider from=%s", from)); + DBUG_PRINT("info",("spider to=%s", to)); + if ( + sql_command == SQLCOM_CREATE_INDEX || + sql_command == SQLCOM_DROP_INDEX + ) + DBUG_RETURN(0); + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + goto error; + if ( + trx->locked_connections && + /* SQLCOM_RENAME_TABLE doesn't come here */ + sql_command == SQLCOM_ALTER_TABLE + ) { + my_message(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM, + ER_SPIDER_ALTER_BEFORE_UNLOCK_STR, MYF(0)); + error_num = ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM; + goto error; + } + if ( + sql_command == SQLCOM_RENAME_TABLE || + (sql_command == SQLCOM_ALTER_TABLE && !trx->tmp_flg) || + !(alter_table_from = + (SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, + (uchar*) from, from_len)) + ) { + if ( + !(table_tables = spider_open_sys_table( + current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, FALSE, + &error_num)) + ) { + goto error; + } + if ( + (error_num = spider_update_tables_name( + table_tables, from, to, &old_link_count)) + ) { + goto error; + } + spider_close_sys_table(current_thd, table_tables, + &open_tables_backup, FALSE); + table_tables = NULL; + + /* release table mon list */ + for (roop_count = 0; roop_count < old_link_count; roop_count++) + spider_release_ping_table_mon_list(from, from_len, roop_count); + } else if (sql_command == SQLCOM_ALTER_TABLE) + { + int to_len = strlen(to); + DBUG_PRINT("info",("spider alter_table_from=%p", alter_table_from)); + if ((alter_table_to = + (SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, + (uchar*) to, to_len)) + ) { + DBUG_PRINT("info",("spider copy link_statuses")); + uint all_link_count = alter_table_from->all_link_count; + if (all_link_count > alter_table_to->all_link_count) + all_link_count = alter_table_to->all_link_count; + for (roop_count = 0; roop_count < (int) all_link_count; roop_count++) + { + if (alter_table_from->tmp_link_statuses[roop_count] <= + SPIDER_LINK_STATUS_NO_CHANGE) + alter_table_from->tmp_link_statuses[roop_count] = + alter_table_to->tmp_link_statuses[roop_count]; + } + } + + DBUG_PRINT("info", + ("spider alter_info.flags=%u", thd->lex->alter_info.flags)); + if ( + (thd->lex->alter_info.flags & + ( + ALTER_ADD_PARTITION | ALTER_DROP_PARTITION | + ALTER_COALESCE_PARTITION | ALTER_REORGANIZE_PARTITION | + ALTER_TABLE_REORG | ALTER_REBUILD_PARTITION + ) + ) + ) + need_lock = TRUE; + + if ( + !(table_tables = spider_open_sys_table( + current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock, + &error_num)) + ) { + goto error; + } + + if (alter_table_from->now_create) + { + SPIDER_SHARE tmp_share; + tmp_share.table_name = (char*) to; + tmp_share.table_name_length = to_len; + tmp_share.priority = alter_table_from->tmp_priority; + tmp_share.link_count = alter_table_from->link_count; + tmp_share.all_link_count = alter_table_from->all_link_count; + memcpy(&tmp_share.alter_table, alter_table_from, + sizeof(*alter_table_from)); + if ( + (error_num = spider_insert_tables(table_tables, &tmp_share)) + ) { + goto error; + } + } else { + if ( + (error_num = spider_update_tables_priority( + table_tables, alter_table_from, to, &old_link_count)) + ) { + goto error; + } + } + spider_close_sys_table(current_thd, table_tables, + &open_tables_backup, need_lock); + table_tables = NULL; + + if (!alter_table_from->now_create) + { + /* release table mon list */ + for (roop_count = 0; roop_count < (int) alter_table_from->all_link_count; + roop_count++) + spider_release_ping_table_mon_list(from, from_len, roop_count); + for (roop_count = 0; roop_count < old_link_count; roop_count++) + spider_release_ping_table_mon_list(to, to_len, roop_count); + } +/* + spider_free_trx_alter_table_alloc(trx, alter_table_from); +*/ + } + + spider_delete_init_error_table(from); + DBUG_RETURN(0); + +error: + if (table_tables) + spider_close_sys_table(current_thd, table_tables, + &open_tables_backup, need_lock); + DBUG_RETURN(error_num); +} + +int ha_spider::delete_table( + const char *name +) { + int error_num; + THD *thd = ha_thd(); + SPIDER_TRX *trx; + TABLE *table_tables = NULL; + uint sql_command = thd_sql_command(thd); + SPIDER_ALTER_TABLE *alter_table; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + bool need_lock = FALSE; + DBUG_ENTER("ha_spider::delete_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider name=%s", name)); + if ( + sql_command == SQLCOM_CREATE_INDEX || + sql_command == SQLCOM_DROP_INDEX + ) + DBUG_RETURN(0); + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + goto error; + if ( + trx->locked_connections && + /* SQLCOM_DROP_DB doesn't come here */ + ( + sql_command == SQLCOM_DROP_TABLE || + sql_command == SQLCOM_ALTER_TABLE + ) + ) { + my_message(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM, + ER_SPIDER_ALTER_BEFORE_UNLOCK_STR, MYF(0)); + error_num = ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM; + goto error; + } + if (sql_command == SQLCOM_DROP_TABLE || + sql_command == SQLCOM_DROP_DB || + sql_command == SQLCOM_ALTER_TABLE || + sql_command == SQLCOM_CREATE_TABLE) + { + int roop_count, old_link_count = 0, name_len = strlen(name); + if ( + sql_command == SQLCOM_ALTER_TABLE && + (alter_table = + (SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, + (uchar*) name, name_len)) && + alter_table->now_create + ) + DBUG_RETURN(0); + + DBUG_PRINT("info", + ("spider alter_info.flags=%u", thd->lex->alter_info.flags)); + if ( + sql_command == SQLCOM_ALTER_TABLE && + (thd->lex->alter_info.flags & + ( + ALTER_ADD_PARTITION | ALTER_DROP_PARTITION | + ALTER_COALESCE_PARTITION | ALTER_REORGANIZE_PARTITION | + ALTER_TABLE_REORG | ALTER_REBUILD_PARTITION + ) + ) + ) + need_lock = TRUE; + + if ( + !(table_tables = spider_open_sys_table( + current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock, + &error_num)) + ) { + goto error; + } + if ( + (error_num = spider_delete_tables( + table_tables, name, &old_link_count)) + ) { + goto error; + } + spider_close_sys_table(current_thd, table_tables, + &open_tables_backup, need_lock); + table_tables = NULL; + + /* release table mon list */ + for (roop_count = 0; roop_count < old_link_count; roop_count++) + spider_release_ping_table_mon_list(name, name_len, roop_count); + } + + spider_delete_init_error_table(name); + DBUG_RETURN(0); + +error: + if (table_tables) + spider_close_sys_table(current_thd, table_tables, + &open_tables_backup, need_lock); + DBUG_RETURN(error_num); +} + +bool ha_spider::is_crashed() const +{ + DBUG_ENTER("ha_spider::is_crashed"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +bool ha_spider::auto_repair() const +{ + DBUG_ENTER("ha_spider::auto_repair"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int ha_spider::disable_indexes( + uint mode +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::disable_indexes"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_disable_keys(this))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::enable_indexes( + uint mode +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::enable_indexes"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_enable_keys(this))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + + +int ha_spider::check( + THD* thd, + HA_CHECK_OPT* check_opt +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::check"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_check_table(this, check_opt))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::repair( + THD* thd, + HA_CHECK_OPT* check_opt +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::repair"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_repair_table(this, check_opt))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +bool ha_spider::check_and_repair( + THD *thd +) { + HA_CHECK_OPT check_opt; + DBUG_ENTER("ha_spider::check_and_repair"); + DBUG_PRINT("info",("spider this=%p", this)); + check_opt.init(); + check_opt.flags = T_MEDIUM; + if (spider_db_check_table(this, &check_opt)) + { + check_opt.flags = T_QUICK; + if (spider_db_repair_table(this, &check_opt)) + DBUG_RETURN(TRUE); + } + DBUG_RETURN(FALSE); +} + +int ha_spider::analyze( + THD* thd, + HA_CHECK_OPT* check_opt +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::analyze"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_analyze_table(this))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +int ha_spider::optimize( + THD* thd, + HA_CHECK_OPT* check_opt +) { + int error_num; + backup_error_status(); + DBUG_ENTER("ha_spider::optimize"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_optimize_table(this))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); +} + +bool ha_spider::is_fatal_error( + int error_num, + uint flags +) { + DBUG_ENTER("ha_spider::is_fatal_error"); + DBUG_PRINT("info",("spider error_num=%d", error_num)); + DBUG_PRINT("info",("spider flags=%u", flags)); + if ( + !handler::is_fatal_error(error_num, flags) + ) { + DBUG_PRINT("info",("spider FALSE")); + DBUG_RETURN(FALSE); + } + DBUG_PRINT("info",("spider TRUE")); + DBUG_RETURN(TRUE); +} + +Field *ha_spider::get_top_table_field( + uint16 field_index +) { + Field *field; + DBUG_ENTER("ha_spider::get_top_table_field"); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + DBUG_RETURN(pt_clone_source_handler->get_top_table_field(field_index)); + } +#endif + DBUG_PRINT("info",("spider field_index=%u", field_index)); +#ifdef HANDLER_HAS_TOP_TABLE_FIELDS + if (set_top_table_fields) + { + field = top_table->field[field_index]; + } else { +#endif + field = table->field[field_index]; +#ifdef HANDLER_HAS_TOP_TABLE_FIELDS + } +#endif + DBUG_PRINT("info",("spider out field=%p", field)); + DBUG_RETURN(field); +} + +Field *ha_spider::field_exchange( + Field *field +) { + DBUG_ENTER("ha_spider::field_exchange"); +#ifdef HA_CAN_BULK_ACCESS + if (is_bulk_access_clone) + { + DBUG_RETURN(pt_clone_source_handler->field_exchange(field)); + } +#endif + DBUG_PRINT("info",("spider in field=%p", field)); +#ifdef HANDLER_HAS_TOP_TABLE_FIELDS + if (set_top_table_fields) + { + if (field->table != top_table) + DBUG_RETURN(NULL); + if (!(field = top_table_field[field->field_index])) + DBUG_RETURN(NULL); + } else { +#endif + if (field->table != table) + DBUG_RETURN(NULL); +#ifdef HANDLER_HAS_TOP_TABLE_FIELDS + } +#endif + DBUG_PRINT("info",("spider out field=%p", field)); + DBUG_RETURN(field); +} + +const COND *ha_spider::cond_push( + const COND *cond +) { + DBUG_ENTER("ha_spider::cond_push"); + cond_check = FALSE; + if (cond) + { + SPIDER_CONDITION *tmp_cond; + if (!(tmp_cond = (SPIDER_CONDITION *) + spider_malloc(spider_current_trx, 3, sizeof(*tmp_cond), MYF(MY_WME))) + ) + DBUG_RETURN(cond); + tmp_cond->cond = (COND *) cond; + tmp_cond->next = condition; + condition = tmp_cond; + } + DBUG_RETURN(NULL); +} + +void ha_spider::cond_pop() +{ + DBUG_ENTER("ha_spider::cond_pop"); + if (condition) + { + SPIDER_CONDITION *tmp_cond = condition->next; + spider_free(spider_current_trx, condition, MYF(0)); + condition = tmp_cond; + } + DBUG_VOID_RETURN; +} + +int ha_spider::info_push( + uint info_type, + void *info +) { + int error_num = 0; + DBUG_ENTER("ha_spider::info_push"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef HA_CAN_BULK_ACCESS + if ( + info_type != INFO_KIND_BULK_ACCESS_BEGIN && + info_type != INFO_KIND_BULK_ACCESS_CURRENT && + info_type != INFO_KIND_BULK_ACCESS_END && + info_type != INFO_KIND_HS_RET_FIELDS + ) { + if (!is_bulk_access_clone) + { + if ( + bulk_access_executing && + bulk_access_link_exec_tgt->called + ) { + DBUG_RETURN(bulk_access_link_exec_tgt->spider->info_push(info_type, + info)); + } else if (bulk_access_started) + { + DBUG_RETURN(bulk_access_link_current->spider->info_push(info_type, + info)); + } + } + } +#endif + +#if defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) || defined(HA_CAN_BULK_ACCESS) + switch (info_type) + { +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + case INFO_KIND_HS_RET_FIELDS: + { + DBUG_PRINT("info",("spider INFO_KIND_HS_RET_FIELDS")); + size_t roop_count; + Field *field; + SPIDER_HS_UINT32_INFO *tmp_info = (SPIDER_HS_UINT32_INFO *) info; + hs_pushed_ret_fields_num = tmp_info->info_size; + if (hs_pushed_ret_fields_size < hs_pushed_ret_fields_num) + { + if (hs_pushed_ret_fields) + spider_free(spider_current_trx, hs_pushed_ret_fields, MYF(0)); + if (!(hs_pushed_ret_fields = (uint32 *) + spider_bulk_malloc(spider_current_trx, 17, MYF(MY_WME), + &hs_pushed_ret_fields, sizeof(uint32) * hs_pushed_ret_fields_num, + NullS)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + hs_pushed_ret_fields_size = hs_pushed_ret_fields_num; + } + memcpy(hs_pushed_ret_fields, tmp_info->info, + sizeof(uint32) * hs_pushed_ret_fields_num); + bitmap_clear_all(table->read_set); + bitmap_clear_all(table->write_set); + hs_pushed_lcl_fields_num = 0; + for (roop_count = 0; roop_count < hs_pushed_ret_fields_num; roop_count++) + { + field = get_top_table_field(hs_pushed_ret_fields[roop_count]); + if ((field = field_exchange(field))) + { + if (!bitmap_is_set(table->read_set, field->field_index)) + { + ++hs_pushed_lcl_fields_num; + bitmap_set_bit(table->read_set, field->field_index); + bitmap_set_bit(table->write_set, field->field_index); + } + } + } + } + break; + case INFO_KIND_HS_APPEND_STRING_REF: + { + DBUG_PRINT("info",("spider INFO_KIND_HS_APPEND_STRING_REF")); +#ifndef DBUG_OFF + SPIDER_HS_STRING_REF *tmp_ref = (SPIDER_HS_STRING_REF*) info; + char print_buf[MAX_FIELD_WIDTH]; + if (tmp_ref->size() < MAX_FIELD_WIDTH) + { + memcpy(print_buf, tmp_ref->begin(), tmp_ref->size()); + print_buf[tmp_ref->size()] = '\0'; + DBUG_PRINT("info",("spider info=%s", print_buf)); + } +#endif + Field *field; + if (hs_pushed_ret_fields) + { + field = get_top_table_field( + hs_pushed_ret_fields[hs_pushed_strref_num]); + } else { + field = get_top_table_field( + pt_clone_source_handler->hs_pushed_ret_fields[hs_pushed_strref_num]); + } + if (!field_exchange(field)) + { + hs_pushed_strref_num++; + break; + } + hs_pushed_strref_num++; + if ((error_num = push_back_hs_upds(*((SPIDER_HS_STRING_REF*) info)))) + { + DBUG_RETURN(error_num); + } + break; + } + case INFO_KIND_HS_CLEAR_STRING_REF: + DBUG_PRINT("info",("spider INFO_KIND_HS_CLEAR_STRING_REF")); + hs_pushed_strref_num = 0; + if ((error_num = reset_hs_upds(SPIDER_SQL_TYPE_UPDATE_HS))) + { + DBUG_RETURN(error_num); + } + break; + case INFO_KIND_HS_INCREMENT_BEGIN: + DBUG_PRINT("info",("spider INFO_KIND_HS_INCREMENT_BEGIN")); + hs_increment = TRUE; + break; + case INFO_KIND_HS_INCREMENT_END: + DBUG_PRINT("info",("spider INFO_KIND_HS_INCREMENT_END")); + hs_increment = FALSE; + break; + case INFO_KIND_HS_DECREMENT_BEGIN: + DBUG_PRINT("info",("spider INFO_KIND_HS_DECREMENT_BEGIN")); + hs_decrement = TRUE; + break; + case INFO_KIND_HS_DECREMENT_END: + DBUG_PRINT("info",("spider INFO_KIND_HS_DECREMENT_END")); + hs_decrement = FALSE; + break; +#endif + case INFO_KIND_UPDATE_FIELDS: + DBUG_PRINT("info",("spider INFO_KIND_UPDATE_FIELDS")); + direct_update_fields = (List *) info; + break; + case INFO_KIND_UPDATE_VALUES: + DBUG_PRINT("info",("spider INFO_KIND_UPDATE_VALUES")); + direct_update_values = (List *) info; + break; +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + case INFO_KIND_FORCE_LIMIT_BEGIN: + DBUG_PRINT("info",("spider INFO_KIND_FORCE_LIMIT_BEGIN")); + info_limit = *((longlong *) info); + trx->direct_aggregate_count++; + break; + case INFO_KIND_FORCE_LIMIT_END: + DBUG_PRINT("info",("spider INFO_KIND_FORCE_LIMIT_END")); + info_limit = 9223372036854775807LL; + break; +#endif +#endif +#ifdef HA_CAN_BULK_ACCESS + case INFO_KIND_BULK_ACCESS_BEGIN: + DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_BEGIN")); + if (bulk_access_started) + { + if (!bulk_access_link_current->next) + { + if (!(bulk_access_link_current->next = create_bulk_access_link())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + bulk_access_link_current->next->sequence_num = + bulk_access_link_current->sequence_num + 1; + } + bulk_access_link_current = bulk_access_link_current->next; + } else { + if (!bulk_access_link_first) + { + if (!(bulk_access_link_first = create_bulk_access_link())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + bulk_access_link_first->sequence_num = 0; + } + bulk_access_link_current = bulk_access_link_first; + bulk_access_started = TRUE; + bulk_access_executing = FALSE; + } + if ( + (error_num = bulk_access_link_current->spider-> + sync_from_clone_source(this)) || + (error_num = bulk_access_link_current->spider-> + check_access_kind(trx->thd, (lock_type >= TL_WRITE_ALLOW_WRITE))) + ) { + DBUG_RETURN(error_num); + } + memset( + bulk_access_link_current->spider->result_list.hs_r_bulk_open_index, 0, + share->link_bitmap_size); + memset( + bulk_access_link_current->spider->result_list.hs_w_bulk_open_index, 0, + share->link_bitmap_size); +/* +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = bulk_access_link_current->spider->reset_hs_strs_pos( + SPIDER_SQL_TYPE_UPDATE_HS))) + { + DBUG_RETURN(error_num); + } +#endif +*/ + bulk_access_link_current->spider->bulk_access_executing = FALSE; + bulk_access_link_current->spider->bulk_access_pre_called = FALSE; + bulk_access_link_current->used = TRUE; + bulk_access_link_current->called = FALSE; + *((void **) info) = bulk_access_link_current; + break; + case INFO_KIND_BULK_ACCESS_CURRENT: + DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_CURRENT")); + bulk_access_executing = TRUE; + bulk_access_link_exec_tgt = (SPIDER_BULK_ACCESS_LINK *) info; + if (bulk_access_link_exec_tgt->spider->pt_clone_source_handler != this) + { + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider pt_clone_source_handler=%p", + bulk_access_link_exec_tgt->spider->pt_clone_source_handler)); + /* partitioned */ + uint sequence_num = bulk_access_link_exec_tgt->sequence_num; + for ( + bulk_access_link_exec_tgt = bulk_access_link_first; + bulk_access_link_exec_tgt; + bulk_access_link_exec_tgt = bulk_access_link_exec_tgt->next + ) { + if (bulk_access_link_exec_tgt->sequence_num >= sequence_num) + { + DBUG_ASSERT( + bulk_access_link_exec_tgt->sequence_num == sequence_num); + break; + } + } + } + bulk_access_link_exec_tgt->spider->bulk_access_executing = TRUE; + break; + case INFO_KIND_BULK_ACCESS_END: + DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_END")); + bulk_access_started = FALSE; + break; +#endif + default: + break; + } +#endif + DBUG_RETURN(error_num); +} + +TABLE *ha_spider::get_table() +{ + DBUG_ENTER("ha_spider::get_table"); + DBUG_RETURN(table); +} + +void ha_spider::set_searched_bitmap() +{ + int roop_count; + DBUG_ENTER("ha_spider::set_searched_bitmap"); + for (roop_count = 0; roop_count < (int) ((table_share->fields + 7) / 8); + roop_count++) + { + searched_bitmap[roop_count] = + ((uchar *) table->read_set->bitmap)[roop_count] | + ((uchar *) table->write_set->bitmap)[roop_count]; + DBUG_PRINT("info",("spider roop_count=%d", roop_count)); + DBUG_PRINT("info",("spider searched_bitmap=%d", + searched_bitmap[roop_count])); + DBUG_PRINT("info",("spider read_set=%d", + ((uchar *) table->read_set->bitmap)[roop_count])); + DBUG_PRINT("info",("spider write_set=%d", + ((uchar *) table->write_set->bitmap)[roop_count])); + } + if (sql_command == SQLCOM_UPDATE || sql_command == SQLCOM_UPDATE_MULTI) + { + DBUG_PRINT("info",("spider update option start")); + Item *item; + List_iterator_fast fi(table->pos_in_table_list->select_lex-> + item_list); + while ((item = fi++)) + { + if (item->type() == Item::FIELD_ITEM) + { + Field *field = ((Item_field *)item)->field; + if (!(field = field_exchange(field))) + { + DBUG_PRINT("info",("spider field is for different table")); + continue; + } + spider_set_bit(searched_bitmap, field->field_index); + DBUG_PRINT("info",("spider set searched_bitmap=%u", + field->field_index)); + } else { + DBUG_PRINT("info",("spider item type is not field")); + } + } + } + DBUG_VOID_RETURN; +} + +void ha_spider::set_clone_searched_bitmap() +{ + DBUG_ENTER("ha_spider::set_clone_searched_bitmap"); + memcpy(searched_bitmap, pt_clone_source_handler->searched_bitmap, + (table_share->fields + 7) / 8); + DBUG_VOID_RETURN; +} + +void ha_spider::set_select_column_mode() +{ + int roop_count; + KEY *key_info; + KEY_PART_INFO *key_part; + Field *field; + THD *thd = trx->thd; + DBUG_ENTER("ha_spider::set_select_column_mode"); + position_bitmap_init = FALSE; +#ifndef DBUG_OFF + for (roop_count = 0; roop_count < (int) ((table_share->fields + 7) / 8); + roop_count++) + DBUG_PRINT("info", ("spider bitmap is %x", + ((uchar *) table->read_set->bitmap)[roop_count])); +#endif + select_column_mode = spider_param_select_column_mode(thd, + share->select_column_mode); + if (select_column_mode) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + if ( + partition_handler_share && + partition_handler_share->searched_bitmap + ) { + if (partition_handler_share->searched_bitmap != searched_bitmap) + memcpy(searched_bitmap, partition_handler_share->searched_bitmap, + (table_share->fields + 7) / 8); + partition_handler_share->between_flg = FALSE; + DBUG_PRINT("info",("spider copy searched_bitmap")); + } else { +#endif + set_searched_bitmap(); + if (result_list.lock_type == F_WRLCK && sql_command != SQLCOM_SELECT) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + uint part_num = 0; + if (update_request) + part_num = check_partitioned(); +#endif + if ( +#ifdef WITH_PARTITION_STORAGE_ENGINE + part_num || +#endif + table_share->primary_key == MAX_KEY + ) { + /* need all columns */ + for (roop_count = 0; roop_count < (int) table_share->fields; + roop_count++) + spider_set_bit(searched_bitmap, roop_count); + } else { + /* need primary key columns */ + key_info = &table_share->key_info[table_share->primary_key]; + key_part = key_info->key_part; + for (roop_count = 0; roop_count < (int) key_info->key_parts; + roop_count++) + { + field = key_part[roop_count].field; + spider_set_bit(searched_bitmap, field->field_index); + } + } +#ifndef DBUG_OFF + for (roop_count = 0; + roop_count < (int) ((table_share->fields + 7) / 8); + roop_count++) + DBUG_PRINT("info", ("spider change bitmap is %x", + searched_bitmap[roop_count])); +#endif + } +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (partition_handler_share) + { + partition_handler_share->searched_bitmap = searched_bitmap; + partition_handler_share->between_flg = TRUE; + DBUG_PRINT("info",("spider set searched_bitmap")); + } + } +#endif + } + DBUG_VOID_RETURN; +} + +#ifdef WITH_PARTITION_STORAGE_ENGINE +void ha_spider::check_select_column(bool rnd) +{ + THD *thd = trx->thd; + DBUG_ENTER("ha_spider::check_select_column"); + select_column_mode = spider_param_select_column_mode(thd, + share->select_column_mode); + if (select_column_mode && partition_handler_share) + { + if (!rnd) + { + if (partition_handler_share->between_flg) + { + memcpy(partition_handler_share->idx_read_bitmap, + table->read_set->bitmap, (table_share->fields + 7) / 8); + memcpy(partition_handler_share->idx_write_bitmap, + table->write_set->bitmap, (table_share->fields + 7) / 8); + partition_handler_share->between_flg = FALSE; + partition_handler_share->idx_bitmap_is_set = TRUE; + DBUG_PRINT("info",("spider set idx_bitmap")); + } else if (partition_handler_share->idx_bitmap_is_set) + { + memcpy(table->read_set->bitmap, + partition_handler_share->idx_read_bitmap, + (table_share->fields + 7) / 8); + memcpy(table->write_set->bitmap, + partition_handler_share->idx_write_bitmap, + (table_share->fields + 7) / 8); + DBUG_PRINT("info",("spider copy idx_bitmap")); + } + } else { + if ( + !partition_handler_share->rnd_bitmap_is_set && + ( + partition_handler_share->between_flg || + partition_handler_share->idx_bitmap_is_set + ) + ) { + memcpy(partition_handler_share->rnd_read_bitmap, + table->read_set->bitmap, (table_share->fields + 7) / 8); + memcpy(partition_handler_share->rnd_write_bitmap, + table->write_set->bitmap, (table_share->fields + 7) / 8); + partition_handler_share->between_flg = FALSE; + partition_handler_share->rnd_bitmap_is_set = TRUE; + DBUG_PRINT("info",("spider set rnd_bitmap")); + } else if (partition_handler_share->rnd_bitmap_is_set) + { + memcpy(table->read_set->bitmap, + partition_handler_share->rnd_read_bitmap, + (table_share->fields + 7) / 8); + memcpy(table->write_set->bitmap, + partition_handler_share->rnd_write_bitmap, + (table_share->fields + 7) / 8); + DBUG_PRINT("info",("spider copy rnd_bitmap")); + } + } + } + DBUG_VOID_RETURN; +} +#endif + +bool ha_spider::check_and_start_bulk_update( + spider_bulk_upd_start bulk_upd_start +) { + DBUG_ENTER("ha_spider::check_and_start_bulk_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider bulk_update_start=%d", + result_list.bulk_update_start)); + if ( + result_list.bulk_update_start == SPD_BU_NOT_START || + ( + !result_list.bulk_update_mode && + bulk_upd_start == SPD_BU_START_BY_BULK_INIT + ) + ) { + THD *thd = ha_thd(); + int bulk_update_mode = spider_param_bulk_update_mode(thd, + share->bulk_update_mode); + longlong split_read = spider_split_read_param(this); + result_list.bulk_update_size = spider_param_bulk_update_size(thd, + share->bulk_update_size); +#ifndef WITHOUT_SPIDER_BG_SEARCH + int bgs_mode = spider_param_bgs_mode(thd, share->bgs_mode); +#endif + if (!support_bulk_update_sql()) + { + result_list.bulk_update_mode = 0; + } else if ( +#ifndef WITHOUT_SPIDER_BG_SEARCH + bgs_mode || +#endif + split_read != 9223372036854775807LL + ) + result_list.bulk_update_mode = 2; + else { + if (result_list.bulk_update_start == SPD_BU_NOT_START) + result_list.bulk_update_mode = bulk_update_mode; + else + result_list.bulk_update_mode = 1; + } + result_list.bulk_update_start = bulk_upd_start; + DBUG_RETURN(FALSE); + } + DBUG_RETURN(TRUE); +} + +int ha_spider::check_and_end_bulk_update( + spider_bulk_upd_start bulk_upd_start +) { + int error_num = 0; + uint dup_key_found = 0; + DBUG_ENTER("ha_spider::check_and_end_bulk_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider bulk_update_start=%d", + result_list.bulk_update_start)); + DBUG_PRINT("info",("spider bulk_update_mode=%d", + result_list.bulk_update_mode)); + if (result_list.bulk_update_start == bulk_upd_start) + { + if (result_list.bulk_update_mode) + error_num = spider_db_bulk_update_end(this, &dup_key_found); + result_list.bulk_update_size = 0; + result_list.bulk_update_mode = 0; + result_list.bulk_update_start = SPD_BU_NOT_START; + } + DBUG_RETURN(error_num); +} + +uint ha_spider::check_partitioned() +{ + uint part_num; + DBUG_ENTER("ha_spider::check_partitioned"); + DBUG_PRINT("info",("spider this=%p", this)); + table->file->get_no_parts("", &part_num); + if (part_num) + DBUG_RETURN(part_num); + + TABLE_LIST *tmp_table_list = table->pos_in_table_list; + while ((tmp_table_list = tmp_table_list->parent_l)) + { + tmp_table_list->table->file->get_no_parts("", &part_num); + if (part_num) + DBUG_RETURN(part_num); + } + DBUG_RETURN(0); +} + +void ha_spider::check_direct_order_limit() +{ + int roop_count; + DBUG_ENTER("ha_spider::check_direct_order_limit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!result_list.check_direct_order_limit) + { + if (spider_check_direct_order_limit(this)) + { + result_list.direct_order_limit = TRUE; + sql_kinds = SPIDER_SQL_KIND_SQL; + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; + } else + result_list.direct_order_limit = FALSE; + result_list.check_direct_order_limit = TRUE; + } + DBUG_VOID_RETURN; +} + +int ha_spider::drop_tmp_tables() +{ + int error_num = 0, tmp_error_num, need_mon; + DBUG_ENTER("ha_spider::drop_tmp_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + if (result_list.tmp_tables_created) + { + int roop_start, roop_end, roop_count, tmp_lock_mode; + tmp_lock_mode = spider_conn_lock_mode(this); + if (tmp_lock_mode) + { + /* "for update" or "lock in share mode" */ + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if (spider_bit_is_set(result_list.tmp_table_created, roop_count)) + { + uint dbton_id = share->use_sql_dbton_ids[roop_count]; + spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; + SPIDER_CONN *conn = conns[roop_count]; + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_TMP_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec( + SPIDER_SQL_TYPE_TMP_SQL, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_TMP_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + conn->need_mon = &need_mon; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((tmp_error_num = spider_db_set_names(this, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + tmp_error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + error_num = tmp_error_num; + } + if (!tmp_error_num) + { + spider_conn_set_timeout_from_share(conn, roop_count, + trx->thd, share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL, + conn, + -1, + &need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + tmp_error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + tmp_error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + error_num = tmp_error_num; + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + spider_clear_bit(result_list.tmp_table_created, roop_count); + } + } + result_list.tmp_tables_created = FALSE; + } + DBUG_RETURN(error_num); +} + +bool ha_spider::handler_opened( + int link_idx, + uint tgt_conn_kind +) { + DBUG_ENTER("ha_spider::handler_opened"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); + DBUG_PRINT("info",("spider tgt_conn_kind=%u", tgt_conn_kind)); + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ( + tgt_conn_kind == SPIDER_CONN_KIND_MYSQL && +#endif + spider_bit_is_set(m_handler_opened, link_idx) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) || + ( + tgt_conn_kind == SPIDER_CONN_KIND_HS_READ && + spider_bit_is_set(r_handler_opened, link_idx) + ) || + ( + tgt_conn_kind == SPIDER_CONN_KIND_HS_WRITE && + spider_bit_is_set(w_handler_opened, link_idx) + ) +#endif + ) { + DBUG_PRINT("info",("spider TRUE")); + DBUG_RETURN(TRUE); + } + DBUG_PRINT("info",("spider FALSE")); + DBUG_RETURN(FALSE); +} + +void ha_spider::set_handler_opened( + int link_idx +) { + DBUG_ENTER("ha_spider::set_handler_opened"); + DBUG_PRINT("info",("spider this=%p", this)); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) +#endif + spider_set_bit(m_handler_opened, link_idx); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else if (conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) + spider_set_bit(r_handler_opened, link_idx); + else + spider_set_bit(w_handler_opened, link_idx); +#endif + DBUG_VOID_RETURN; +} + +void ha_spider::clear_handler_opened( + int link_idx, + uint tgt_conn_kind +) { + DBUG_ENTER("ha_spider::clear_handler_opened"); + DBUG_PRINT("info",("spider this=%p", this)); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (tgt_conn_kind == SPIDER_CONN_KIND_MYSQL) +#endif + spider_clear_bit(m_handler_opened, link_idx); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else if (tgt_conn_kind == SPIDER_CONN_KIND_HS_READ) + spider_clear_bit(r_handler_opened, link_idx); + else + spider_clear_bit(w_handler_opened, link_idx); +#endif + DBUG_VOID_RETURN; +} + +int ha_spider::close_opened_handler( + int link_idx, + bool release_conn +) { + int error_num = 0, error_num2; + DBUG_ENTER("ha_spider::close_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + + if (spider_bit_is_set(m_handler_opened, link_idx)) + { + if ((error_num2 = spider_db_close_handler(this, + conns[link_idx], link_idx, SPIDER_CONN_KIND_MYSQL)) + ) { + if ( + share->monitoring_kind[link_idx] && + need_mons[link_idx] + ) { + error_num2 = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + conn_link_idx[link_idx], + NULL, + 0, + share->monitoring_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + } + error_num = error_num2; + } + spider_clear_bit(m_handler_opened, link_idx); + if (release_conn) + { + spider_free_conn_from_trx(trx, conns[link_idx], FALSE, FALSE, NULL); + conns[link_idx] = NULL; + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider_bit_is_set(r_handler_opened, link_idx)) + { + if ((error_num2 = spider_db_close_handler(this, + hs_r_conns[link_idx], link_idx, SPIDER_CONN_KIND_HS_READ)) + ) { + if ( + share->monitoring_kind[link_idx] && + need_mons[link_idx] + ) { + error_num2 = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + conn_link_idx[link_idx], + NULL, + 0, + share->monitoring_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + } + error_num = error_num2; + } + spider_clear_bit(r_handler_opened, link_idx); + if (release_conn) + { + if ( + !hs_r_conns[link_idx]->opened_handlers && + trx->trx_hs_r_conn_adjustment == trx_hs_r_conn_adjustment && + spider_param_hs_r_conn_recycle_mode(trx->thd) != 2 + ) { + trx->trx_hs_r_conn_adjustment++; + } + spider_free_conn_from_trx(trx, hs_r_conns[link_idx], FALSE, FALSE, NULL); + hs_r_conns[link_idx] = NULL; + } + } + if (spider_bit_is_set(w_handler_opened, link_idx)) + { + if ((error_num2 = spider_db_close_handler(this, + hs_w_conns[link_idx], link_idx, SPIDER_CONN_KIND_HS_WRITE)) + ) { + if ( + share->monitoring_kind[link_idx] && + need_mons[link_idx] + ) { + error_num2 = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + conn_link_idx[link_idx], + NULL, + 0, + share->monitoring_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + } + error_num = error_num2; + } + spider_clear_bit(w_handler_opened, link_idx); + if (release_conn) + { + if ( + !hs_w_conns[link_idx]->opened_handlers && + trx->trx_hs_w_conn_adjustment == trx_hs_w_conn_adjustment && + spider_param_hs_w_conn_recycle_mode(trx->thd) != 2 + ) { + trx->trx_hs_w_conn_adjustment++; + } + spider_free_conn_from_trx(trx, hs_w_conns[link_idx], FALSE, FALSE, NULL); + hs_w_conns[link_idx] = NULL; + } + } +#endif + DBUG_RETURN(error_num); +} + +int ha_spider::index_handler_init() +{ + int lock_mode, error_num; + int roop_start, roop_end, roop_count; + DBUG_ENTER("ha_spider::index_handler_init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!init_index_handler) + { + init_index_handler = TRUE; + lock_mode = spider_conn_lock_mode(this); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + sql_kinds = 0; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + direct_update_kinds = 0; +#endif + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if ( + spider_conn_use_handler(this, lock_mode, roop_count) && + spider_conn_need_open_handler(this, active_index, roop_count) + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint tmp_conn_kind1; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if ( + do_direct_update && + spider_bit_is_set(do_hs_direct_update, roop_count) + ) { + tmp_conn_kind1 = SPIDER_CONN_KIND_HS_WRITE; + } else { +#endif + tmp_conn_kind1 = conn_kind[roop_count]; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + } +#endif +#endif + if ((error_num = spider_db_open_handler(this, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (tmp_conn_kind1 == SPIDER_CONN_KIND_MYSQL ? +#endif + conns[roop_count] +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + : tmp_conn_kind1 == SPIDER_CONN_KIND_HS_READ ? + hs_r_conns[roop_count] : hs_w_conns[roop_count] + ) +#endif + , roop_count)) + ) { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + uint tmp_conn_kind2 = conn_kind[roop_count]; + conn_kind[roop_count] = tmp_conn_kind1; +#endif +#endif + set_handler_opened(roop_count); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + conn_kind[roop_count] = tmp_conn_kind2; +#endif +#endif + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); + DBUG_PRINT("info",("spider SPIDER_SQL_KIND_HANDLER")); + result_list.semi_split_read = 1; + result_list.semi_split_read_limit = 9223372036854775807LL; + if (select_limit == 9223372036854775807LL) + { + DBUG_PRINT("info",("spider set limit to 1")); + result_list.semi_split_read_base = 1; + result_list.split_read = 1; + } else { + DBUG_PRINT("info",("spider set limit to %lld", select_limit)); + result_list.semi_split_read_base = select_limit; + result_list.split_read = select_limit; + } + } + } + DBUG_RETURN(0); +} + +int ha_spider::rnd_handler_init() +{ + int error_num, lock_mode; + int roop_start, roop_end, roop_count; + DBUG_ENTER("ha_spider::rnd_handler_init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!init_rnd_handler) + { + init_rnd_handler = TRUE; + lock_mode = spider_conn_lock_mode(this); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + roop_start = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = share->link_count; + } else { + roop_start = search_link_idx; + roop_end = search_link_idx + 1; + } + sql_kinds = 0; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + direct_update_kinds = 0; +#endif + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if ( + spider_conn_use_handler(this, lock_mode, roop_count) && + spider_conn_need_open_handler(this, MAX_KEY, roop_count) + ) { + if ((error_num = spider_db_open_handler(this, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL ? +#endif + conns[roop_count] +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + : conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ ? + hs_r_conns[roop_count] : hs_w_conns[roop_count] + ) +#endif + , roop_count)) + ) { + if ( + share->monitoring_kind[roop_count] && + need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + set_handler_opened(roop_count); + } + } + if (sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); + DBUG_PRINT("info",("spider SPIDER_SQL_KIND_HANDLER")); + result_list.semi_split_read = 1; + result_list.semi_split_read_limit = 9223372036854775807LL; + if (select_limit == 9223372036854775807LL) + { + DBUG_PRINT("info",("spider set limit to 1")); + result_list.semi_split_read_base = 1; + result_list.split_read = 1; + } else { + DBUG_PRINT("info",("spider set limit to %lld", select_limit)); + result_list.semi_split_read_base = select_limit; + result_list.split_read = select_limit; + } + } + } + DBUG_RETURN(0); +} + +void ha_spider::set_error_mode() +{ + THD *thd = trx->thd; + DBUG_ENTER("ha_spider::set_error_mode"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (thd_sql_command(thd)) + { + case SQLCOM_SELECT: + case SQLCOM_SHOW_DATABASES: + case SQLCOM_SHOW_TABLES: + case SQLCOM_SHOW_FIELDS: + case SQLCOM_SHOW_KEYS: + case SQLCOM_SHOW_VARIABLES: + case SQLCOM_SHOW_STATUS: + case SQLCOM_SHOW_ENGINE_LOGS: + case SQLCOM_SHOW_ENGINE_STATUS: + case SQLCOM_SHOW_ENGINE_MUTEX: + case SQLCOM_SHOW_PROCESSLIST: + case SQLCOM_SHOW_MASTER_STAT: + case SQLCOM_SHOW_SLAVE_STAT: + case SQLCOM_SHOW_GRANTS: + case SQLCOM_SHOW_CREATE: + case SQLCOM_SHOW_CHARSETS: + case SQLCOM_SHOW_COLLATIONS: + case SQLCOM_SHOW_CREATE_DB: + case SQLCOM_SHOW_TABLE_STATUS: + case SQLCOM_SHOW_TRIGGERS: + case SQLCOM_CHANGE_DB: + case SQLCOM_HA_OPEN: + case SQLCOM_HA_CLOSE: + case SQLCOM_HA_READ: + case SQLCOM_SHOW_SLAVE_HOSTS: + case SQLCOM_SHOW_BINLOG_EVENTS: + case SQLCOM_SHOW_WARNS: + case SQLCOM_EMPTY_QUERY: + case SQLCOM_SHOW_ERRORS: + case SQLCOM_SHOW_STORAGE_ENGINES: + case SQLCOM_SHOW_PRIVILEGES: + case SQLCOM_HELP: + case SQLCOM_SHOW_CREATE_PROC: + case SQLCOM_SHOW_CREATE_FUNC: + case SQLCOM_SHOW_STATUS_PROC: + case SQLCOM_SHOW_STATUS_FUNC: + case SQLCOM_SHOW_PROC_CODE: + case SQLCOM_SHOW_FUNC_CODE: + case SQLCOM_SHOW_AUTHORS: + case SQLCOM_SHOW_PLUGINS: + case SQLCOM_SHOW_CONTRIBUTORS: + case SQLCOM_SHOW_CREATE_EVENT: + case SQLCOM_SHOW_EVENTS: + case SQLCOM_SHOW_CREATE_TRIGGER: + case SQLCOM_SHOW_PROFILE: + case SQLCOM_SHOW_PROFILES: +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + case SQLCOM_HS_READ: +#endif + error_mode = spider_param_error_read_mode(thd, share->error_read_mode); + DBUG_PRINT("info",("spider read error_mode=%d", error_mode)); + break; + default: + error_mode = spider_param_error_write_mode(thd, share->error_write_mode); + DBUG_PRINT("info",("spider write error_mode=%d", error_mode)); + break; + } + DBUG_VOID_RETURN; +} + +void ha_spider::backup_error_status() +{ + THD *thd = ha_thd(); + DBUG_ENTER("ha_spider::backup_error_status"); + if (thd) + da_status = thd->is_error(); + DBUG_VOID_RETURN; +} + +int ha_spider::check_error_mode( + int error_num +) { + THD *thd = ha_thd(); + DBUG_ENTER("ha_spider::check_error_mode"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider error_num=%d", error_num)); + if (!thd || !error_mode) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider error reset")); + SPIDER_RESTORE_DASTATUS; + DBUG_RETURN(0); +} + +int ha_spider::check_error_mode_eof( + int error_num +) { + DBUG_ENTER("ha_spider::check_error_mode_eof"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider error_num=%d", error_num)); + if (error_num == HA_ERR_END_OF_FILE) + DBUG_RETURN(HA_ERR_END_OF_FILE); + if (check_error_mode(error_num)) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider result_list.finish_flg = TRUE")); + result_list.finish_flg = TRUE; + if (result_list.current) + { + DBUG_PRINT("info",("spider result_list.current->finish_flg = TRUE")); + result_list.current->finish_flg = TRUE; + } + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_END_OF_FILE); +} + +void ha_spider::check_pre_call( + bool use_parallel +) { + DBUG_ENTER("ha_spider::check_pre_call"); + DBUG_PRINT("info",("spider this=%p", this)); + use_pre_call = use_parallel; + if (!use_pre_call) + { + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); + if ( + select_lex && + (!select_lex->explicit_limit || !select_limit) + ) { + use_pre_call = TRUE; + } + } + DBUG_VOID_RETURN; +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +void ha_spider::check_insert_dup_update_pushdown() +{ + THD *thd = trx->thd; + DBUG_ENTER("ha_spider::check_insert_dup_update_pushdown"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!spider_param_direct_dup_insert(thd, share->direct_dup_insert)) + { + DBUG_PRINT("info",("spider FALSE by direct_dup_insert")); + DBUG_VOID_RETURN; + } + direct_update_fields = &thd->lex->update_list; + direct_update_values = &thd->lex->value_list; + if (!append_dup_update_pushdown_sql_part(NULL, 0)) + { + result_list.insert_dup_update_pushdown = TRUE; + } + DBUG_VOID_RETURN; +} +#endif + +#ifdef HA_CAN_BULK_ACCESS +SPIDER_BULK_ACCESS_LINK *ha_spider::create_bulk_access_link() +{ + uchar *ref; + ha_spider *spider; + SPIDER_BULK_ACCESS_LINK *bulk_access_link; + DBUG_ENTER("ha_spider::create_bulk_access_link"); + DBUG_PRINT("info",("spider this=%p", this)); +/* + if (!init_ha_mem_root) + { + SPD_INIT_ALLOC_ROOT(&ha_mem_root, sizeof(ha_spider) * 16, + sizeof(ha_spider) * 16, MYF(MY_WME)); + init_ha_mem_root = TRUE; + } +*/ + if (!(bulk_access_link = (SPIDER_BULK_ACCESS_LINK *) + spider_bulk_malloc(spider_current_trx, 168, MYF(MY_WME), + &bulk_access_link, sizeof(SPIDER_BULK_ACCESS_LINK), + &ref, ALIGN_SIZE(ref_length) * 2, + NullS)) + ) { + goto error_bulk_malloc; + } + SPD_INIT_ALLOC_ROOT(&bulk_access_link->mem_root, sizeof(ha_spider), 0, + MYF(MY_WME)); +/* + if (!(spider = new ha_spider(spider_hton_ptr, table_share))) + if (!(spider = (ha_spider *) spider_create_handler( + spider_hton_ptr, table_share, &ha_mem_root))) +*/ + if (!(spider = (ha_spider *) spider_create_handler( + spider_hton_ptr, table_share, &bulk_access_link->mem_root))) + { + goto error_new_spider; + } + DBUG_PRINT("info",("spider spider=%p", spider)); + bulk_access_link->spider = spider; + spider->ref = ref; + bulk_access_link->next = NULL; + spider->is_clone = TRUE; + spider->is_bulk_access_clone = TRUE; + spider->pt_clone_source_handler = this; + if (spider->ha_open(table, share->table_name, table->db_stat, + HA_OPEN_IGNORE_IF_LOCKED)) + { + goto error_ha_open; + } + DBUG_RETURN(bulk_access_link); + +error_ha_open: + delete spider; +error_new_spider: + free_root(&bulk_access_link->mem_root, MYF(0)); + spider_free(spider_current_trx, bulk_access_link, MYF(0)); +error_bulk_malloc: + DBUG_RETURN(NULL); +} + +void ha_spider::delete_bulk_access_link( + SPIDER_BULK_ACCESS_LINK *bulk_access_link +) { + ha_spider *spider = bulk_access_link->spider; + DBUG_ENTER("ha_spider::delete_bulk_access_link"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider spider=%p", spider)); + DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", + spider->dbton_handler)); + DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", + &spider->dbton_handler)); + spider->close(); + delete spider; + free_root(&bulk_access_link->mem_root, MYF(0)); + spider_free(spider_current_trx, bulk_access_link, MYF(0)); + DBUG_VOID_RETURN; +} + +int ha_spider::sync_from_clone_source( + ha_spider *spider +) { + int error_num; + DBUG_ENTER("ha_spider::sync_from_clone_source"); + sync_from_clone_source_base(spider); + if (!synced_from_clone_source) + { + DBUG_PRINT("info",("spider synced from clone source all")); + trx = spider->trx; + sql_command = spider->sql_command; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = spider->do_direct_update; +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + memcpy(do_hs_direct_update, spider->do_hs_direct_update, + share->link_bitmap_size); +#endif +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + conn_kinds = spider->conn_kinds; + memcpy(conn_kind, spider->conn_kind, sizeof(uint) * share->link_count); +#endif + result_list.lock_type = spider->result_list.lock_type; + lock_type = spider->lock_type; + selupd_lock_mode = spider->selupd_lock_mode; + update_request = spider->update_request; + lock_mode = spider->lock_mode; + high_priority = spider->high_priority; + insert_delayed = spider->insert_delayed; + low_priority = spider->low_priority; + memcpy(conns, spider->conns, + sizeof(SPIDER_CONN *) * share->link_count); + memcpy(hs_r_conns, spider->hs_r_conns, + sizeof(SPIDER_CONN *) * share->link_count); + memcpy(hs_w_conns, spider->hs_w_conns, + sizeof(SPIDER_CONN *) * share->link_count); + spider_thread_id = spider->spider_thread_id; + trx_conn_adjustment = spider->trx_conn_adjustment; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + trx_hs_r_conn_adjustment = spider->trx_hs_r_conn_adjustment; + trx_hs_w_conn_adjustment = spider->trx_hs_w_conn_adjustment; +#endif + search_link_idx = spider->search_link_idx; + external_lock_cnt = spider->external_lock_cnt; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl, *dbton_hdl2; + for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) + { + dbton_id = share->use_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + dbton_hdl2 = spider->dbton_handler[dbton_id]; + dbton_hdl->sync_from_clone_source(dbton_hdl2); + } + synced_from_clone_source = TRUE; + } else if (external_lock_cnt != spider->external_lock_cnt) + { + DBUG_PRINT("info",("spider synced from clone source")); + sql_command = spider->sql_command; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + do_direct_update = spider->do_direct_update; +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + memcpy(do_hs_direct_update, spider->do_hs_direct_update, + share->link_bitmap_size); +#endif +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + conn_kinds = spider->conn_kinds; + memcpy(conn_kind, spider->conn_kind, sizeof(uint) * share->link_count); +#endif + result_list.lock_type = spider->result_list.lock_type; + lock_type = spider->lock_type; + selupd_lock_mode = spider->selupd_lock_mode; + update_request = spider->update_request; + lock_mode = spider->lock_mode; + high_priority = spider->high_priority; + insert_delayed = spider->insert_delayed; + low_priority = spider->low_priority; + + if ((error_num = spider_check_trx_and_get_conn(spider->trx->thd, + this, TRUE))) + { + DBUG_RETURN(error_num); + } + external_lock_cnt = spider->external_lock_cnt; + } + + if (spider->hs_pushed_ret_fields_num < MAX_FIELDS) + { + SPIDER_HS_UINT32_INFO tmp_info; + tmp_info.info_size = spider->hs_pushed_ret_fields_num; + tmp_info.info = spider->hs_pushed_ret_fields; + if ((error_num = info_push(INFO_KIND_HS_RET_FIELDS, &tmp_info))) + { + DBUG_RETURN(error_num); + } + } + DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", + dbton_handler)); + DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", + &dbton_handler)); + DBUG_RETURN(0); +} +#endif + +void ha_spider::sync_from_clone_source_base( + ha_spider *spider +) { + uint roop_count2, dbton_id; + spider_db_handler *dbton_hdl, *dbton_hdl2; + DBUG_ENTER("ha_spider::sync_from_clone_source_base"); + for (roop_count2 = 0; roop_count2 < share->use_dbton_count; roop_count2++) + { + dbton_id = share->use_dbton_ids[roop_count2]; + dbton_hdl = dbton_handler[dbton_id]; + dbton_hdl2 = spider->dbton_handler[dbton_id]; + dbton_hdl->first_link_idx = dbton_hdl2->first_link_idx; + } + DBUG_VOID_RETURN; +} + +void ha_spider::set_first_link_idx() +{ + int roop_count, all_link_idx; + uint roop_count2, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::set_first_link_idx"); + for (roop_count2 = 0; roop_count2 < share->use_dbton_count; roop_count2++) + { + dbton_id = share->use_dbton_ids[roop_count2]; + dbton_hdl = dbton_handler[dbton_id]; + dbton_hdl->first_link_idx = -1; + } + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + all_link_idx = conn_link_idx[roop_count]; + dbton_id = share->sql_dbton_ids[all_link_idx]; + if (dbton_id < SPIDER_DBTON_SIZE) + { + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx == -1) + { + dbton_hdl->first_link_idx = roop_count; + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + dbton_id = share->hs_dbton_ids[all_link_idx]; + if (dbton_id < SPIDER_DBTON_SIZE) + { + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx == -1) + { + dbton_hdl->first_link_idx = roop_count; + } + } +#endif + } + DBUG_VOID_RETURN; +} + +void ha_spider::reset_first_link_idx() +{ + int all_link_idx; + uint roop_count2, dbton_id; + spider_db_handler *dbton_hdl; + int lock_mode = spider_conn_lock_mode(this); + DBUG_ENTER("ha_spider::reset_first_link_idx"); + if (!lock_mode) + { + DBUG_PRINT("info",("spider use only search_link_idx")); + for (roop_count2 = 0; roop_count2 < share->use_dbton_count; roop_count2++) + { + dbton_id = share->use_dbton_ids[roop_count2]; + dbton_hdl = dbton_handler[dbton_id]; + dbton_hdl->first_link_idx = -1; + } + all_link_idx = conn_link_idx[search_link_idx]; + dbton_id = share->sql_dbton_ids[all_link_idx]; + if (dbton_id < SPIDER_DBTON_SIZE) + { + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx == -1) + { + dbton_hdl->first_link_idx = search_link_idx; + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + dbton_id = share->hs_dbton_ids[all_link_idx]; + if (dbton_id < SPIDER_DBTON_SIZE) + { + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx == -1) + { + dbton_hdl->first_link_idx = search_link_idx; + } + } +#endif + } + DBUG_VOID_RETURN; +} + +int ha_spider::reset_sql_sql( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + DBUG_ENTER("ha_spider::reset_sql_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + if ((error_num = dbton_handler[dbton_id]->reset_sql(sql_type))) + { + DBUG_RETURN(error_num); + } + } + + if (sql_type & SPIDER_SQL_TYPE_BULK_UPDATE_SQL) + { + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + result_list.update_sqls[roop_count].length(0); + } + } + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int ha_spider::reset_hs_sql( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + DBUG_ENTER("ha_spider::reset_hs_sql"); + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + if ((error_num = dbton_handler[dbton_id]->reset_sql(sql_type))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::reset_hs_keys( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + DBUG_ENTER("ha_spider::reset_hs_keys"); + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + if ((error_num = dbton_handler[dbton_id]->reset_keys(sql_type))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::reset_hs_upds( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + DBUG_ENTER("ha_spider::reset_hs_upds"); + for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) + { + dbton_id = share->use_dbton_ids[roop_count]; + if ((error_num = dbton_handler[dbton_id]->reset_upds(sql_type))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::reset_hs_strs( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + DBUG_ENTER("ha_spider::reset_hs_strs"); + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + if ((error_num = dbton_handler[dbton_id]->reset_strs(sql_type))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::reset_hs_strs_pos( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + DBUG_ENTER("ha_spider::reset_hs_strs_pos"); + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + if ((error_num = dbton_handler[dbton_id]->reset_strs_pos(sql_type))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::push_back_hs_upds( + SPIDER_HS_STRING_REF &info +) { + int error_num; + uint roop_count, dbton_id; + DBUG_ENTER("ha_spider::push_back_hs_upds"); + for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) + { + dbton_id = share->use_dbton_ids[roop_count]; + if ((error_num = dbton_handler[dbton_id]->push_back_upds(info))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} +#endif + +int ha_spider::append_tmp_table_and_sql_for_bka( + const key_range *start_key +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_tmp_table_and_sql_for_bka"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_tmp_table_and_sql_for_bka(start_key)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::reuse_tmp_table_and_sql_for_bka() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::reuse_tmp_table_and_sql_for_bka"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->reuse_tmp_table_and_sql_for_bka()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_insert_sql_part() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_insert_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_insert_part()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_update_sql_part() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_update_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_update_part()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int ha_spider::append_increment_update_set_sql_part() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_increment_update_set_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_increment_update_set_part()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} +#endif +#endif + +int ha_spider::append_update_set_sql_part() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_update_set_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_update_set_part()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int ha_spider::append_direct_update_set_sql_part() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_direct_update_set_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_direct_update_set_part()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int ha_spider::append_direct_update_set_hs_part() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_direct_update_set_hs_part"); + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_direct_update_set_part()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} +#endif +#endif + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int ha_spider::append_dup_update_pushdown_sql_part( + const char *alias, + uint alias_length +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_dup_update_pushdown_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_dup_update_pushdown_part( + alias, alias_length)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_update_columns_sql_part( + const char *alias, + uint alias_length +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_update_columns_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_update_columns_part( + alias, alias_length)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::check_update_columns_sql_part() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::check_update_columns_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->check_update_columns_part()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} +#endif + +int ha_spider::append_delete_sql_part() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_delete_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_delete_part()) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_select_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_select_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_select_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_table_select_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_table_select_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_table_select_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_key_select_sql_part( + ulong sql_type, + uint idx +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_key_select_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_key_select_part(sql_type, idx)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_minimum_select_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_minimum_select_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_minimum_select_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_from_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_from_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_from_part(sql_type, + dbton_hdl->first_link_idx)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_hint_after_table_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_hint_after_table_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_hint_after_table_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +void ha_spider::set_where_pos_sql( + ulong sql_type +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::set_where_pos_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + dbton_hdl->set_where_pos(sql_type); + } + DBUG_VOID_RETURN; +} + +void ha_spider::set_where_to_pos_sql( + ulong sql_type +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::set_where_to_pos_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + dbton_hdl->set_where_to_pos(sql_type); + } + DBUG_VOID_RETURN; +} + +int ha_spider::check_item_type_sql( + Item *item +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::check_item_type_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->check_item_type(item)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_values_connector_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_values_connector_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = + dbton_hdl->append_values_connector_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_values_terminator_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_values_terminator_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = + dbton_hdl->append_values_terminator_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_key_column_values_sql_part( + const key_range *start_key, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_key_column_values_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = + dbton_hdl->append_key_column_values_part(start_key, sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_key_where_sql_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_key_where_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_key_where_part(start_key, end_key, + sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int ha_spider::append_key_where_hs_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_key_where_hs_part"); + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_key_where_part(start_key, end_key, + sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} +#endif + +int ha_spider::append_match_where_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_match_where_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_match_where_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_condition_sql_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_condition_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_condition_part(alias, alias_length, + sql_type, test_flg)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_match_select_sql_part( + ulong sql_type, + const char *alias, + uint alias_length +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_match_select_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_match_select_part(sql_type, + alias, alias_length)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +void ha_spider::set_order_pos_sql( + ulong sql_type +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::set_order_pos_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + dbton_hdl->set_order_pos(sql_type); + } + DBUG_VOID_RETURN; +} + +void ha_spider::set_order_to_pos_sql( + ulong sql_type +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::set_order_to_pos_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + dbton_hdl->set_order_to_pos(sql_type); + } + DBUG_VOID_RETURN; +} + +int ha_spider::append_key_order_for_merge_with_alias_sql_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_key_order_for_merge_with_alias_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_key_order_for_merge_with_alias_part( + alias, alias_length, sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_key_order_for_direct_order_limit_with_alias_sql_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_key_order_for_direct_order_limit_with_alias_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = + dbton_hdl->append_key_order_for_direct_order_limit_with_alias_part( + alias, alias_length, sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_key_order_with_alias_sql_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_key_order_with_alias_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_key_order_with_alias_part( + alias, alias_length, sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_limit_sql_part( + longlong offset, + longlong limit, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_limit_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_limit_part(offset, limit, sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int ha_spider::append_limit_hs_part( + longlong offset, + longlong limit, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_limit_hs_part"); + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_limit_part(offset, limit, sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} +#endif + +int ha_spider::reappend_limit_sql_part( + longlong offset, + longlong limit, + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::reappend_limit_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->reappend_limit_part(offset, limit, sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_insert_terminator_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_insert_terminator_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_insert_terminator_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_insert_values_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_insert_values_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_insert_values_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int ha_spider::append_insert_values_hs_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_insert_values_hs_part"); + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_insert_values_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} +#endif + +int ha_spider::append_into_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_into_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_into_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +void ha_spider::set_insert_to_pos_sql( + ulong sql_type +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::set_insert_to_pos_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + dbton_hdl->set_insert_to_pos(sql_type); + } + DBUG_VOID_RETURN; +} + +bool ha_spider::is_bulk_insert_exec_period( + bool bulk_end +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::is_bulk_insert_exec_period"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (sql_kinds & SPIDER_SQL_KIND_SQL) + { +#endif + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + dbton_hdl->is_bulk_insert_exec_period(bulk_end) + ) { + DBUG_RETURN(TRUE); + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } + if (sql_kinds & SPIDER_SQL_KIND_HS) + { + for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) + { + dbton_id = share->use_hs_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + dbton_hdl->is_bulk_insert_exec_period(bulk_end) + ) { + DBUG_RETURN(TRUE); + } + } + } +#endif + DBUG_RETURN(FALSE); +} + +int ha_spider::append_select_lock_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_select_lock_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_select_lock_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_union_all_start_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_union_all_start_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_union_all_start_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_union_all_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_union_all_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_union_all_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_union_all_end_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_union_all_end_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_union_all_end_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_multi_range_cnt_sql_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_multi_range_cnt_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_multi_range_cnt_part( + sql_type, multi_range_cnt, with_comma)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_delete_all_rows_sql_part( + ulong sql_type +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_delete_all_rows_sql_part"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_delete_all_rows_part(sql_type)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_update_sql( + const TABLE *table, + my_ptrdiff_t ptr_diff, + bool bulk +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_update"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_update(table, ptr_diff)) + ) { + DBUG_RETURN(error_num); + } + } + if (!bulk) + { + DBUG_RETURN(0); + } + + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + dbton_id = share->sql_dbton_ids[conn_link_idx[roop_count]]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + dbton_hdl->need_copy_for_update(roop_count) + ) { + if ((error_num = dbton_hdl->append_update(table, ptr_diff, roop_count))) + { + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int ha_spider::append_delete_sql( + const TABLE *table, + my_ptrdiff_t ptr_diff, + bool bulk +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::append_delete"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->append_delete(table, ptr_diff)) + ) { + DBUG_RETURN(error_num); + } + } + if (!bulk) + { + DBUG_RETURN(0); + } + + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, -1, share->link_count, SPIDER_LINK_STATUS_RECOVERY); + roop_count < share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + dbton_id = share->sql_dbton_ids[conn_link_idx[roop_count]]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + dbton_hdl->need_copy_for_update(roop_count) + ) { + if ((error_num = dbton_hdl->append_delete(table, ptr_diff, roop_count))) + { + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +bool ha_spider::sql_is_filled_up( + ulong sql_type +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::sql_is_filled_up"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + dbton_hdl->sql_is_filled_up(sql_type) + ) { + DBUG_RETURN(TRUE); + } + } + DBUG_RETURN(FALSE); +} + +bool ha_spider::sql_is_empty( + ulong sql_type +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::sql_is_empty"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + !dbton_hdl->sql_is_empty(sql_type) + ) { + DBUG_RETURN(FALSE); + } + } + DBUG_RETURN(TRUE); +} + +bool ha_spider::support_multi_split_read_sql() +{ + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::support_multi_split_read_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + !dbton_hdl->support_multi_split_read() + ) { + DBUG_RETURN(FALSE); + } + } + DBUG_RETURN(TRUE); +} + +bool ha_spider::support_bulk_update_sql() +{ + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::support_bulk_update_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + !dbton_hdl->support_bulk_update() + ) { + DBUG_RETURN(FALSE); + } + } + DBUG_RETURN(TRUE); +} + +int ha_spider::bulk_tmp_table_insert() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + TABLE **tmp_table = result_list.upd_tmp_tbls; + DBUG_ENTER("ha_spider::bulk_tmp_table_insert"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->bulk_tmp_table_insert()) + ) { + DBUG_RETURN(error_num); + } + } + + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + if (tmp_table[roop_count]) + { + dbton_id = share->sql_dbton_ids[conn_link_idx[roop_count]]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->bulk_tmp_table_insert(roop_count)) + ) { + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int ha_spider::bulk_tmp_table_end_bulk_insert() +{ + int error_num = 0, error_num2; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + TABLE **tmp_table = result_list.upd_tmp_tbls; + DBUG_ENTER("ha_spider::bulk_tmp_table_end_bulk_insert"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num2 = dbton_hdl->bulk_tmp_table_end_bulk_insert()) + ) { + error_num = error_num2; + } + } + + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + if (tmp_table[roop_count]) + { + if ( + (error_num2 = tmp_table[roop_count]->file->ha_end_bulk_insert()) + ) { + error_num = error_num2; + } + } + } + DBUG_RETURN(error_num); +} + +int ha_spider::bulk_tmp_table_rnd_init() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + TABLE **tmp_table = result_list.upd_tmp_tbls; + DBUG_ENTER("ha_spider::bulk_tmp_table_rnd_init"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->bulk_tmp_table_rnd_init()) + ) { + goto error_1; + } + } + + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + if (tmp_table[roop_count]) + { + tmp_table[roop_count]->file->extra(HA_EXTRA_CACHE); + if ( + (error_num = tmp_table[roop_count]->file->ha_rnd_init(TRUE)) + ) + goto error_2; + } + } + DBUG_RETURN(0); + +error_2: + for (; roop_count > 0; roop_count--) + { + if (tmp_table[roop_count - 1]) + { + tmp_table[roop_count - 1]->file->ha_rnd_end(); + } + } + roop_count = share->use_sql_dbton_count; +error_1: + for (; roop_count > 0; roop_count--) + { + dbton_id = share->use_sql_dbton_ids[roop_count - 1]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + dbton_hdl->bulk_tmp_table_rnd_end(); + } + DBUG_RETURN(error_num); +} + +int ha_spider::bulk_tmp_table_rnd_next() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + TABLE **tmp_table = result_list.upd_tmp_tbls; + DBUG_ENTER("ha_spider::bulk_tmp_table_rnd_next"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->bulk_tmp_table_rnd_next()) + ) { + DBUG_RETURN(error_num); + } + } + + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + if (tmp_table[roop_count]) + { + if ( +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + !(error_num = tmp_table[roop_count]->file->ha_rnd_next( + tmp_table[roop_count]->record[0])) +#else + !(error_num = tmp_table[roop_count]->file->rnd_next( + tmp_table[roop_count]->record[0])) +#endif + ) { + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int ha_spider::bulk_tmp_table_rnd_end() +{ + int error_num = 0, error_num2; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + TABLE **tmp_table = result_list.upd_tmp_tbls; + DBUG_ENTER("ha_spider::bulk_tmp_table_rnd_end"); + for (roop_count = share->link_count; roop_count > 0; roop_count--) + { + if (tmp_table[roop_count - 1]) + { + if ((error_num2 = tmp_table[roop_count - 1]->file->ha_rnd_end())) + { + error_num = error_num2; + } + } + } + + for (roop_count = share->use_sql_dbton_count; roop_count > 0; roop_count--) + { + dbton_id = share->use_sql_dbton_ids[roop_count - 1]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num2 = dbton_hdl->bulk_tmp_table_rnd_end()) + ) { + error_num = error_num2; + } + } + DBUG_RETURN(error_num); +} + +int ha_spider::mk_bulk_tmp_table_and_bulk_start() +{ + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + TABLE **tmp_table = result_list.upd_tmp_tbls; + DBUG_ENTER("ha_spider::mk_bulk_tmp_table_and_bulk_start"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + { + if (dbton_hdl->bulk_tmp_table_created()) + { + DBUG_RETURN(0); + } else { + break; + } + } + } + + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = dbton_hdl->mk_bulk_tmp_table_and_bulk_start()) + ) { + goto error_1; + } + } + + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + dbton_id = share->sql_dbton_ids[conn_link_idx[roop_count]]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + dbton_hdl->need_copy_for_update(roop_count) + ) { + if ( + !tmp_table[roop_count] && + !(tmp_table[roop_count] = spider_mk_sys_tmp_table( + trx->thd, table, &result_list.upd_tmp_tbl_prms[roop_count], "a", + result_list.update_sqls[roop_count].charset())) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_2; + } + tmp_table[roop_count]->file->extra(HA_EXTRA_WRITE_CACHE); + tmp_table[roop_count]->file->ha_start_bulk_insert((ha_rows) 0); + } + } + DBUG_RETURN(0); + +error_2: + for (; roop_count > 0; roop_count--) + { + if (tmp_table[roop_count - 1]) + { + tmp_table[roop_count - 1]->file->ha_end_bulk_insert(); + spider_rm_sys_tmp_table(trx->thd, tmp_table[roop_count - 1], + &result_list.upd_tmp_tbl_prms[roop_count - 1]); + tmp_table[roop_count - 1] = NULL; + } + } + roop_count = share->use_sql_dbton_count; +error_1: + for (; roop_count > 0; roop_count--) + { + dbton_id = share->use_sql_dbton_ids[roop_count - 1]; + if (dbton_hdl->first_link_idx >= 0) + { + dbton_handler[dbton_id]->bulk_tmp_table_end_bulk_insert(); + dbton_handler[dbton_id]->rm_bulk_tmp_table(); + } + } + DBUG_RETURN(error_num); +} + +void ha_spider::rm_bulk_tmp_table() +{ + uint roop_count, dbton_id; + TABLE **tmp_table = result_list.upd_tmp_tbls; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::bulk_tmp_table_rnd_end"); + for (roop_count = share->link_count; roop_count > 0; roop_count--) + { + if (tmp_table[roop_count - 1]) + { + spider_rm_sys_tmp_table(trx->thd, tmp_table[roop_count - 1], + &result_list.upd_tmp_tbl_prms[roop_count - 1]); + tmp_table[roop_count - 1] = NULL; + } + } + + for (roop_count = share->use_sql_dbton_count; roop_count > 0; roop_count--) + { + dbton_id = share->use_sql_dbton_ids[roop_count - 1]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + dbton_hdl->rm_bulk_tmp_table(); + } + DBUG_VOID_RETURN; +} + +bool ha_spider::bulk_tmp_table_created() +{ + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::bulk_tmp_table_created"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if (dbton_hdl->first_link_idx >= 0) + { + if (dbton_hdl->bulk_tmp_table_created()) + { + DBUG_RETURN(TRUE); + } + } + } + DBUG_RETURN(FALSE); +} + +int ha_spider::print_item_type( + Item *item, + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::print_item_type"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + (error_num = spider_db_print_item_type(item, this, str, + alias, alias_length, dbton_id)) + ) { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +bool ha_spider::support_use_handler_sql( + int use_handler +) { + uint roop_count, dbton_id; + spider_db_handler *dbton_hdl; + DBUG_ENTER("ha_spider::support_use_handler_sql"); + for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) + { + dbton_id = share->use_sql_dbton_ids[roop_count]; + dbton_hdl = dbton_handler[dbton_id]; + if ( + dbton_hdl->first_link_idx >= 0 && + !dbton_hdl->support_use_handler(use_handler) + ) { + DBUG_RETURN(FALSE); + } + } + DBUG_RETURN(TRUE); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +bool ha_spider::support_bulk_access_hs() const +{ + uint roop_count; + DBUG_ENTER("ha_spider::support_bulk_access_hs"); + if (!share) + DBUG_RETURN(FALSE); + for (roop_count = 0; roop_count < share->all_link_count; roop_count++) + { + if (share->hs_dbton_ids[roop_count] == SPIDER_DBTON_SIZE) + DBUG_RETURN(FALSE); + } + DBUG_RETURN(TRUE); +} +#endif diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h new file mode 100644 index 00000000000..d2f479f8d90 --- /dev/null +++ b/storage/spider/ha_spider.h @@ -0,0 +1,1014 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifdef USE_PRAGMA_INTERFACE +#pragma interface +#endif + +#define SPIDER_CONNECT_INFO_MAX_LEN 64 +#define SPIDER_CONNECT_INFO_PATH_MAX_LEN FN_REFLEN +#define SPIDER_LONGLONG_LEN 20 +#define SPIDER_MAX_KEY_LENGTH 16384 + +#define SPIDER_SET_CONNS_PARAM(param_name, param_val, conns, link_statuses, conn_link_idx, link_count, link_status) \ + for ( \ + roop_count = spider_conn_link_idx_next(link_statuses, \ + conn_link_idx, -1, link_count, link_status); \ + roop_count < link_count; \ + roop_count = spider_conn_link_idx_next(link_statuses, \ + conn_link_idx, roop_count, link_count, link_status) \ + ) { \ + if (conns[roop_count]) \ + conns[roop_count]->param_name = param_val; \ + } + +class ha_spider; +struct st_spider_ft_info +{ + struct _ft_vft *please; + st_spider_ft_info *next; + ha_spider *file; + uint target; + bool used_in_where; + float score; + uint flags; + uint inx; + String *key; +}; + +class ha_spider: public handler +{ +public: + THR_LOCK_DATA lock; + SPIDER_SHARE *share; + SPIDER_TRX *trx; + ulonglong spider_thread_id; + ulonglong trx_conn_adjustment; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ulonglong trx_hs_r_conn_adjustment; + ulonglong trx_hs_w_conn_adjustment; +#endif + uint mem_calc_id; + const char *mem_calc_func_name; + const char *mem_calc_file_name; + ulong mem_calc_line_no; + uint sql_kinds; + uint *sql_kind; + ulonglong *connection_ids; + uint conn_kinds; + uint *conn_kind; + char *conn_keys_first_ptr; + char **conn_keys; + SPIDER_CONN **conns; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char **hs_r_conn_keys; + SPIDER_CONN **hs_r_conns; + ulonglong *hs_r_conn_ages; + char **hs_w_conn_keys; + SPIDER_CONN **hs_w_conns; + ulonglong *hs_w_conn_ages; +#endif + /* for active-standby mode */ + uint *conn_link_idx; + uchar *conn_can_fo; + void **quick_targets; + int *need_mons; + query_id_t search_link_query_id; + int search_link_idx; + int result_link_idx; + SPIDER_RESULT_LIST result_list; + SPIDER_CONDITION *condition; + spider_string *blob_buff; + uchar *searched_bitmap; + bool position_bitmap_init; + uchar *position_bitmap; + SPIDER_POSITION *pushed_pos; + SPIDER_POSITION pushed_pos_buf; +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share; + ha_spider *pt_handler_share_creator; +#endif +#ifdef HA_CAN_BULK_ACCESS + int pre_direct_init_result; + bool is_bulk_access_clone; + bool synced_from_clone_source; + bool bulk_access_started; + bool bulk_access_executing; + bool bulk_access_pre_called; + SPIDER_BULK_ACCESS_LINK *bulk_access_link_first; + SPIDER_BULK_ACCESS_LINK *bulk_access_link_current; + SPIDER_BULK_ACCESS_LINK *bulk_access_link_exec_tgt; +/* + bool init_ha_mem_root; + MEM_ROOT ha_mem_root; +*/ + ulonglong external_lock_cnt; +#endif + bool is_clone; + bool clone_bitmap_init; + ha_spider *pt_clone_source_handler; + ha_spider *pt_clone_last_searcher; + + bool init_index_handler; + bool init_rnd_handler; + + bool da_status; + bool use_spatial_index; + + /* for mrr */ + bool mrr_with_cnt; + uint multi_range_cnt; + uint multi_range_hit_point; +#ifdef HA_MRR_USE_DEFAULT_IMPL + int multi_range_num; + bool have_second_range; + KEY_MULTI_RANGE mrr_second_range; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + range_id_t *multi_range_keys; +#else + char **multi_range_keys; +#endif +#else + KEY_MULTI_RANGE *multi_range_ranges; +#endif + + char *append_tblnm_alias; + uint append_tblnm_alias_length; + + ha_spider *next; + + bool rnd_scan_and_first; + bool quick_mode; + bool keyread; + bool ignore_dup_key; + bool write_can_replace; + bool insert_with_update; + bool low_priority; + bool high_priority; + bool insert_delayed; + bool use_pre_call; + enum thr_lock_type lock_type; + int lock_mode; + uint sql_command; + int selupd_lock_mode; + bool bulk_insert; +#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC + bool info_auto_called; +#endif + int bulk_size; + int direct_dup_insert; + int store_error_num; + uint dup_key_idx; + int select_column_mode; + bool update_request; + bool pk_update; + bool force_auto_increment; + int bka_mode; + bool cond_check; + int cond_check_error; + int error_mode; + ulonglong store_last_insert_id; + + ulonglong *db_request_id; + uchar *db_request_phase; + uchar *m_handler_opened; + uint *m_handler_id; + char **m_handler_cid; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uchar *r_handler_opened; + uint *r_handler_id; + uint *r_handler_index; + uchar *w_handler_opened; + uint *w_handler_id; + uint *w_handler_index; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + uchar *do_hs_direct_update; + uint32 **hs_r_ret_fields; + uint32 **hs_w_ret_fields; + size_t *hs_r_ret_fields_num; + size_t *hs_w_ret_fields_num; + uint32 *hs_pushed_ret_fields; + size_t hs_pushed_ret_fields_num; + size_t hs_pushed_ret_fields_size; + size_t hs_pushed_lcl_fields_num; + uchar *tmp_column_bitmap; + bool hs_increment; + bool hs_decrement; + uint32 hs_pushed_strref_num; +#endif +#endif +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + bool do_direct_update; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + bool maybe_do_hs_direct_update; +#endif + uint direct_update_kinds; + List *direct_update_fields; + List *direct_update_values; +#endif +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + longlong info_limit; +#endif + + /* for fulltext search */ + bool ft_init_and_first; + uint ft_init_idx; + uint ft_count; + bool ft_init_without_index_init; + st_spider_ft_info *ft_first; + st_spider_ft_info *ft_current; + + /* for dbton */ + spider_db_handler **dbton_handler; + + ha_spider(); + ha_spider( + handlerton *hton, + TABLE_SHARE *table_arg + ); + virtual ~ha_spider(); + handler *clone( + const char *name, + MEM_ROOT *mem_root + ); + const char **bas_ext() const; + int open( + const char* name, + int mode, + uint test_if_locked + ); + int close(); + int check_access_kind( + THD *thd, + bool write_request + ); +#ifdef HA_CAN_BULK_ACCESS + int additional_lock( + THD *thd, + enum thr_lock_type lock_type + ); +#endif + THR_LOCK_DATA **store_lock( + THD *thd, + THR_LOCK_DATA **to, + enum thr_lock_type lock_type + ); + int external_lock( + THD *thd, + int lock_type + ); + int reset(); + int extra( + enum ha_extra_function operation + ); + int index_init( + uint idx, + bool sorted + ); +#ifdef HA_CAN_BULK_ACCESS + int pre_index_init( + uint idx, + bool sorted + ); +#endif + int index_end(); +#ifdef HA_CAN_BULK_ACCESS + int pre_index_end(); +#endif + int index_read_map( + uchar *buf, + const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag + ); + int index_read_last_map( + uchar *buf, + const uchar *key, + key_part_map keypart_map + ); + int index_next( + uchar *buf + ); + int index_prev( + uchar *buf + ); + int index_first( + uchar *buf + ); + int index_last( + uchar *buf + ); + int index_next_same( + uchar *buf, + const uchar *key, + uint keylen + ); + int read_range_first( + const key_range *start_key, + const key_range *end_key, + bool eq_range, + bool sorted + ); + int read_range_next(); +#ifdef HA_MRR_USE_DEFAULT_IMPL +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + ha_rows multi_range_read_info_const( + uint keyno, + RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, + uint *bufsz, + uint *flags, + Cost_estimate *cost + ); + ha_rows multi_range_read_info( + uint keyno, + uint n_ranges, + uint keys, + uint key_parts, + uint *bufsz, + uint *flags, + Cost_estimate *cost + ); +#else + ha_rows multi_range_read_info_const( + uint keyno, + RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, + uint *bufsz, + uint *flags, + COST_VECT *cost + ); + ha_rows multi_range_read_info( + uint keyno, + uint n_ranges, + uint keys, + uint key_parts, + uint *bufsz, + uint *flags, + COST_VECT *cost + ); +#endif + int multi_range_read_init( + RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, + uint mode, + HANDLER_BUFFER *buf + ); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + int multi_range_read_next( + range_id_t *range_info + ); + int multi_range_read_next_first( + range_id_t *range_info + ); + int multi_range_read_next_next( + range_id_t *range_info + ); +#else + int multi_range_read_next( + char **range_info + ); + int multi_range_read_next_first( + char **range_info + ); + int multi_range_read_next_next( + char **range_info + ); +#endif +#else + int read_multi_range_first( + KEY_MULTI_RANGE **found_range_p, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + HANDLER_BUFFER *buffer + ); + int read_multi_range_next( + KEY_MULTI_RANGE **found_range_p + ); +#endif + int rnd_init( + bool scan + ); +#ifdef HA_CAN_BULK_ACCESS + int pre_rnd_init( + bool scan + ); +#endif + int rnd_end(); +#ifdef HA_CAN_BULK_ACCESS + int pre_rnd_end(); +#endif + int rnd_next( + uchar *buf + ); + void position( + const uchar *record + ); + int rnd_pos( + uchar *buf, + uchar *pos + ); + int cmp_ref( + const uchar *ref1, + const uchar *ref2 + ); + int ft_init(); + void ft_end(); + FT_INFO *ft_init_ext( + uint flags, + uint inx, + String *key + ); + int ft_read( + uchar *buf + ); + int pre_index_read_map( + const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag, + bool use_parallel + ); + int pre_index_first(bool use_parallel); + int pre_index_last(bool use_parallel); + int pre_index_read_last_map( + const uchar *key, + key_part_map keypart_map, + bool use_parallel + ); +#ifdef HA_MRR_USE_DEFAULT_IMPL +#else + int pre_read_multi_range_first( + KEY_MULTI_RANGE **found_range_p, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + HANDLER_BUFFER *buffer, + bool use_parallel + ); +#endif + int pre_read_range_first( + const key_range *start_key, + const key_range *end_key, + bool eq_range, + bool sorted, + bool use_parallel + ); + int pre_ft_read(bool use_parallel); + int pre_rnd_next(bool use_parallel); + int info( + uint flag + ); + ha_rows records_in_range( + uint inx, + key_range *start_key, + key_range *end_key + ); + int check_crd(); + ha_rows records(); + const char *table_type() const; + ulonglong table_flags() const; + const char *index_type( + uint key_number + ); + ulong index_flags( + uint idx, + uint part, + bool all_parts + ) const; + uint max_supported_record_length() const; + uint max_supported_keys() const; + uint max_supported_key_parts() const; + uint max_supported_key_length() const; + uint max_supported_key_part_length() const; + uint8 table_cache_type(); +#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC + bool need_info_for_auto_inc(); +#endif + int update_auto_increment(); + void get_auto_increment( + ulonglong offset, + ulonglong increment, + ulonglong nb_desired_values, + ulonglong *first_value, + ulonglong *nb_reserved_values + ); + int reset_auto_increment( + ulonglong value + ); + void release_auto_increment(); + void start_bulk_insert( + ha_rows rows + ); + int end_bulk_insert(); + int write_row( + uchar *buf + ); +#ifdef HA_CAN_BULK_ACCESS + int pre_write_row( + uchar *buf + ); +#endif + bool start_bulk_update(); + int exec_bulk_update( + uint *dup_key_found + ); + void end_bulk_update(); + int bulk_update_row( + const uchar *old_data, + uchar *new_data, + uint *dup_key_found + ); + int update_row( + const uchar *old_data, + uchar *new_data + ); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int direct_update_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data + ); +#ifdef HA_CAN_BULK_ACCESS + int pre_direct_update_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data + ); +#endif + int direct_update_rows( + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data, + uint *update_rows + ); +#ifdef HA_CAN_BULK_ACCESS + int pre_direct_update_rows( + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data, + uint *update_rows + ); +#endif +#endif + bool start_bulk_delete(); + int end_bulk_delete(); + int delete_row( + const uchar *buf + ); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int direct_delete_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted + ); +#ifdef HA_CAN_BULK_ACCESS + int pre_direct_delete_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted + ); +#endif + int direct_delete_rows( + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uint *delete_rows + ); +#ifdef HA_CAN_BULK_ACCESS + int pre_direct_delete_rows( + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uint *delete_rows + ); +#endif +#endif + int delete_all_rows(); + int truncate(); + double scan_time(); + double read_time( + uint index, + uint ranges, + ha_rows rows + ); +#ifdef HA_CAN_BULK_ACCESS + void bulk_req_exec(); +#endif + const key_map *keys_to_use_for_scanning(); + ha_rows estimate_rows_upper_bound(); + bool get_error_message( + int error, + String *buf + ); + int create( + const char *name, + TABLE *form, + HA_CREATE_INFO *info + ); + void update_create_info( + HA_CREATE_INFO* create_info + ); + int rename_table( + const char *from, + const char *to + ); + int delete_table( + const char *name + ); + bool is_crashed() const; + bool auto_repair() const; + int disable_indexes( + uint mode + ); + int enable_indexes( + uint mode + ); + int check( + THD* thd, + HA_CHECK_OPT* check_opt + ); + int repair( + THD* thd, + HA_CHECK_OPT* check_opt + ); + bool check_and_repair( + THD *thd + ); + int analyze( + THD* thd, + HA_CHECK_OPT* check_opt + ); + int optimize( + THD* thd, + HA_CHECK_OPT* check_opt + ); + bool is_fatal_error( + int error_num, + uint flags + ); + Field *get_top_table_field( + uint16 field_index + ); + Field *field_exchange( + Field *field + ); + const COND *cond_push( + const COND* cond + ); + void cond_pop(); + int info_push( + uint info_type, + void *info + ); + TABLE *get_table(); + void set_searched_bitmap(); + void set_clone_searched_bitmap(); + void set_select_column_mode(); +#ifdef WITH_PARTITION_STORAGE_ENGINE + void check_select_column(bool rnd); +#endif + bool check_and_start_bulk_update( + spider_bulk_upd_start bulk_upd_start + ); + int check_and_end_bulk_update( + spider_bulk_upd_start bulk_upd_start + ); + uint check_partitioned(); + void check_direct_order_limit(); + int drop_tmp_tables(); + bool handler_opened( + int link_idx, + uint tgt_conn_kind + ); + void set_handler_opened( + int link_idx + ); + void clear_handler_opened( + int link_idx, + uint tgt_conn_kind + ); + int close_opened_handler( + int link_idx, + bool release_conn + ); + int index_handler_init(); + int rnd_handler_init(); + void set_error_mode(); + void backup_error_status(); + int check_error_mode( + int error_num + ); + int check_error_mode_eof( + int error_num + ); + int index_read_map_internal( + uchar *buf, + const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag + ); + int index_read_last_map_internal( + uchar *buf, + const uchar *key, + key_part_map keypart_map + ); + int index_first_internal(uchar *buf); + int index_last_internal(uchar *buf); + int read_range_first_internal( + uchar *buf, + const key_range *start_key, + const key_range *end_key, + bool eq_range, + bool sorted + ); +#ifdef HA_MRR_USE_DEFAULT_IMPL +#else + int read_multi_range_first_internal( + uchar *buf, + KEY_MULTI_RANGE **found_range_p, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + HANDLER_BUFFER *buffer + ); +#endif + int ft_read_internal(uchar *buf); + int rnd_next_internal(uchar *buf); + void check_pre_call( + bool use_parallel + ); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + void check_insert_dup_update_pushdown(); +#endif +#ifdef HA_CAN_BULK_ACCESS + SPIDER_BULK_ACCESS_LINK *create_bulk_access_link(); + void delete_bulk_access_link( + SPIDER_BULK_ACCESS_LINK *bulk_access_link + ); + int sync_from_clone_source( + ha_spider *spider + ); +#endif + void sync_from_clone_source_base( + ha_spider *spider + ); + void set_first_link_idx(); + void reset_first_link_idx(); + int reset_sql_sql( + ulong sql_type + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int reset_hs_sql( + ulong sql_type + ); + int reset_hs_keys( + ulong sql_type + ); + int reset_hs_upds( + ulong sql_type + ); + int reset_hs_strs( + ulong sql_type + ); + int reset_hs_strs_pos( + ulong sql_type + ); + int push_back_hs_upds( + SPIDER_HS_STRING_REF &info + ); +#endif + int append_tmp_table_and_sql_for_bka( + const key_range *start_key + ); + int reuse_tmp_table_and_sql_for_bka(); + int append_insert_sql_part(); + int append_update_sql_part(); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_increment_update_set_sql_part(); +#endif +#endif + int append_update_set_sql_part(); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_direct_update_set_sql_part(); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int append_direct_update_set_hs_part(); +#endif +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int append_dup_update_pushdown_sql_part( + const char *alias, + uint alias_length + ); + int append_update_columns_sql_part( + const char *alias, + uint alias_length + ); + int check_update_columns_sql_part(); +#endif + int append_delete_sql_part(); + int append_select_sql_part( + ulong sql_type + ); + int append_table_select_sql_part( + ulong sql_type + ); + int append_key_select_sql_part( + ulong sql_type, + uint idx + ); + int append_minimum_select_sql_part( + ulong sql_type + ); + int append_from_sql_part( + ulong sql_type + ); + int append_hint_after_table_sql_part( + ulong sql_type + ); + void set_where_pos_sql( + ulong sql_type + ); + void set_where_to_pos_sql( + ulong sql_type + ); + int check_item_type_sql( + Item *item + ); + int append_values_connector_sql_part( + ulong sql_type + ); + int append_values_terminator_sql_part( + ulong sql_type + ); + int append_key_column_values_sql_part( + const key_range *start_key, + ulong sql_type + ); + int append_key_where_sql_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int append_key_where_hs_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type + ); +#endif + int append_match_where_sql_part( + ulong sql_type + ); + int append_condition_sql_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg + ); + int append_match_select_sql_part( + ulong sql_type, + const char *alias, + uint alias_length + ); + void set_order_pos_sql( + ulong sql_type + ); + void set_order_to_pos_sql( + ulong sql_type + ); + int append_key_order_for_merge_with_alias_sql_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_for_direct_order_limit_with_alias_sql_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_with_alias_sql_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_limit_sql_part( + longlong offset, + longlong limit, + ulong sql_type + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int append_limit_hs_part( + longlong offset, + longlong limit, + ulong sql_type + ); +#endif + int reappend_limit_sql_part( + longlong offset, + longlong limit, + ulong sql_type + ); + int append_insert_terminator_sql_part( + ulong sql_type + ); + int append_insert_values_sql_part( + ulong sql_type + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int append_insert_values_hs_part( + ulong sql_type + ); +#endif + int append_into_sql_part( + ulong sql_type + ); + void set_insert_to_pos_sql( + ulong sql_type + ); + bool is_bulk_insert_exec_period( + bool bulk_end + ); + int append_select_lock_sql_part( + ulong sql_type + ); + int append_union_all_start_sql_part( + ulong sql_type + ); + int append_union_all_sql_part( + ulong sql_type + ); + int append_union_all_end_sql_part( + ulong sql_type + ); + int append_multi_range_cnt_sql_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma + ); + int append_delete_all_rows_sql_part( + ulong sql_type + ); + int append_update_sql( + const TABLE *table, + my_ptrdiff_t ptr_diff, + bool bulk + ); + int append_delete_sql( + const TABLE *table, + my_ptrdiff_t ptr_diff, + bool bulk + ); + bool sql_is_filled_up( + ulong sql_type + ); + bool sql_is_empty( + ulong sql_type + ); + bool support_multi_split_read_sql(); + bool support_bulk_update_sql(); + int bulk_tmp_table_insert(); + int bulk_tmp_table_end_bulk_insert(); + int bulk_tmp_table_rnd_init(); + int bulk_tmp_table_rnd_next(); + int bulk_tmp_table_rnd_end(); + int mk_bulk_tmp_table_and_bulk_start(); + void rm_bulk_tmp_table(); + bool bulk_tmp_table_created(); + int print_item_type( + Item *item, + spider_string *str, + const char *alias, + uint alias_length + ); + bool support_use_handler_sql( + int use_handler + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + bool support_bulk_access_hs() const; +#endif +}; diff --git a/storage/spider/hs_client/allocator.hpp b/storage/spider/hs_client/allocator.hpp new file mode 100644 index 00000000000..b54c7430d30 --- /dev/null +++ b/storage/spider/hs_client/allocator.hpp @@ -0,0 +1,43 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_ALLOCATOR_HPP +#define DENA_ALLOCATOR_HPP + +#if 0 +extern "C" { +#include +}; +#define DENA_MALLOC(x) tlsf_malloc(x) +#define DENA_REALLOC(x, y) tlsf_realloc(x, y) +#define DENA_FREE(x) tlsf_free(x) +#define DENA_NEWCHAR(x) static_cast(tlsf_malloc(x)) +#define DENA_DELETE(x) tlsf_free(x) +#endif + +#if 1 +#define DENA_MALLOC(x) malloc(x) +#define DENA_REALLOC(x, y) realloc(x, y) +#define DENA_FREE(x) free(x) +#define DENA_NEWCHAR(x) (new char[x]) +#define DENA_DELETE(x) (delete [] x) +#endif + +#if 1 +#define DENA_ALLOCA_ALLOCATE(typ, len) \ + static_cast(alloca((len) * sizeof(typ))) +#define DENA_ALLOCA_FREE(x) +#else +#define DENA_ALLOCA_ALLOCATE(typ, len) \ + static_cast(malloc((len) * sizeof(typ))) +#define DENA_ALLOCA_FREE(x) free(x) +#endif + +#endif + diff --git a/storage/spider/hs_client/auto_addrinfo.hpp b/storage/spider/hs_client/auto_addrinfo.hpp new file mode 100644 index 00000000000..5262ad11d4a --- /dev/null +++ b/storage/spider/hs_client/auto_addrinfo.hpp @@ -0,0 +1,49 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_AUTO_ADDRINFO_HPP +#define DENA_AUTO_ADDRINFO_HPP + +#ifndef __WIN__ +#include +#endif + +#include "util.hpp" + +namespace dena { + +struct auto_addrinfo : private noncopyable { + auto_addrinfo() : addr(0) { } + ~auto_addrinfo() { + reset(); + } + void reset(addrinfo *a = 0) { + if (addr != 0) { + freeaddrinfo(addr); + } + addr = a; + } + const addrinfo *get() const { return addr; } + int resolve(const char *node, const char *service, int flags = 0, + int family = AF_UNSPEC, int socktype = SOCK_STREAM, int protocol = 0) { + reset(); + addrinfo hints; + hints.ai_flags = flags; + hints.ai_family = family; + hints.ai_socktype = socktype; + hints.ai_protocol = protocol; + return getaddrinfo(node, service, &hints, &addr); + } + private: + addrinfo *addr; +}; + +}; + +#endif + diff --git a/storage/spider/hs_client/auto_file.hpp b/storage/spider/hs_client/auto_file.hpp new file mode 100644 index 00000000000..ddd1f8c9196 --- /dev/null +++ b/storage/spider/hs_client/auto_file.hpp @@ -0,0 +1,67 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_AUTO_FILE_HPP +#define DENA_AUTO_FILE_HPP + +/* +#ifndef __WIN__ +#include +#endif +*/ + +#include "util.hpp" + +namespace dena { + +struct auto_file : private noncopyable { + auto_file() : fd(-1) { } + ~auto_file() { + reset(); + } + int get() const { return fd; } + int close() { + if (fd < 0) { + return 0; + } + const int r = ::close(fd); + fd = -1; + return r; + } + void reset(int x = -1) { + if (fd >= 0) { + this->close(); + } + fd = x; + } + private: + int fd; +}; + +/* +struct auto_dir : private noncopyable { + auto_dir() : dp(0) { } + ~auto_dir() { + reset(); + } + DIR *get() const { return dp; } + void reset(DIR *d = 0) { + if (dp != 0) { + closedir(dp); + } + dp = d; + } + private: + DIR *dp; +}; +*/ + +}; + +#endif + diff --git a/storage/spider/hs_client/auto_ptrcontainer.hpp b/storage/spider/hs_client/auto_ptrcontainer.hpp new file mode 100644 index 00000000000..3629f19c8ea --- /dev/null +++ b/storage/spider/hs_client/auto_ptrcontainer.hpp @@ -0,0 +1,70 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_AUTO_PTRCONTAINER_HPP +#define DENA_AUTO_PTRCONTAINER_HPP + +namespace dena { + +/* +template +struct auto_ptrcontainer { + typedef Tcnt container_type; + typedef typename container_type::value_type value_type; + typedef typename container_type::pointer pointer; + typedef typename container_type::reference reference; + typedef typename container_type::const_reference const_reference; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::iterator iterator; + typedef typename container_type::const_iterator const_iterator; + typedef typename container_type::reverse_iterator reverse_iterator; + typedef typename container_type::const_reverse_iterator + const_reverse_iterator; + iterator begin() { return cnt.begin(); } + const_iterator begin() const { return cnt.begin(); } + iterator end() { return cnt.end(); } + const_iterator end() const { return cnt.end(); } + reverse_iterator rbegin() { return cnt.rbegin(); } + reverse_iterator rend() { return cnt.rend(); } + const_reverse_iterator rbegin() const { return cnt.rbegin(); } + const_reverse_iterator rend() const { return cnt.rend(); } + size_type size() const { return cnt.size(); } + size_type max_size() const { return cnt.max_size(); } + bool empty() const { return cnt.empty(); } + reference front() { return cnt.front(); } + const_reference front() const { cnt.front(); } + reference back() { return cnt.back(); } + const_reference back() const { cnt.back(); } + void swap(auto_ptrcontainer& x) { cnt.swap(x.cnt); } + ~auto_ptrcontainer() { + for (iterator i = begin(); i != end(); ++i) { + delete *i; + } + } + template void push_back_ptr(Tap& ap) { + cnt.push_back(ap.get()); + ap.release(); + } + void erase_ptr(iterator i) { + delete *i; + cnt.erase(i); + } + reference operator [](size_type n) { return cnt[n]; } + const_reference operator [](size_type n) const { return cnt[n]; } + void clear() { cnt.clear(); } + private: + Tcnt cnt; +}; +*/ + +}; + +#endif + diff --git a/storage/spider/hs_client/config.cpp b/storage/spider/hs_client/config.cpp new file mode 100644 index 00000000000..8f6447829e1 --- /dev/null +++ b/storage/spider/hs_client/config.cpp @@ -0,0 +1,291 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#endif + +#include "config.hpp" + +namespace dena { + +unsigned int verbose_level = 0; + +uchar * +conf_get_key( + conf_param *param, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + *length = param->key.length(); + return (uchar*) param->key.ptr(); +} + +config::config() +{ + if (my_hash_init(&conf_hash, &my_charset_bin, 32, 0, 0, + (my_hash_get_key) conf_get_key, 0, 0)) + init = FALSE; + else + init = TRUE; + return; +} + +config::~config() +{ + if (init) + { + conf_param *param; + while ((param = (conf_param *) my_hash_element(&conf_hash, 0))) + { + my_hash_delete(&conf_hash, (uchar*) param); + delete param; + } + my_hash_free(&conf_hash); + } +} + +conf_param * +config::find(const String& key) const +{ + if (init) + return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key.ptr(), + key.length()); + else + return NULL; +} + +conf_param * +config::find(const char *key) const +{ + if (init) + return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key, + strlen(key)); + else + return NULL; +} + +String +config::get_str(const String& key, const String& def) const +{ + DENA_VERBOSE(30, list_all_params()); + conf_param *param = find(key); + if (!param) { + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key.ptr(), + def.ptr())); + return def; + } + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", key.ptr(), + param->val.ptr())); + return param->val; +} + +String +config::get_str(const char *key, const char *def) const +{ + DENA_VERBOSE(30, list_all_params()); + conf_param *param = find(key); + if (!param) { + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key, def)); + return String(def, strlen(def), &my_charset_bin); + } + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", + key, param->val.ptr())); + return param->val; +} + +long long +config::get_int(const String& key, long long def) const +{ + int err; + DENA_VERBOSE(30, list_all_params()); + conf_param *param = find(key); + if (!param) { + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key.ptr(), + def)); + return def; + } + const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err); + if (err) { + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key.ptr(), + def)); + return def; + } + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key.ptr(), r)); + return r; +} + +long long +config::get_int(const char *key, long long def) const +{ + int err; + DENA_VERBOSE(30, list_all_params()); + conf_param *param = find(key); + if (!param) { + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key, def)); + return def; + } + const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err); + if (err) { + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key, def)); + return def; + } + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key, r)); + return r; +} + +bool +config::replace(const char *key, const char *val) +{ + uint32 val_len = strlen(val); + conf_param *param = find(key); + if (!param) { + /* create */ + if (!(param = new conf_param())) + return TRUE; + uint32 key_len = strlen(key); + if ( + param->key.reserve(key_len + 1) || + param->val.reserve(val_len + 1) + ) { + delete param; + return TRUE; + } + param->key.q_append(key, key_len); + param->val.q_append(val, val_len); + param->key.c_ptr_safe(); + param->val.c_ptr_safe(); + if (my_hash_insert(&conf_hash, (uchar*) param)) + { + delete param; + return TRUE; + } + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(create)\n", + param->key.ptr(), param->val.ptr())); + return FALSE; + } + /* replace */ + param->val.length(0); + if (param->val.reserve(val_len + 1)) + return TRUE; + param->val.q_append(val, val_len); + param->val.c_ptr_safe(); + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(replace)\n", + param->key.ptr(), param->val.ptr())); + return FALSE; +} + +bool +config::replace(const char *key, long long val) +{ + char val_str[22]; + sprintf(val_str, "%lld", val); + return replace(key, val_str); +} + +bool +config::compare(const char *key, const char *val) +{ + conf_param *param = find(key); + if (!param) + return FALSE; + return !strcmp(param->val.ptr(), val); +} + +void +config::list_all_params() const +{ + conf_param *param; + DENA_VERBOSE(10, fprintf(stderr, "list_all_params start\n")); + for(ulong i = 0; i < conf_hash.records; i++) + { + if ((param = (conf_param *) my_hash_element((HASH *) &conf_hash, i))) + { + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", + param->key.ptr(), param->val.ptr())); + } + } + DENA_VERBOSE(10, fprintf(stderr, "list_all_params end\n")); +} + +config& +config::operator =(const config& x) +{ + DENA_VERBOSE(10, fprintf(stderr, "config operator = start")); + if (this != &x && init && x.init) { + conf_param *param, *new_param; + for(ulong i = 0; i < x.conf_hash.records; i++) + { + if ( + (param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i)) && + (new_param = new conf_param()) + ) { + if ( + !new_param->key.copy(param->key) && + !new_param->val.copy(param->val) + ) { + new_param->key.c_ptr_safe(); + new_param->val.c_ptr_safe(); + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", + new_param->key.ptr(), new_param->val.ptr())); + if (my_hash_insert(&conf_hash, (uchar*) new_param)) + delete new_param; + } else + delete new_param; + } + } + } + DENA_VERBOSE(10, fprintf(stderr, "config operator = end %p", this)); + return *this; +} + +void +parse_args(int argc, char **argv, config& conf) +{ + conf_param *param; + for (int i = 1; i < argc; ++i) { + const char *const arg = argv[i]; + const char *const eq = strchr(arg, '='); + if (eq == 0) { + continue; + } + if (!(param = new conf_param())) + continue; + uint32 key_len = eq - arg; + uint32 val_len = strlen(eq + 1); + if ( + param->key.reserve(key_len + 1) || + param->val.reserve(val_len + 1) + ) { + delete param; + continue; + } + param->key.q_append(arg, key_len); + param->val.q_append(eq + 1, val_len); + param->key.c_ptr_safe(); + param->val.c_ptr_safe(); + if (my_hash_insert(&conf.conf_hash, (uchar*) param)) + { + delete param; + continue; + } + } + param = conf.find("verbose"); + if (param) { + verbose_level = atoi(param->val.c_ptr()); + } +} + +}; + diff --git a/storage/spider/hs_client/config.hpp b/storage/spider/hs_client/config.hpp new file mode 100644 index 00000000000..2880f2f5a33 --- /dev/null +++ b/storage/spider/hs_client/config.hpp @@ -0,0 +1,81 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_CONFIG_HPP +#define DENA_CONFIG_HPP + +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#endif + +#define DENA_VERBOSE(lv, x) if (dena::verbose_level >= (lv)) { (x); } + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +#define INFO_KIND_HS_RET_FIELDS 1 +#define INFO_KIND_HS_APPEND_STRING_REF 3 +#define INFO_KIND_HS_CLEAR_STRING_REF 4 +#define INFO_KIND_HS_INCREMENT_BEGIN 5 +#define INFO_KIND_HS_INCREMENT_END 6 +#define INFO_KIND_HS_DECREMENT_BEGIN 7 +#define INFO_KIND_HS_DECREMENT_END 8 +#endif + +namespace dena { + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +struct uint32_info { + size_t info_size; + uint32 *info; +}; +#endif + +struct conf_param { + String key; + String val; +}; + +uchar *conf_get_key( + conf_param *share, + size_t *length, + my_bool not_used __attribute__ ((unused)) +); + +struct config { + bool init; + HASH conf_hash; + config(); + ~config(); + conf_param *find(const String& key) const; + conf_param *find(const char *key) const; + String get_str(const String& key, const String& def = + String("", &my_charset_bin)) const; + String get_str(const char *key, const char *def = "") const; + long long get_int(const String& key, long long def = 0) const; + long long get_int(const char *key, long long def = 0) const; + bool replace(const char *key, const char *val); + bool replace(const char *key, long long val); + bool compare(const char *key, const char *val); + void list_all_params() const; + config& operator =(const config& x); +}; + +void parse_args(int argc, char **argv, config& conf); + +extern unsigned int verbose_level; + +}; + +#endif + diff --git a/storage/spider/hs_client/escape.cpp b/storage/spider/hs_client/escape.cpp new file mode 100644 index 00000000000..d382dfbc07e --- /dev/null +++ b/storage/spider/hs_client/escape.cpp @@ -0,0 +1,127 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. + * See COPYRIGHT.txt for details. + */ + +#include "mysql_version.h" +#include "hs_compat.h" +#include "escape.hpp" +#include "string_buffer.hpp" +#include "fatal.hpp" +#include "string_util.hpp" + +#define DBG_OP(x) +#define DBG_BUF(x) + +namespace dena { + +enum special_char_t { + special_char_escape_prefix = 0x01, /* SOH */ + special_char_noescape_min = 0x10, /* DLE */ + special_char_escape_shift = 0x40, /* '@' */ +}; + +void +escape_string(char *& wp, const char *start, const char *finish) +{ + while (start != finish) { + const unsigned char c = *start; + if (c >= special_char_noescape_min) { + wp[0] = c; /* no need to escape */ + } else { + wp[0] = special_char_escape_prefix; + ++wp; + wp[0] = c + special_char_escape_shift; + } + ++start; + ++wp; + } +} + +void +escape_string(string_buffer& ar, const char *start, const char *finish) +{ + const size_t buflen = (finish - start) * 2; + char *const wp_begin = ar.make_space(buflen); + char *wp = wp_begin; + escape_string(wp, start, finish); + ar.space_wrote(wp - wp_begin); +} + +bool +unescape_string(char *& wp, const char *start, const char *finish) +{ + /* works even if wp == start */ + while (start != finish) { + const unsigned char c = *start; + if (c != special_char_escape_prefix) { + wp[0] = c; + } else if (start + 1 != finish) { + ++start; + const unsigned char cn = *start; + if (cn < special_char_escape_shift) { + return false; + } + wp[0] = cn - special_char_escape_shift; + } else { + return false; + } + ++start; + ++wp; + } + return true; +} + +bool +unescape_string(string_buffer& ar, const char *start, const char *finish) +{ + const size_t buflen = finish - start; + char *const wp_begin = ar.make_space(buflen); + char *wp = wp_begin; + const bool r = unescape_string(wp, start, finish); + ar.space_wrote(wp - wp_begin); + return r; +} + +uint32 +read_ui32(char *& start, char *finish) +{ + char *const n_begin = start; + read_token(start, finish); + char *const n_end = start; + uint32 v = 0; + for (char *p = n_begin; p != n_end; ++p) { + const char ch = p[0]; + if (ch >= '0' && ch <= '9') { + v *= 10; + v += (ch - '0'); + } + } + return v; +} + +void +write_ui32(string_buffer& buf, uint32 v) +{ + char *wp = buf.make_space(12); + int len = snprintf(wp, 12, "%u", v); + if (len > 0) { + buf.space_wrote(len); + } +} + +void +write_ui64(string_buffer& buf, uint64 v) +{ + char *wp = buf.make_space(22); + int len = snprintf(wp, 22, "%llu", static_cast(v)); + if (len > 0) { + buf.space_wrote(len); + } +} + +}; + diff --git a/storage/spider/hs_client/escape.hpp b/storage/spider/hs_client/escape.hpp new file mode 100644 index 00000000000..4c23e16701c --- /dev/null +++ b/storage/spider/hs_client/escape.hpp @@ -0,0 +1,64 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. + * See COPYRIGHT.txt for details. + */ + +#include "string_buffer.hpp" +#include "string_ref.hpp" +#include "string_util.hpp" + +#ifndef DENA_ESCAPE_HPP +#define DENA_ESCAPE_HPP + +namespace dena { + +void escape_string(char *& wp, const char *start, const char *finish); +void escape_string(string_buffer& ar, const char *start, const char *finish); +bool unescape_string(char *& wp, const char *start, const char *finish); + /* unescaped_string() works even if wp == start */ +bool unescape_string(string_buffer& ar, const char *start, const char *finish); + +uint32 read_ui32(char *& start, char *finish); +void write_ui32(string_buffer& buf, uint32 v); +void write_ui64(string_buffer& buf, uint64 v); + +inline bool +is_null_expression(const char *start, const char *finish) +{ + return (finish == start + 1 && start[0] == 0); +} + +inline void +read_token(char *& start, char *finish) +{ + char *const p = memchr_char(start, '\t', finish - start); + if (p == 0) { + start = finish; + } else { + start = p; + } +} + +inline void +skip_token_delim_fold(char *& start, char *finish) +{ + while (start != finish && start[0] == '\t') { + ++start; + } +} + +inline void +skip_one(char *& start, char *finish) +{ + if (start != finish) { + ++start; + } +} + +}; + +#endif + diff --git a/storage/spider/hs_client/fatal.cpp b/storage/spider/hs_client/fatal.cpp new file mode 100644 index 00000000000..b26fb50f4fb --- /dev/null +++ b/storage/spider/hs_client/fatal.cpp @@ -0,0 +1,68 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#endif + +#include "fatal.hpp" + +namespace dena { + +/* +const int opt_syslog = LOG_ERR | LOG_PID | LOG_CONS; +*/ + +void +fatal_exit(const String& message) +{ + fprintf(stderr, "FATAL_EXIT: %s\n", message.ptr()); +/* + syslog(opt_syslog, "FATAL_EXIT: %s", message.ptr()); +*/ + _exit(1); +} + +void +fatal_exit(const char *message) +{ + fprintf(stderr, "FATAL_EXIT: %s\n", message); +/* + syslog(opt_syslog, "FATAL_EXIT: %s", message); +*/ + _exit(1); +} + +void +fatal_abort(const String& message) +{ + fprintf(stderr, "FATAL_COREDUMP: %s\n", message.ptr()); +/* + syslog(opt_syslog, "FATAL_COREDUMP: %s", message.ptr()); +*/ + abort(); +} + +void +fatal_abort(const char *message) +{ + fprintf(stderr, "FATAL_COREDUMP: %s\n", message); +/* + syslog(opt_syslog, "FATAL_COREDUMP: %s", message); +*/ + abort(); +} + +}; + diff --git a/storage/spider/hs_client/fatal.hpp b/storage/spider/hs_client/fatal.hpp new file mode 100644 index 00000000000..a75c56bddad --- /dev/null +++ b/storage/spider/hs_client/fatal.hpp @@ -0,0 +1,33 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_FATAL_HPP +#define DENA_FATAL_HPP + +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#endif + +namespace dena { + +void fatal_exit(const String& message); +void fatal_exit(const char *message); +void fatal_abort(const String& message); +void fatal_abort(const char *message); + +}; + +#endif + diff --git a/storage/spider/hs_client/hs_compat.h b/storage/spider/hs_client/hs_compat.h new file mode 100644 index 00000000000..920b4efa508 --- /dev/null +++ b/storage/spider/hs_client/hs_compat.h @@ -0,0 +1,31 @@ +/* Copyright (C) 2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef HS_COMPAT_H +#define HS_COMPAT_H + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ + my_init_dynamic_array2(A, B, C, D, E, F) +#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ + init_alloc_root(A, B, C, D) +#else +#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ + my_init_dynamic_array2(A, B, C, D, E) +#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ + init_alloc_root(A, B, C) +#endif + +#endif diff --git a/storage/spider/hs_client/hstcpcli.cpp b/storage/spider/hs_client/hstcpcli.cpp new file mode 100644 index 00000000000..6ff9ed84a81 --- /dev/null +++ b/storage/spider/hs_client/hstcpcli.cpp @@ -0,0 +1,643 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#include "mysql_version.h" +#include "hs_compat.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#endif + +#include "hstcpcli.hpp" +#include "auto_file.hpp" +#include "string_util.hpp" +#include "auto_addrinfo.hpp" +#include "escape.hpp" +#include "util.hpp" + +/* TODO */ +#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(MSG_NOSIGNAL) +#define MSG_NOSIGNAL 0 +#endif + +#define DBG(x) + +namespace dena { + +hstresult::hstresult() +{ + SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, + MYF(MY_WME)); +} + +hstresult::~hstresult() +{ + delete_dynamic(&flds); +} + +struct hstcpcli : public hstcpcli_i, private noncopyable { + hstcpcli(const socket_args& args); + virtual ~hstcpcli(); + virtual void close(); + virtual int reconnect(); + virtual bool stable_point(); + virtual void request_buf_open_index(size_t pst_id, const char *dbn, + const char *tbl, const char *idx, const char *retflds, const char *filflds); + virtual void request_buf_auth(const char *secret, const char *typ); + virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op, + const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, + const string_ref& mod_op, const string_ref *mvs, size_t mvslen, + const hstcpcli_filter *fils, size_t filslen, int invalues_keypart, + const string_ref *invalues, size_t invalueslen); + virtual size_t request_buf_append(const char *start, const char *finish); + virtual void request_reset(); + virtual int request_send(); + virtual int response_recv(size_t& num_flds_r); + virtual int get_result(hstresult& result); + virtual const string_ref *get_next_row(); + virtual const string_ref *get_next_row_from_result(hstresult& result); + virtual void response_buf_remove(); + virtual int get_error_code(); + virtual String& get_error(); + virtual void clear_error(); + virtual int set_timeout(int send_timeout, int recv_timeout); + virtual size_t get_num_req_bufd() { return num_req_bufd; } + virtual size_t get_num_req_sent() { return num_req_sent; } + virtual size_t get_num_req_rcvd() { return num_req_rcvd; } + virtual size_t get_response_end_offset() { return response_end_offset; } + virtual const char *get_readbuf_begin() { return readbuf.begin(); } + virtual const char *get_readbuf_end() { return readbuf.end(); } + virtual void write_error_to_log(const char *func_name, const char *file_name, + ulong line_no); + private: + int read_more(); + int set_error(int code, const String& str); + int set_error(int code, const char *str); + private: + auto_file fd; + socket_args sargs; + string_buffer readbuf; + string_buffer writebuf; + size_t response_end_offset; /* incl newline */ + size_t cur_row_offset; + size_t num_flds; + size_t num_req_bufd; /* buffered but not yet sent */ + size_t num_req_sent; /* sent but not yet received */ + size_t num_req_rcvd; /* received but not yet removed */ + int error_code; + String error_str; + DYNAMIC_ARRAY flds; + int errno_buf; +}; + +hstcpcli::hstcpcli(const socket_args& args) + : sargs(args), response_end_offset(0), cur_row_offset(0), num_flds(0), + num_req_bufd(0), num_req_sent(0), num_req_rcvd(0), error_code(0), errno_buf(0) +{ + String err; + SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, MYF(MY_WME)); + if (socket_connect(fd, sargs, err) != 0) { + set_error(-1, err); + } +} + +hstcpcli::~hstcpcli() +{ + delete_dynamic(&flds); +} + +void +hstcpcli::close() +{ + fd.close(); + readbuf.clear(); + writebuf.clear(); + response_end_offset = 0; + cur_row_offset = 0; + num_flds = 0; + num_req_bufd = 0; + num_req_sent = 0; + num_req_rcvd = 0; +} + +int +hstcpcli::reconnect() +{ + clear_error(); + close(); + String err; + if (socket_connect(fd, sargs, err) != 0) { + set_error(-1, err); + } + return error_code; +} + +int +hstcpcli::set_timeout(int send_timeout, int recv_timeout) +{ + String err; + sargs.send_timeout = send_timeout; + sargs.recv_timeout = recv_timeout; + if (socket_set_timeout(fd, sargs, err) != 0) { + set_error(-1, err); + } + return error_code; +} + +bool +hstcpcli::stable_point() +{ + /* returns true if cli can send a new request */ + return fd.get() >= 0 && num_req_bufd == 0 && num_req_sent == 0 && + num_req_rcvd == 0 && response_end_offset == 0; +} + +int +hstcpcli::get_error_code() +{ + return error_code; +} + +String& +hstcpcli::get_error() +{ + return error_str; +} + +int +hstcpcli::read_more() +{ + const size_t block_size = 4096; // FIXME + char *const wp = readbuf.make_space(block_size); + int rlen; + errno = 0; + while ((rlen = read(fd.get(), wp, block_size)) <= 0) { + errno_buf = errno; + if (rlen < 0) { + if (errno == EINTR || errno == EAGAIN) + { + errno = 0; + continue; + } + error_str = String("read: failed", &my_charset_bin); + } else { + error_str = String("read: eof", &my_charset_bin); + } + return rlen; + } + readbuf.space_wrote(rlen); + return rlen; +} + +void +hstcpcli::clear_error() +{ + DBG(fprintf(stderr, "CLEAR_ERROR: %d\n", error_code)); + error_code = 0; + error_str.length(0); +} + +int +hstcpcli::set_error(int code, const String& str) +{ + DBG(fprintf(stderr, "SET_ERROR: %d\n", code)); + error_code = code; + error_str = str; + return error_code; +} + +int +hstcpcli::set_error(int code, const char *str) +{ + uint32 str_len = strlen(str); + DBG(fprintf(stderr, "SET_ERROR: %d\n", code)); + error_code = code; + error_str.length(0); + if (error_str.reserve(str_len + 1)) + return 0; + error_str.q_append(str, str_len); + error_str.c_ptr_safe(); + return error_code; +} + +void +hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn, + const char *tbl, const char *idx, const char *retflds, const char *filflds) +{ +/* + if (num_req_sent > 0 || num_req_rcvd > 0) { +*/ + if (num_req_rcvd > 0) { + close(); + set_error(-1, "request_buf_open_index: protocol out of sync"); + return; + } + const string_ref dbn_ref(dbn, strlen(dbn)); + const string_ref tbl_ref(tbl, strlen(tbl)); + const string_ref idx_ref(idx, strlen(idx)); + const string_ref rfs_ref(retflds, strlen(retflds)); + writebuf.append_literal("P\t"); + append_uint32(writebuf, pst_id); // FIXME size_t ? + writebuf.append_literal("\t"); + writebuf.append(dbn_ref.begin(), dbn_ref.end()); + writebuf.append_literal("\t"); + writebuf.append(tbl_ref.begin(), tbl_ref.end()); + writebuf.append_literal("\t"); + writebuf.append(idx_ref.begin(), idx_ref.end()); + writebuf.append_literal("\t"); + writebuf.append(rfs_ref.begin(), rfs_ref.end()); + if (filflds != 0) { + const string_ref fls_ref(filflds, strlen(filflds)); + writebuf.append_literal("\t"); + writebuf.append(fls_ref.begin(), fls_ref.end()); + } + writebuf.append_literal("\n"); + ++num_req_bufd; +} + +void +hstcpcli::request_buf_auth(const char *secret, const char *typ) +{ +/* + if (num_req_sent > 0 || num_req_rcvd > 0) { +*/ + if (num_req_rcvd > 0) { + close(); + set_error(-1, "request_buf_auth: protocol out of sync"); + return; + } + if (typ == 0) { + typ = "1"; + } + const string_ref typ_ref(typ, strlen(typ)); + const string_ref secret_ref(secret, strlen(secret)); + writebuf.append_literal("A\t"); + writebuf.append(typ_ref.begin(), typ_ref.end()); + writebuf.append_literal("\t"); + writebuf.append(secret_ref.begin(), secret_ref.end()); + writebuf.append_literal("\n"); + ++num_req_bufd; +} + +namespace { + +void +append_delim_value(string_buffer& buf, const char *start, const char *finish) +{ + if (start == 0) { + /* null */ + const char t[] = "\t\0"; + buf.append(t, t + 2); + } else { + /* non-null */ + buf.append_literal("\t"); + escape_string(buf, start, finish); + } +} + +}; + +void +hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op, + const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, + const string_ref& mod_op, const string_ref *mvs, size_t mvslen, + const hstcpcli_filter *fils, size_t filslen, int invalues_keypart, + const string_ref *invalues, size_t invalueslen) +{ +/* + if (num_req_sent > 0 || num_req_rcvd > 0) { +*/ + if (num_req_rcvd > 0) { + close(); + set_error(-1, "request_buf_exec_generic: protocol out of sync"); + return; + } + append_uint32(writebuf, pst_id); // FIXME size_t ? + writebuf.append_literal("\t"); + writebuf.append(op.begin(), op.end()); + writebuf.append_literal("\t"); + append_uint32(writebuf, kvslen); // FIXME size_t ? + for (size_t i = 0; i < kvslen; ++i) { + const string_ref& kv = kvs[i]; + append_delim_value(writebuf, kv.begin(), kv.end()); + } + if (limit != 0 || skip != 0 || invalues_keypart >= 0 || + mod_op.size() != 0 || filslen != 0) { + /* has more option */ + writebuf.append_literal("\t"); + append_uint32(writebuf, limit); // FIXME size_t ? + if (skip != 0 || invalues_keypart >= 0 || + mod_op.size() != 0 || filslen != 0) { + writebuf.append_literal("\t"); + append_uint32(writebuf, skip); // FIXME size_t ? + } + if (invalues_keypart >= 0) { + writebuf.append_literal("\t@\t"); + append_uint32(writebuf, invalues_keypart); + writebuf.append_literal("\t"); + append_uint32(writebuf, invalueslen); + for (size_t i = 0; i < invalueslen; ++i) { + const string_ref& s = invalues[i]; + append_delim_value(writebuf, s.begin(), s.end()); + } + } + for (size_t i = 0; i < filslen; ++i) { + const hstcpcli_filter& f = fils[i]; + writebuf.append_literal("\t"); + writebuf.append(f.filter_type.begin(), f.filter_type.end()); + writebuf.append_literal("\t"); + writebuf.append(f.op.begin(), f.op.end()); + writebuf.append_literal("\t"); + append_uint32(writebuf, f.ff_offset); + append_delim_value(writebuf, f.val.begin(), f.val.end()); + } + if (mod_op.size() != 0) { + writebuf.append_literal("\t"); + writebuf.append(mod_op.begin(), mod_op.end()); + for (size_t i = 0; i < mvslen; ++i) { + const string_ref& mv = mvs[i]; + append_delim_value(writebuf, mv.begin(), mv.end()); + } + } + } + writebuf.append_literal("\n"); + ++num_req_bufd; +} + +size_t +hstcpcli::request_buf_append(const char *start, const char *finish) +{ +/* + if (num_req_sent > 0 || num_req_rcvd > 0) { +*/ + if (num_req_rcvd > 0) { + close(); + set_error(-1, "request_buf_append: protocol out of sync"); + return 0; + } + const char *nl = start; + size_t num_req = 0; + while ((nl = memchr_char(nl, '\n', finish - nl))) { + if (nl == finish) + break; + num_req++; + nl++; + } + num_req++; + writebuf.append(start, finish); + if (*(finish - 1) != '\n') + writebuf.append_literal("\n"); + num_req_bufd += num_req; + return num_req; +} + +void +hstcpcli::request_reset() +{ + if (num_req_bufd) { + writebuf.erase_front(writebuf.size()); + num_req_bufd = 0; + } +} + +int +hstcpcli::request_send() +{ + if (error_code < 0) { + return error_code; + } + clear_error(); + if (fd.get() < 0) { + close(); + return set_error(-1, "write: closed"); + } +/* + if (num_req_bufd == 0 || num_req_sent > 0 || num_req_rcvd > 0) { +*/ + if (num_req_bufd == 0 || num_req_rcvd > 0) { + close(); + return set_error(-1, "request_send: protocol out of sync"); + } + const size_t wrlen = writebuf.size(); + const ssize_t r = send(fd.get(), writebuf.begin(), wrlen, MSG_NOSIGNAL); + if (r <= 0) { + close(); + return set_error(-1, r < 0 ? "write: failed" : "write: eof"); + } + writebuf.erase_front(r); + if (static_cast(r) != wrlen) { + close(); + return set_error(-1, "write: incomplete"); + } + num_req_sent += num_req_bufd; + num_req_bufd = 0; + DBG(fprintf(stderr, "REQSEND 0\n")); + return 0; +} + +int +hstcpcli::response_recv(size_t& num_flds_r) +{ + if (error_code < 0) { + return error_code; + } + clear_error(); + if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 || + response_end_offset != 0) { + close(); + return set_error(-1, "response_recv: protocol out of sync"); + } + cur_row_offset = 0; + num_flds_r = num_flds = 0; + if (fd.get() < 0) { + return set_error(-1, "read: closed"); + } + size_t offset = 0; + while (true) { + const char *const lbegin = readbuf.begin() + offset; + const char *const lend = readbuf.end(); + if (lbegin < lend) + { + const char *const nl = memchr_char(lbegin, '\n', lend - lbegin); + if (nl != 0) { + offset += (nl + 1) - lbegin; + break; + } + offset += lend - lbegin; + } + if (read_more() <= 0) { + close(); + error_code = -1; + return error_code; + } + } + response_end_offset = offset; + --num_req_sent; + ++num_req_rcvd; + char *start = readbuf.begin(); + char *const finish = start + response_end_offset - 1; + const size_t resp_code = read_ui32(start, finish); + skip_one(start, finish); + num_flds_r = num_flds = read_ui32(start, finish); + if (resp_code != 0) { + skip_one(start, finish); + char *const err_begin = start; + read_token(start, finish); + char *const err_end = start; + String e = String(err_begin, err_end - err_begin, &my_charset_bin); + if (!e.length()) { + e = String("unknown_error", &my_charset_bin); + } + return set_error(resp_code, e); + } + cur_row_offset = start - readbuf.begin(); + DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n", + String(readbuf.begin(), readbuf.begin() + response_end_offset) + .c_str(), + cur_row_offset, response_end_offset)); + DBG(fprintf(stderr, "RES 0\n")); + if (flds.max_element < num_flds) + { + if (allocate_dynamic(&flds, num_flds)) + return set_error(-1, "out of memory"); + } + flds.elements = num_flds; + return 0; +} + +int +hstcpcli::get_result(hstresult& result) +{ +/* + readbuf.swap(result.readbuf); +*/ + char *const wp = result.readbuf.make_space(response_end_offset); + memcpy(wp, readbuf.begin(), response_end_offset); + result.readbuf.space_wrote(response_end_offset); + result.response_end_offset = response_end_offset; + result.num_flds = num_flds; + result.cur_row_offset = cur_row_offset; + if (result.flds.max_element < num_flds) + { + if (allocate_dynamic(&result.flds, num_flds)) + return set_error(-1, "out of memory"); + } + result.flds.elements = num_flds; + return 0; +} + +const string_ref * +hstcpcli::get_next_row() +{ + if (num_flds == 0 || flds.elements < num_flds) { + DBG(fprintf(stderr, "GNR NF 0\n")); + return 0; + } + char *start = readbuf.begin() + cur_row_offset; + char *const finish = readbuf.begin() + response_end_offset - 1; + if (start >= finish) { /* start[0] == nl */ + DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish)); + return 0; + } + for (size_t i = 0; i < num_flds; ++i) { + skip_one(start, finish); + char *const fld_begin = start; + read_token(start, finish); + char *const fld_end = start; + char *wp = fld_begin; + if (is_null_expression(fld_begin, fld_end)) { + /* null */ + ((string_ref *) flds.buffer)[i] = string_ref(); + } else { + unescape_string(wp, fld_begin, fld_end); /* in-place */ + ((string_ref *) flds.buffer)[i] = string_ref(fld_begin, wp); + } + } + cur_row_offset = start - readbuf.begin(); + return (string_ref *) flds.buffer; +} + +const string_ref * +hstcpcli::get_next_row_from_result(hstresult& result) +{ + if (result.num_flds == 0 || result.flds.elements < result.num_flds) { + DBG(fprintf(stderr, "GNR NF 0\n")); + return 0; + } + char *start = result.readbuf.begin() + result.cur_row_offset; + char *const finish = result.readbuf.begin() + result.response_end_offset - 1; + if (start >= finish) { /* start[0] == nl */ + DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish)); + return 0; + } + for (size_t i = 0; i < result.num_flds; ++i) { + skip_one(start, finish); + char *const fld_begin = start; + read_token(start, finish); + char *const fld_end = start; + char *wp = fld_begin; + if (is_null_expression(fld_begin, fld_end)) { + /* null */ + ((string_ref *) result.flds.buffer)[i] = string_ref(); + } else { + unescape_string(wp, fld_begin, fld_end); /* in-place */ + ((string_ref *) result.flds.buffer)[i] = string_ref(fld_begin, wp); + } + } + result.cur_row_offset = start - result.readbuf.begin(); + return (string_ref *) result.flds.buffer; +} + +void +hstcpcli::response_buf_remove() +{ + if (response_end_offset == 0) { + close(); + set_error(-1, "response_buf_remove: protocol out of sync"); + return; + } + readbuf.erase_front(response_end_offset); + response_end_offset = 0; + --num_req_rcvd; + cur_row_offset = 0; + num_flds = 0; +} + +void +hstcpcli::write_error_to_log( + const char *func_name, + const char *file_name, + ulong line_no +) { + if (errno_buf) { + time_t cur_time = (time_t) time((time_t*) 0); + struct tm lt; + struct tm *l_time = localtime_r(&cur_time, <); + fprintf(stderr, + "%04d%02d%02d %02d:%02d:%02d [ERROR] hstcpcli: [%d][%s]" + " [%s][%s][%lu] errno=%d\n", + l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday, + l_time->tm_hour, l_time->tm_min, l_time->tm_sec, + error_code, error_str.c_ptr_safe(), + func_name, file_name, line_no, errno_buf); + } +} + +hstcpcli_ptr +hstcpcli_i::create(const socket_args& args) +{ + return hstcpcli_ptr(new hstcpcli(args)); +} + +}; + diff --git a/storage/spider/hs_client/hstcpcli.hpp b/storage/spider/hs_client/hstcpcli.hpp new file mode 100644 index 00000000000..2c43f4230c4 --- /dev/null +++ b/storage/spider/hs_client/hstcpcli.hpp @@ -0,0 +1,93 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_HSTCPCLI_HPP +#define DENA_HSTCPCLI_HPP + +#define HANDLERSOCKET_MYSQL_UTIL 1 + +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#endif + +#include "config.hpp" +#include "socket.hpp" +#include "string_ref.hpp" +#include "string_buffer.hpp" + +namespace dena { + +struct hstcpcli_filter { + string_ref filter_type; + string_ref op; + size_t ff_offset; + string_ref val; + hstcpcli_filter() : ff_offset(0) { } +}; + +struct hstcpcli_i; +typedef hstcpcli_i *hstcpcli_ptr; + +struct hstresult { + hstresult(); + virtual ~hstresult(); + string_buffer readbuf; + size_t response_end_offset; + size_t num_flds; + size_t cur_row_offset; + DYNAMIC_ARRAY flds; +}; + +struct hstcpcli_i { + virtual ~hstcpcli_i() { } + virtual void close() = 0; + virtual int reconnect() = 0; + virtual bool stable_point() = 0; + virtual void request_buf_auth(const char *secret, const char *typ) = 0; + virtual void request_buf_open_index(size_t pst_id, const char *dbn, + const char *tbl, const char *idx, const char *retflds, + const char *filflds = 0) = 0; + virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op, + const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, + const string_ref& mod_op, const string_ref *mvs, size_t mvslen, + const hstcpcli_filter *fils = 0, size_t filslen = 0, + int invalues_keypart = -1, const string_ref *invalues = 0, + size_t invalueslen = 0) = 0; // FIXME: too long + virtual size_t request_buf_append(const char *start, const char *finish) = 0; + virtual void request_reset() = 0; + virtual int request_send() = 0; + virtual int response_recv(size_t& num_flds_r) = 0; + virtual int get_result(hstresult& result) = 0; + virtual const string_ref *get_next_row() = 0; + virtual const string_ref *get_next_row_from_result(hstresult& result) = 0; + virtual void response_buf_remove() = 0; + virtual int get_error_code() = 0; + virtual String& get_error() = 0; + virtual void clear_error() = 0; + virtual int set_timeout(int send_timeout, int recv_timeout) = 0; + virtual size_t get_num_req_bufd() = 0; + virtual size_t get_num_req_sent() = 0; + virtual size_t get_num_req_rcvd() = 0; + virtual size_t get_response_end_offset() = 0; + virtual const char *get_readbuf_begin() = 0; + virtual const char *get_readbuf_end() = 0; + virtual void write_error_to_log(const char *func_name, const char *file_name, + ulong line_no) = 0; + static hstcpcli_ptr create(const socket_args& args); +}; + +}; + +#endif + diff --git a/storage/spider/hs_client/mutex.hpp b/storage/spider/hs_client/mutex.hpp new file mode 100644 index 00000000000..8e331fb6ab2 --- /dev/null +++ b/storage/spider/hs_client/mutex.hpp @@ -0,0 +1,48 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_MUTEX_HPP +#define DENA_MUTEX_HPP + +#include "fatal.hpp" +#include "util.hpp" + +namespace dena { + +struct condition; + +struct mutex : private noncopyable { + friend struct condition; + mutex() { + if (pthread_mutex_init(&mtx, 0) != 0) { + fatal_abort("pthread_mutex_init"); + } + } + ~mutex() { + if (pthread_mutex_destroy(&mtx) != 0) { + fatal_abort("pthread_mutex_destroy"); + } + } + void lock() const { + if (pthread_mutex_lock(&mtx) != 0) { + fatal_abort("pthread_mutex_lock"); + } + } + void unlock() const { + if (pthread_mutex_unlock(&mtx) != 0) { + fatal_abort("pthread_mutex_unlock"); + } + } + private: + mutable pthread_mutex_t mtx; +}; + +}; + +#endif + diff --git a/storage/spider/hs_client/socket.cpp b/storage/spider/hs_client/socket.cpp new file mode 100644 index 00000000000..6515987124c --- /dev/null +++ b/storage/spider/hs_client/socket.cpp @@ -0,0 +1,310 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef __WIN__ +#include +#endif + +#include "mysql_version.h" +#include "hs_compat.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +#include +#endif +#include "sql_priv.h" +#include "probes_mysql.h" +#endif + +#include "socket.hpp" +#include "string_util.hpp" +#include "fatal.hpp" + +/* +struct sockaddr_un { + short sun_family; + char sun_path[108]; +}; +*/ + +namespace dena { + +void +ignore_sigpipe() +{ +#if defined(SIGPIPE) && !defined(__WIN__) + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { + fatal_abort("SIGPIPE SIG_IGN"); + } +#endif +} + +void +socket_args::set(const config& conf) +{ + timeout = (int) conf.get_int("timeout", 600); + listen_backlog = (int) conf.get_int("listen_backlog", 256); + String node = conf.get_str("host", ""); + String port = conf.get_str("port", ""); + if (node.length() || port.length()) { + if (family == AF_UNIX || !strcmp(node.c_ptr(), "/")) { + set_unix_domain(port.c_ptr()); + } else { + const char *nd = !node.length() ? 0 : node.c_ptr(); + if (resolve(nd, port.c_ptr()) != 0) { + String message("getaddrinfo failed: ", &my_charset_bin); + message.reserve(node.length() + sizeof(":") - 1 + port.length()); + message.append(node); + message.q_append(":", sizeof(":") - 1); + message.append(port); + fatal_exit(message); + } + } + } + sndbuf = (int) conf.get_int("sndbuf", 0); + rcvbuf = (int) conf.get_int("rcvbuf", 0); +} + +void +socket_args::set_unix_domain(const char *path) +{ +#ifndef __WIN__ + family = AF_UNIX; + addr = sockaddr_storage(); + addrlen = sizeof(sockaddr_un); + sockaddr_un *const ap = reinterpret_cast(&addr); + ap->sun_family = AF_UNIX; + strncpy(ap->sun_path, path, sizeof(ap->sun_path) - 1); +#endif +} + +int +socket_args::resolve(const char *node, const char *service) +{ + const int flags = (node == 0) ? AI_PASSIVE : 0; + auto_addrinfo ai; + addr = sockaddr_storage(); + addrlen = 0; + const int r = ai.resolve(node, service, flags, family, socktype, protocol); + if (r != 0) { + return r; + } + memcpy(&addr, ai.get()->ai_addr, ai.get()->ai_addrlen); + addrlen = ai.get()->ai_addrlen; + return 0; +} + +int +socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r) +{ + if (!args.nonblocking) { +#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) + if (args.recv_timeout != 0) { +#ifndef __WIN__ + struct timeval tv; + tv.tv_sec = args.recv_timeout; + tv.tv_usec = 0; +#else + int tv = args.recv_timeout * 1000; +#endif + if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, +#ifndef __WIN__ + (const void *) &tv, +#else + (const char *) &tv, +#endif + sizeof(tv)) != 0) { + return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); + } + } + if (args.send_timeout != 0) { +#ifndef __WIN__ + struct timeval tv; + tv.tv_sec = args.send_timeout; + tv.tv_usec = 0; +#else + int tv = args.send_timeout * 1000; +#endif + if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO, +#ifndef __WIN__ + (const void *) &tv, +#else + (const char *) &tv, +#endif + sizeof(tv)) != 0) { + return errno_string("setsockopt SO_SNDTIMEO", errno, err_r); + } + } +#endif + } + return 0; +} + +int +socket_set_options(auto_file& fd, const socket_args& args, String& err_r) +{ + if (args.timeout != 0 && !args.nonblocking) { +#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) +#ifndef __WIN__ + struct timeval tv; + tv.tv_sec = args.timeout; + tv.tv_usec = 0; +#else + int tv = args.timeout * 1000; +#endif + if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, +#ifndef __WIN__ + (const void *) &tv, +#else + (const char *) &tv, +#endif + sizeof(tv)) != 0) { + return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); + } +#ifndef __WIN__ + tv.tv_sec = args.timeout; + tv.tv_usec = 0; +#else + tv = args.timeout * 1000; +#endif + if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO, +#ifndef __WIN__ + (const void *) &tv, +#else + (const char *) &tv, +#endif + sizeof(tv)) != 0) { + return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); + } +#endif + } +#ifndef __WIN__ + if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) { + return errno_string("fcntl O_NONBLOCK", errno, err_r); + } +#endif + if (args.sndbuf != 0) { + const int v = args.sndbuf; + if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDBUF, +#ifndef __WIN__ + (const void *) &v, +#else + (const char *) &v, +#endif + sizeof(v)) != 0) { + return errno_string("setsockopt SO_SNDBUF", errno, err_r); + } + } + if (args.rcvbuf != 0) { + const int v = args.rcvbuf; + if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVBUF, +#ifndef __WIN__ + (const void *) &v, +#else + (const char *) &v, +#endif + sizeof(v)) != 0) { + return errno_string("setsockopt SO_RCVBUF", errno, err_r); + } + } + return 0; +} + +int +socket_open(auto_file& fd, const socket_args& args, String& err_r) +{ + fd.reset(socket(args.family, args.socktype, args.protocol)); + if (fd.get() < 0) { + return errno_string("socket", errno, err_r); + } + return socket_set_options(fd, args, err_r); +} + +int +socket_connect(auto_file& fd, const socket_args& args, String& err_r) +{ + int r = 0; + if ((r = socket_open(fd, args, err_r)) != 0) { + return r; + } + if (connect(fd.get(), reinterpret_cast(&args.addr), + args.addrlen) != 0) { + if (!args.nonblocking +#ifndef __WIN__ + || errno != EINPROGRESS +#endif + ) { + return errno_string("connect", errno, err_r); + } + } + return 0; +} + +int +socket_bind(auto_file& fd, const socket_args& args, String& err_r) +{ + fd.reset(socket(args.family, args.socktype, args.protocol)); + if (fd.get() < 0) { + return errno_string("socket", errno, err_r); + } + if (args.reuseaddr) { +#ifndef __WIN__ + if (args.family == AF_UNIX) { + const sockaddr_un *const ap = + reinterpret_cast(&args.addr); + if (unlink(ap->sun_path) != 0 && errno != ENOENT) { + return errno_string("unlink uds", errno, err_r); + } + } else { +#endif + int v = 1; + if (setsockopt(fd.get(), SOL_SOCKET, SO_REUSEADDR, +#ifndef __WIN__ + (const void *) &v, +#else + (const char *) &v, +#endif + sizeof(v)) != 0) { + return errno_string("setsockopt SO_REUSEADDR", errno, err_r); + } +#ifndef __WIN__ + } +#endif + } + if (bind(fd.get(), reinterpret_cast(&args.addr), + args.addrlen) != 0) { + return errno_string("bind", errno, err_r); + } + if (listen(fd.get(), args.listen_backlog) != 0) { + return errno_string("listen", errno, err_r); + } +#ifndef __WIN__ + if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) { + return errno_string("fcntl O_NONBLOCK", errno, err_r); + } +#endif + return 0; +} + +int +socket_accept(int listen_fd, auto_file& fd, const socket_args& args, + sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r) +{ + fd.reset(accept(listen_fd, reinterpret_cast(&addr_r), + &addrlen_r)); + if (fd.get() < 0) { + return errno_string("accept", errno, err_r); + } + return socket_set_options(fd, args, err_r); +} + +}; + diff --git a/storage/spider/hs_client/socket.hpp b/storage/spider/hs_client/socket.hpp new file mode 100644 index 00000000000..a3e6527a46d --- /dev/null +++ b/storage/spider/hs_client/socket.hpp @@ -0,0 +1,62 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_SOCKET_HPP +#define DENA_SOCKET_HPP + +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#endif + +#include "auto_addrinfo.hpp" +#include "auto_file.hpp" +#include "config.hpp" + +namespace dena { + +struct socket_args { + sockaddr_storage addr; + socklen_t addrlen; + int family; + int socktype; + int protocol; + int timeout; + int send_timeout; + int recv_timeout; + int listen_backlog; + bool reuseaddr; + bool nonblocking; + bool use_epoll; + int sndbuf; + int rcvbuf; + socket_args() : addr(), addrlen(0), family(AF_INET), socktype(SOCK_STREAM), + protocol(0), timeout(600), send_timeout(600), recv_timeout(600), + listen_backlog(256), reuseaddr(true), nonblocking(false), use_epoll(false), + sndbuf(0), rcvbuf(0) { } + void set(const config& conf); + void set_unix_domain(const char *path); + int resolve(const char *node, const char *service); +}; + +void ignore_sigpipe(); +int socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r); +int socket_bind(auto_file& fd, const socket_args& args, String& err_r); +int socket_connect(auto_file& fd, const socket_args& args, String& err_r); +int socket_accept(int listen_fd, auto_file& fd, const socket_args& args, + sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r); + +}; + +#endif + diff --git a/storage/spider/hs_client/string_buffer.hpp b/storage/spider/hs_client/string_buffer.hpp new file mode 100644 index 00000000000..c9a6074819b --- /dev/null +++ b/storage/spider/hs_client/string_buffer.hpp @@ -0,0 +1,146 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_STRING_BUFFER_HPP +#define DENA_STRING_BUFFER_HPP + +/* +#include +#include +*/ + +#include "util.hpp" +#include "allocator.hpp" +#include "fatal.hpp" + +namespace dena { + +struct string_buffer : private noncopyable { + string_buffer() : buffer(0), begin_offset(0), end_offset(0), alloc_size(0) { } + ~string_buffer() { + real_free(); + } + void real_free() { + if (alloc_size) { + DENA_FREE(buffer); + buffer = 0; + begin_offset = 0; + end_offset = 0; + alloc_size = 0; + } + } + size_t real_size() { + return alloc_size; + } + const char *begin() const { + return buffer + begin_offset; + } + const char *end() const { + return buffer + end_offset; + } + char *begin() { + return buffer + begin_offset; + } + char *end() { + return buffer + end_offset; + } + size_t size() const { + return end_offset - begin_offset; + } + void clear() { + begin_offset = end_offset = 0; + } + void resize(size_t len) { + if (size() < len) { + reserve(len); + memset(buffer + end_offset, 0, len - size()); + } + end_offset = begin_offset + len; + } + void reserve(size_t len) { + if (alloc_size >= begin_offset + len) { + return; + } + size_t asz = alloc_size; + while (asz < begin_offset + len) { + if (asz == 0) { + asz = 16; + } + const size_t asz_n = asz << 1; + if (asz_n < asz) { + fatal_abort("string_buffer::resize() overflow"); + } + asz = asz_n; + } + void *const p = DENA_REALLOC(buffer, asz); + if (p == 0) { + fatal_abort("string_buffer::resize() realloc"); + } + buffer = static_cast(p); + alloc_size = asz; + } + void erase_front(size_t len) { + if (len >= size()) { + clear(); + } else { + begin_offset += len; + } + } + char *make_space(size_t len) { + reserve(size() + len); + return buffer + end_offset; + } + void space_wrote(size_t len) { + len = len < alloc_size - end_offset ? len : alloc_size - end_offset; + end_offset += len; + } + template + void append_literal(const char (& str)[N]) { + append(str, str + N - 1); + } + void append(const char *start, const char *finish) { + const size_t len = finish - start; + reserve(size() + len); + memcpy(buffer + end_offset, start, len); + end_offset += len; + } + void append_2(const char *s1, const char *f1, const char *s2, + const char *f2) { + const size_t l1 = f1 - s1; + const size_t l2 = f2 - s2; + reserve(end_offset + l1 + l2); + memcpy(buffer + end_offset, s1, l1); + memcpy(buffer + end_offset + l1, s2, l2); + end_offset += l1 + l2; + } + void swap(string_buffer& sb) { + char *tmp_buffer = buffer; + size_t tmp_begin_offset = begin_offset; + size_t tmp_end_offset = end_offset; + size_t tmp_alloc_size = alloc_size; + buffer = sb.buffer; + begin_offset = sb.begin_offset; + end_offset = sb.end_offset; + alloc_size = sb.alloc_size; + sb.buffer = tmp_buffer; + sb.begin_offset = tmp_begin_offset; + sb.end_offset = tmp_end_offset; + sb.alloc_size = tmp_alloc_size; + } + private: + char *buffer; + size_t begin_offset; + size_t end_offset; + size_t alloc_size; +}; + +}; + +#endif + diff --git a/storage/spider/hs_client/string_ref.hpp b/storage/spider/hs_client/string_ref.hpp new file mode 100644 index 00000000000..028c4146c73 --- /dev/null +++ b/storage/spider/hs_client/string_ref.hpp @@ -0,0 +1,106 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_STRING_REF_HPP +#define DENA_STRING_REF_HPP + +namespace dena { + +struct string_wref { + typedef char value_type; + char *begin() const { return start; } + char *end() const { return start + length; } + size_t size() const { return length; } + private: + char *start; + size_t length; + public: + string_wref(char *s = 0, size_t len = 0) : start(s), length(len) { } +}; + +struct string_ref { + typedef const char value_type; + const char *begin() const { return start; } + const char *end() const { return start + length; } + size_t size() const { return length; } + void set(const char *s, size_t len) { start = s; length = len; } + void set(const char *s, const char *f) { start = s; length = f - s; } + private: + const char *start; + size_t length; + public: + string_ref(const char *s = 0, size_t len = 0) : start(s), length(len) { } + string_ref(const char *s, const char *f) : start(s), length(f - s) { } + string_ref(const string_wref& w) : start(w.begin()), length(w.size()) { } +}; + +template inline bool +operator ==(const string_ref& x, const char (& y)[N]) { + return (x.size() == N - 1) && (::memcmp(x.begin(), y, N - 1) == 0); +} + +inline bool +operator ==(const string_ref& x, const string_ref& y) { + return (x.size() == y.size()) && + (::memcmp(x.begin(), y.begin(), x.size()) == 0); +} + +inline bool +operator !=(const string_ref& x, const string_ref& y) { + return (x.size() != y.size()) || + (::memcmp(x.begin(), y.begin(), x.size()) != 0); +} + +struct string_ref_list_wrap { + string_ref_list_wrap() { + if (SPD_INIT_DYNAMIC_ARRAY2(&string_ref_list, sizeof(string_ref), + NULL, 16, 16, MYF(MY_WME))) + string_ref_list_init = FALSE; + else + string_ref_list_init = TRUE; + } + virtual ~string_ref_list_wrap() { + if (string_ref_list_init) delete_dynamic(&string_ref_list); } + void clear() { + if (string_ref_list_init) string_ref_list.elements = 0; } + void push_back(string_ref &e) { + if (string_ref_list_init) insert_dynamic(&string_ref_list, (uchar*) &e); + return; } + size_t size() { + return string_ref_list_init ? string_ref_list.elements : 0; } + bool resize(size_t new_size) { + if (string_ref_list_init) { + if (string_ref_list.max_element < new_size && allocate_dynamic( + &string_ref_list, new_size)) return TRUE; + string_ref_list.elements = new_size; + return FALSE; + } + return TRUE; + } + bool empty() { + return string_ref_list_init ? string_ref_list.elements ? + FALSE : TRUE : TRUE; } + string_ref &operator [](size_t n) { + return ((string_ref *) (string_ref_list.buffer + + string_ref_list.size_of_element * n))[0]; } + bool string_ref_list_init; + DYNAMIC_ARRAY string_ref_list; +}; + +inline String * +q_append_str(String *str, const char *p) { + uint32 p_len = strlen(p); + if (str->reserve(p_len)) return NULL; + str->q_append(p, p_len); return str; +} + +}; + +#endif + diff --git a/storage/spider/hs_client/string_util.cpp b/storage/spider/hs_client/string_util.cpp new file mode 100644 index 00000000000..133143165c2 --- /dev/null +++ b/storage/spider/hs_client/string_util.cpp @@ -0,0 +1,206 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#include "mysql_version.h" +#include "hs_compat.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#endif + +#include "string_util.hpp" + +namespace dena { + +string_wref +get_token(char *& wp, char *wp_end, char delim) +{ + char *const wp_begin = wp; + char *const p = memchr_char(wp_begin, delim, wp_end - wp_begin); + if (p == 0) { + wp = wp_end; + return string_wref(wp_begin, wp_end - wp_begin); + } + wp = p + 1; + return string_wref(wp_begin, p - wp_begin); +} + +uint32 +atoi_uint32_nocheck(const char *start, const char *finish) +{ + uint32 v = 0; + for (; start != finish; ++start) { + const char c = *start; + if (c < '0' || c > '9') { + break; + } + v *= 10; + v += (uint32) (c - '0'); + } + return v; +} + +long long +atoll_nocheck(const char *start, const char *finish) +{ + long long v = 0; + bool negative = false; + if (start != finish) { + if (start[0] == '-') { + ++start; + negative = true; + } else if (start[0] == '+') { + ++start; + } + } + for (; start != finish; ++start) { + const char c = *start; + if (c < '0' || c > '9') { + break; + } + v *= 10; + if (negative) { + v -= (long long) (c - '0'); + } else { + v += (long long) (c - '0'); + } + } + return v; +} + +void +append_uint32(string_buffer& buf, uint32 v) +{ + char *const wp = buf.make_space(64); + const int len = snprintf(wp, 64, "%lu", static_cast(v)); + if (len > 0) { + buf.space_wrote(len); + } +} + +/* +String * +to_stdstring(uint32 v) +{ + char buf[64]; + int str_len; + String *str; + str_len = snprintf(buf, sizeof(buf), "%lu", static_cast(v)); + if ((str = new String(str_len + 1))) + str->q_append(buf, str_len); + return str; +} +*/ + +int +errno_string(const char *s, int en, String& err_r) +{ + char buf[64]; + int str_len; + str_len = snprintf(buf, sizeof(buf), "%s: %d", s, en); + if (!err_r.reserve(str_len + 1)) + err_r.q_append(buf, str_len); + return en; +} + +size_t +split(char delim, const string_ref& buf, string_ref *parts, + size_t parts_len) +{ + size_t i = 0; + const char *start = buf.begin(); + const char *const finish = buf.end(); + for (i = 0; i < parts_len; ++i) { + const char *const p = memchr_char(start, delim, finish - start); + if (p == 0) { + parts[i] = string_ref(start, finish - start); + ++i; + break; + } + parts[i] = string_ref(start, p - start); + start = p + 1; + } + const size_t r = i; + for (; i < parts_len; ++i) { + parts[i] = string_ref(); + } + return r; +} + +size_t +split(char delim, const string_wref& buf, string_wref *parts, + size_t parts_len) +{ + size_t i = 0; + char *start = buf.begin(); + char *const finish = buf.end(); + for (i = 0; i < parts_len; ++i) { + char *const p = memchr_char(start, delim, finish - start); + if (p == 0) { + parts[i] = string_wref(start, finish - start); + ++i; + break; + } + parts[i] = string_wref(start, p - start); + start = p + 1; + } + const size_t r = i; + for (; i < parts_len; ++i) { + parts[i] = string_wref(); + } + return r; +} + +size_t +split(char delim, const string_ref& buf, DYNAMIC_ARRAY& parts_r) +{ + size_t i = 0; + const char *start = buf.begin(); + const char *finish = buf.end(); + while (true) { + const char *p = memchr_char(start, delim, finish - start); + if (p == 0) { + string_ref param(start, finish - start); + insert_dynamic(&parts_r, (uchar *) ¶m); + break; + } + string_ref param(start, p - start); + insert_dynamic(&parts_r, (uchar *) ¶m); + start = p + 1; + } + const size_t r = i; + return r; +} + +size_t +split(char delim, const string_wref& buf, DYNAMIC_ARRAY& parts_r) +{ + size_t i = 0; + char *start = buf.begin(); + char *finish = buf.end(); + while (true) { + char *p = memchr_char(start, delim, finish - start); + if (p == 0) { + string_wref param(start, finish - start); + insert_dynamic(&parts_r, (uchar *) ¶m); + break; + } + string_wref param(start, p - start); + insert_dynamic(&parts_r, (uchar *) ¶m); + start = p + 1; + } + const size_t r = i; + return r; +} + +}; + diff --git a/storage/spider/hs_client/string_util.hpp b/storage/spider/hs_client/string_util.hpp new file mode 100644 index 00000000000..b886addecfb --- /dev/null +++ b/storage/spider/hs_client/string_util.hpp @@ -0,0 +1,51 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_STRING_UTIL_HPP +#define DENA_STRING_UTIL_HPP + +#include "string_buffer.hpp" +#include "string_ref.hpp" + +namespace dena { + +inline const char * +memchr_char(const char *s, int c, size_t n) +{ + return static_cast(memchr(s, c, n)); +} + +inline char * +memchr_char(char *s, int c, size_t n) +{ + return static_cast(memchr(s, c, n)); +} + +string_wref get_token(char *& wp, char *wp_end, char delim); +uint32 atoi_uint32_nocheck(const char *start, const char *finish); +/* +String *to_stdstring(uint32 v); +*/ +void append_uint32(string_buffer& buf, uint32 v); +long long atoll_nocheck(const char *start, const char *finish); + +int errno_string(const char *s, int en, String& err_r); + +size_t split(char delim, const string_ref& buf, string_ref *parts, + size_t parts_len); +size_t split(char delim, const string_wref& buf, string_wref *parts, + size_t parts_len); +size_t split(char delim, const string_ref& buf, + DYNAMIC_ARRAY& parts_r); +size_t split(char delim, const string_wref& buf, + DYNAMIC_ARRAY& parts_r); +}; + +#endif + diff --git a/storage/spider/hs_client/thread.hpp b/storage/spider/hs_client/thread.hpp new file mode 100644 index 00000000000..79fba706a42 --- /dev/null +++ b/storage/spider/hs_client/thread.hpp @@ -0,0 +1,84 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. + * Copyright (C) 2011 Kentoku SHIBA + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_THREAD_HPP +#define DENA_THREAD_HPP + +#include "fatal.hpp" + +namespace dena { + +/* +template +struct thread : private noncopyable { + template thread(const Ta& arg, size_t stack_sz = 256 * 1024) + : obj(arg), thr(0), need_join(false), stack_size(stack_sz) { } + template thread(const Ta0& a0, + volatile Ta1& a1, size_t stack_sz = 256 * 1024) + : obj(a0, a1), thr(0), need_join(false), stack_size(stack_sz) { } + ~thread() { + join(); + } + void start() { + if (!start_nothrow()) { + fatal_abort("thread::start"); + } + } + bool start_nothrow() { + if (need_join) { + return need_join; + } + void *const arg = this; + pthread_attr_t attr; + if (pthread_attr_init(&attr) != 0) { + fatal_abort("pthread_attr_init"); + } + if (pthread_attr_setstacksize(&attr, stack_size) != 0) { + fatal_abort("pthread_attr_setstacksize"); + } + const int r = pthread_create(&thr, &attr, thread_main, arg); + if (pthread_attr_destroy(&attr) != 0) { + fatal_abort("pthread_attr_destroy"); + } + if (r != 0) { + return need_join; + } + need_join = true; + return need_join; + } + void join() { + if (!need_join) { + return; + } + int e = 0; + if ((e = pthread_join(thr, 0)) != 0) { + fatal_abort("pthread_join"); + } + need_join = false; + } + T& operator *() { return obj; } + T *operator ->() { return &obj; } + private: + static void *thread_main(void *arg) { + thread *p = static_cast(arg); + p->obj(); + return 0; + } + private: + T obj; + pthread_t thr; + bool need_join; + size_t stack_size; +}; +*/ + +}; + +#endif + diff --git a/storage/spider/hs_client/util.hpp b/storage/spider/hs_client/util.hpp new file mode 100644 index 00000000000..93d78cc7dc0 --- /dev/null +++ b/storage/spider/hs_client/util.hpp @@ -0,0 +1,25 @@ + +// vim:sw=2:ai + +/* + * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. + * See COPYRIGHT.txt for details. + */ + +#ifndef DENA_UTIL_HPP +#define DENA_UTIL_HPP + +namespace dena { + +/* boost::noncopyable */ +struct noncopyable { + noncopyable() { } + private: + noncopyable(const noncopyable&); + noncopyable& operator =(const noncopyable&); +}; + +}; + +#endif + diff --git a/storage/spider/mysql-test/spider/bg/include/deinit_child2_1.inc b/storage/spider/mysql-test/spider/bg/include/deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/deinit_child2_2.inc b/storage/spider/mysql-test/spider/bg/include/deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/deinit_child2_3.inc b/storage/spider/mysql-test/spider/bg/include/deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/deinit_child3_1.inc b/storage/spider/mysql-test/spider/bg/include/deinit_child3_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/deinit_child3_2.inc b/storage/spider/mysql-test/spider/bg/include/deinit_child3_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/deinit_child3_3.inc b/storage/spider/mysql-test/spider/bg/include/deinit_child3_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/deinit_master_1.inc b/storage/spider/mysql-test/spider/bg/include/deinit_master_1.inc new file mode 100644 index 00000000000..c19e376d10a --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/deinit_master_1.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/bg/include/deinit_slave1_1.inc b/storage/spider/mysql-test/spider/bg/include/deinit_slave1_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_1.inc b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_2.inc b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_3.inc b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_1.inc b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_1.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_1.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_2.inc b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_2.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_2.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_3.inc b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_3.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_deinit_child3_3.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/bg/include/ha_deinit_master_1.inc b/storage/spider/mysql-test/spider/bg/include/ha_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/ha_init_child2_1.inc b/storage/spider/mysql-test/spider/bg/include/ha_init_child2_1.inc new file mode 100644 index 00000000000..59c0175d349 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_init_child2_1.inc @@ -0,0 +1,8 @@ +let $CHILD2_1_HA_AS_DROP_TABLES= + $CHILD2_1_DROP_TABLES; +let $CHILD2_1_HA_AS_CREATE_TABLES= + $CHILD2_1_CREATE_TABLES; +let $CHILD2_1_HA_AS_DROP_TABLES2= + $CHILD2_1_DROP_TABLES2; +let $CHILD2_1_HA_AS_CREATE_TABLES2= + $CHILD2_1_CREATE_TABLES2; diff --git a/storage/spider/mysql-test/spider/bg/include/ha_init_child2_2.inc b/storage/spider/mysql-test/spider/bg/include/ha_init_child2_2.inc new file mode 100644 index 00000000000..90d27ed704d --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_init_child2_2.inc @@ -0,0 +1,4 @@ +let $CHILD2_2_HA_DROP_TABLES= + $CHILD2_2_DROP_TABLES; +let $CHILD2_2_HA_CREATE_TABLES= + $CHILD2_2_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/bg/include/ha_init_child2_3.inc b/storage/spider/mysql-test/spider/bg/include/ha_init_child2_3.inc new file mode 100644 index 00000000000..11abf112b1f --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_init_child2_3.inc @@ -0,0 +1,4 @@ +let $CHILD2_3_HA_DROP_TABLES= + $CHILD2_3_DROP_TABLES; +let $CHILD2_3_HA_CREATE_TABLES= + $CHILD2_3_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/bg/include/ha_init_child3_1.inc b/storage/spider/mysql-test/spider/bg/include/ha_init_child3_1.inc new file mode 100644 index 00000000000..56de7df4e52 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_init_child3_1.inc @@ -0,0 +1,140 @@ +--let $CHILD3_1_ENGINE_TYPE=Spider +--let $CHILD3_1_ENGINE=ENGINE=Spider +--source ../../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_1_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_1_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_1_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/bg/include/ha_init_child3_2.inc b/storage/spider/mysql-test/spider/bg/include/ha_init_child3_2.inc new file mode 100644 index 00000000000..fdb3a84cca7 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_init_child3_2.inc @@ -0,0 +1,140 @@ +--let $CHILD3_2_ENGINE_TYPE=Spider +--let $CHILD3_2_ENGINE=ENGINE=Spider +--source ../../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_2_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_2_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_2_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_2_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_2_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_2_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_2_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_2_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_2_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_2_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/bg/include/ha_init_child3_3.inc b/storage/spider/mysql-test/spider/bg/include/ha_init_child3_3.inc new file mode 100644 index 00000000000..d08ff4d0d34 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_init_child3_3.inc @@ -0,0 +1,140 @@ +--let $CHILD3_3_ENGINE_TYPE=Spider +--let $CHILD3_3_ENGINE=ENGINE=Spider +--source ../../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_3_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_3_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_3_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_3_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_3_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_3_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_3_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_3_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_3_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_3_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/bg/include/ha_init_master_1.inc b/storage/spider/mysql-test/spider/bg/include/ha_init_master_1.inc new file mode 100644 index 00000000000..78797d80ce7 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/ha_init_master_1.inc @@ -0,0 +1,105 @@ +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $MASTER_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $MASTER_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $MASTER_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $MASTER_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $MASTER_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; +let $MASTER_1_COPY_TABLES_2_1= + SELECT spider_copy_tables('ta_l', '0', '1'); + +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $MASTER_1_COMMENT_HA_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_COMMENT_HA_AS_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $MASTER_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $MASTER_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +let $MASTER_1_COPY_TABLES_P_2_1= + SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +let $MASTER_1_CHECK_HA_STATUS= + SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +let $MASTER_1_CHANGE_HA_MON= + SELECT spider_flush_table_mon_cache(); diff --git a/storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_1.inc b/storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_2.inc b/storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_3.inc b/storage/spider/mysql-test/spider/bg/include/hs_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/hs_deinit_master_1.inc b/storage/spider/mysql-test/spider/bg/include/hs_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/hs_init_child2_1.inc b/storage/spider/mysql-test/spider/bg/include/hs_init_child2_1.inc new file mode 100644 index 00000000000..2ea1c0c9cd6 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/hs_init_child2_1.inc @@ -0,0 +1,24 @@ +let $CHILD2_1_HS_DROP_TABLES= + DROP TABLE IF EXISTS hs_r; +let $CHILD2_1_HS_CREATE_TABLES= + CREATE TABLE hs_r ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_HS_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r ORDER BY a; +let $CHILD2_1_HS_DROP_TABLES2= + DROP TABLE IF EXISTS hs_r2; +let $CHILD2_1_HS_CREATE_TABLES2= + CREATE TABLE hs_r2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_HS_SELECT_TABLES2= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r2 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/bg/include/hs_init_child2_2.inc b/storage/spider/mysql-test/spider/bg/include/hs_init_child2_2.inc new file mode 100644 index 00000000000..7c69d73ced6 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/hs_init_child2_2.inc @@ -0,0 +1,12 @@ +let $CHILD2_2_HS_DROP_TABLES= + DROP TABLE IF EXISTS hs_r3; +let $CHILD2_2_HS_CREATE_TABLES= + CREATE TABLE hs_r3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_HS_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r3 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/bg/include/hs_init_child2_3.inc b/storage/spider/mysql-test/spider/bg/include/hs_init_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/hs_init_master_1.inc b/storage/spider/mysql-test/spider/bg/include/hs_init_master_1.inc new file mode 100644 index 00000000000..a43e995647e --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/hs_init_master_1.inc @@ -0,0 +1,12 @@ +let $MASTER_1_HS_COMMENT_TMP= + COMMENT=''; +let $MASTER_1_HS_COMMENT_2_1= + COMMENT='srv "s_2_1", table "hs_r", uhr "1", uhw "1", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT", hwr "0"'; +let $MASTER_1_HS_COMMENT_P_2_1= + COMMENT='uhr "1", uhw "1", hwr "0"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) + COMMENT='srv "s_2_1", table "hs_r2", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", table "hs_r3", hrp "$CHILD2_2_HSRPORT", hwp "$CHILD2_2_HSWPORT"' + ); diff --git a/storage/spider/mysql-test/spider/bg/include/init_child2_1.inc b/storage/spider/mysql-test/spider/bg/include/init_child2_1.inc new file mode 100644 index 00000000000..6e25765f25e --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/init_child2_1.inc @@ -0,0 +1,175 @@ +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS ta_r; +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE ta_r ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +let $CHILD2_1_DROP_TABLES2= + DROP TABLE IF EXISTS ta_r2; +let $CHILD2_1_CREATE_TABLES2= + CREATE TABLE ta_r2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES2= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r2 ORDER BY a; +let $CHILD2_1_DROP_TABLES3= + DROP TABLE IF EXISTS ta_r_no_idx; +let $CHILD2_1_CREATE_TABLES3= + CREATE TABLE ta_r_no_idx ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES3= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_no_idx ORDER BY a; +let $CHILD2_1_DROP_TABLES4= + DROP TABLE IF EXISTS ta_r_auto_inc; +let $CHILD2_1_CREATE_TABLES4= + CREATE TABLE ta_r_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES4= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_auto_inc + ORDER BY a; +let $CHILD2_1_DROP_TABLES5= + DROP TABLE IF EXISTS ta_r_int; +let $CHILD2_1_CREATE_TABLES5= + CREATE TABLE ta_r_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES5= + SELECT a, b, c FROM ta_r_int ORDER BY a; +let $CHILD2_1_DROP_TABLES6= + DROP TABLE IF EXISTS ta_r_3; +let $CHILD2_1_CREATE_TABLES6= + CREATE TABLE ta_r_3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES6= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_3 ORDER BY a; +let $CHILD2_1_DROP_FT_TABLES= + DROP TABLE IF EXISTS ft_r; +let $CHILD2_1_CREATE_FT_TABLES= + CREATE TABLE ft_r ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET; +let $CHILD2_1_SELECT_FT_TABLES= + SELECT a, b, c, d FROM ft_r ORDER BY a; +let $CHILD2_1_DROP_FT_TABLES2= + DROP TABLE IF EXISTS ft_r2; +let $CHILD2_1_CREATE_FT_TABLES2= + CREATE TABLE ft_r2 ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET; +let $CHILD2_1_SELECT_FT_TABLES2= + SELECT a, b, c, d FROM ft_r2 ORDER BY a; +let $CHILD2_1_DROP_GM_TABLES= + DROP TABLE IF EXISTS gm_r; +let $CHILD2_1_CREATE_GM_TABLES= + CREATE TABLE gm_r ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET; +let $CHILD2_1_SELECT_GM_TABLES= + SELECT a, b, c FROM gm_r ORDER BY a; +let $CHILD2_1_DROP_GM_TABLES2= + DROP TABLE IF EXISTS gm_r2; +let $CHILD2_1_CREATE_GM_TABLES2= + CREATE TABLE gm_r2 ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET; +let $CHILD2_1_SELECT_GM_TABLES2= + SELECT a, b, c FROM gm_r2 ORDER BY a; +let $CHILD2_1_DROP_LOCK_TABLES1= + DROP TABLE IF EXISTS t1_1; +let $CHILD2_1_CREATE_LOCK_TABLES1= + CREATE TABLE t1_1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_DROP_LOCK_TABLES2= + DROP TABLE IF EXISTS t2_2; +let $CHILD2_1_CREATE_LOCK_TABLES2= + CREATE TABLE t2_2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_DROP_INCREMENT_TABLES1= + DROP TABLE IF EXISTS t1_1; +let $CHILD2_1_CREATE_INCREMENT_TABLES1= + CREATE TABLE t1_1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_INCREMENT_TABLES1= + SELECT id FROM t1_1 ORDER BY id; +let $CHILD2_1_DROP_TEXT_PK_TABLES1= + DROP TABLE IF EXISTS t1; +let $CHILD2_1_CREATE_TEXT_PK_TABLES1= + CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY (a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET2; +let $CHILD2_1_SELECT_TEXT_PK_TABLES1= + SELECT a FROM t1 ORDER BY a; +let $CHILD2_1_DROP_TEXT_KEY_TABLES1= + DROP TABLE IF EXISTS t1; +let $CHILD2_1_CREATE_TEXT_KEY_TABLES1= + CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TEXT_KEY_TABLES1= + SELECT a, b FROM t1 ORDER BY a, b; +let $CHILD2_1_AUTO_INCREMENT_INCREMENT1= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 1; +let $CHILD2_1_AUTO_INCREMENT_INCREMENT2= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 4; +let $CHILD2_1_AUTO_INCREMENT_OFFSET1= + SET GLOBAL AUTO_INCREMENT_OFFSET = 1; +let $CHILD2_1_AUTO_INCREMENT_OFFSET2= + SET GLOBAL AUTO_INCREMENT_OFFSET = 2; diff --git a/storage/spider/mysql-test/spider/bg/include/init_child2_2.inc b/storage/spider/mysql-test/spider/bg/include/init_child2_2.inc new file mode 100644 index 00000000000..3524fc4a2b7 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/init_child2_2.inc @@ -0,0 +1,80 @@ +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS ta_r3; +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE ta_r3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_TABLES5= + DROP TABLE IF EXISTS ta_r_int; +let $CHILD2_2_CREATE_TABLES5= + CREATE TABLE ta_r_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r3 ORDER BY a; +let $CHILD2_2_DROP_FT_TABLES= + DROP TABLE IF EXISTS ft_r3; +let $CHILD2_2_CREATE_FT_TABLES= + CREATE TABLE ft_r3 ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_2_FT_ENGINE $CHILD2_2_FT_CHARSET; +let $CHILD2_2_SELECT_FT_TABLES= + SELECT a, b, c, d FROM ft_r3 ORDER BY a; +let $CHILD2_2_DROP_GM_TABLES= + DROP TABLE IF EXISTS gm_r3; +let $CHILD2_2_CREATE_GM_TABLES= + CREATE TABLE gm_r3 ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_2_GM_ENGINE $CHILD2_2_GM_CHARSET; +let $CHILD2_2_SELECT_GM_TABLES= + SELECT a, b, c FROM gm_r3 ORDER BY a; +let $CHILD2_2_DROP_LOCK_TABLES1= + DROP TABLE IF EXISTS t1_2; +let $CHILD2_2_CREATE_LOCK_TABLES1= + CREATE TABLE t1_2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_LOCK_TABLES2= + DROP TABLE IF EXISTS t2_1; +let $CHILD2_2_CREATE_LOCK_TABLES2= + CREATE TABLE t2_1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_INCREMENT_TABLES1= + DROP TABLE IF EXISTS t1_2; +let $CHILD2_2_CREATE_INCREMENT_TABLES1= + CREATE TABLE t1_2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_SELECT_INCREMENT_TABLES1= + SELECT id FROM t1_2 ORDER BY id; +let $CHILD2_2_AUTO_INCREMENT_INCREMENT1= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 1; +let $CHILD2_2_AUTO_INCREMENT_INCREMENT2= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 4; +let $CHILD2_2_AUTO_INCREMENT_OFFSET1= + SET GLOBAL AUTO_INCREMENT_OFFSET = 1; +let $CHILD2_2_AUTO_INCREMENT_OFFSET2= + SET GLOBAL AUTO_INCREMENT_OFFSET = 3; diff --git a/storage/spider/mysql-test/spider/bg/include/init_child2_3.inc b/storage/spider/mysql-test/spider/bg/include/init_child2_3.inc new file mode 100644 index 00000000000..d857a787ac0 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/init_child2_3.inc @@ -0,0 +1,11 @@ +let $CHILD2_3_DROP_TABLES= + DROP TABLE IF EXISTS ta_r4; +let $CHILD2_3_CREATE_TABLES= + CREATE TABLE ta_r4 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_3_ENGINE $CHILD2_3_CHARSET; +let $CHILD2_3_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r4 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/bg/include/init_child3_1.inc b/storage/spider/mysql-test/spider/bg/include/init_child3_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/init_child3_2.inc b/storage/spider/mysql-test/spider/bg/include/init_child3_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/init_child3_3.inc b/storage/spider/mysql-test/spider/bg/include/init_child3_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/bg/include/init_master_1.inc b/storage/spider/mysql-test/spider/bg/include/init_master_1.inc new file mode 100644 index 00000000000..d6e302a6e1f --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/init_master_1.inc @@ -0,0 +1,194 @@ +--source ../../include/init_spider.inc +SET spider_internal_sql_log_off= 0; +SET spider_bgs_mode= 1; +SET spider_bgs_first_read= 2; +SET spider_bgs_second_read= 2; +SET spider_split_read= 2; +SET spider_conn_recycle_mode= 2; +SET spider_multi_split_read= 1; +SET spider_reset_sql_alloc= 0; +SET spider_bulk_update_size= 40; +SET spider_direct_order_limit= 10000; +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_2_1= + COMMENT='database "auto_test_remote", table "ta_r"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_2_1= + COMMENT='database "auto_test_remote", table "ta_r"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT2_2_1= + COMMENT='database "auto_test_remote", table "ta_r_no_idx"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password "", prt "2000000"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT2_2_1= + COMMENT='database "auto_test_remote", table "ta_r_no_idx"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password "", prt "2000000"'; +} +let $MASTER_1_COMMENT_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1", table "ta_r2", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT2_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ta_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT3_2_1= + COMMENT='database "auto_test_remote", table "ta_r_auto_inc"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT3_2_1= + COMMENT='database "auto_test_remote", table "ta_r_auto_inc"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +let $MASTER_1_COMMENT3_P_2_1= + COMMENT='table "ta_r_int"' + PARTITION BY LIST(MOD(a, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='srv "s_2_1", priority "1000"', + PARTITION pt2 VALUES IN (1) + COMMENT='srv "s_2_2", priority "1000001"' + ); +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT4_2_1= + COMMENT='database "auto_test_remote", table "ta_r_int"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT4_2_1= + COMMENT='database "auto_test_remote", table "ta_r_int"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT5_2_1= + COMMENT='database "auto_test_remote", table "ta_r_3"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT5_2_1= + COMMENT='database "auto_test_remote", table "ta_r_3"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_FT_2_1= + COMMENT='database "auto_test_remote", table "ft_r"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_FT_2_1= + COMMENT='database "auto_test_remote", table "ft_r"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +let $MASTER_1_COMMENT2_FT_P_2_1= + COMMENT='table "ft_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ft_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT_GM_2_1= + COMMENT='srv "s_2_1", table "gm_r"'; +let $MASTER_1_COMMENT2_GM_P_2_1= + COMMENT='table "gm_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "gm_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT_LOCK1= + COMMENT 'tbl "t1_1 t1_2", srv "s_2_1 s_2_2"'; +let $MASTER_1_COMMENT_LOCK2= + COMMENT 'tbl "t2_1 t2_2", srv "s_2_2 s_2_1"'; +let $MASTER_1_COMMENT_INCREMENT1_1= + COMMENT 'aim "1", tbl "t1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_INCREMENT1_P_1= + COMMENT 'aim "1"' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='tbl "t1_1", srv "s_2_1"', + PARTITION pt2 VALUES IN (1) + COMMENT='tbl "t1_2", srv "s_2_2"' + ); +let $MASTER_1_COMMENT_READONLY1_1= + COMMENT 'read_only_mode "1", tbl "t1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_ERROR_MODE1_1= + COMMENT 'erm "1", ewm "1", tbl "ter1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_TEXT_PK1_1= + COMMENT 'tbl "t1", srv "s_2_1"'; +let $MASTER_1_COMMENT_TEXT_KEY1_1= + COMMENT 'tbl "t1", srv "s_2_1"'; +let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS= + SHOW STATUS LIKE 'Spider_direct_update'; +let $MASTER_1_CHECK_DIRECT_DELETE_STATUS= + SHOW STATUS LIKE 'Spider_direct_delete'; +let $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS= + SHOW STATUS LIKE 'Spider_direct_order_limit'; +let $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS= + SHOW STATUS LIKE 'Spider_direct_aggregate'; +let $MASTER_1_AUTO_INCREMENT_INCREMENT1= + SET SESSION AUTO_INCREMENT_INCREMENT = 1 $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_INCREMENT2= + SET SESSION AUTO_INCREMENT_INCREMENT = 777 $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET1= + SET SESSION AUTO_INCREMENT_OFFSET = 1 $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET2= + SET SESSION AUTO_INCREMENT_OFFSET = 777 $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET3= + SET SESSION AUTO_INCREMENT_OFFSET = 1; +let $MASTER_1_AUTO_INCREMENT_OFFSET4= + SET SESSION AUTO_INCREMENT_OFFSET = 777; diff --git a/storage/spider/mysql-test/spider/bg/include/init_slave1_1.inc b/storage/spider/mysql-test/spider/bg/include/init_slave1_1.inc new file mode 100644 index 00000000000..87c05f1f690 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/include/init_slave1_1.inc @@ -0,0 +1,10 @@ +let $SLAVE1_1_COMMENT_INCREMENT1_1= + COMMENT ''; +let $SLAVE1_1_COMMENT_INCREMENT1_P_1= + COMMENT '' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='', + PARTITION pt2 VALUES IN (1) + COMMENT='' + ); diff --git a/storage/spider/mysql-test/spider/bg/my.cnf b/storage/spider/mysql-test/spider/bg/my.cnf new file mode 100644 index 00000000000..7f9d7c44c05 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/my.cnf @@ -0,0 +1,176 @@ +# Use default setting for mysqld processes +!include include/default_mysqld.cnf + +[mysqld.1.1] +loose_handlersocket_port= 20000 +loose_handlersocket_port_wr= 20001 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 +loose_partition= 1 + +[mysqld.2.1] +loose_handlersocket_port= 20002 +loose_handlersocket_port_wr= 20003 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[mysqld.2.2] +loose_handlersocket_port= 20004 +loose_handlersocket_port_wr= 20005 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[mysqld.2.3] + +[mysqld.3.1] +loose_partition= 1 + +[mysqld.3.2] +loose_partition= 1 + +[mysqld.3.3] +loose_partition= 1 + +[mysqld.4.1] +loose_partition= 1 + + +[ENV] +USE_GEOMETRY_TEST= 1 +USE_FULLTEXT_TEST= 1 +USE_HA_TEST= 1 +USE_GENERAL_LOG= 1 +USE_REPLICATION= 1 +MASTER_1_MYPORT= @mysqld.1.1.port +MASTER_1_HSRPORT= 20000 +MASTER_1_HSWPORT= 20001 +MASTER_1_MYSOCK= @mysqld.1.1.socket +MASTER_1_ENGINE_TYPE= Spider +#MASTER_1_ENGINE_TYPE= MyISAM +MASTER_1_ENGINE= ENGINE=Spider +MASTER_1_CHARSET= DEFAULT CHARSET=utf8 +MASTER_1_ENGINE2= ENGINE=MyISAM +MASTER_1_CHARSET2= DEFAULT CHARSET=utf8 +MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +SLAVE1_1_MYPORT= @mysqld.4.1.port +SLAVE1_1_MYSOCK= @mysqld.4.1.socket +SLAVE1_1_ENGINE_TYPE= MyISAM +SLAVE1_1_ENGINE= ENGINE=MyISAM +SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP2= 1 +OUTPUT_CHILD_GROUP2= 0 +CHILD2_1_MYPORT= @mysqld.2.1.port +CHILD2_1_HSRPORT= 20002 +CHILD2_1_HSWPORT= 20003 +CHILD2_1_MYSOCK= @mysqld.2.1.socket +CHILD2_1_ENGINE_TYPE= InnoDB +CHILD2_1_ENGINE= ENGINE=InnoDB +CHILD2_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +CHILD2_2_MYPORT= @mysqld.2.2.port +CHILD2_2_HSRPORT= 20004 +CHILD2_2_HSWPORT= 20005 +CHILD2_2_MYSOCK= @mysqld.2.2.socket +CHILD2_2_ENGINE_TYPE= InnoDB +CHILD2_2_ENGINE= ENGINE=InnoDB +CHILD2_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_3_MYPORT= @mysqld.2.3.port +CHILD2_3_MYSOCK= @mysqld.2.3.socket +CHILD2_3_ENGINE_TYPE= InnoDB +CHILD2_3_ENGINE= ENGINE=InnoDB +CHILD2_3_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_FT_MYPORT= @mysqld.1.1.port +CHILD2_1_FT_MYSOCK= @mysqld.1.1.socket +CHILD2_1_FT_ENGINE_TYPE= MyISAM +CHILD2_1_FT_ENGINE= ENGINE=MyISAM +CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_FT_MYPORT= @mysqld.2.2.port +CHILD2_2_FT_MYSOCK= @mysqld.2.2.socket +CHILD2_2_FT_ENGINE_TYPE= MyISAM +CHILD2_2_FT_ENGINE= ENGINE=MyISAM +CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_GM_MYPORT= @mysqld.2.1.port +CHILD2_1_GM_MYSOCK= @mysqld.2.1.socket +CHILD2_1_GM_ENGINE_TYPE= MyISAM +CHILD2_1_GM_ENGINE= ENGINE=MyISAM +CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_GM_MYPORT= @mysqld.2.2.port +CHILD2_2_GM_MYSOCK= @mysqld.2.2.socket +CHILD2_2_GM_ENGINE_TYPE= MyISAM +CHILD2_2_GM_ENGINE= ENGINE=MyISAM +CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP3= 1 +OUTPUT_CHILD_GROUP3= 0 +CHILD3_1_MYPORT= @mysqld.3.1.port +CHILD3_1_MYSOCK= @mysqld.3.1.socket +CHILD3_1_ENGINE_TYPE= InnoDB +CHILD3_1_ENGINE= ENGINE=InnoDB +CHILD3_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_2_MYPORT= @mysqld.3.2.port +CHILD3_2_MYSOCK= @mysqld.3.2.socket +CHILD3_2_ENGINE_TYPE= InnoDB +CHILD3_2_ENGINE= ENGINE=InnoDB +CHILD3_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_3_MYPORT= @mysqld.3.3.port +CHILD3_3_MYSOCK= @mysqld.3.3.socket +CHILD3_3_ENGINE_TYPE= InnoDB +CHILD3_3_ENGINE= ENGINE=InnoDB +CHILD3_3_CHARSET= DEFAULT CHARSET=utf8 + +STR_SEMICOLON= ; + +#The followings are setted in include/init_xxx.inc files +#MASTER_1_COMMENT_2_1 +#MASTER_1_COMMENT2_2_1 +#MASTER_1_COMMENT3_2_1 +#MASTER_1_COMMENT4_2_1 +#MASTER_1_COMMENT5_2_1 +#MASTER_1_COMMENT_P_2_1 +#CHILD2_1_DROP_TABLES +#CHILD2_1_CREATE_TABLES +#CHILD2_1_SELECT_TABLES +#CHILD2_1_DROP_TABLES2 +#CHILD2_1_CREATE_TABLES2 +#CHILD2_1_SELECT_TABLES2 +#CHILD2_1_DROP_TABLES3 +#CHILD2_1_CREATE_TABLES3 +#CHILD2_1_SELECT_TABLES3 +#CHILD2_1_DROP_TABLES4 +#CHILD2_1_CREATE_TABLES4 +#CHILD2_1_SELECT_TABLES4 +#CHILD2_1_DROP_TABLES5 +#CHILD2_1_CREATE_TABLES5 +#CHILD2_1_SELECT_TABLES5 +#CHILD2_1_DROP_TABLES6 +#CHILD2_1_CREATE_TABLES6 +#CHILD2_1_SELECT_TABLES6 +#CHILD2_2_DROP_TABLES +#CHILD2_2_CREATE_TABLES +#CHILD2_2_SELECT_TABLES diff --git a/storage/spider/mysql-test/spider/bg/r/basic_sql.result b/storage/spider/mysql-test/spider/bg/r/basic_sql.result new file mode 100644 index 00000000000..e6202327ef6 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/basic_sql.result @@ -0,0 +1,701 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'f', '2008-07-01 10:21:39'), +(2, 'g', '2000-02-01 00:00:00'), +(3, 'j', '2007-05-04 20:03:11'), +(4, 'i', '2003-10-30 05:01:03'), +(5, 'h', '2001-10-31 23:59:59'); +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l +Warnings: +Warning 1062 Duplicate entry '1' for key 'PRIMARY' +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +Warning 1062 Duplicate entry '3' for key 'PRIMARY' +Warning 1062 Duplicate entry '4' for key 'PRIMARY' +Warning 1062 Duplicate entry '5' for key 'PRIMARY' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create table with partition and select test +CREATE TABLE ta_l2 ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create no index table +DROP TABLE IF EXISTS ta_l_no_idx; +CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table shared mode +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table for update +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table join +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table straight_join +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_small_result +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_big_result +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_buffer_result +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_cache +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_no_cache +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_calc_found_rows +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +SELECT found_rows(); +found_rows() +5 + +select high_priority +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select distinct +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select count +SELECT count(*) FROM ta_l ORDER BY a; +count(*) +5 + +select table join not use index +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select using index and pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using index pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +insert +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +insert select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 + +insert low_priority +TRUNCATE TABLE ta_l; +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert high_priority +TRUNCATE TABLE ta_l; +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert ignore +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +Warnings: +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (insert) +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (update) +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2005-08-08 11:11:11 + +replace +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2008-02-02 02:02:02 + +replace select +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace select a +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace low_priority +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 g 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 f 2008-02-02 02:02:02 + +update select +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update select a +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 h 2010-04-04 04:04:04 +2 g 2009-03-03 03:03:03 + +update join +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 + +update join a +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update low_priority +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update ignore +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update pushdown +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 j 2009-03-03 03:03:03 + +update index pushdown +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update partition pushdown +UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 e 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update partition index pushdown +UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete all +DELETE FROM ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE IGNORE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE QUICK FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete partition pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete partition index pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +truncate +TRUNCATE TABLE ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/bg/r/direct_aggregate.result b/storage/spider/mysql-test/spider/bg/r/direct_aggregate.result new file mode 100644 index 00000000000..7bf1cb4aea7 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/direct_aggregate.result @@ -0,0 +1,132 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_aggregating test +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 0 +SELECT COUNT(*) FROM ta_l; +COUNT(*) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l; +MAX(a) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MIN(a) FROM ta_l; +MIN(a) +1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l WHERE a < 5; +MAX(a) +4 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MIN(a) FROM ta_l WHERE a > 1; +MIN(a) +2 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 + +with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT COUNT(*) FROM ta_l2; +COUNT(*) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l2; +MAX(a) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MIN(a) FROM ta_l2; +MIN(a) +1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l2 WHERE a < 5; +MAX(a) +4 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MIN(a) FROM ta_l2 WHERE a > 1; +MIN(a) +2 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/bg/r/direct_update.result b/storage/spider/mysql-test/spider/bg/r/direct_update.result new file mode 100644 index 00000000000..135734641c1 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/direct_update.result @@ -0,0 +1,226 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_updating test +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l2 SET c = ADDDATE(c, 1); +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l2 SET b = 'x' WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l2 WHERE b = 'c'; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l2 WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/bg/r/function.result b/storage/spider/mysql-test/spider/bg/r/function.result new file mode 100644 index 00000000000..764c774514b --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/function.result @@ -0,0 +1,149 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +in() +CREATE TABLE t1 ( +a VARCHAR(255), +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1 +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +select a from t1 where a in ('15', '120'); +a +120 +15 + +date_sub() +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-08-01 10:21:39 +2 b 1999-01-01 00:00:00 +3 e 2006-06-04 20:03:11 +4 d 2002-11-30 05:01:03 +5 c 2000-12-31 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-11-01 10:21:39 +2 b 1999-04-01 00:00:00 +3 e 2006-09-04 20:03:11 +4 d 2003-02-28 05:01:03 +5 c 2001-03-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-01 10:21:39 +2 b 1999-03-01 00:00:00 +3 e 2006-08-04 20:03:11 +4 d 2003-01-28 05:01:03 +5 c 2001-02-28 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-08 10:21:39 +2 b 1999-03-08 00:00:00 +3 e 2006-08-11 20:03:11 +4 d 2003-02-04 05:01:03 +5 c 2001-03-07 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 10:21:39 +2 b 1999-03-07 00:00:00 +3 e 2006-08-10 20:03:11 +4 d 2003-02-03 05:01:03 +5 c 2001-03-06 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:21:39 +2 b 1999-03-07 01:00:00 +3 e 2006-08-10 21:03:11 +4 d 2003-02-03 06:01:03 +5 c 2001-03-07 00:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:39 +2 b 1999-03-07 00:59:00 +3 e 2006-08-10 21:02:11 +4 d 2003-02-03 06:00:03 +5 c 2001-03-07 00:58:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:40 +2 b 1999-03-07 00:59:01 +3 e 2006-08-10 21:02:12 +4 d 2003-02-03 06:00:04 +5 c 2001-03-07 00:59:00 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/bg/r/ha.result b/storage/spider/mysql-test/spider/bg/r/ha.result new file mode 100644 index 00000000000..e05ecb32e1b --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/ha.result @@ -0,0 +1,431 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +CREATE DATABASE auto_test_remote3; +USE auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; + +test select 1 +SELECT 1; +1 +1 + +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 0 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote2.ta_r3' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 2 +SELECT spider_copy_tables('ta_l', '0', '1'); +spider_copy_tables('ta_l', '0', '1') +1 +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote3.ta_r4' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 2 +SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +spider_copy_tables('ta_l2#P#pt2', '0', '1') +1 +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +active standby test +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote.ta_r' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 3 +auto_test_local ta_l 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote.ta_r2' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 3 +auto_test_local ta_l2#P#pt2 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +auto_test_local ta_l2#P#pt2 0 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 3 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result b/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result new file mode 100644 index 00000000000..a570e542771 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result @@ -0,0 +1,371 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +3.1 +auto_increment +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t2; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +778 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t2; +MAX(id) +2331 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1555 +SELECT id FROM t1 ORDER BY id; +id +777 +778 +1554 +1555 +2331 +2332 +3109 +3886 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT id FROM t2 ORDER BY id; +id +777 +778 +1554 +1555 +2331 +2332 +3108 +3109 +3885 +3886 +4662 +5439 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t2 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +6993 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +10000 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +5000 +10000 +auto_increment with partition +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t2; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +778 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t2; +MAX(id) +2331 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1555 +SELECT id FROM t1 ORDER BY id; +id +777 +778 +1554 +1555 +2331 +2332 +3109 +3886 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT id FROM t2 ORDER BY id; +id +777 +778 +1554 +1555 +2331 +2332 +3108 +3109 +3885 +3886 +4662 +5439 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t2 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +6993 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +10000 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +5000 +10000 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/bg/r/spider_fixes.result b/storage/spider/mysql-test/spider/bg/r/spider_fixes.result new file mode 100644 index 00000000000..aedde01e178 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/spider_fixes.result @@ -0,0 +1,692 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +2.13 +select table with "order by desc" and "<" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 +2 b 2000-01-01 00:00:00 + +select table with "order by desc" and "<=" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +5 c 2001-12-31 23:59:59 +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 + +2.14 +update table with range scan and split_read +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-02-02 00:00:00 +3 e 2000-02-02 00:00:00 +4 d 2000-02-02 00:00:00 +5 c 2000-02-02 00:00:00 + +2.15 +select table with range scan +TRUNCATE TABLE ta_l; +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a int(11) NOT NULL DEFAULT '0', +b char(1) DEFAULT NULL, +c datetime DEFAULT NULL, +PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +a b c +5 c 2001-12-31 23:59:59 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 + +2.16 +auto_increment insert with trigger +CREATE TABLE ta_l_auto_inc ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tc_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;; +INSERT INTO ta_l_auto_inc (a, b, c) VALUES +(NULL, 's', '2008-12-31 20:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 s 2008-12-31 20:59:59 + +2.17 +engine-condition-pushdown with "or" and joining +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +partition with sort +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +2.23 +partition update with moving partition +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); +UPDATE ta_l2 SET a = 4 WHERE a = 3; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 B 2010-09-26 00:00:00 +index merge +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 +index merge with partition +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 + +2.24 +index scan update without PK +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT NOT NULL, +b INT DEFAULT 10, +c INT DEFAULT 11, +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +UPDATE ta_l_int SET c = 4 WHERE b = 2; +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +1 2 4 +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 +17 2 4 + +2.25 +direct order limit +SHOW STATUS LIKE 'Spider_direct_order_limit'; +Variable_name Value +Spider_direct_order_limit 0 +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +a b c +1 2 4 +2 3 4 +4 5 6 +SHOW STATUS LIKE 'Spider_direct_order_limit'; +Variable_name Value +Spider_direct_order_limit 0 + +2.26 +lock tables +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1 +CREATE TABLE t2 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2 +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + +auto_increment +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t1; +MAX(id) +2331 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT MAX(id) FROM t1; +MAX(id) +3108 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +SELECT id FROM t1 ORDER BY id; +id +777 +1000 +1554 +2331 +3108 +3885 +4662 +5000 +5439 +6216 +10000 + +auto_increment with partition +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t1; +MAX(id) +2331 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT MAX(id) FROM t1; +MAX(id) +3108 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +SELECT id FROM t1 ORDER BY id; +id +777 +1000 +1554 +2331 +3108 +3885 +4662 +5000 +5439 +6216 +10000 + +read only +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1 +SELECT id FROM t1 ORDER BY id; +id +1000 +1554 +3108 +4662 +5000 +6216 +10000 +INSERT INTO t1 (id) VALUES (1); +ERROR HY000: Table 'auto_test_local.t1' is read only +UPDATE t1 SET id = 4 WHERE id = 1000; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1 WHERE id = 1000; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1; +ERROR HY000: Table 'auto_test_local.t1' is read only +TRUNCATE t1; +ERROR HY000: Table 'auto_test_local.t1' is read only + +2.27 +error mode +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1 +SELECT id FROM t1 ORDER BY id; +id +Warnings: +Error 12702 Remote table 'auto_test_remote.ter1_1' is not found +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +INSERT INTO t1 (id) VALUES (1); +Warnings: +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +DELETE FROM t1; +Warnings: +Error 12702 Remote table 'auto_test_remote.ter1_1' is not found +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +TRUNCATE t1; +Warnings: +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist + +3.0 +is null +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +a VARCHAR(255), +b VARCHAR(255), +c VARCHAR(255), +KEY idx1(a,b), +KEY idx2(b), +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1 +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +select a from t1 where a is null order by a limit 30; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +select b from t1 where b is null order by b limit 30; +b +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL + +direct_order_limit +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +a b c +10 74 74 +10 42 42 +10 234 234 +10 202 202 +10 170 170 +select a, c from t1 where a = '10' order by b desc limit 5; +a c +10 74 +10 42 +10 234 +10 202 +10 170 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/bg/r/vp_fixes.result b/storage/spider/mysql-test/spider/bg/r/vp_fixes.result new file mode 100644 index 00000000000..15dd29aa4d3 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/vp_fixes.result @@ -0,0 +1,80 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +0.9 +create different primary key table +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT AUTO_INCREMENT, +c INT DEFAULT 11, +PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +create un-correspond primary key table +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT DEFAULT 12, +c INT DEFAULT 11, +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/bg/suite.opt b/storage/spider/mysql-test/spider/bg/suite.opt new file mode 100644 index 00000000000..48457b17309 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/suite.opt @@ -0,0 +1 @@ +--loose-innodb diff --git a/storage/spider/mysql-test/spider/bg/suite.pm b/storage/spider/mysql-test/spider/bg/suite.pm new file mode 100644 index 00000000000..5569c57bec9 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/suite.pm @@ -0,0 +1,9 @@ +package My::Suite::Spider; + +@ISA = qw(My::Suite); + +return "No Spider engine" unless $ENV{HA_SPIDER_SO}; +return "Not run for embedded server" if $::opt_embedded_server; + +bless { }; + diff --git a/storage/spider/mysql-test/spider/bg/t/basic_sql.test b/storage/spider/mysql-test/spider/bg/t/basic_sql.test new file mode 100644 index 00000000000..2264b0e4e37 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/basic_sql.test @@ -0,0 +1,3189 @@ +# This test tests by executing basic SQL +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'f', '2008-07-01 10:21:39'), + (2, 'g', '2000-02-01 00:00:00'), + (3, 'j', '2007-05-04 20:03:11'), + (4, 'i', '2003-10-30 05:01:03'), + (5, 'h', '2001-10-31 23:59:59'); +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT IGNORE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + REPLACE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table with partition and select test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + } + --enable_query_log + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo create no index table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_no_idx; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_NEEDPK) +{ + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + } +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES3; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; + +--echo +--echo select table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table shared mode +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table for update +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table straight_join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_small_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_big_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_buffer_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_no_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_calc_found_rows +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT found_rows(); + +--echo +--echo select high_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select distinct +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select count +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT count(*) FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join not use index +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using index and pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select partition using pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo select partition using index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.a > 0 AND a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo insert +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select a +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert low_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert high_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (insert) +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (update) +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace +--connection master_1 +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update index pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update partition pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo update partition index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete all +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE IGNORE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE QUICK FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete partition pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete partition index pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo truncate +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bg/t/connect_child2_1.inc b/storage/spider/mysql-test/spider/bg/t/connect_child2_1.inc new file mode 100644 index 00000000000..cd9b0c9ca9b --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/connect_child2_1.inc @@ -0,0 +1 @@ +--connect (child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/bg/t/connect_child2_2.inc b/storage/spider/mysql-test/spider/bg/t/connect_child2_2.inc new file mode 100644 index 00000000000..e145f66b630 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/connect_child2_2.inc @@ -0,0 +1 @@ +--connect (child2_2, localhost, root, , , $CHILD2_2_MYPORT, $CHILD2_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/bg/t/connect_child2_3.inc b/storage/spider/mysql-test/spider/bg/t/connect_child2_3.inc new file mode 100644 index 00000000000..d356348d8ea --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/connect_child2_3.inc @@ -0,0 +1 @@ +--connect (child2_3, localhost, root, , , $CHILD2_3_MYPORT, $CHILD2_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/bg/t/connect_child3_1.inc b/storage/spider/mysql-test/spider/bg/t/connect_child3_1.inc new file mode 100644 index 00000000000..03e5c188c89 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/connect_child3_1.inc @@ -0,0 +1 @@ +--connect (child3_1, localhost, root, , , $CHILD3_1_MYPORT, $CHILD3_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/bg/t/connect_child3_2.inc b/storage/spider/mysql-test/spider/bg/t/connect_child3_2.inc new file mode 100644 index 00000000000..d62a7ada824 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/connect_child3_2.inc @@ -0,0 +1 @@ +--connect (child3_2, localhost, root, , , $CHILD3_2_MYPORT, $CHILD3_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/bg/t/connect_child3_3.inc b/storage/spider/mysql-test/spider/bg/t/connect_child3_3.inc new file mode 100644 index 00000000000..fb49f5bfdac --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/connect_child3_3.inc @@ -0,0 +1 @@ +--connect (child3_3, localhost, root, , , $CHILD3_3_MYPORT, $CHILD3_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/bg/t/connect_master_1.inc b/storage/spider/mysql-test/spider/bg/t/connect_master_1.inc new file mode 100644 index 00000000000..0c129ce5775 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/connect_master_1.inc @@ -0,0 +1 @@ +--connect (master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/bg/t/connect_slave1_1.inc b/storage/spider/mysql-test/spider/bg/t/connect_slave1_1.inc new file mode 100644 index 00000000000..45a822743e0 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/connect_slave1_1.inc @@ -0,0 +1 @@ +--connect (slave1_1, localhost, root, , , $SLAVE1_1_MYPORT, $SLAVE1_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/bg/t/direct_aggregate.test b/storage/spider/mysql-test/spider/bg/t/direct_aggregate.test new file mode 100644 index 00000000000..59c45f3f190 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/direct_aggregate.test @@ -0,0 +1,316 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_aggregating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT COUNT(*) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l WHERE a < 5; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l WHERE a > 1; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT COUNT(*) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2 WHERE a < 5; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2 WHERE a > 1; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bg/t/direct_update.test b/storage/spider/mysql-test/spider/bg/t/direct_update.test new file mode 100644 index 00000000000..1c3ce91ff3f --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/direct_update.test @@ -0,0 +1,354 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_updating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key +DELETE FROM ta_l WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update all rows with function + UPDATE ta_l2 SET c = ADDDATE(c, 1); + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key + UPDATE ta_l2 SET b = 'x' WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by a column without index + UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key with order and limit + UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key with order and limit + DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by a column without index + DELETE FROM ta_l2 WHERE b = 'c'; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key + DELETE FROM ta_l2 WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bg/t/function.test b/storage/spider/mysql-test/spider/bg/t/function.test new file mode 100644 index 00000000000..2b1b53c8a4f --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/function.test @@ -0,0 +1,276 @@ +# This test tests for using functions +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo in() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_PK_TABLES1; + echo CHILD2_1_CREATE_TEXT_PK_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_PK_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_PK_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET3 $MASTER_1_COMMENT_TEXT_PK1_1; +--enable_query_log +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a in ('15', '120'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo date_sub() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bg/t/ha.test b/storage/spider/mysql-test/spider/bg/t/ha.test new file mode 100644 index 00000000000..319b1793753 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/ha.test @@ -0,0 +1,1794 @@ +# This test tests for ha features +--let $SKIP_REASON= +if ($USE_HA_TEST) +{ +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source ha_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + CREATE DATABASE auto_test_remote3; + USE auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + } + if ($USE_CHILD_GROUP3) + { + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + } + --disable_query_log + --disable_result_log + --source ha_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + --connection child2_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + SELECT 1; + --connection child3_2 + SELECT 1; + --connection child3_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_2_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_CREATE_TABLES; + } + eval $CHILD2_2_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_RECOVERY_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_COPY_TABLES_2_1; +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_3_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_CREATE_TABLES; + } + eval $CHILD2_3_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_COPY_TABLES_P_2_1; + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo active standby test +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_AS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES2; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES2; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES2; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_AS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; +} +--disable_query_log +--disable_result_log +--source ha_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +} +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bg/t/ha_test_deinit.inc b/storage/spider/mysql-test/spider/bg/t/ha_test_deinit.inc new file mode 100644 index 00000000000..53d0409d066 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/ha_test_deinit.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_deinit_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_deinit_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_deinit_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_deinit_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/bg/t/ha_test_init.inc b/storage/spider/mysql-test/spider/bg/t/ha_test_init.inc new file mode 100644 index 00000000000..70576ab16dc --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/ha_test_init.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_init_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_init_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_init_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_init_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/bg/t/have_engine.inc b/storage/spider/mysql-test/spider/bg/t/have_engine.inc new file mode 100644 index 00000000000..64bef7499cb --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/have_engine.inc @@ -0,0 +1,7 @@ +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = '$TEST_ENGINE_TYPE'`) +{ + SELECT engine, support FROM information_schema.engines; + --let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine" +} diff --git a/storage/spider/mysql-test/spider/bg/t/have_func.inc b/storage/spider/mysql-test/spider/bg/t/have_func.inc new file mode 100644 index 00000000000..e0823e73fc8 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/have_func.inc @@ -0,0 +1,5 @@ +if (!`SELECT count(*) FROM mysql.func WHERE name = '$TEST_FUNC_NAME'`) +{ + SELECT name FROM mysql.func; + --let $SKIP_REASON= "Need $TEST_FUNC_NAME function" +} diff --git a/storage/spider/mysql-test/spider/bg/t/have_partition.inc b/storage/spider/mysql-test/spider/bg/t/have_partition.inc new file mode 100644 index 00000000000..573c76ab43b --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/have_partition.inc @@ -0,0 +1,7 @@ +let $HAVE_PARTITION= 0; +if (`SELECT count(*) FROM information_schema.plugins WHERE + plugin_status = 'ACTIVE' AND + plugin_name = 'partition'`) +{ + let $HAVE_PARTITION= 1; +} diff --git a/storage/spider/mysql-test/spider/bg/t/have_trigger.inc b/storage/spider/mysql-test/spider/bg/t/have_trigger.inc new file mode 100644 index 00000000000..10c0871dd5f --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/have_trigger.inc @@ -0,0 +1,2 @@ +let $HAVE_TRIGGER= `SELECT COUNT(*) FROM information_schema.tables + WHERE TABLE_SCHEMA = 'information_schema' AND TABLE_NAME = 'TRIGGERS'`; diff --git a/storage/spider/mysql-test/spider/bg/t/hs_test_deinit.inc b/storage/spider/mysql-test/spider/bg/t/hs_test_deinit.inc new file mode 100644 index 00000000000..7ec2e981fd2 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/hs_test_deinit.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_deinit_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/bg/t/hs_test_init.inc b/storage/spider/mysql-test/spider/bg/t/hs_test_init.inc new file mode 100644 index 00000000000..831bf479524 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/hs_test_init.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_init_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/bg/t/slave_test_deinit.inc b/storage/spider/mysql-test/spider/bg/t/slave_test_deinit.inc new file mode 100644 index 00000000000..e9d99b7a960 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/slave_test_deinit.inc @@ -0,0 +1,6 @@ +# get connection and exist engine test +--echo for slave1_1 +--connection slave1_1 +STOP SLAVE; +--source ../include/deinit_slave1_1.inc +--disconnect slave1_1 diff --git a/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc b/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc new file mode 100644 index 00000000000..739d88970c5 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc @@ -0,0 +1,44 @@ +# get connection and exist engine test +--echo for slave1_1 +--source connect_slave1_1.inc +--connection slave1_1 +SET SESSION sql_log_bin= 0; +--let $SLAVE1_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $SLAVE1_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_slave1_1.inc +--source have_engine.inc +--let $SLAVE1_1_SLAVE_STATUS=`SHOW SLAVE STATUS` +if (!$SLAVE1_1_SLAVE_STATUS) +{ + eval CHANGE MASTER TO + MASTER_HOST = '127.0.0.1', + MASTER_USER = 'root', + MASTER_PASSWORD = '', + MASTER_PORT = $MASTER_1_MYPORT + ; +} +START SLAVE; +--connection master_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +--connection slave1_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} diff --git a/storage/spider/mysql-test/spider/bg/t/spider3_fixes.test b/storage/spider/mysql-test/spider/bg/t/spider3_fixes.test new file mode 100644 index 00000000000..4139f3af955 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/spider3_fixes.test @@ -0,0 +1,570 @@ +# This test tests for Spider 3.0's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo 3.1 +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +SET INSERT_ID=5000; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + TRUNCATE TABLE t1; + TRUNCATE TABLE t2; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + SET INSERT_ID=5000; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bg/t/spider_fixes.test b/storage/spider/mysql-test/spider/bg/t/spider_fixes.test new file mode 100644 index 00000000000..b9ff61abcb4 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/spider_fixes.test @@ -0,0 +1,1967 @@ +# This test tests for Spider's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 2.13 +--echo select table with "order by desc" and "<" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table with "order by desc" and "<=" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.14 +--echo update table with range scan and split_read +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo 2.15 +--echo select table with range scan +TRUNCATE TABLE ta_l; +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_CREATE_TABLES6; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES6; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES6; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.16 +--echo auto_increment insert with trigger +if ($HAVE_TRIGGER) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_CREATE_TABLES4; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES4; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES4; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; + eval CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; + echo CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE2 MASTER_1_CHARSET2; + eval CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; + --enable_query_log + --eval CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + INSERT INTO ta_l_auto_inc (a, b, c) VALUES + (NULL, 's', '2008-12-31 20:59:59'); + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES4; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +} + +--echo +--echo 2.17 +--echo engine-condition-pushdown with "or" and joining +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo partition with sort +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 + ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.23 +--echo partition update with moving partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); + UPDATE ta_l2 SET a = 4 WHERE a = 3; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo index merge +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo index merge with partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l_int; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_2_DROP_TABLES5; + echo CHILD2_2_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES5; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES5; + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1; + eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_P_2_1; + --enable_query_log + INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); + INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) + WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.24 +--echo index scan update without PK +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +if (!$MASTER_1_NEEDPK) +{ + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +--enable_query_log +SELECT a, b, c FROM ta_l_int ORDER BY a; +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l_int SET c = 4 WHERE b = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; + + +--echo +--echo 2.25 +--echo direct order limit +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; + + +--echo +--echo 2.26 +--echo lock tables +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_LOCK_TABLES1; + echo CHILD2_1_DROP_LOCK_TABLES2; + echo CHILD2_1_CREATE_LOCK_TABLES1; + echo CHILD2_1_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_LOCK_TABLES1; + eval $CHILD2_1_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_LOCK_TABLES1; + eval $CHILD2_1_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_LOCK_TABLES1; + echo CHILD2_2_DROP_LOCK_TABLES2; + echo CHILD2_2_CREATE_LOCK_TABLES1; + echo CHILD2_2_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_2_DROP_LOCK_TABLES1; + eval $CHILD2_2_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_2_CREATE_LOCK_TABLES1; + eval $CHILD2_2_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1; +eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2; +eval CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK2; +--enable_query_log +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + + +--echo +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + SET INSERT_ID=5000; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo read only +let $MASTER_1_ENGINE_IS_SPIDER= + `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'Spider' OR + '$MASTER_1_HIDDEN_ENGINE_TYPE' = 'Spider', 1, 0)`; +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_READONLY1_1; + --let $MIN_VAL= `SELECT MIN(id) FROM t1` + --enable_query_log + SELECT id FROM t1 ORDER BY id; + --error 12518 + INSERT INTO t1 (id) VALUES (1); + --error 12518 + eval UPDATE t1 SET id = 4 WHERE id = $MIN_VAL; + --error 12518 + eval DELETE FROM t1 WHERE id = $MIN_VAL; + --error 12518 + DELETE FROM t1; + --error 12518 + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 2.27 +--echo error mode +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_ERROR_MODE1_1; + --enable_query_log + SELECT id FROM t1 ORDER BY id; + INSERT INTO t1 (id) VALUES (1); + DELETE FROM t1; + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 3.0 +--echo is null +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_KEY_TABLES1; + echo CHILD2_1_CREATE_TEXT_KEY_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_KEY_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_KEY_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_TEXT_KEY1_1; +--enable_query_log +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a is null order by a limit 30; +select b from t1 where b is null order by b limit 30; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo direct_order_limit +--connection master_1 +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +select a, c from t1 where a = '10' order by b desc limit 5; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bg/t/test_deinit.inc b/storage/spider/mysql-test/spider/bg/t/test_deinit.inc new file mode 100644 index 00000000000..989bde26d3c --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/test_deinit.inc @@ -0,0 +1,37 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/deinit_master_1.inc +--disconnect master_1 +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/deinit_child2_1.inc + --disconnect child2_1 + --echo child2_2 + --connection child2_2 + --source ../include/deinit_child2_2.inc + --disconnect child2_2 + --echo child2_3 + --connection child2_3 + --source ../include/deinit_child2_3.inc + --disconnect child2_3 +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/deinit_child3_1.inc + --disconnect child3_1 + --echo child3_2 + --connection child3_2 + --source ../include/deinit_child3_2.inc + --disconnect child3_2 + --echo child3_3 + --connection child3_3 + --source ../include/deinit_child3_3.inc + --disconnect child3_3 +} diff --git a/storage/spider/mysql-test/spider/bg/t/test_init.inc b/storage/spider/mysql-test/spider/bg/t/test_init.inc new file mode 100644 index 00000000000..f2cd6c0269f --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/test_init.inc @@ -0,0 +1,74 @@ +# get connection and exist engine test +--echo for master_1 +--source connect_master_1.inc +--connection master_1 +CALL mtr.add_suppression("unknown variable"); +SET SESSION sql_log_bin= 0; +--let $MASTER_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $MASTER_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_master_1.inc +--source have_engine.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --source connect_child2_1.inc + --connection child2_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE + --source ../include/init_child2_1.inc + --source have_engine.inc + --echo child2_2 + --source connect_child2_2.inc + --connection child2_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE + --source ../include/init_child2_2.inc + --source have_engine.inc + --echo child2_3 + --source connect_child2_3.inc + --connection child2_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE + --source ../include/init_child2_3.inc + --source have_engine.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --source connect_child3_1.inc + --connection child3_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE + --source ../include/init_child3_1.inc + --source have_engine.inc + --echo child3_2 + --source connect_child3_2.inc + --connection child3_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE + --source ../include/init_child3_2.inc + --source have_engine.inc + --echo child3_3 + --source connect_child3_3.inc + --connection child3_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE + --source ../include/init_child3_3.inc + --source have_engine.inc +} diff --git a/storage/spider/mysql-test/spider/bg/t/vp_fixes.test b/storage/spider/mysql-test/spider/bg/t/vp_fixes.test new file mode 100644 index 00000000000..46e7b0afc36 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/t/vp_fixes.test @@ -0,0 +1,358 @@ +# This test tests for VP's bug fixes +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 0.9 +--echo create different primary key table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--let $MASTER_1_IS_VP= `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'VP', 1, 0)` +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo create un-correspond primary key table +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/handler/include/deinit_child2_1.inc b/storage/spider/mysql-test/spider/handler/include/deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/deinit_child2_2.inc b/storage/spider/mysql-test/spider/handler/include/deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/deinit_child2_3.inc b/storage/spider/mysql-test/spider/handler/include/deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/deinit_child3_1.inc b/storage/spider/mysql-test/spider/handler/include/deinit_child3_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/deinit_child3_2.inc b/storage/spider/mysql-test/spider/handler/include/deinit_child3_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/deinit_child3_3.inc b/storage/spider/mysql-test/spider/handler/include/deinit_child3_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/deinit_master_1.inc b/storage/spider/mysql-test/spider/handler/include/deinit_master_1.inc new file mode 100644 index 00000000000..c19e376d10a --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/deinit_master_1.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/handler/include/deinit_slave1_1.inc b/storage/spider/mysql-test/spider/handler/include/deinit_slave1_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_1.inc b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_2.inc b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_3.inc b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_1.inc b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_1.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_1.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_2.inc b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_2.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_2.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_3.inc b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_3.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_deinit_child3_3.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/handler/include/ha_deinit_master_1.inc b/storage/spider/mysql-test/spider/handler/include/ha_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/ha_init_child2_1.inc b/storage/spider/mysql-test/spider/handler/include/ha_init_child2_1.inc new file mode 100644 index 00000000000..59c0175d349 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_init_child2_1.inc @@ -0,0 +1,8 @@ +let $CHILD2_1_HA_AS_DROP_TABLES= + $CHILD2_1_DROP_TABLES; +let $CHILD2_1_HA_AS_CREATE_TABLES= + $CHILD2_1_CREATE_TABLES; +let $CHILD2_1_HA_AS_DROP_TABLES2= + $CHILD2_1_DROP_TABLES2; +let $CHILD2_1_HA_AS_CREATE_TABLES2= + $CHILD2_1_CREATE_TABLES2; diff --git a/storage/spider/mysql-test/spider/handler/include/ha_init_child2_2.inc b/storage/spider/mysql-test/spider/handler/include/ha_init_child2_2.inc new file mode 100644 index 00000000000..90d27ed704d --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_init_child2_2.inc @@ -0,0 +1,4 @@ +let $CHILD2_2_HA_DROP_TABLES= + $CHILD2_2_DROP_TABLES; +let $CHILD2_2_HA_CREATE_TABLES= + $CHILD2_2_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/handler/include/ha_init_child2_3.inc b/storage/spider/mysql-test/spider/handler/include/ha_init_child2_3.inc new file mode 100644 index 00000000000..11abf112b1f --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_init_child2_3.inc @@ -0,0 +1,4 @@ +let $CHILD2_3_HA_DROP_TABLES= + $CHILD2_3_DROP_TABLES; +let $CHILD2_3_HA_CREATE_TABLES= + $CHILD2_3_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/handler/include/ha_init_child3_1.inc b/storage/spider/mysql-test/spider/handler/include/ha_init_child3_1.inc new file mode 100644 index 00000000000..56de7df4e52 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_init_child3_1.inc @@ -0,0 +1,140 @@ +--let $CHILD3_1_ENGINE_TYPE=Spider +--let $CHILD3_1_ENGINE=ENGINE=Spider +--source ../../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_1_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_1_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_1_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/handler/include/ha_init_child3_2.inc b/storage/spider/mysql-test/spider/handler/include/ha_init_child3_2.inc new file mode 100644 index 00000000000..fdb3a84cca7 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_init_child3_2.inc @@ -0,0 +1,140 @@ +--let $CHILD3_2_ENGINE_TYPE=Spider +--let $CHILD3_2_ENGINE=ENGINE=Spider +--source ../../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_2_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_2_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_2_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_2_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_2_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_2_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_2_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_2_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_2_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_2_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/handler/include/ha_init_child3_3.inc b/storage/spider/mysql-test/spider/handler/include/ha_init_child3_3.inc new file mode 100644 index 00000000000..d08ff4d0d34 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_init_child3_3.inc @@ -0,0 +1,140 @@ +--let $CHILD3_3_ENGINE_TYPE=Spider +--let $CHILD3_3_ENGINE=ENGINE=Spider +--source ../../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_3_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_3_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_3_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_3_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_3_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_3_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_3_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_3_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_3_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_3_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/handler/include/ha_init_master_1.inc b/storage/spider/mysql-test/spider/handler/include/ha_init_master_1.inc new file mode 100644 index 00000000000..78797d80ce7 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/ha_init_master_1.inc @@ -0,0 +1,105 @@ +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $MASTER_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $MASTER_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $MASTER_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $MASTER_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $MASTER_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; +let $MASTER_1_COPY_TABLES_2_1= + SELECT spider_copy_tables('ta_l', '0', '1'); + +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $MASTER_1_COMMENT_HA_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_COMMENT_HA_AS_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $MASTER_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $MASTER_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +let $MASTER_1_COPY_TABLES_P_2_1= + SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +let $MASTER_1_CHECK_HA_STATUS= + SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +let $MASTER_1_CHANGE_HA_MON= + SELECT spider_flush_table_mon_cache(); diff --git a/storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_1.inc b/storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_2.inc b/storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_3.inc b/storage/spider/mysql-test/spider/handler/include/hs_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/hs_deinit_master_1.inc b/storage/spider/mysql-test/spider/handler/include/hs_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/hs_init_child2_1.inc b/storage/spider/mysql-test/spider/handler/include/hs_init_child2_1.inc new file mode 100644 index 00000000000..2ea1c0c9cd6 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/hs_init_child2_1.inc @@ -0,0 +1,24 @@ +let $CHILD2_1_HS_DROP_TABLES= + DROP TABLE IF EXISTS hs_r; +let $CHILD2_1_HS_CREATE_TABLES= + CREATE TABLE hs_r ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_HS_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r ORDER BY a; +let $CHILD2_1_HS_DROP_TABLES2= + DROP TABLE IF EXISTS hs_r2; +let $CHILD2_1_HS_CREATE_TABLES2= + CREATE TABLE hs_r2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_HS_SELECT_TABLES2= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r2 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/handler/include/hs_init_child2_2.inc b/storage/spider/mysql-test/spider/handler/include/hs_init_child2_2.inc new file mode 100644 index 00000000000..7c69d73ced6 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/hs_init_child2_2.inc @@ -0,0 +1,12 @@ +let $CHILD2_2_HS_DROP_TABLES= + DROP TABLE IF EXISTS hs_r3; +let $CHILD2_2_HS_CREATE_TABLES= + CREATE TABLE hs_r3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_HS_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r3 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/handler/include/hs_init_child2_3.inc b/storage/spider/mysql-test/spider/handler/include/hs_init_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/hs_init_master_1.inc b/storage/spider/mysql-test/spider/handler/include/hs_init_master_1.inc new file mode 100644 index 00000000000..0ff5e2a10d9 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/hs_init_master_1.inc @@ -0,0 +1,12 @@ +let $MASTER_1_HS_COMMENT_TMP= + COMMENT=''; +let $MASTER_1_HS_COMMENT_2_1= + COMMENT='srv "s_2_1", table "hs_r", uhr "1", uhw "1", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"'; +let $MASTER_1_HS_COMMENT_P_2_1= + COMMENT='uhr "1", uhw "1"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) + COMMENT='srv "s_2_1", table "hs_r2", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", table "hs_r3", hrp "$CHILD2_2_HSRPORT", hwp "$CHILD2_2_HSWPORT"' + ); diff --git a/storage/spider/mysql-test/spider/handler/include/init_child2_1.inc b/storage/spider/mysql-test/spider/handler/include/init_child2_1.inc new file mode 100644 index 00000000000..7773f0e2dde --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/init_child2_1.inc @@ -0,0 +1,176 @@ +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS ta_r; +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE ta_r ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +let $CHILD2_1_DROP_TABLES2= + DROP TABLE IF EXISTS ta_r2; +let $CHILD2_1_CREATE_TABLES2= + CREATE TABLE ta_r2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES2= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r2 ORDER BY a; +let $CHILD2_1_DROP_TABLES3= + DROP TABLE IF EXISTS ta_r_no_idx; +let $CHILD2_1_CREATE_TABLES3= + CREATE TABLE ta_r_no_idx ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES3= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_no_idx ORDER BY a; +let $CHILD2_1_DROP_TABLES4= + DROP TABLE IF EXISTS ta_r_auto_inc; +let $CHILD2_1_CREATE_TABLES4= + CREATE TABLE ta_r_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES4= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_auto_inc + ORDER BY a; +let $CHILD2_1_DROP_TABLES5= + DROP TABLE IF EXISTS ta_r_int; +let $CHILD2_1_CREATE_TABLES5= + CREATE TABLE ta_r_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES5= + SELECT a, b, c FROM ta_r_int ORDER BY a; +let $CHILD2_1_DROP_TABLES6= + DROP TABLE IF EXISTS ta_r_3; +let $CHILD2_1_CREATE_TABLES6= + CREATE TABLE ta_r_3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES6= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_3 ORDER BY a; +let $CHILD2_1_DROP_FT_TABLES= + DROP TABLE IF EXISTS ft_r; +let $CHILD2_1_CREATE_FT_TABLES= + CREATE TABLE ft_r ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET; +let $CHILD2_1_SELECT_FT_TABLES= + SELECT a, b, c, d FROM ft_r ORDER BY a; +let $CHILD2_1_DROP_FT_TABLES2= + DROP TABLE IF EXISTS ft_r2; +let $CHILD2_1_CREATE_FT_TABLES2= + CREATE TABLE ft_r2 ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET; +let $CHILD2_1_SELECT_FT_TABLES2= + SELECT a, b, c, d FROM ft_r2 ORDER BY a; +let $CHILD2_1_DROP_GM_TABLES= + DROP TABLE IF EXISTS gm_r; +let $CHILD2_1_CREATE_GM_TABLES= + CREATE TABLE gm_r ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET; +let $CHILD2_1_SELECT_GM_TABLES= + SELECT a, b, c FROM gm_r ORDER BY a; +let $CHILD2_1_DROP_GM_TABLES2= + DROP TABLE IF EXISTS gm_r2; +let $CHILD2_1_CREATE_GM_TABLES2= + CREATE TABLE gm_r2 ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET; +let $CHILD2_1_SELECT_GM_TABLES2= + SELECT a, b, c FROM gm_r2 ORDER BY a; +let $CHILD2_1_DROP_LOCK_TABLES1= + DROP TABLE IF EXISTS t1_1; +let $CHILD2_1_CREATE_LOCK_TABLES1= + CREATE TABLE t1_1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_DROP_LOCK_TABLES2= + DROP TABLE IF EXISTS t2_2; +let $CHILD2_1_CREATE_LOCK_TABLES2= + CREATE TABLE t2_2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_DROP_INCREMENT_TABLES1= + DROP TABLE IF EXISTS t1_1; +let $CHILD2_1_CREATE_INCREMENT_TABLES1= + CREATE TABLE t1_1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_INCREMENT_TABLES1= + SELECT id FROM t1_1 ORDER BY id; +let $CHILD2_1_DROP_TEXT_PK_TABLES1= + DROP TABLE IF EXISTS t1; +let $CHILD2_1_CREATE_TEXT_PK_TABLES1= + CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY (a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET2; +let $CHILD2_1_SELECT_TEXT_PK_TABLES1= + SELECT a FROM t1 ORDER BY a; +let $CHILD2_1_DROP_TEXT_KEY_TABLES1= + DROP TABLE IF EXISTS t1; +let $CHILD2_1_CREATE_TEXT_KEY_TABLES1= + CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TEXT_KEY_TABLES1= + SELECT a, b FROM t1 ORDER BY a, b; +let $CHILD2_1_AUTO_INCREMENT_INCREMENT1= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 1; +let $CHILD2_1_AUTO_INCREMENT_INCREMENT2= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 4; +let $CHILD2_1_AUTO_INCREMENT_OFFSET1= + SET GLOBAL AUTO_INCREMENT_OFFSET = 1; +let $CHILD2_1_AUTO_INCREMENT_OFFSET2= + SET GLOBAL AUTO_INCREMENT_OFFSET = 2; diff --git a/storage/spider/mysql-test/spider/handler/include/init_child2_2.inc b/storage/spider/mysql-test/spider/handler/include/init_child2_2.inc new file mode 100644 index 00000000000..3524fc4a2b7 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/init_child2_2.inc @@ -0,0 +1,80 @@ +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS ta_r3; +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE ta_r3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_TABLES5= + DROP TABLE IF EXISTS ta_r_int; +let $CHILD2_2_CREATE_TABLES5= + CREATE TABLE ta_r_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r3 ORDER BY a; +let $CHILD2_2_DROP_FT_TABLES= + DROP TABLE IF EXISTS ft_r3; +let $CHILD2_2_CREATE_FT_TABLES= + CREATE TABLE ft_r3 ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_2_FT_ENGINE $CHILD2_2_FT_CHARSET; +let $CHILD2_2_SELECT_FT_TABLES= + SELECT a, b, c, d FROM ft_r3 ORDER BY a; +let $CHILD2_2_DROP_GM_TABLES= + DROP TABLE IF EXISTS gm_r3; +let $CHILD2_2_CREATE_GM_TABLES= + CREATE TABLE gm_r3 ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_2_GM_ENGINE $CHILD2_2_GM_CHARSET; +let $CHILD2_2_SELECT_GM_TABLES= + SELECT a, b, c FROM gm_r3 ORDER BY a; +let $CHILD2_2_DROP_LOCK_TABLES1= + DROP TABLE IF EXISTS t1_2; +let $CHILD2_2_CREATE_LOCK_TABLES1= + CREATE TABLE t1_2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_LOCK_TABLES2= + DROP TABLE IF EXISTS t2_1; +let $CHILD2_2_CREATE_LOCK_TABLES2= + CREATE TABLE t2_1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_INCREMENT_TABLES1= + DROP TABLE IF EXISTS t1_2; +let $CHILD2_2_CREATE_INCREMENT_TABLES1= + CREATE TABLE t1_2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_SELECT_INCREMENT_TABLES1= + SELECT id FROM t1_2 ORDER BY id; +let $CHILD2_2_AUTO_INCREMENT_INCREMENT1= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 1; +let $CHILD2_2_AUTO_INCREMENT_INCREMENT2= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 4; +let $CHILD2_2_AUTO_INCREMENT_OFFSET1= + SET GLOBAL AUTO_INCREMENT_OFFSET = 1; +let $CHILD2_2_AUTO_INCREMENT_OFFSET2= + SET GLOBAL AUTO_INCREMENT_OFFSET = 3; diff --git a/storage/spider/mysql-test/spider/handler/include/init_child2_3.inc b/storage/spider/mysql-test/spider/handler/include/init_child2_3.inc new file mode 100644 index 00000000000..d857a787ac0 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/init_child2_3.inc @@ -0,0 +1,11 @@ +let $CHILD2_3_DROP_TABLES= + DROP TABLE IF EXISTS ta_r4; +let $CHILD2_3_CREATE_TABLES= + CREATE TABLE ta_r4 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_3_ENGINE $CHILD2_3_CHARSET; +let $CHILD2_3_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r4 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/handler/include/init_child3_1.inc b/storage/spider/mysql-test/spider/handler/include/init_child3_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/init_child3_2.inc b/storage/spider/mysql-test/spider/handler/include/init_child3_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/init_child3_3.inc b/storage/spider/mysql-test/spider/handler/include/init_child3_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/handler/include/init_master_1.inc b/storage/spider/mysql-test/spider/handler/include/init_master_1.inc new file mode 100644 index 00000000000..9c487bc73fe --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/init_master_1.inc @@ -0,0 +1,186 @@ +--source ../../include/init_spider.inc +SET spider_internal_sql_log_off= 0; +SET spider_use_handler= 3; +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_2_1= + COMMENT='database "auto_test_remote", table "ta_r"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_2_1= + COMMENT='database "auto_test_remote", table "ta_r"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT2_2_1= + COMMENT='database "auto_test_remote", table "ta_r_no_idx"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password "", prt "2000000"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT2_2_1= + COMMENT='database "auto_test_remote", table "ta_r_no_idx"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password "", prt "2000000"'; +} +let $MASTER_1_COMMENT_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1", table "ta_r2", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT2_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ta_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT3_2_1= + COMMENT='database "auto_test_remote", table "ta_r_auto_inc"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT3_2_1= + COMMENT='database "auto_test_remote", table "ta_r_auto_inc"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +let $MASTER_1_COMMENT3_P_2_1= + COMMENT='table "ta_r_int"' + PARTITION BY LIST(MOD(a, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='srv "s_2_1", priority "1000"', + PARTITION pt2 VALUES IN (1) + COMMENT='srv "s_2_2", priority "1000001"' + ); +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT4_2_1= + COMMENT='database "auto_test_remote", table "ta_r_int"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT4_2_1= + COMMENT='database "auto_test_remote", table "ta_r_int"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT5_2_1= + COMMENT='database "auto_test_remote", table "ta_r_3"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT5_2_1= + COMMENT='database "auto_test_remote", table "ta_r_3"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_FT_2_1= + COMMENT='database "auto_test_remote", table "ft_r"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_FT_2_1= + COMMENT='database "auto_test_remote", table "ft_r"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +let $MASTER_1_COMMENT2_FT_P_2_1= + COMMENT='table "ft_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ft_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT_GM_2_1= + COMMENT='srv "s_2_1", table "gm_r"'; +let $MASTER_1_COMMENT2_GM_P_2_1= + COMMENT='table "gm_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "gm_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT_LOCK1= + COMMENT 'tbl "t1_1 t1_2", srv "s_2_1 s_2_2"'; +let $MASTER_1_COMMENT_LOCK2= + COMMENT 'tbl "t2_1 t2_2", srv "s_2_2 s_2_1"'; +let $MASTER_1_COMMENT_INCREMENT1_1= + COMMENT 'aim "2", tbl "t1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_INCREMENT1_P_1= + COMMENT 'aim "2"' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='tbl "t1_1", srv "s_2_1"', + PARTITION pt2 VALUES IN (1) + COMMENT='tbl "t1_2", srv "s_2_2"' + ); +let $MASTER_1_COMMENT_READONLY1_1= + COMMENT 'read_only_mode "1", tbl "t1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_ERROR_MODE1_1= + COMMENT 'erm "1", ewm "1", tbl "ter1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_TEXT_PK1_1= + COMMENT 'tbl "t1", srv "s_2_1"'; +let $MASTER_1_COMMENT_TEXT_KEY1_1= + COMMENT 'tbl "t1", srv "s_2_1"'; +let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS= + SHOW STATUS LIKE 'Spider_direct_update'; +let $MASTER_1_CHECK_DIRECT_DELETE_STATUS= + SHOW STATUS LIKE 'Spider_direct_delete'; +let $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS= + SHOW STATUS LIKE 'Spider_direct_order_limit'; +let $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS= + SHOW STATUS LIKE 'Spider_direct_aggregate'; +let $MASTER_1_AUTO_INCREMENT_INCREMENT1= + SET SESSION AUTO_INCREMENT_INCREMENT = 1 $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_INCREMENT2= + SET SESSION AUTO_INCREMENT_INCREMENT = 777 $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET1= + SET SESSION AUTO_INCREMENT_OFFSET = 1 $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET2= + SET SESSION AUTO_INCREMENT_OFFSET = 777 $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET3= + SET SESSION AUTO_INCREMENT_OFFSET = 1; +let $MASTER_1_AUTO_INCREMENT_OFFSET4= + SET SESSION AUTO_INCREMENT_OFFSET = 777; diff --git a/storage/spider/mysql-test/spider/handler/include/init_slave1_1.inc b/storage/spider/mysql-test/spider/handler/include/init_slave1_1.inc new file mode 100644 index 00000000000..87c05f1f690 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/include/init_slave1_1.inc @@ -0,0 +1,10 @@ +let $SLAVE1_1_COMMENT_INCREMENT1_1= + COMMENT ''; +let $SLAVE1_1_COMMENT_INCREMENT1_P_1= + COMMENT '' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='', + PARTITION pt2 VALUES IN (1) + COMMENT='' + ); diff --git a/storage/spider/mysql-test/spider/handler/my.cnf b/storage/spider/mysql-test/spider/handler/my.cnf new file mode 100644 index 00000000000..6b79d0a8f87 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/my.cnf @@ -0,0 +1,176 @@ +# Use default setting for mysqld processes +!include include/default_mysqld.cnf + +[mysqld.1.1] +loose_handlersocket_port= 20000 +loose_handlersocket_port_wr= 20001 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 0 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 +loose_partition= 1 + +[mysqld.2.1] +loose_handlersocket_port= 20002 +loose_handlersocket_port_wr= 20003 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 0 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[mysqld.2.2] +loose_handlersocket_port= 20004 +loose_handlersocket_port_wr= 20005 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 0 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[mysqld.2.3] + +[mysqld.3.1] +loose_partition= 1 + +[mysqld.3.2] +loose_partition= 1 + +[mysqld.3.3] +loose_partition= 1 + +[mysqld.4.1] +loose_partition= 1 + + +[ENV] +USE_GEOMETRY_TEST= 1 +USE_FULLTEXT_TEST= 1 +USE_HA_TEST= 1 +USE_GENERAL_LOG= 1 +USE_REPLICATION= 1 +MASTER_1_MYPORT= @mysqld.1.1.port +MASTER_1_HSRPORT= 20000 +MASTER_1_HSWPORT= 20001 +MASTER_1_MYSOCK= @mysqld.1.1.socket +MASTER_1_ENGINE_TYPE= Spider +#MASTER_1_ENGINE_TYPE= MyISAM +MASTER_1_ENGINE= ENGINE=Spider +MASTER_1_CHARSET= DEFAULT CHARSET=utf8 +MASTER_1_ENGINE2= ENGINE=MyISAM +MASTER_1_CHARSET2= DEFAULT CHARSET=utf8 +MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +SLAVE1_1_MYPORT= @mysqld.4.1.port +SLAVE1_1_MYSOCK= @mysqld.4.1.socket +SLAVE1_1_ENGINE_TYPE= MyISAM +SLAVE1_1_ENGINE= ENGINE=MyISAM +SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP2= 1 +OUTPUT_CHILD_GROUP2= 0 +CHILD2_1_MYPORT= @mysqld.2.1.port +CHILD2_1_HSRPORT= 20002 +CHILD2_1_HSWPORT= 20003 +CHILD2_1_MYSOCK= @mysqld.2.1.socket +CHILD2_1_ENGINE_TYPE= InnoDB +CHILD2_1_ENGINE= ENGINE=InnoDB +CHILD2_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +CHILD2_2_MYPORT= @mysqld.2.2.port +CHILD2_2_HSRPORT= 20004 +CHILD2_2_HSWPORT= 20005 +CHILD2_2_MYSOCK= @mysqld.2.2.socket +CHILD2_2_ENGINE_TYPE= InnoDB +CHILD2_2_ENGINE= ENGINE=InnoDB +CHILD2_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_3_MYPORT= @mysqld.2.3.port +CHILD2_3_MYSOCK= @mysqld.2.3.socket +CHILD2_3_ENGINE_TYPE= InnoDB +CHILD2_3_ENGINE= ENGINE=InnoDB +CHILD2_3_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_FT_MYPORT= @mysqld.1.1.port +CHILD2_1_FT_MYSOCK= @mysqld.1.1.socket +CHILD2_1_FT_ENGINE_TYPE= MyISAM +CHILD2_1_FT_ENGINE= ENGINE=MyISAM +CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_FT_MYPORT= @mysqld.2.2.port +CHILD2_2_FT_MYSOCK= @mysqld.2.2.socket +CHILD2_2_FT_ENGINE_TYPE= MyISAM +CHILD2_2_FT_ENGINE= ENGINE=MyISAM +CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_GM_MYPORT= @mysqld.2.1.port +CHILD2_1_GM_MYSOCK= @mysqld.2.1.socket +CHILD2_1_GM_ENGINE_TYPE= MyISAM +CHILD2_1_GM_ENGINE= ENGINE=MyISAM +CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_GM_MYPORT= @mysqld.2.2.port +CHILD2_2_GM_MYSOCK= @mysqld.2.2.socket +CHILD2_2_GM_ENGINE_TYPE= MyISAM +CHILD2_2_GM_ENGINE= ENGINE=MyISAM +CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP3= 1 +OUTPUT_CHILD_GROUP3= 0 +CHILD3_1_MYPORT= @mysqld.3.1.port +CHILD3_1_MYSOCK= @mysqld.3.1.socket +CHILD3_1_ENGINE_TYPE= InnoDB +CHILD3_1_ENGINE= ENGINE=InnoDB +CHILD3_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_2_MYPORT= @mysqld.3.2.port +CHILD3_2_MYSOCK= @mysqld.3.2.socket +CHILD3_2_ENGINE_TYPE= InnoDB +CHILD3_2_ENGINE= ENGINE=InnoDB +CHILD3_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_3_MYPORT= @mysqld.3.3.port +CHILD3_3_MYSOCK= @mysqld.3.3.socket +CHILD3_3_ENGINE_TYPE= InnoDB +CHILD3_3_ENGINE= ENGINE=InnoDB +CHILD3_3_CHARSET= DEFAULT CHARSET=utf8 + +STR_SEMICOLON= ; + +#The followings are setted in include/init_xxx.inc files +#MASTER_1_COMMENT_2_1 +#MASTER_1_COMMENT2_2_1 +#MASTER_1_COMMENT3_2_1 +#MASTER_1_COMMENT4_2_1 +#MASTER_1_COMMENT5_2_1 +#MASTER_1_COMMENT_P_2_1 +#CHILD2_1_DROP_TABLES +#CHILD2_1_CREATE_TABLES +#CHILD2_1_SELECT_TABLES +#CHILD2_1_DROP_TABLES2 +#CHILD2_1_CREATE_TABLES2 +#CHILD2_1_SELECT_TABLES2 +#CHILD2_1_DROP_TABLES3 +#CHILD2_1_CREATE_TABLES3 +#CHILD2_1_SELECT_TABLES3 +#CHILD2_1_DROP_TABLES4 +#CHILD2_1_CREATE_TABLES4 +#CHILD2_1_SELECT_TABLES4 +#CHILD2_1_DROP_TABLES5 +#CHILD2_1_CREATE_TABLES5 +#CHILD2_1_SELECT_TABLES5 +#CHILD2_1_DROP_TABLES6 +#CHILD2_1_CREATE_TABLES6 +#CHILD2_1_SELECT_TABLES6 +#CHILD2_2_DROP_TABLES +#CHILD2_2_CREATE_TABLES +#CHILD2_2_SELECT_TABLES diff --git a/storage/spider/mysql-test/spider/handler/r/basic_sql.result b/storage/spider/mysql-test/spider/handler/r/basic_sql.result new file mode 100644 index 00000000000..da24c08e9fd --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/r/basic_sql.result @@ -0,0 +1,693 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'f', '2008-07-01 10:21:39'), +(2, 'g', '2000-02-01 00:00:00'), +(3, 'j', '2007-05-04 20:03:11'), +(4, 'i', '2003-10-30 05:01:03'), +(5, 'h', '2001-10-31 23:59:59'); +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create table with partition and select test +CREATE TABLE ta_l2 ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create no index table +DROP TABLE IF EXISTS ta_l_no_idx; +CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table shared mode +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table for update +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table join +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table straight_join +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_small_result +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_big_result +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_buffer_result +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_cache +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_no_cache +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_calc_found_rows +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +SELECT found_rows(); +found_rows() +5 + +select high_priority +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select distinct +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select count +SELECT count(*) FROM ta_l ORDER BY a; +count(*) +5 + +select table join not use index +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select using index and pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using index pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +insert +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +insert select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 + +insert low_priority +TRUNCATE TABLE ta_l; +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert high_priority +TRUNCATE TABLE ta_l; +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert ignore +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (insert) +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (update) +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2005-08-08 11:11:11 + +replace +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2008-02-02 02:02:02 + +replace select +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace select a +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace low_priority +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 g 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 f 2008-02-02 02:02:02 + +update select +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update select a +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 h 2010-04-04 04:04:04 +2 g 2009-03-03 03:03:03 + +update join +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 + +update join a +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update low_priority +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update ignore +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update pushdown +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 j 2009-03-03 03:03:03 + +update index pushdown +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update partition pushdown +UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 e 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update partition index pushdown +UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete all +DELETE FROM ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE IGNORE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE QUICK FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete partition pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete partition index pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +truncate +TRUNCATE TABLE ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/handler/r/direct_aggregate.result b/storage/spider/mysql-test/spider/handler/r/direct_aggregate.result new file mode 100644 index 00000000000..0e845fabda1 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/r/direct_aggregate.result @@ -0,0 +1,132 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_aggregating test +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 0 +SELECT COUNT(*) FROM ta_l; +COUNT(*) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l; +MAX(a) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 2 +SELECT MIN(a) FROM ta_l; +MIN(a) +1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l WHERE a < 5; +MAX(a) +4 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 4 +SELECT MIN(a) FROM ta_l WHERE a > 1; +MIN(a) +2 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 5 + +handler with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 5 +SELECT COUNT(*) FROM ta_l2; +COUNT(*) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 7 +SELECT MAX(a) FROM ta_l2; +MAX(a) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 9 +SELECT MIN(a) FROM ta_l2; +MIN(a) +1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 11 +SELECT MAX(a) FROM ta_l2 WHERE a < 5; +MAX(a) +4 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 13 +SELECT MIN(a) FROM ta_l2 WHERE a > 1; +MIN(a) +2 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 15 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/handler/r/direct_update.result b/storage/spider/mysql-test/spider/handler/r/direct_update.result new file mode 100644 index 00000000000..ea3a23eb8b8 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/r/direct_update.result @@ -0,0 +1,242 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_updating test +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 0 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 2 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 3 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 4 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +Spider_direct_delete 1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +Spider_direct_delete 2 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +Spider_direct_delete 3 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +handler with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 4 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l2 SET c = ADDDATE(c, 1); +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 6 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l2 SET b = 'x' WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 7 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 9 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +Spider_direct_update 10 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +Spider_direct_delete 4 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l2 WHERE b = 'c'; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +Spider_direct_delete 6 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l2 WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +Spider_direct_delete 7 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/handler/r/function.result b/storage/spider/mysql-test/spider/handler/r/function.result new file mode 100644 index 00000000000..764c774514b --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/r/function.result @@ -0,0 +1,149 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +in() +CREATE TABLE t1 ( +a VARCHAR(255), +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1 +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +select a from t1 where a in ('15', '120'); +a +120 +15 + +date_sub() +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-08-01 10:21:39 +2 b 1999-01-01 00:00:00 +3 e 2006-06-04 20:03:11 +4 d 2002-11-30 05:01:03 +5 c 2000-12-31 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-11-01 10:21:39 +2 b 1999-04-01 00:00:00 +3 e 2006-09-04 20:03:11 +4 d 2003-02-28 05:01:03 +5 c 2001-03-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-01 10:21:39 +2 b 1999-03-01 00:00:00 +3 e 2006-08-04 20:03:11 +4 d 2003-01-28 05:01:03 +5 c 2001-02-28 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-08 10:21:39 +2 b 1999-03-08 00:00:00 +3 e 2006-08-11 20:03:11 +4 d 2003-02-04 05:01:03 +5 c 2001-03-07 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 10:21:39 +2 b 1999-03-07 00:00:00 +3 e 2006-08-10 20:03:11 +4 d 2003-02-03 05:01:03 +5 c 2001-03-06 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:21:39 +2 b 1999-03-07 01:00:00 +3 e 2006-08-10 21:03:11 +4 d 2003-02-03 06:01:03 +5 c 2001-03-07 00:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:39 +2 b 1999-03-07 00:59:00 +3 e 2006-08-10 21:02:11 +4 d 2003-02-03 06:00:03 +5 c 2001-03-07 00:58:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:40 +2 b 1999-03-07 00:59:01 +3 e 2006-08-10 21:02:12 +4 d 2003-02-03 06:00:04 +5 c 2001-03-07 00:59:00 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/handler/r/ha.result b/storage/spider/mysql-test/spider/handler/r/ha.result new file mode 100644 index 00000000000..e05ecb32e1b --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/r/ha.result @@ -0,0 +1,431 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +CREATE DATABASE auto_test_remote3; +USE auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; + +test select 1 +SELECT 1; +1 +1 + +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 0 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote2.ta_r3' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 2 +SELECT spider_copy_tables('ta_l', '0', '1'); +spider_copy_tables('ta_l', '0', '1') +1 +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote3.ta_r4' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 2 +SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +spider_copy_tables('ta_l2#P#pt2', '0', '1') +1 +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +active standby test +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote.ta_r' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 3 +auto_test_local ta_l 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote.ta_r2' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 3 +auto_test_local ta_l2#P#pt2 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +auto_test_local ta_l2#P#pt2 0 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 3 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/handler/r/spider3_fixes.result b/storage/spider/mysql-test/spider/handler/r/spider3_fixes.result new file mode 100644 index 00000000000..6de174e1a2d --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/r/spider3_fixes.result @@ -0,0 +1,403 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +3.1 +auto_increment +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT MAX(id) FROM t1; +MAX(id) +2 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6 +SELECT MAX(id) FROM t2; +MAX(id) +6 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT MAX(id) FROM t1; +MAX(id) +10 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +14 +SELECT MAX(id) FROM t2; +MAX(id) +14 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT id FROM t1 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +30 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +34 +SELECT id FROM t2 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +30 +34 +38 +42 +46 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT id FROM t1 ORDER BY id; +id +2 +6 +10 +14 +INSERT INTO t2 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT id FROM t2 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +30 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +34 +SELECT MAX(id) FROM t1; +MAX(id) +34 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +38 +SELECT MAX(id) FROM t2; +MAX(id) +38 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +42 +SELECT MAX(id) FROM t1; +MAX(id) +42 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +46 +SELECT MAX(id) FROM t2; +MAX(id) +46 +SELECT id FROM t1 ORDER BY id; +id +2 +34 +777 +1554 +2331 +10000 +auto_increment with partition +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT MAX(id) FROM t1; +MAX(id) +2 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +SELECT MAX(id) FROM t2; +MAX(id) +3 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +7 +SELECT MAX(id) FROM t1; +MAX(id) +7 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6 +SELECT MAX(id) FROM t2; +MAX(id) +7 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT id FROM t1 ORDER BY id; +id +2 +3 +6 +7 +10 +11 +14 +15 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT id FROM t2 ORDER BY id; +id +2 +3 +6 +7 +10 +11 +14 +15 +18 +19 +22 +23 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT id FROM t1 ORDER BY id; +id +2 +3 +6 +7 +INSERT INTO t2 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT id FROM t2 ORDER BY id; +id +2 +3 +6 +7 +10 +11 +14 +15 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT MAX(id) FROM t1; +MAX(id) +18 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +19 +SELECT MAX(id) FROM t2; +MAX(id) +19 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +22 +SELECT MAX(id) FROM t1; +MAX(id) +22 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +26 +SELECT MAX(id) FROM t2; +MAX(id) +26 +SELECT id FROM t1 ORDER BY id; +id +2 +18 +777 +1554 +2331 +10000 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/handler/r/spider_fixes.result b/storage/spider/mysql-test/spider/handler/r/spider_fixes.result new file mode 100644 index 00000000000..9fd24bcc43f --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/r/spider_fixes.result @@ -0,0 +1,699 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +2.13 +select table with "order by desc" and "<" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 +2 b 2000-01-01 00:00:00 + +select table with "order by desc" and "<=" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +5 c 2001-12-31 23:59:59 +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 + +2.14 +update table with range scan and split_read +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-02-02 00:00:00 +3 e 2000-02-02 00:00:00 +4 d 2000-02-02 00:00:00 +5 c 2000-02-02 00:00:00 + +2.15 +select table with range scan +TRUNCATE TABLE ta_l; +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a int(11) NOT NULL DEFAULT '0', +b char(1) DEFAULT NULL, +c datetime DEFAULT NULL, +PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +a b c +5 c 2001-12-31 23:59:59 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 + +2.16 +auto_increment insert with trigger +CREATE TABLE ta_l_auto_inc ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tc_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;; +INSERT INTO ta_l_auto_inc (a, b, c) VALUES +(NULL, 's', '2008-12-31 20:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 s 2008-12-31 20:59:59 + +2.17 +engine-condition-pushdown with "or" and joining +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +partition with sort +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +2.23 +partition update with moving partition +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); +UPDATE ta_l2 SET a = 4 WHERE a = 3; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 B 2010-09-26 00:00:00 +index merge +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 +index merge with partition +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 + +2.24 +index scan update without PK +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT NOT NULL, +b INT DEFAULT 10, +c INT DEFAULT 11, +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +UPDATE ta_l_int SET c = 4 WHERE b = 2; +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +1 2 4 +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 +17 2 4 + +2.25 +direct order limit +SHOW STATUS LIKE 'Spider_direct_order_limit'; +Variable_name Value +Spider_direct_order_limit 2 +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +a b c +1 2 4 +2 3 4 +4 5 6 +SHOW STATUS LIKE 'Spider_direct_order_limit'; +Variable_name Value +Spider_direct_order_limit 3 + +2.26 +lock tables +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1 +CREATE TABLE t2 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2 +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + +auto_increment +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT MAX(id) FROM t1; +MAX(id) +2 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6 +SELECT MAX(id) FROM t1; +MAX(id) +6 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT MAX(id) FROM t1; +MAX(id) +10 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +14 +SELECT MAX(id) FROM t1; +MAX(id) +14 +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT id FROM t1 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +30 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +34 +SELECT MAX(id) FROM t1; +MAX(id) +34 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +38 +SELECT MAX(id) FROM t1; +MAX(id) +38 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +42 +SELECT MAX(id) FROM t1; +MAX(id) +42 +SELECT id FROM t1 ORDER BY id; +id +2 +6 +10 +14 +18 +34 +777 +1000 +1554 +2331 +10000 + +auto_increment with partition +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT MAX(id) FROM t1; +MAX(id) +2 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +SELECT MAX(id) FROM t1; +MAX(id) +3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6 +SELECT MAX(id) FROM t1; +MAX(id) +6 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +7 +SELECT MAX(id) FROM t1; +MAX(id) +7 +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT id FROM t1 ORDER BY id; +id +2 +3 +6 +7 +10 +11 +14 +15 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT MAX(id) FROM t1; +MAX(id) +18 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +22 +SELECT MAX(id) FROM t1; +MAX(id) +22 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +26 +SELECT MAX(id) FROM t1; +MAX(id) +26 +SELECT id FROM t1 ORDER BY id; +id +2 +3 +6 +7 +10 +18 +777 +1000 +1554 +2331 +10000 + +read only +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1 +SELECT id FROM t1 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +INSERT INTO t1 (id) VALUES (1); +ERROR HY000: Table 'auto_test_local.t1' is read only +UPDATE t1 SET id = 4 WHERE id = 2; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1 WHERE id = 2; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1; +ERROR HY000: Table 'auto_test_local.t1' is read only +TRUNCATE t1; +ERROR HY000: Table 'auto_test_local.t1' is read only + +2.27 +error mode +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1 +SELECT id FROM t1 ORDER BY id; +id +Warnings: +Error 12702 Remote table 'auto_test_remote.ter1_1' is not found +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +INSERT INTO t1 (id) VALUES (1); +Warnings: +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +DELETE FROM t1; +Warnings: +Error 12702 Remote table 'auto_test_remote.ter1_1' is not found +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +TRUNCATE t1; +Warnings: +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist + +3.0 +is null +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +a VARCHAR(255), +b VARCHAR(255), +c VARCHAR(255), +KEY idx1(a,b), +KEY idx2(b), +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1 +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +select a from t1 where a is null order by a limit 30; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +select b from t1 where b is null order by b limit 30; +b +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL + +direct_order_limit +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +a b c +10 74 74 +10 42 42 +10 234 234 +10 202 202 +10 170 170 +select a, c from t1 where a = '10' order by b desc limit 5; +a c +10 74 +10 42 +10 234 +10 202 +10 170 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/handler/r/vp_fixes.result b/storage/spider/mysql-test/spider/handler/r/vp_fixes.result new file mode 100644 index 00000000000..15dd29aa4d3 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/r/vp_fixes.result @@ -0,0 +1,80 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +0.9 +create different primary key table +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT AUTO_INCREMENT, +c INT DEFAULT 11, +PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +create un-correspond primary key table +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT DEFAULT 12, +c INT DEFAULT 11, +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/handler/t/basic_sql.test b/storage/spider/mysql-test/spider/handler/t/basic_sql.test new file mode 100644 index 00000000000..2264b0e4e37 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/basic_sql.test @@ -0,0 +1,3189 @@ +# This test tests by executing basic SQL +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'f', '2008-07-01 10:21:39'), + (2, 'g', '2000-02-01 00:00:00'), + (3, 'j', '2007-05-04 20:03:11'), + (4, 'i', '2003-10-30 05:01:03'), + (5, 'h', '2001-10-31 23:59:59'); +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT IGNORE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + REPLACE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table with partition and select test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + } + --enable_query_log + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo create no index table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_no_idx; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_NEEDPK) +{ + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + } +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES3; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; + +--echo +--echo select table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table shared mode +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table for update +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table straight_join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_small_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_big_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_buffer_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_no_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_calc_found_rows +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT found_rows(); + +--echo +--echo select high_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select distinct +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select count +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT count(*) FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join not use index +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using index and pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select partition using pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo select partition using index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.a > 0 AND a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo insert +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select a +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert low_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert high_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (insert) +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (update) +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace +--connection master_1 +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update index pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update partition pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo update partition index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete all +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE IGNORE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE QUICK FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete partition pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete partition index pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo truncate +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/handler/t/connect_child2_1.inc b/storage/spider/mysql-test/spider/handler/t/connect_child2_1.inc new file mode 100644 index 00000000000..cd9b0c9ca9b --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/connect_child2_1.inc @@ -0,0 +1 @@ +--connect (child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/handler/t/connect_child2_2.inc b/storage/spider/mysql-test/spider/handler/t/connect_child2_2.inc new file mode 100644 index 00000000000..e145f66b630 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/connect_child2_2.inc @@ -0,0 +1 @@ +--connect (child2_2, localhost, root, , , $CHILD2_2_MYPORT, $CHILD2_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/handler/t/connect_child2_3.inc b/storage/spider/mysql-test/spider/handler/t/connect_child2_3.inc new file mode 100644 index 00000000000..d356348d8ea --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/connect_child2_3.inc @@ -0,0 +1 @@ +--connect (child2_3, localhost, root, , , $CHILD2_3_MYPORT, $CHILD2_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/handler/t/connect_child3_1.inc b/storage/spider/mysql-test/spider/handler/t/connect_child3_1.inc new file mode 100644 index 00000000000..03e5c188c89 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/connect_child3_1.inc @@ -0,0 +1 @@ +--connect (child3_1, localhost, root, , , $CHILD3_1_MYPORT, $CHILD3_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/handler/t/connect_child3_2.inc b/storage/spider/mysql-test/spider/handler/t/connect_child3_2.inc new file mode 100644 index 00000000000..d62a7ada824 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/connect_child3_2.inc @@ -0,0 +1 @@ +--connect (child3_2, localhost, root, , , $CHILD3_2_MYPORT, $CHILD3_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/handler/t/connect_child3_3.inc b/storage/spider/mysql-test/spider/handler/t/connect_child3_3.inc new file mode 100644 index 00000000000..fb49f5bfdac --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/connect_child3_3.inc @@ -0,0 +1 @@ +--connect (child3_3, localhost, root, , , $CHILD3_3_MYPORT, $CHILD3_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/handler/t/connect_master_1.inc b/storage/spider/mysql-test/spider/handler/t/connect_master_1.inc new file mode 100644 index 00000000000..0c129ce5775 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/connect_master_1.inc @@ -0,0 +1 @@ +--connect (master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/handler/t/connect_slave1_1.inc b/storage/spider/mysql-test/spider/handler/t/connect_slave1_1.inc new file mode 100644 index 00000000000..45a822743e0 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/connect_slave1_1.inc @@ -0,0 +1 @@ +--connect (slave1_1, localhost, root, , , $SLAVE1_1_MYPORT, $SLAVE1_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/handler/t/direct_aggregate.test b/storage/spider/mysql-test/spider/handler/t/direct_aggregate.test new file mode 100644 index 00000000000..59c45f3f190 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/direct_aggregate.test @@ -0,0 +1,316 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_aggregating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT COUNT(*) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l WHERE a < 5; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l WHERE a > 1; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT COUNT(*) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2 WHERE a < 5; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2 WHERE a > 1; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/handler/t/direct_update.test b/storage/spider/mysql-test/spider/handler/t/direct_update.test new file mode 100644 index 00000000000..1c3ce91ff3f --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/direct_update.test @@ -0,0 +1,354 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_updating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key +DELETE FROM ta_l WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update all rows with function + UPDATE ta_l2 SET c = ADDDATE(c, 1); + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key + UPDATE ta_l2 SET b = 'x' WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by a column without index + UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key with order and limit + UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key with order and limit + DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by a column without index + DELETE FROM ta_l2 WHERE b = 'c'; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key + DELETE FROM ta_l2 WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/handler/t/function.test b/storage/spider/mysql-test/spider/handler/t/function.test new file mode 100644 index 00000000000..2b1b53c8a4f --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/function.test @@ -0,0 +1,276 @@ +# This test tests for using functions +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo in() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_PK_TABLES1; + echo CHILD2_1_CREATE_TEXT_PK_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_PK_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_PK_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET3 $MASTER_1_COMMENT_TEXT_PK1_1; +--enable_query_log +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a in ('15', '120'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo date_sub() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/handler/t/ha.test b/storage/spider/mysql-test/spider/handler/t/ha.test new file mode 100644 index 00000000000..319b1793753 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/ha.test @@ -0,0 +1,1794 @@ +# This test tests for ha features +--let $SKIP_REASON= +if ($USE_HA_TEST) +{ +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source ha_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + CREATE DATABASE auto_test_remote3; + USE auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + } + if ($USE_CHILD_GROUP3) + { + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + } + --disable_query_log + --disable_result_log + --source ha_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + --connection child2_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + SELECT 1; + --connection child3_2 + SELECT 1; + --connection child3_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_2_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_CREATE_TABLES; + } + eval $CHILD2_2_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_RECOVERY_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_COPY_TABLES_2_1; +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_3_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_CREATE_TABLES; + } + eval $CHILD2_3_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_COPY_TABLES_P_2_1; + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo active standby test +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_AS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES2; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES2; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES2; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_AS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; +} +--disable_query_log +--disable_result_log +--source ha_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +} +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/handler/t/ha_test_deinit.inc b/storage/spider/mysql-test/spider/handler/t/ha_test_deinit.inc new file mode 100644 index 00000000000..53d0409d066 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/ha_test_deinit.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_deinit_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_deinit_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_deinit_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_deinit_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/handler/t/ha_test_init.inc b/storage/spider/mysql-test/spider/handler/t/ha_test_init.inc new file mode 100644 index 00000000000..70576ab16dc --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/ha_test_init.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_init_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_init_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_init_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_init_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/handler/t/have_engine.inc b/storage/spider/mysql-test/spider/handler/t/have_engine.inc new file mode 100644 index 00000000000..64bef7499cb --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/have_engine.inc @@ -0,0 +1,7 @@ +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = '$TEST_ENGINE_TYPE'`) +{ + SELECT engine, support FROM information_schema.engines; + --let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine" +} diff --git a/storage/spider/mysql-test/spider/handler/t/have_func.inc b/storage/spider/mysql-test/spider/handler/t/have_func.inc new file mode 100644 index 00000000000..e0823e73fc8 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/have_func.inc @@ -0,0 +1,5 @@ +if (!`SELECT count(*) FROM mysql.func WHERE name = '$TEST_FUNC_NAME'`) +{ + SELECT name FROM mysql.func; + --let $SKIP_REASON= "Need $TEST_FUNC_NAME function" +} diff --git a/storage/spider/mysql-test/spider/handler/t/have_partition.inc b/storage/spider/mysql-test/spider/handler/t/have_partition.inc new file mode 100644 index 00000000000..573c76ab43b --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/have_partition.inc @@ -0,0 +1,7 @@ +let $HAVE_PARTITION= 0; +if (`SELECT count(*) FROM information_schema.plugins WHERE + plugin_status = 'ACTIVE' AND + plugin_name = 'partition'`) +{ + let $HAVE_PARTITION= 1; +} diff --git a/storage/spider/mysql-test/spider/handler/t/have_trigger.inc b/storage/spider/mysql-test/spider/handler/t/have_trigger.inc new file mode 100644 index 00000000000..10c0871dd5f --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/have_trigger.inc @@ -0,0 +1,2 @@ +let $HAVE_TRIGGER= `SELECT COUNT(*) FROM information_schema.tables + WHERE TABLE_SCHEMA = 'information_schema' AND TABLE_NAME = 'TRIGGERS'`; diff --git a/storage/spider/mysql-test/spider/handler/t/hs_test_deinit.inc b/storage/spider/mysql-test/spider/handler/t/hs_test_deinit.inc new file mode 100644 index 00000000000..7ec2e981fd2 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/hs_test_deinit.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_deinit_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/handler/t/hs_test_init.inc b/storage/spider/mysql-test/spider/handler/t/hs_test_init.inc new file mode 100644 index 00000000000..831bf479524 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/hs_test_init.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_init_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/handler/t/slave_test_deinit.inc b/storage/spider/mysql-test/spider/handler/t/slave_test_deinit.inc new file mode 100644 index 00000000000..e9d99b7a960 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/slave_test_deinit.inc @@ -0,0 +1,6 @@ +# get connection and exist engine test +--echo for slave1_1 +--connection slave1_1 +STOP SLAVE; +--source ../include/deinit_slave1_1.inc +--disconnect slave1_1 diff --git a/storage/spider/mysql-test/spider/handler/t/slave_test_init.inc b/storage/spider/mysql-test/spider/handler/t/slave_test_init.inc new file mode 100644 index 00000000000..739d88970c5 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/slave_test_init.inc @@ -0,0 +1,44 @@ +# get connection and exist engine test +--echo for slave1_1 +--source connect_slave1_1.inc +--connection slave1_1 +SET SESSION sql_log_bin= 0; +--let $SLAVE1_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $SLAVE1_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_slave1_1.inc +--source have_engine.inc +--let $SLAVE1_1_SLAVE_STATUS=`SHOW SLAVE STATUS` +if (!$SLAVE1_1_SLAVE_STATUS) +{ + eval CHANGE MASTER TO + MASTER_HOST = '127.0.0.1', + MASTER_USER = 'root', + MASTER_PASSWORD = '', + MASTER_PORT = $MASTER_1_MYPORT + ; +} +START SLAVE; +--connection master_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +--connection slave1_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} diff --git a/storage/spider/mysql-test/spider/handler/t/spider3_fixes.test b/storage/spider/mysql-test/spider/handler/t/spider3_fixes.test new file mode 100644 index 00000000000..4139f3af955 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/spider3_fixes.test @@ -0,0 +1,570 @@ +# This test tests for Spider 3.0's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo 3.1 +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +SET INSERT_ID=5000; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + TRUNCATE TABLE t1; + TRUNCATE TABLE t2; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + SET INSERT_ID=5000; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/handler/t/spider_fixes.test b/storage/spider/mysql-test/spider/handler/t/spider_fixes.test new file mode 100644 index 00000000000..b9ff61abcb4 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/spider_fixes.test @@ -0,0 +1,1967 @@ +# This test tests for Spider's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 2.13 +--echo select table with "order by desc" and "<" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table with "order by desc" and "<=" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.14 +--echo update table with range scan and split_read +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo 2.15 +--echo select table with range scan +TRUNCATE TABLE ta_l; +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_CREATE_TABLES6; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES6; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES6; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.16 +--echo auto_increment insert with trigger +if ($HAVE_TRIGGER) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_CREATE_TABLES4; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES4; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES4; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; + eval CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; + echo CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE2 MASTER_1_CHARSET2; + eval CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; + --enable_query_log + --eval CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + INSERT INTO ta_l_auto_inc (a, b, c) VALUES + (NULL, 's', '2008-12-31 20:59:59'); + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES4; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +} + +--echo +--echo 2.17 +--echo engine-condition-pushdown with "or" and joining +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo partition with sort +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 + ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.23 +--echo partition update with moving partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); + UPDATE ta_l2 SET a = 4 WHERE a = 3; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo index merge +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo index merge with partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l_int; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_2_DROP_TABLES5; + echo CHILD2_2_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES5; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES5; + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1; + eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_P_2_1; + --enable_query_log + INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); + INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) + WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.24 +--echo index scan update without PK +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +if (!$MASTER_1_NEEDPK) +{ + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +--enable_query_log +SELECT a, b, c FROM ta_l_int ORDER BY a; +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l_int SET c = 4 WHERE b = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; + + +--echo +--echo 2.25 +--echo direct order limit +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; + + +--echo +--echo 2.26 +--echo lock tables +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_LOCK_TABLES1; + echo CHILD2_1_DROP_LOCK_TABLES2; + echo CHILD2_1_CREATE_LOCK_TABLES1; + echo CHILD2_1_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_LOCK_TABLES1; + eval $CHILD2_1_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_LOCK_TABLES1; + eval $CHILD2_1_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_LOCK_TABLES1; + echo CHILD2_2_DROP_LOCK_TABLES2; + echo CHILD2_2_CREATE_LOCK_TABLES1; + echo CHILD2_2_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_2_DROP_LOCK_TABLES1; + eval $CHILD2_2_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_2_CREATE_LOCK_TABLES1; + eval $CHILD2_2_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1; +eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2; +eval CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK2; +--enable_query_log +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + + +--echo +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + SET INSERT_ID=5000; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo read only +let $MASTER_1_ENGINE_IS_SPIDER= + `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'Spider' OR + '$MASTER_1_HIDDEN_ENGINE_TYPE' = 'Spider', 1, 0)`; +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_READONLY1_1; + --let $MIN_VAL= `SELECT MIN(id) FROM t1` + --enable_query_log + SELECT id FROM t1 ORDER BY id; + --error 12518 + INSERT INTO t1 (id) VALUES (1); + --error 12518 + eval UPDATE t1 SET id = 4 WHERE id = $MIN_VAL; + --error 12518 + eval DELETE FROM t1 WHERE id = $MIN_VAL; + --error 12518 + DELETE FROM t1; + --error 12518 + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 2.27 +--echo error mode +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_ERROR_MODE1_1; + --enable_query_log + SELECT id FROM t1 ORDER BY id; + INSERT INTO t1 (id) VALUES (1); + DELETE FROM t1; + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 3.0 +--echo is null +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_KEY_TABLES1; + echo CHILD2_1_CREATE_TEXT_KEY_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_KEY_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_KEY_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_TEXT_KEY1_1; +--enable_query_log +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a is null order by a limit 30; +select b from t1 where b is null order by b limit 30; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo direct_order_limit +--connection master_1 +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +select a, c from t1 where a = '10' order by b desc limit 5; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/handler/t/test_deinit.inc b/storage/spider/mysql-test/spider/handler/t/test_deinit.inc new file mode 100644 index 00000000000..989bde26d3c --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/test_deinit.inc @@ -0,0 +1,37 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/deinit_master_1.inc +--disconnect master_1 +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/deinit_child2_1.inc + --disconnect child2_1 + --echo child2_2 + --connection child2_2 + --source ../include/deinit_child2_2.inc + --disconnect child2_2 + --echo child2_3 + --connection child2_3 + --source ../include/deinit_child2_3.inc + --disconnect child2_3 +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/deinit_child3_1.inc + --disconnect child3_1 + --echo child3_2 + --connection child3_2 + --source ../include/deinit_child3_2.inc + --disconnect child3_2 + --echo child3_3 + --connection child3_3 + --source ../include/deinit_child3_3.inc + --disconnect child3_3 +} diff --git a/storage/spider/mysql-test/spider/handler/t/test_init.inc b/storage/spider/mysql-test/spider/handler/t/test_init.inc new file mode 100644 index 00000000000..f2cd6c0269f --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/test_init.inc @@ -0,0 +1,74 @@ +# get connection and exist engine test +--echo for master_1 +--source connect_master_1.inc +--connection master_1 +CALL mtr.add_suppression("unknown variable"); +SET SESSION sql_log_bin= 0; +--let $MASTER_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $MASTER_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_master_1.inc +--source have_engine.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --source connect_child2_1.inc + --connection child2_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE + --source ../include/init_child2_1.inc + --source have_engine.inc + --echo child2_2 + --source connect_child2_2.inc + --connection child2_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE + --source ../include/init_child2_2.inc + --source have_engine.inc + --echo child2_3 + --source connect_child2_3.inc + --connection child2_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE + --source ../include/init_child2_3.inc + --source have_engine.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --source connect_child3_1.inc + --connection child3_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE + --source ../include/init_child3_1.inc + --source have_engine.inc + --echo child3_2 + --source connect_child3_2.inc + --connection child3_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE + --source ../include/init_child3_2.inc + --source have_engine.inc + --echo child3_3 + --source connect_child3_3.inc + --connection child3_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE + --source ../include/init_child3_3.inc + --source have_engine.inc +} diff --git a/storage/spider/mysql-test/spider/handler/t/vp_fixes.test b/storage/spider/mysql-test/spider/handler/t/vp_fixes.test new file mode 100644 index 00000000000..46e7b0afc36 --- /dev/null +++ b/storage/spider/mysql-test/spider/handler/t/vp_fixes.test @@ -0,0 +1,358 @@ +# This test tests for VP's bug fixes +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 0.9 +--echo create different primary key table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--let $MASTER_1_IS_VP= `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'VP', 1, 0)` +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo create un-correspond primary key table +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/include/deinit_child2_1.inc b/storage/spider/mysql-test/spider/include/deinit_child2_1.inc new file mode 100644 index 00000000000..cee137a6aeb --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_child2_1.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD2_1_ENGINE +--source ../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/include/deinit_child2_2.inc b/storage/spider/mysql-test/spider/include/deinit_child2_2.inc new file mode 100644 index 00000000000..a1f9fe3fb19 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_child2_2.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD2_2_ENGINE +--source ../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/include/deinit_child2_3.inc b/storage/spider/mysql-test/spider/include/deinit_child2_3.inc new file mode 100644 index 00000000000..f996a40e786 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_child2_3.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD2_3_ENGINE +--source ../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/include/deinit_child3_1.inc b/storage/spider/mysql-test/spider/include/deinit_child3_1.inc new file mode 100644 index 00000000000..e0e3a4c41f4 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_child3_1.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_1_ENGINE +--source ../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/include/deinit_child3_2.inc b/storage/spider/mysql-test/spider/include/deinit_child3_2.inc new file mode 100644 index 00000000000..82eb70d331f --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_child3_2.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_2_ENGINE +--source ../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/include/deinit_child3_3.inc b/storage/spider/mysql-test/spider/include/deinit_child3_3.inc new file mode 100644 index 00000000000..3741ef76c3c --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_child3_3.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_3_ENGINE +--source ../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/include/deinit_engine.inc b/storage/spider/mysql-test/spider/include/deinit_engine.inc new file mode 100644 index 00000000000..f3b6b3189f5 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_engine.inc @@ -0,0 +1,4 @@ +if ($INIT_TEST_ENGINE) +{ + --echo Deinit $TEST_ENGINE_TYPE engine +} diff --git a/storage/spider/mysql-test/spider/include/deinit_handlersocket.inc b/storage/spider/mysql-test/spider/include/deinit_handlersocket.inc new file mode 100644 index 00000000000..3ebf80ef675 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_handlersocket.inc @@ -0,0 +1 @@ +UNINSTALL PLUGIN handlersocket; diff --git a/storage/spider/mysql-test/spider/include/deinit_innodb_plugin.inc b/storage/spider/mysql-test/spider/include/deinit_innodb_plugin.inc new file mode 100644 index 00000000000..d1013fe86d6 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_innodb_plugin.inc @@ -0,0 +1 @@ +UNINSTALL PLUGIN InnoDB; diff --git a/storage/spider/mysql-test/spider/include/deinit_master_1.inc b/storage/spider/mysql-test/spider/include/deinit_master_1.inc new file mode 100644 index 00000000000..482c8013734 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_master_1.inc @@ -0,0 +1 @@ +--source ../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/include/deinit_slave1_1.inc b/storage/spider/mysql-test/spider/include/deinit_slave1_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/deinit_spider.inc b/storage/spider/mysql-test/spider/include/deinit_spider.inc new file mode 100644 index 00000000000..c9c414eb56e --- /dev/null +++ b/storage/spider/mysql-test/spider/include/deinit_spider.inc @@ -0,0 +1,17 @@ +DROP FUNCTION spider_direct_sql; +DROP FUNCTION spider_bg_direct_sql; +DROP FUNCTION spider_ping_table; +DROP FUNCTION spider_copy_tables; +DROP FUNCTION spider_flush_table_mon_cache; +UNINSTALL PLUGIN spider; +DROP TABLE IF EXISTS mysql.spider_xa; +DROP TABLE IF EXISTS mysql.spider_xa_member; +DROP TABLE IF EXISTS mysql.spider_tables; +DROP TABLE IF EXISTS mysql.spider_link_mon_servers; +DROP TABLE IF EXISTS mysql.spider_link_failed_log; +DROP SERVER s_2_1; +DROP SERVER s_2_2; +DROP SERVER s_2_3; +DROP SERVER s_3_1; +DROP SERVER s_3_2; +DROP SERVER s_3_3; diff --git a/storage/spider/mysql-test/spider/include/ha_deinit_child2_1.inc b/storage/spider/mysql-test/spider/include/ha_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/ha_deinit_child2_2.inc b/storage/spider/mysql-test/spider/include/ha_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/ha_deinit_child2_3.inc b/storage/spider/mysql-test/spider/include/ha_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/ha_deinit_child3_1.inc b/storage/spider/mysql-test/spider/include/ha_deinit_child3_1.inc new file mode 100644 index 00000000000..f5f7db7e3fa --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_deinit_child3_1.inc @@ -0,0 +1 @@ +--source ../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/include/ha_deinit_child3_2.inc b/storage/spider/mysql-test/spider/include/ha_deinit_child3_2.inc new file mode 100644 index 00000000000..f5f7db7e3fa --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_deinit_child3_2.inc @@ -0,0 +1 @@ +--source ../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/include/ha_deinit_child3_3.inc b/storage/spider/mysql-test/spider/include/ha_deinit_child3_3.inc new file mode 100644 index 00000000000..f5f7db7e3fa --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_deinit_child3_3.inc @@ -0,0 +1 @@ +--source ../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/include/ha_deinit_master_1.inc b/storage/spider/mysql-test/spider/include/ha_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/ha_init_child2_1.inc b/storage/spider/mysql-test/spider/include/ha_init_child2_1.inc new file mode 100644 index 00000000000..59c0175d349 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_init_child2_1.inc @@ -0,0 +1,8 @@ +let $CHILD2_1_HA_AS_DROP_TABLES= + $CHILD2_1_DROP_TABLES; +let $CHILD2_1_HA_AS_CREATE_TABLES= + $CHILD2_1_CREATE_TABLES; +let $CHILD2_1_HA_AS_DROP_TABLES2= + $CHILD2_1_DROP_TABLES2; +let $CHILD2_1_HA_AS_CREATE_TABLES2= + $CHILD2_1_CREATE_TABLES2; diff --git a/storage/spider/mysql-test/spider/include/ha_init_child2_2.inc b/storage/spider/mysql-test/spider/include/ha_init_child2_2.inc new file mode 100644 index 00000000000..90d27ed704d --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_init_child2_2.inc @@ -0,0 +1,4 @@ +let $CHILD2_2_HA_DROP_TABLES= + $CHILD2_2_DROP_TABLES; +let $CHILD2_2_HA_CREATE_TABLES= + $CHILD2_2_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/include/ha_init_child2_3.inc b/storage/spider/mysql-test/spider/include/ha_init_child2_3.inc new file mode 100644 index 00000000000..11abf112b1f --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_init_child2_3.inc @@ -0,0 +1,4 @@ +let $CHILD2_3_HA_DROP_TABLES= + $CHILD2_3_DROP_TABLES; +let $CHILD2_3_HA_CREATE_TABLES= + $CHILD2_3_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/include/ha_init_child3_1.inc b/storage/spider/mysql-test/spider/include/ha_init_child3_1.inc new file mode 100644 index 00000000000..67f6676a07a --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_init_child3_1.inc @@ -0,0 +1,140 @@ +--let $CHILD3_1_ENGINE_TYPE=Spider +--let $CHILD3_1_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_1_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_1_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_1_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/include/ha_init_child3_2.inc b/storage/spider/mysql-test/spider/include/ha_init_child3_2.inc new file mode 100644 index 00000000000..9b61a2e2b73 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_init_child3_2.inc @@ -0,0 +1,140 @@ +--let $CHILD3_2_ENGINE_TYPE=Spider +--let $CHILD3_2_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_2_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_2_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_2_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_2_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_2_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_2_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_2_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_2_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_2_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_2_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/include/ha_init_child3_3.inc b/storage/spider/mysql-test/spider/include/ha_init_child3_3.inc new file mode 100644 index 00000000000..5724a50b3d9 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_init_child3_3.inc @@ -0,0 +1,140 @@ +--let $CHILD3_3_ENGINE_TYPE=Spider +--let $CHILD3_3_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_3_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_3_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_3_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_3_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_3_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_3_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_3_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_3_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_3_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_3_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/include/ha_init_master_1.inc b/storage/spider/mysql-test/spider/include/ha_init_master_1.inc new file mode 100644 index 00000000000..78797d80ce7 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/ha_init_master_1.inc @@ -0,0 +1,105 @@ +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $MASTER_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $MASTER_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $MASTER_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $MASTER_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $MASTER_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; +let $MASTER_1_COPY_TABLES_2_1= + SELECT spider_copy_tables('ta_l', '0', '1'); + +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $MASTER_1_COMMENT_HA_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_COMMENT_HA_AS_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $MASTER_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $MASTER_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +let $MASTER_1_COPY_TABLES_P_2_1= + SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +let $MASTER_1_CHECK_HA_STATUS= + SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +let $MASTER_1_CHANGE_HA_MON= + SELECT spider_flush_table_mon_cache(); diff --git a/storage/spider/mysql-test/spider/include/hs_deinit_child2_1.inc b/storage/spider/mysql-test/spider/include/hs_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/hs_deinit_child2_2.inc b/storage/spider/mysql-test/spider/include/hs_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/hs_deinit_child2_3.inc b/storage/spider/mysql-test/spider/include/hs_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/hs_deinit_master_1.inc b/storage/spider/mysql-test/spider/include/hs_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/hs_init_child2_1.inc b/storage/spider/mysql-test/spider/include/hs_init_child2_1.inc new file mode 100644 index 00000000000..2ea1c0c9cd6 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/hs_init_child2_1.inc @@ -0,0 +1,24 @@ +let $CHILD2_1_HS_DROP_TABLES= + DROP TABLE IF EXISTS hs_r; +let $CHILD2_1_HS_CREATE_TABLES= + CREATE TABLE hs_r ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_HS_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r ORDER BY a; +let $CHILD2_1_HS_DROP_TABLES2= + DROP TABLE IF EXISTS hs_r2; +let $CHILD2_1_HS_CREATE_TABLES2= + CREATE TABLE hs_r2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_HS_SELECT_TABLES2= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r2 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/include/hs_init_child2_2.inc b/storage/spider/mysql-test/spider/include/hs_init_child2_2.inc new file mode 100644 index 00000000000..7c69d73ced6 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/hs_init_child2_2.inc @@ -0,0 +1,12 @@ +let $CHILD2_2_HS_DROP_TABLES= + DROP TABLE IF EXISTS hs_r3; +let $CHILD2_2_HS_CREATE_TABLES= + CREATE TABLE hs_r3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + d INT DEFAULT 11, + PRIMARY KEY(a) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_HS_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r3 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/include/hs_init_child2_3.inc b/storage/spider/mysql-test/spider/include/hs_init_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/include/hs_init_master_1.inc b/storage/spider/mysql-test/spider/include/hs_init_master_1.inc new file mode 100644 index 00000000000..0ff5e2a10d9 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/hs_init_master_1.inc @@ -0,0 +1,12 @@ +let $MASTER_1_HS_COMMENT_TMP= + COMMENT=''; +let $MASTER_1_HS_COMMENT_2_1= + COMMENT='srv "s_2_1", table "hs_r", uhr "1", uhw "1", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"'; +let $MASTER_1_HS_COMMENT_P_2_1= + COMMENT='uhr "1", uhw "1"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) + COMMENT='srv "s_2_1", table "hs_r2", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", table "hs_r3", hrp "$CHILD2_2_HSRPORT", hwp "$CHILD2_2_HSWPORT"' + ); diff --git a/storage/spider/mysql-test/spider/include/init_child2_1.inc b/storage/spider/mysql-test/spider/include/init_child2_1.inc new file mode 100644 index 00000000000..ff4e1666ee1 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_child2_1.inc @@ -0,0 +1,178 @@ +--let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE +--source ../include/init_engine.inc +--let $INIT_CHILD2_1_ENGINE= $INIT_TEST_ENGINE +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS ta_r; +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE ta_r ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +let $CHILD2_1_DROP_TABLES2= + DROP TABLE IF EXISTS ta_r2; +let $CHILD2_1_CREATE_TABLES2= + CREATE TABLE ta_r2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES2= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r2 ORDER BY a; +let $CHILD2_1_DROP_TABLES3= + DROP TABLE IF EXISTS ta_r_no_idx; +let $CHILD2_1_CREATE_TABLES3= + CREATE TABLE ta_r_no_idx ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES3= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_no_idx ORDER BY a; +let $CHILD2_1_DROP_TABLES4= + DROP TABLE IF EXISTS ta_r_auto_inc; +let $CHILD2_1_CREATE_TABLES4= + CREATE TABLE ta_r_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES4= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_auto_inc + ORDER BY a; +let $CHILD2_1_DROP_TABLES5= + DROP TABLE IF EXISTS ta_r_int; +let $CHILD2_1_CREATE_TABLES5= + CREATE TABLE ta_r_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES5= + SELECT a, b, c FROM ta_r_int ORDER BY a; +let $CHILD2_1_DROP_TABLES6= + DROP TABLE IF EXISTS ta_r_3; +let $CHILD2_1_CREATE_TABLES6= + CREATE TABLE ta_r_3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES6= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_3 ORDER BY a; +let $CHILD2_1_DROP_FT_TABLES= + DROP TABLE IF EXISTS ft_r; +let $CHILD2_1_CREATE_FT_TABLES= + CREATE TABLE ft_r ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET; +let $CHILD2_1_SELECT_FT_TABLES= + SELECT a, b, c, d FROM ft_r ORDER BY a; +let $CHILD2_1_DROP_FT_TABLES2= + DROP TABLE IF EXISTS ft_r2; +let $CHILD2_1_CREATE_FT_TABLES2= + CREATE TABLE ft_r2 ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET; +let $CHILD2_1_SELECT_FT_TABLES2= + SELECT a, b, c, d FROM ft_r2 ORDER BY a; +let $CHILD2_1_DROP_GM_TABLES= + DROP TABLE IF EXISTS gm_r; +let $CHILD2_1_CREATE_GM_TABLES= + CREATE TABLE gm_r ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET; +let $CHILD2_1_SELECT_GM_TABLES= + SELECT a, b, c FROM gm_r ORDER BY a; +let $CHILD2_1_DROP_GM_TABLES2= + DROP TABLE IF EXISTS gm_r2; +let $CHILD2_1_CREATE_GM_TABLES2= + CREATE TABLE gm_r2 ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET; +let $CHILD2_1_SELECT_GM_TABLES2= + SELECT a, b, c FROM gm_r2 ORDER BY a; +let $CHILD2_1_DROP_LOCK_TABLES1= + DROP TABLE IF EXISTS t1_1; +let $CHILD2_1_CREATE_LOCK_TABLES1= + CREATE TABLE t1_1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_DROP_LOCK_TABLES2= + DROP TABLE IF EXISTS t2_2; +let $CHILD2_1_CREATE_LOCK_TABLES2= + CREATE TABLE t2_2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_DROP_INCREMENT_TABLES1= + DROP TABLE IF EXISTS t1_1; +let $CHILD2_1_CREATE_INCREMENT_TABLES1= + CREATE TABLE t1_1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_INCREMENT_TABLES1= + SELECT id FROM t1_1 ORDER BY id; +let $CHILD2_1_DROP_TEXT_PK_TABLES1= + DROP TABLE IF EXISTS t1; +let $CHILD2_1_CREATE_TEXT_PK_TABLES1= + CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY (a) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET2; +let $CHILD2_1_SELECT_TEXT_PK_TABLES1= + SELECT a FROM t1 ORDER BY a; +let $CHILD2_1_DROP_TEXT_KEY_TABLES1= + DROP TABLE IF EXISTS t1; +let $CHILD2_1_CREATE_TEXT_KEY_TABLES1= + CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TEXT_KEY_TABLES1= + SELECT a, b FROM t1 ORDER BY a, b; +let $CHILD2_1_AUTO_INCREMENT_INCREMENT1= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 1; +let $CHILD2_1_AUTO_INCREMENT_INCREMENT2= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 4; +let $CHILD2_1_AUTO_INCREMENT_OFFSET1= + SET GLOBAL AUTO_INCREMENT_OFFSET = 1; +let $CHILD2_1_AUTO_INCREMENT_OFFSET2= + SET GLOBAL AUTO_INCREMENT_OFFSET = 2; diff --git a/storage/spider/mysql-test/spider/include/init_child2_2.inc b/storage/spider/mysql-test/spider/include/init_child2_2.inc new file mode 100644 index 00000000000..b20783cc42b --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_child2_2.inc @@ -0,0 +1,83 @@ +--let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE +--source ../include/init_engine.inc +--let $INIT_CHILD2_2_ENGINE= $INIT_TEST_ENGINE +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS ta_r3; +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE ta_r3 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_TABLES5= + DROP TABLE IF EXISTS ta_r_int; +let $CHILD2_2_CREATE_TABLES5= + CREATE TABLE ta_r_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r3 ORDER BY a; +let $CHILD2_2_DROP_FT_TABLES= + DROP TABLE IF EXISTS ft_r3; +let $CHILD2_2_CREATE_FT_TABLES= + CREATE TABLE ft_r3 ( + a INT DEFAULT 0, + b TEXT, + c TEXT, + d TEXT, + PRIMARY KEY(a), + FULLTEXT INDEX ft_idx1(b), + FULLTEXT INDEX ft_idx2(c) + ) $CHILD2_2_FT_ENGINE $CHILD2_2_FT_CHARSET; +let $CHILD2_2_SELECT_FT_TABLES= + SELECT a, b, c, d FROM ft_r3 ORDER BY a; +let $CHILD2_2_DROP_GM_TABLES= + DROP TABLE IF EXISTS gm_r3; +let $CHILD2_2_CREATE_GM_TABLES= + CREATE TABLE gm_r3 ( + a INT DEFAULT 0, + b GEOMETRY NOT NULL, + c GEOMETRY NOT NULL, + PRIMARY KEY(a), + SPATIAL INDEX sp_idx1(b), + SPATIAL INDEX sp_idx2(c) + ) $CHILD2_2_GM_ENGINE $CHILD2_2_GM_CHARSET; +let $CHILD2_2_SELECT_GM_TABLES= + SELECT a, b, c FROM gm_r3 ORDER BY a; +let $CHILD2_2_DROP_LOCK_TABLES1= + DROP TABLE IF EXISTS t1_2; +let $CHILD2_2_CREATE_LOCK_TABLES1= + CREATE TABLE t1_2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_LOCK_TABLES2= + DROP TABLE IF EXISTS t2_1; +let $CHILD2_2_CREATE_LOCK_TABLES2= + CREATE TABLE t2_1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_DROP_INCREMENT_TABLES1= + DROP TABLE IF EXISTS t1_2; +let $CHILD2_2_CREATE_INCREMENT_TABLES1= + CREATE TABLE t1_2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +let $CHILD2_2_SELECT_INCREMENT_TABLES1= + SELECT id FROM t1_2 ORDER BY id; +let $CHILD2_2_AUTO_INCREMENT_INCREMENT1= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 1; +let $CHILD2_2_AUTO_INCREMENT_INCREMENT2= + SET GLOBAL AUTO_INCREMENT_INCREMENT = 4; +let $CHILD2_2_AUTO_INCREMENT_OFFSET1= + SET GLOBAL AUTO_INCREMENT_OFFSET = 1; +let $CHILD2_2_AUTO_INCREMENT_OFFSET2= + SET GLOBAL AUTO_INCREMENT_OFFSET = 3; diff --git a/storage/spider/mysql-test/spider/include/init_child2_3.inc b/storage/spider/mysql-test/spider/include/init_child2_3.inc new file mode 100644 index 00000000000..4e8d289bdc9 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_child2_3.inc @@ -0,0 +1,14 @@ +--let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE +--source ../include/init_engine.inc +--let $INIT_CHILD2_3_ENGINE= $INIT_TEST_ENGINE +let $CHILD2_3_DROP_TABLES= + DROP TABLE IF EXISTS ta_r4; +let $CHILD2_3_CREATE_TABLES= + CREATE TABLE ta_r4 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD2_3_ENGINE $CHILD2_3_CHARSET; +let $CHILD2_3_SELECT_TABLES= + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r4 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/include/init_child3_1.inc b/storage/spider/mysql-test/spider/include/init_child3_1.inc new file mode 100644 index 00000000000..7e4c05d9500 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_child3_1.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE +--source ../include/init_engine.inc +--let $INIT_CHILD3_1_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/include/init_child3_2.inc b/storage/spider/mysql-test/spider/include/init_child3_2.inc new file mode 100644 index 00000000000..246a7985984 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_child3_2.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE +--source ../include/init_engine.inc +--let $INIT_CHILD3_2_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/include/init_child3_3.inc b/storage/spider/mysql-test/spider/include/init_child3_3.inc new file mode 100644 index 00000000000..a0e5fdf6981 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_child3_3.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE +--source ../include/init_engine.inc +--let $INIT_CHILD3_3_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/include/init_engine.inc b/storage/spider/mysql-test/spider/include/init_engine.inc new file mode 100644 index 00000000000..820a598f54e --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_engine.inc @@ -0,0 +1,10 @@ +let $INIT_TEST_ENGINE=0; +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = '$TEST_ENGINE_TYPE'`) +{ + if (!$SKIP_REASON) + { + --let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine" + } +} diff --git a/storage/spider/mysql-test/spider/include/init_master_1.inc b/storage/spider/mysql-test/spider/include/init_master_1.inc new file mode 100644 index 00000000000..93947a8d454 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_master_1.inc @@ -0,0 +1,186 @@ +--source ../include/init_spider.inc +SET spider_direct_order_limit= 10000; +SET spider_init_sql_alloc_size= 1; +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_2_1= + COMMENT='database "auto_test_remote", table "ta_r"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_2_1= + COMMENT='database "auto_test_remote", table "ta_r"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT2_2_1= + COMMENT='database "auto_test_remote", table "ta_r_no_idx"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password "", prt "2000000"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT2_2_1= + COMMENT='database "auto_test_remote", table "ta_r_no_idx"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password "", prt "2000000"'; +} +let $MASTER_1_COMMENT_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1", table "ta_r2", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT2_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ta_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT3_2_1= + COMMENT='database "auto_test_remote", table "ta_r_auto_inc"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT3_2_1= + COMMENT='database "auto_test_remote", table "ta_r_auto_inc"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +let $MASTER_1_COMMENT3_P_2_1= + COMMENT='table "ta_r_int"' + PARTITION BY LIST(MOD(a, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='srv "s_2_1", priority "1000"', + PARTITION pt2 VALUES IN (1) + COMMENT='srv "s_2_2", priority "1000001"' + ); +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT4_2_1= + COMMENT='database "auto_test_remote", table "ta_r_int"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT4_2_1= + COMMENT='database "auto_test_remote", table "ta_r_int"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT5_2_1= + COMMENT='database "auto_test_remote", table "ta_r_3"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT5_2_1= + COMMENT='database "auto_test_remote", table "ta_r_3"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_FT_2_1= + COMMENT='database "auto_test_remote", table "ft_r"' + CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root", + password ""'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_FT_2_1= + COMMENT='database "auto_test_remote", table "ft_r"' + CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", + password ""'; +} +let $MASTER_1_COMMENT2_FT_P_2_1= + COMMENT='table "ft_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ft_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT_GM_2_1= + COMMENT='srv "s_2_1", table "gm_r"'; +let $MASTER_1_COMMENT2_GM_P_2_1= + COMMENT='table "gm_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "gm_r2", priority "1000"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001"' + ); +let $MASTER_1_COMMENT_LOCK1= + COMMENT 'tbl "t1_1 t1_2", srv "s_2_1 s_2_2"'; +let $MASTER_1_COMMENT_LOCK2= + COMMENT 'tbl "t2_1 t2_2", srv "s_2_2 s_2_1"'; +let $MASTER_1_COMMENT_INCREMENT1_1= + COMMENT 'aim "0", tbl "t1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_INCREMENT1_P_1= + COMMENT 'aim "0"' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='tbl "t1_1", srv "s_2_1"', + PARTITION pt2 VALUES IN (1) + COMMENT='tbl "t1_2", srv "s_2_2"' + ); +let $MASTER_1_COMMENT_READONLY1_1= + COMMENT 'read_only_mode "1", tbl "t1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_ERROR_MODE1_1= + COMMENT 'erm "1", ewm "1", tbl "ter1_1", srv "s_2_1"'; +let $MASTER_1_COMMENT_TEXT_PK1_1= + COMMENT 'tbl "t1", srv "s_2_1"'; +let $MASTER_1_COMMENT_TEXT_KEY1_1= + COMMENT 'tbl "t1", srv "s_2_1"'; +let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS= + SHOW STATUS LIKE 'Spider_direct_update'; +let $MASTER_1_CHECK_DIRECT_DELETE_STATUS= + SHOW STATUS LIKE 'Spider_direct_delete'; +let $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS= + SHOW STATUS LIKE 'Spider_direct_order_limit'; +let $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS= + SHOW STATUS LIKE 'Spider_direct_aggregate'; +let $MASTER_1_AUTO_INCREMENT_INCREMENT1= + SET SESSION AUTO_INCREMENT_INCREMENT = 1 $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_INCREMENT2= + SET SESSION AUTO_INCREMENT_INCREMENT = 777 $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET1= + SET SESSION AUTO_INCREMENT_OFFSET = 1 $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET2= + SET SESSION AUTO_INCREMENT_OFFSET = 777 $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', + 'srv "s_2_1"') $STR_SEMICOLON + SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', + 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET3= + SET SESSION AUTO_INCREMENT_OFFSET = 1; +let $MASTER_1_AUTO_INCREMENT_OFFSET4= + SET SESSION AUTO_INCREMENT_OFFSET = 777; diff --git a/storage/spider/mysql-test/spider/include/init_slave1_1.inc b/storage/spider/mysql-test/spider/include/init_slave1_1.inc new file mode 100644 index 00000000000..87c05f1f690 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_slave1_1.inc @@ -0,0 +1,10 @@ +let $SLAVE1_1_COMMENT_INCREMENT1_1= + COMMENT ''; +let $SLAVE1_1_COMMENT_INCREMENT1_P_1= + COMMENT '' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='', + PARTITION pt2 VALUES IN (1) + COMMENT='' + ); diff --git a/storage/spider/mysql-test/spider/include/init_spider.inc b/storage/spider/mysql-test/spider/include/init_spider.inc new file mode 100644 index 00000000000..90c4b7d7084 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/init_spider.inc @@ -0,0 +1,339 @@ +let $VERSION_COMPILE_OS_WIN= + `SELECT IF(@@version_compile_os like 'Win%', 1, 0)`; +if ($VERSION_COMPILE_OS_WIN) +{ + INSTALL PLUGIN spider SONAME 'ha_spider.dll'; + CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.dll'; + CREATE AGGREGATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.dll'; + CREATE FUNCTION spider_ping_table RETURNS INT SONAME 'ha_spider.dll'; + CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.dll'; + CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.dll'; + eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_remote', + USER 'root', + PASSWORD '', + PORT $CHILD2_1_MYPORT + ); + eval CREATE SERVER s_2_2 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_remote2', + USER 'root', + PASSWORD '', + PORT $CHILD2_2_MYPORT + ); + eval CREATE SERVER s_2_3 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_remote3', + USER 'root', + PASSWORD '', + PORT $CHILD2_3_MYPORT + ); + eval CREATE SERVER s_3_1 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD3_1_MYPORT + ); + eval CREATE SERVER s_3_2 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD3_2_MYPORT + ); + eval CREATE SERVER s_3_3 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD2_3_MYPORT + ); +} +if (!$VERSION_COMPILE_OS_WIN) +{ + INSTALL PLUGIN spider SONAME 'ha_spider.so'; + CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; + CREATE AGGREGATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; + CREATE FUNCTION spider_ping_table RETURNS INT SONAME 'ha_spider.so'; + CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; + CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; + eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_remote', + USER 'root', + PASSWORD '', + SOCKET '$CHILD2_1_MYSOCK' + ); + eval CREATE SERVER s_2_2 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_remote2', + USER 'root', + PASSWORD '', + SOCKET '$CHILD2_2_MYSOCK' + ); + eval CREATE SERVER s_2_3 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_remote3', + USER 'root', + PASSWORD '', + SOCKET '$CHILD2_3_MYSOCK' + ); + eval CREATE SERVER s_3_1 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_1_MYSOCK' + ); + eval CREATE SERVER s_3_2 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_2_MYSOCK' + ); + eval CREATE SERVER s_3_3 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_3_MYSOCK' + ); +} + +let $PLUGIN_VERSION= + `SELECT SUBSTRING_INDEX(plugin_version, '.', 1) + FROM information_schema.plugins + WHERE plugin_name = 'SPIDER'`; +if (`SELECT IF($PLUGIN_VERSION = 1, 1, 0)`) +{ + DROP TABLE IF EXISTS mysql.spider_xa; + CREATE TABLE mysql.spider_xa( + format_id int not null default 0, + gtrid_length int not null default 0, + bqual_length int not null default 0, + data char(128) charset binary not null default '', + status char(8) not null default '', + PRIMARY KEY (data, format_id, gtrid_length), + KEY idx1 (status) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_xa_member; + CREATE TABLE mysql.spider_xa_member( + format_id int not null default 0, + gtrid_length int not null default 0, + bqual_length int not null default 0, + data char(128) charset binary not null default '', + scheme char(64) not null default '', + host char(64) not null default '', + port char(5) not null default '', + socket char(64) not null default '', + username char(64) not null default '', + password char(64) not null default '', + PRIMARY KEY (data, format_id, gtrid_length, host, port, socket) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_tables; + CREATE TABLE mysql.spider_tables( + db_name char(64) not null default '', + table_name char(64) not null default '', + priority bigint not null default 0, + server char(64) default null, + scheme char(64) default null, + host char(64) default null, + port char(5) default null, + socket char(64) default null, + username char(64) default null, + password char(64) default null, + tgt_db_name char(64) default null, + tgt_table_name char(64) default null, + PRIMARY KEY (db_name, table_name), + KEY idx1 (priority) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +} +if (`SELECT IF($PLUGIN_VERSION = 2, 1, 0)`) +{ + DROP TABLE IF EXISTS mysql.spider_xa; + CREATE TABLE mysql.spider_xa( + format_id int not null default 0, + gtrid_length int not null default 0, + bqual_length int not null default 0, + data char(128) charset binary not null default '', + status char(8) not null default '', + PRIMARY KEY (data, format_id, gtrid_length), + KEY idx1 (status) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_xa_member; + CREATE TABLE mysql.spider_xa_member( + format_id int not null default 0, + gtrid_length int not null default 0, + bqual_length int not null default 0, + data char(128) charset binary not null default '', + scheme char(64) not null default '', + host char(64) not null default '', + port char(5) not null default '', + socket char(64) not null default '', + username char(64) not null default '', + password char(64) not null default '', + ssl_ca char(64) default null, + ssl_capath char(64) default null, + ssl_cert char(64) default null, + ssl_cipher char(64) default null, + ssl_key char(64) default null, + ssl_verify_server_cert tinyint not null default 0, + default_file char(64) default null, + default_group char(64) default null, + PRIMARY KEY (data, format_id, gtrid_length, host, port, socket) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_tables; + CREATE TABLE mysql.spider_tables( + db_name char(64) not null default '', + table_name char(64) not null default '', + link_id int not null default 0, + priority bigint not null default 0, + server char(64) default null, + scheme char(64) default null, + host char(64) default null, + port char(5) default null, + socket char(64) default null, + username char(64) default null, + password char(64) default null, + ssl_ca char(64) default null, + ssl_capath char(64) default null, + ssl_cert char(64) default null, + ssl_cipher char(64) default null, + ssl_key char(64) default null, + ssl_verify_server_cert tinyint not null default 0, + default_file char(64) default null, + default_group char(64) default null, + tgt_db_name char(64) default null, + tgt_table_name char(64) default null, + link_status tinyint not null default 1, + PRIMARY KEY (db_name, table_name, link_id), + KEY idx1 (priority) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_link_mon_servers; + CREATE TABLE mysql.spider_link_mon_servers( + db_name char(64) not null default '', + table_name char(64) not null default '', + link_id char(5) not null default '', + sid int not null default 0, + server char(64) default null, + scheme char(64) default null, + host char(64) default null, + port char(5) default null, + socket char(64) default null, + username char(64) default null, + password char(64) default null, + ssl_ca char(64) default null, + ssl_capath char(64) default null, + ssl_cert char(64) default null, + ssl_cipher char(64) default null, + ssl_key char(64) default null, + ssl_verify_server_cert tinyint not null default 0, + default_file char(64) default null, + default_group char(64) default null, + PRIMARY KEY (db_name, table_name, link_id, sid) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_link_failed_log; + CREATE TABLE mysql.spider_link_failed_log( + db_name char(64) not null default '', + table_name char(64) not null default '', + link_id int not null default 0, + failed_time timestamp not null default current_timestamp + ) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +} +if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) +{ + DROP TABLE IF EXISTS mysql.spider_xa; + CREATE TABLE mysql.spider_xa( + format_id int not null default 0, + gtrid_length int not null default 0, + bqual_length int not null default 0, + data char(128) charset binary not null default '', + status char(8) not null default '', + PRIMARY KEY (data, format_id, gtrid_length), + KEY idx1 (status) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_xa_member; + CREATE TABLE mysql.spider_xa_member( + format_id int not null default 0, + gtrid_length int not null default 0, + bqual_length int not null default 0, + data char(128) charset binary not null default '', + scheme char(64) not null default '', + host char(64) not null default '', + port char(5) not null default '', + socket text not null default '', + username char(64) not null default '', + password char(64) not null default '', + ssl_ca text default null, + ssl_capath text default null, + ssl_cert text default null, + ssl_cipher char(64) default null, + ssl_key text default null, + ssl_verify_server_cert tinyint not null default 0, + default_file text default null, + default_group char(64) default null, + KEY idx1 (data, format_id, gtrid_length, host) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_tables; + CREATE TABLE mysql.spider_tables( + db_name char(64) not null default '', + table_name char(64) not null default '', + link_id int not null default 0, + priority bigint not null default 0, + server char(64) default null, + scheme char(64) default null, + host char(64) default null, + port char(5) default null, + socket text default null, + username char(64) default null, + password char(64) default null, + ssl_ca text default null, + ssl_capath text default null, + ssl_cert text default null, + ssl_cipher char(64) default null, + ssl_key text default null, + ssl_verify_server_cert tinyint not null default 0, + default_file text default null, + default_group char(64) default null, + tgt_db_name char(64) default null, + tgt_table_name char(64) default null, + link_status tinyint not null default 1, + PRIMARY KEY (db_name, table_name, link_id), + KEY idx1 (priority) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_link_mon_servers; + CREATE TABLE mysql.spider_link_mon_servers( + db_name char(64) not null default '', + table_name char(64) not null default '', + link_id char(5) not null default '', + sid int not null default 0, + server char(64) default null, + scheme char(64) default null, + host char(64) default null, + port char(5) default null, + socket text default null, + username char(64) default null, + password char(64) default null, + ssl_ca text default null, + ssl_capath text default null, + ssl_cert text default null, + ssl_cipher char(64) default null, + ssl_key text default null, + ssl_verify_server_cert tinyint not null default 0, + default_file text default null, + default_group char(64) default null, + PRIMARY KEY (db_name, table_name, link_id, sid) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + DROP TABLE IF EXISTS mysql.spider_link_failed_log; + CREATE TABLE mysql.spider_link_failed_log( + db_name char(64) not null default '', + table_name char(64) not null default '', + link_id int not null default 0, + failed_time timestamp not null default current_timestamp + ) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +} + +SET spider_internal_sql_log_off= 0; diff --git a/storage/spider/mysql-test/spider/my.cnf b/storage/spider/mysql-test/spider/my.cnf new file mode 100644 index 00000000000..deca681c3a3 --- /dev/null +++ b/storage/spider/mysql-test/spider/my.cnf @@ -0,0 +1,177 @@ +# Use default setting for mysqld processes +!include include/default_mysqld.cnf + +[mysqld.1.1] +log-bin= master-bin +loose_handlersocket_port= 20000 +loose_handlersocket_port_wr= 20001 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 +loose_partition= 1 + +[mysqld.2.1] +loose_handlersocket_port= 20002 +loose_handlersocket_port_wr= 20003 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[mysqld.2.2] +loose_handlersocket_port= 20004 +loose_handlersocket_port_wr= 20005 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[mysqld.2.3] + +[mysqld.3.1] +loose_partition= 1 + +[mysqld.3.2] +loose_partition= 1 + +[mysqld.3.3] +loose_partition= 1 + +[mysqld.4.1] +loose_partition= 1 + + +[ENV] +USE_GEOMETRY_TEST= 1 +USE_FULLTEXT_TEST= 1 +USE_HA_TEST= 1 +USE_GENERAL_LOG= 1 +USE_REPLICATION= 1 +MASTER_1_MYPORT= @mysqld.1.1.port +MASTER_1_HSRPORT= 20000 +MASTER_1_HSWPORT= 20001 +MASTER_1_MYSOCK= @mysqld.1.1.socket +MASTER_1_ENGINE_TYPE= Spider +#MASTER_1_ENGINE_TYPE= MyISAM +MASTER_1_ENGINE= ENGINE=Spider +MASTER_1_CHARSET= DEFAULT CHARSET=utf8 +MASTER_1_ENGINE2= ENGINE=MyISAM +MASTER_1_CHARSET2= DEFAULT CHARSET=utf8 +MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +SLAVE1_1_MYPORT= @mysqld.4.1.port +SLAVE1_1_MYSOCK= @mysqld.4.1.socket +SLAVE1_1_ENGINE_TYPE= MyISAM +SLAVE1_1_ENGINE= ENGINE=MyISAM +SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP2= 1 +OUTPUT_CHILD_GROUP2= 0 +CHILD2_1_MYPORT= @mysqld.2.1.port +CHILD2_1_HSRPORT= 20002 +CHILD2_1_HSWPORT= 20003 +CHILD2_1_MYSOCK= @mysqld.2.1.socket +CHILD2_1_ENGINE_TYPE= InnoDB +CHILD2_1_ENGINE= ENGINE=InnoDB +CHILD2_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +CHILD2_2_MYPORT= @mysqld.2.2.port +CHILD2_2_HSRPORT= 20004 +CHILD2_2_HSWPORT= 20005 +CHILD2_2_MYSOCK= @mysqld.2.2.socket +CHILD2_2_ENGINE_TYPE= InnoDB +CHILD2_2_ENGINE= ENGINE=InnoDB +CHILD2_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_3_MYPORT= @mysqld.2.3.port +CHILD2_3_MYSOCK= @mysqld.2.3.socket +CHILD2_3_ENGINE_TYPE= InnoDB +CHILD2_3_ENGINE= ENGINE=InnoDB +CHILD2_3_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_FT_MYPORT= @mysqld.2.1.port +CHILD2_1_FT_MYSOCK= @mysqld.2.1.socket +CHILD2_1_FT_ENGINE_TYPE= MyISAM +CHILD2_1_FT_ENGINE= ENGINE=MyISAM +CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_FT_MYPORT= @mysqld.2.2.port +CHILD2_2_FT_MYSOCK= @mysqld.2.2.socket +CHILD2_2_FT_ENGINE_TYPE= MyISAM +CHILD2_2_FT_ENGINE= ENGINE=MyISAM +CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_GM_MYPORT= @mysqld.2.1.port +CHILD2_1_GM_MYSOCK= @mysqld.2.1.socket +CHILD2_1_GM_ENGINE_TYPE= MyISAM +CHILD2_1_GM_ENGINE= ENGINE=MyISAM +CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_GM_MYPORT= @mysqld.2.2.port +CHILD2_2_GM_MYSOCK= @mysqld.2.2.socket +CHILD2_2_GM_ENGINE_TYPE= MyISAM +CHILD2_2_GM_ENGINE= ENGINE=MyISAM +CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP3= 1 +OUTPUT_CHILD_GROUP3= 0 +CHILD3_1_MYPORT= @mysqld.3.1.port +CHILD3_1_MYSOCK= @mysqld.3.1.socket +CHILD3_1_ENGINE_TYPE= InnoDB +CHILD3_1_ENGINE= ENGINE=InnoDB +CHILD3_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_2_MYPORT= @mysqld.3.2.port +CHILD3_2_MYSOCK= @mysqld.3.2.socket +CHILD3_2_ENGINE_TYPE= InnoDB +CHILD3_2_ENGINE= ENGINE=InnoDB +CHILD3_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_3_MYPORT= @mysqld.3.3.port +CHILD3_3_MYSOCK= @mysqld.3.3.socket +CHILD3_3_ENGINE_TYPE= InnoDB +CHILD3_3_ENGINE= ENGINE=InnoDB +CHILD3_3_CHARSET= DEFAULT CHARSET=utf8 + +STR_SEMICOLON= ; + +#The followings are setted in include/init_xxx.inc files +#MASTER_1_COMMENT_2_1 +#MASTER_1_COMMENT2_2_1 +#MASTER_1_COMMENT3_2_1 +#MASTER_1_COMMENT4_2_1 +#MASTER_1_COMMENT5_2_1 +#MASTER_1_COMMENT_P_2_1 +#CHILD2_1_DROP_TABLES +#CHILD2_1_CREATE_TABLES +#CHILD2_1_SELECT_TABLES +#CHILD2_1_DROP_TABLES2 +#CHILD2_1_CREATE_TABLES2 +#CHILD2_1_SELECT_TABLES2 +#CHILD2_1_DROP_TABLES3 +#CHILD2_1_CREATE_TABLES3 +#CHILD2_1_SELECT_TABLES3 +#CHILD2_1_DROP_TABLES4 +#CHILD2_1_CREATE_TABLES4 +#CHILD2_1_SELECT_TABLES4 +#CHILD2_1_DROP_TABLES5 +#CHILD2_1_CREATE_TABLES5 +#CHILD2_1_SELECT_TABLES5 +#CHILD2_1_DROP_TABLES6 +#CHILD2_1_CREATE_TABLES6 +#CHILD2_1_SELECT_TABLES6 +#CHILD2_2_DROP_TABLES +#CHILD2_2_CREATE_TABLES +#CHILD2_2_SELECT_TABLES diff --git a/storage/spider/mysql-test/spider/oracle/include/deinit_child2_1.inc b/storage/spider/mysql-test/spider/oracle/include/deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/deinit_child2_2.inc b/storage/spider/mysql-test/spider/oracle/include/deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/deinit_child2_3.inc b/storage/spider/mysql-test/spider/oracle/include/deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/deinit_child3_1.inc b/storage/spider/mysql-test/spider/oracle/include/deinit_child3_1.inc new file mode 100644 index 00000000000..9b6a9851ccb --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/deinit_child3_1.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_1_ENGINE +--source ../../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/oracle/include/deinit_child3_2.inc b/storage/spider/mysql-test/spider/oracle/include/deinit_child3_2.inc new file mode 100644 index 00000000000..ac0bcdaa938 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/deinit_child3_2.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_2_ENGINE +--source ../../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/oracle/include/deinit_child3_3.inc b/storage/spider/mysql-test/spider/oracle/include/deinit_child3_3.inc new file mode 100644 index 00000000000..c93a9822d90 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/deinit_child3_3.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_3_ENGINE +--source ../../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/oracle/include/deinit_master_1.inc b/storage/spider/mysql-test/spider/oracle/include/deinit_master_1.inc new file mode 100644 index 00000000000..c19e376d10a --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/deinit_master_1.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/oracle/include/deinit_slave1_1.inc b/storage/spider/mysql-test/spider/oracle/include/deinit_slave1_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_1.inc b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_2.inc b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_3.inc b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_1.inc b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_1.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_1.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_2.inc b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_2.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_2.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_3.inc b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_3.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_child3_3.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_deinit_master_1.inc b/storage/spider/mysql-test/spider/oracle/include/ha_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_1.inc b/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_1.inc new file mode 100644 index 00000000000..59c0175d349 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_1.inc @@ -0,0 +1,8 @@ +let $CHILD2_1_HA_AS_DROP_TABLES= + $CHILD2_1_DROP_TABLES; +let $CHILD2_1_HA_AS_CREATE_TABLES= + $CHILD2_1_CREATE_TABLES; +let $CHILD2_1_HA_AS_DROP_TABLES2= + $CHILD2_1_DROP_TABLES2; +let $CHILD2_1_HA_AS_CREATE_TABLES2= + $CHILD2_1_CREATE_TABLES2; diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_2.inc b/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_2.inc new file mode 100644 index 00000000000..90d27ed704d --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_2.inc @@ -0,0 +1,4 @@ +let $CHILD2_2_HA_DROP_TABLES= + $CHILD2_2_DROP_TABLES; +let $CHILD2_2_HA_CREATE_TABLES= + $CHILD2_2_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_3.inc b/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_3.inc new file mode 100644 index 00000000000..11abf112b1f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_init_child2_3.inc @@ -0,0 +1,4 @@ +let $CHILD2_3_HA_DROP_TABLES= + $CHILD2_3_DROP_TABLES; +let $CHILD2_3_HA_CREATE_TABLES= + $CHILD2_3_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_1.inc b/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_1.inc new file mode 100644 index 00000000000..67f6676a07a --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_1.inc @@ -0,0 +1,140 @@ +--let $CHILD3_1_ENGINE_TYPE=Spider +--let $CHILD3_1_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_1_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_1_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_1_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_2.inc b/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_2.inc new file mode 100644 index 00000000000..9b61a2e2b73 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_2.inc @@ -0,0 +1,140 @@ +--let $CHILD3_2_ENGINE_TYPE=Spider +--let $CHILD3_2_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_2_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_2_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_2_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_2_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_2_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_2_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_2_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_2_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_2_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_2_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_3.inc b/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_3.inc new file mode 100644 index 00000000000..5724a50b3d9 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_init_child3_3.inc @@ -0,0 +1,140 @@ +--let $CHILD3_3_ENGINE_TYPE=Spider +--let $CHILD3_3_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_3_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_3_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_3_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_3_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_3_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_3_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_3_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_3_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_3_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_3_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/oracle/include/ha_init_master_1.inc b/storage/spider/mysql-test/spider/oracle/include/ha_init_master_1.inc new file mode 100644 index 00000000000..8ace39ab641 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/ha_init_master_1.inc @@ -0,0 +1,109 @@ +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $MASTER_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $MASTER_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $MASTER_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", + database "$ORACLE_DATABASE", lst "0 2"'; +let $MASTER_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", + database "$ORACLE_DATABASE", lst "0 1"'; +let $MASTER_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "$ORACLE_DATABASE", lst "1 0"'; +let $MASTER_1_COPY_TABLES_2_1= + SELECT spider_copy_tables('ta_l', '0', '1'); + +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", + database "$ORACLE_DATABASE"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "$ORACLE_DATABASE"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", + database "$ORACLE_DATABASE"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "$ORACLE_DATABASE"'; +} +let $MASTER_1_COMMENT_HA_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_COMMENT_HA_AS_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $MASTER_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $MASTER_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +let $MASTER_1_COPY_TABLES_P_2_1= + SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +let $MASTER_1_CHECK_HA_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +let $MASTER_1_CHANGE_HA_MON= + SELECT spider_flush_table_mon_cache(); diff --git a/storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_1.inc b/storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_2.inc b/storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_3.inc b/storage/spider/mysql-test/spider/oracle/include/hs_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/hs_deinit_master_1.inc b/storage/spider/mysql-test/spider/oracle/include/hs_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/hs_init_child2_1.inc b/storage/spider/mysql-test/spider/oracle/include/hs_init_child2_1.inc new file mode 100644 index 00000000000..e0467b92307 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/hs_init_child2_1.inc @@ -0,0 +1,24 @@ +let $CHILD2_1_HS_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "hs_r"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "hs_r" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + "d" INT DEFAULT 11, + CONSTRAINT "pk_s_2_1_hs_r" PRIMARY KEY("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\'), "d" FROM "hs_r" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_DROP_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "hs_r2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_CREATE_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "hs_r2" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + "d" INT DEFAULT 11, + CONSTRAINT "pk_s_2_1_hs_r2" PRIMARY KEY("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_SELECT_TABLES2= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\'), "d" FROM "hs_r2" ORDER BY "a"', '', 'srv "s_2_1"'); diff --git a/storage/spider/mysql-test/spider/oracle/include/hs_init_child2_2.inc b/storage/spider/mysql-test/spider/oracle/include/hs_init_child2_2.inc new file mode 100644 index 00000000000..0466acbc66b --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/hs_init_child2_2.inc @@ -0,0 +1,12 @@ +let $CHILD2_2_HS_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "hs_r3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_HS_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "hs_r3" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + "d" INT DEFAULT 11, + CONSTRAINT "pk_s_2_2_hs_r3" PRIMARY KEY("a") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_HS_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\'), "d" FROM "hs_r3" ORDER BY "a"', '', 'srv "s_2_2"'); diff --git a/storage/spider/mysql-test/spider/oracle/include/hs_init_child2_3.inc b/storage/spider/mysql-test/spider/oracle/include/hs_init_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle/include/hs_init_master_1.inc b/storage/spider/mysql-test/spider/oracle/include/hs_init_master_1.inc new file mode 100644 index 00000000000..0ff5e2a10d9 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/hs_init_master_1.inc @@ -0,0 +1,12 @@ +let $MASTER_1_HS_COMMENT_TMP= + COMMENT=''; +let $MASTER_1_HS_COMMENT_2_1= + COMMENT='srv "s_2_1", table "hs_r", uhr "1", uhw "1", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"'; +let $MASTER_1_HS_COMMENT_P_2_1= + COMMENT='uhr "1", uhw "1"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) + COMMENT='srv "s_2_1", table "hs_r2", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", table "hs_r3", hrp "$CHILD2_2_HSRPORT", hwp "$CHILD2_2_HSWPORT"' + ); diff --git a/storage/spider/mysql-test/spider/oracle/include/init_child2_1.inc b/storage/spider/mysql-test/spider/oracle/include/init_child2_1.inc new file mode 100644 index 00000000000..18dcc7159cc --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_child2_1.inc @@ -0,0 +1,192 @@ +--connection master_1 +SELECT spider_direct_sql('ALTER SESSION SET NLS_DATE_FORMAT=\'YYYY-MM-DD HH24:MI:SS\'', '', 'srv "s_2_1"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIME_FORMAT=\'HH24:MI:SSXFF\'', '', 'srv "s_2_1"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'YYYY-MM-DD HH24:MI:SSXFF\'', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ta_r" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_1_ta_r" PRIMARY KEY("a") + )', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx1" ON "ta_r"("b")', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "ta_r2" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_1_ta_r2" PRIMARY KEY("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES2= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r2" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES3= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r_no_idx"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES3= + SELECT spider_direct_sql('CREATE TABLE "ta_r_no_idx" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\') + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES3= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r_no_idx" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES4= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r_auto_inc"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES4= + SELECT spider_direct_sql('CREATE TABLE "ta_r_auto_inc" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_1_ta_r_auto_inc" PRIMARY KEY("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES4= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r_auto_inc" + ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES5= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "s_2_1_ta_r_int"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES5= + SELECT spider_direct_sql('CREATE TABLE "s_2_1_ta_r_int" ( + "a" INT DEFAULT 3, + "b" INT DEFAULT 10, + "c" INT DEFAULT 11, + CONSTRAINT "pk_s_2_1_ta_r_int" PRIMARY KEY("a") + )', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx1_s_2_1_ta_r_int" ON "s_2_1_ta_r_int"("b")', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx2_s_2_1_ta_r_int" ON "s_2_1_ta_r_int"("c")', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES5= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "s_2_1_ta_r_int" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES6= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r_3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES6= + SELECT spider_direct_sql('CREATE TABLE "ta_r_3" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\') + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES6= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r_3" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_FT_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ft_r"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_FT_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ft_r" ( + "a" INT DEFAULT 0, + "b" TEXT, + "c" TEXT, + "d" TEXT, + CONSTRAINT "pk_s_2_1_ft_r" PRIMARY KEY("a"), + FULLTEXT INDEX "ft_idx1"("b"), + FULLTEXT INDEX "ft_idx2"("c") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_FT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", "c", "d" FROM "ft_r" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_FT_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ft_r2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_FT_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "ft_r2" ( + "a" INT DEFAULT 0, + "b" TEXT, + "c" TEXT, + "d" TEXT, + CONSTRAINT "pk_s_2_1_ft_r2" PRIMARY KEY("a"), + FULLTEXT INDEX "ft_idx1"("b"), + FULLTEXT INDEX "ft_idx2"("c") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_FT_TABLES2= + SELECT spider_direct_sql('SELECT "a", "b", "c", "d" FROM "ft_r2" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_GM_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "gm_r"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_GM_TABLES= + SELECT spider_direct_sql('CREATE TABLE "gm_r" ( + "a" INT DEFAULT 0, + "b" GEOMETRY NOT NULL, + "c" GEOMETRY NOT NULL, + CONSTRAINT "pk_s_2_1_gm_r" PRIMARY KEY("a"), + SPATIAL INDEX "sp_idx1"("b"), + SPATIAL INDEX "sp_idx2"("c") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_GM_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "gm_r" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_GM_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "gm_r2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_GM_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "gm_r2" ( + "a" INT DEFAULT 0, + "b" GEOMETRY NOT NULL, + "c" GEOMETRY NOT NULL, + CONSTRAINT "pk_s_2_1_gm_r2" PRIMARY KEY("a"), + SPATIAL INDEX "sp_idx1"("b"), + SPATIAL INDEX "sp_idx2"("c") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_GM_TABLES2= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "gm_r2" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_LOCK_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_LOCK_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1_1" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_1_t1_1" PRIMARY KEY ("id") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_LOCK_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t2_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_LOCK_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "t2_2" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_1_t2_2" PRIMARY KEY ("id") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_INCREMENT_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_INCREMENT_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1_1" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_1_t1_1" PRIMARY KEY ("id") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_INCREMENT_TABLES1= + SELECT spider_direct_sql('SELECT "id" FROM "t1_1" ORDER BY "id"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TEXT_PK_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TEXT_PK_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1" ( + "a" VARCHAR(255), + CONSTRAINT "pk_s_2_1_t1" PRIMARY KEY ("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TEXT_PK_TABLES1= + SELECT spider_direct_sql('SELECT "a" FROM "t1" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TEXT_KEY_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TEXT_KEY_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1" ( + "a" VARCHAR(255), + "b" VARCHAR(255), + "c" VARCHAR(255), + CONSTRAINT "pk_s_2_1_t1" PRIMARY KEY ("c") + )', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx1_t1" ON "t1"("a","b")', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx2_t1" ON "t1"("b")', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TEXT_KEY_TABLES1= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "t1" ORDER BY "c"', '', 'srv "s_2_1"'); +let $CHILD2_1_AUTO_INCREMENT_INCREMENT1= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_1"'); +let $CHILD2_1_AUTO_INCREMENT_INCREMENT2= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"'); +let $CHILD2_1_AUTO_INCREMENT_OFFSET1= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_1"'); +let $CHILD2_1_AUTO_INCREMENT_OFFSET2= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"'); diff --git a/storage/spider/mysql-test/spider/oracle/include/init_child2_2.inc b/storage/spider/mysql-test/spider/oracle/include/init_child2_2.inc new file mode 100644 index 00000000000..117040dcca6 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_child2_2.inc @@ -0,0 +1,94 @@ +--connection master_1 +SELECT spider_direct_sql('ALTER SESSION SET NLS_DATE_FORMAT=\'YYYY-MM-DD HH24:MI:SS\'', '', 'srv "s_2_2"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIME_FORMAT=\'HH24:MI:SSXFF\'', '', 'srv "s_2_2"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'YYYY-MM-DD HH24:MI:SSXFF\'', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ta_r3" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_2_ta_r3" PRIMARY KEY("a") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_TABLES5= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "s_2_2_ta_r_int"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_TABLES5= + SELECT spider_direct_sql('CREATE TABLE "s_2_2_ta_r_int" ( + "a" INT DEFAULT 3, + "b" INT DEFAULT 10, + "c" INT DEFAULT 11, + CONSTRAINT "pk_s_2_2_ta_r_int" PRIMARY KEY("a") + )', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx1_s_2_2_ta_r_int" ON "s_2_2_ta_r_int"("b")', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx2_s_2_2_ta_r_int" ON "s_2_2_ta_r_int"("c")', '', 'srv "s_2_2"'); +let $CHILD2_2_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r3" ORDER BY "a"', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_FT_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ft_r3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_FT_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ft_r3" ( + "a" INT DEFAULT 0, + "b" TEXT, + "c" TEXT, + "d" TEXT, + CONSTRAINT "pk_s_2_2_ft_r3" PRIMARY KEY("a"), + FULLTEXT INDEX "ft_idx1"("b"), + FULLTEXT INDEX "ft_idx2"("c") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_SELECT_FT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", "c", "d" FROM "ft_r3" ORDER BY "a"', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_GM_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "gm_r3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_GM_TABLES= + SELECT spider_direct_sql('CREATE TABLE "gm_r3" ( + "a" INT DEFAULT 0, + "b" GEOMETRY NOT NULL, + "c" GEOMETRY NOT NULL, + CONSTRAINT "pk_s_2_2_gm_r3" PRIMARY KEY("a"), + SPATIAL INDEX "sp_idx1"("b"), + SPATIAL INDEX "sp_idx2"("c") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_SELECT_GM_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "gm_r3" ORDER BY "a"', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_LOCK_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_LOCK_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1_2" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_2_t1_2" PRIMARY KEY ("id") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_LOCK_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t2_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_LOCK_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "t2_1" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_2_t2_1" PRIMARY KEY ("id") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_INCREMENT_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_INCREMENT_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1_2" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_2_t1_2" PRIMARY KEY ("id") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_SELECT_INCREMENT_TABLES1= + SELECT spider_direct_sql('SELECT "id" FROM "t1_2" ORDER BY "id"', '', 'srv "s_2_2"'); +let $CHILD2_2_AUTO_INCREMENT_INCREMENT1= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_2"'); +let $CHILD2_2_AUTO_INCREMENT_INCREMENT2= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"'); +let $CHILD2_2_AUTO_INCREMENT_OFFSET1= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_2"'); +let $CHILD2_2_AUTO_INCREMENT_OFFSET2= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"'); diff --git a/storage/spider/mysql-test/spider/oracle/include/init_child2_3.inc b/storage/spider/mysql-test/spider/oracle/include/init_child2_3.inc new file mode 100644 index 00000000000..5c06a9f6a73 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_child2_3.inc @@ -0,0 +1,15 @@ +--connection master_1 +SELECT spider_direct_sql('ALTER SESSION SET NLS_DATE_FORMAT=\'YYYY-MM-DD HH24:MI:SS\'', '', 'srv "s_2_3"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIME_FORMAT=\'HH24:MI:SSXFF\'', '', 'srv "s_2_3"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'YYYY-MM-DD HH24:MI:SSXFF\'', '', 'srv "s_2_3"'); +let $CHILD2_3_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r4"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_3"'); +let $CHILD2_3_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ta_r4" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_3_ta_r4" PRIMARY KEY("a") + )', '', 'srv "s_2_3"'); +let $CHILD2_3_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r4" ORDER BY "a"', '', 'srv "s_2_3"'); diff --git a/storage/spider/mysql-test/spider/oracle/include/init_child3_1.inc b/storage/spider/mysql-test/spider/oracle/include/init_child3_1.inc new file mode 100644 index 00000000000..f70afeb58de --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_child3_1.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE +--source ../../include/init_engine.inc +--let $INIT_CHILD3_1_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/oracle/include/init_child3_2.inc b/storage/spider/mysql-test/spider/oracle/include/init_child3_2.inc new file mode 100644 index 00000000000..e84567f2243 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_child3_2.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE +--source ../../include/init_engine.inc +--let $INIT_CHILD3_2_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/oracle/include/init_child3_3.inc b/storage/spider/mysql-test/spider/oracle/include/init_child3_3.inc new file mode 100644 index 00000000000..d3f31049ff6 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_child3_3.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE +--source ../../include/init_engine.inc +--let $INIT_CHILD3_3_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/oracle/include/init_master_1.inc b/storage/spider/mysql-test/spider/oracle/include/init_master_1.inc new file mode 100644 index 00000000000..8e79b984364 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_master_1.inc @@ -0,0 +1,149 @@ +--source ../include/init_spider.inc +SET spider_direct_order_limit= 10000; +SET spider_init_sql_alloc_size= 1; +SET spider_conn_recycle_mode= 2; +let $MASTER_1_COMMENT_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ta_r", wrapper "oracle", + pk_name "pk_s_2_1_ta_r"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD"'; +let $MASTER_1_COMMENT2_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ta_r_no_idx", wrapper "oracle", + pk_name "pk_s_2_1_ta_r_no_idx"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", prt "2000000"'; +let $MASTER_1_COMMENT_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1", table "ta_r2", + priority "1000", pk_name "pk_s_2_1_ta_r2"', + PARTITION pt2 COMMENT='srv "s_2_2", priority "1000001", + pk_name "pk_s_2_2_ta_r3"' + ); +let $MASTER_1_COMMENT2_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ta_r2", priority "1000", pk_name "pk_s_2_1_ta_r2"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001", pk_name "pk_s_2_2_ta_r3"' + ); +let $MASTER_1_COMMENT3_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ta_r_auto_inc", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", pk_name "pk_s_2_1_ta_r_auto_inc"'; +let $MASTER_1_COMMENT3_P_2_1= + COMMENT='table "s_2_1_ta_r_int"' + PARTITION BY LIST(MOD(a, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='srv "s_2_1", priority "1000", pk_name "pk_s_2_1_ta_r_int"', + PARTITION pt2 VALUES IN (1) + COMMENT='srv "s_2_2", priority "1000001", pk_name "pk_s_2_2_ta_r_int", + table "s_2_2_ta_r_int"' + ); +let $MASTER_1_COMMENT4_2_1= + COMMENT='database "$ORACLE_DATABASE", table "s_2_1_ta_r_int", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", pk_name "pk_s_2_1_ta_r_int"'; +let $MASTER_1_COMMENT5_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ta_r_3", wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", pk_name "pk_s_2_1_ta_r_3"'; +let $MASTER_1_COMMENT_FT_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ft_r", wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", pk_name "pk_s_2_1_ft_r"'; +let $MASTER_1_COMMENT2_FT_P_2_1= + COMMENT='table "ft_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ft_r2", priority "1000", pk_name "pk_s_2_1_ft_r2"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001", pk_name "pk_s_2_2_ft_r3"' + ); +let $MASTER_1_COMMENT_GM_2_1= + COMMENT='srv "s_2_1", table "gm_r", pk_name "pk_s_2_1_gm_r"'; +let $MASTER_1_COMMENT2_GM_P_2_1= + COMMENT='table "gm_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "gm_r2", priority "1000", pk_name "pk_s_2_1_gm_r2"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001", pk_name "pk_s_2_2_gm_r3"' + ); +let $MASTER_1_COMMENT_LOCK1= + COMMENT 'tbl "t1_1 t1_2", srv "s_2_1 s_2_2", + pk_name "pk_s_2_1_t1_1 pk_s_2_2_t1_2"'; +let $MASTER_1_COMMENT_LOCK2= + COMMENT 'tbl "t2_1 t2_2", srv "s_2_2 s_2_1", + pk_name "pk_s_2_2_t2_1 pk_s_2_1_t2_2"'; +let $MASTER_1_COMMENT_INCREMENT1_1= + COMMENT 'aim "0", tbl "t1_1", srv "s_2_1", pk_name "pk_s_2_1_t1_1"'; +let $MASTER_1_COMMENT_INCREMENT1_P_1= + COMMENT 'aim "0"' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='tbl "t1_1", srv "s_2_1", pk_name "pk_s_2_1_t1_1"', + PARTITION pt2 VALUES IN (1) + COMMENT='tbl "t1_2", srv "s_2_2", pk_name "pk_s_2_2_t1_2"' + ); +let $MASTER_1_COMMENT_READONLY1_1= + COMMENT 'read_only_mode "1", tbl "t1_1", srv "s_2_1", + pk_name "pk_s_2_1_t1_1"'; +let $MASTER_1_COMMENT_ERROR_MODE1_1= + COMMENT 'erm "1", ewm "1", tbl "ter1_1", srv "s_2_1", + pk_name "pk_s_2_1_ter1_1"'; +let $MASTER_1_COMMENT_TEXT_PK1_1= + COMMENT 'tbl "t1", srv "s_2_1", pk_name "pk_s_2_1_t1"'; +let $MASTER_1_COMMENT_TEXT_KEY1_1= + COMMENT 'tbl "t1", srv "s_2_1", pk_name "pk_s_2_1_t1"'; +let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +let $MASTER_1_CHECK_DIRECT_DELETE_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +let $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_direct_order_limit%'; +let $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +let $MASTER_1_AUTO_INCREMENT_INCREMENT1= + SET SESSION AUTO_INCREMENT_INCREMENT = 1 $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_INCREMENT2= + SET SESSION AUTO_INCREMENT_INCREMENT = 777 $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET1= + SET SESSION AUTO_INCREMENT_OFFSET = 1 $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET2= + SET SESSION AUTO_INCREMENT_OFFSET = 777 $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET3= + SET SESSION AUTO_INCREMENT_OFFSET = 1; +let $MASTER_1_AUTO_INCREMENT_OFFSET4= + SET SESSION AUTO_INCREMENT_OFFSET = 777; diff --git a/storage/spider/mysql-test/spider/oracle/include/init_slave1_1.inc b/storage/spider/mysql-test/spider/oracle/include/init_slave1_1.inc new file mode 100644 index 00000000000..87c05f1f690 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_slave1_1.inc @@ -0,0 +1,10 @@ +let $SLAVE1_1_COMMENT_INCREMENT1_1= + COMMENT ''; +let $SLAVE1_1_COMMENT_INCREMENT1_P_1= + COMMENT '' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='', + PARTITION pt2 VALUES IN (1) + COMMENT='' + ); diff --git a/storage/spider/mysql-test/spider/oracle/include/init_spider.inc b/storage/spider/mysql-test/spider/oracle/include/init_spider.inc new file mode 100644 index 00000000000..ff9ac9aee29 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/include/init_spider.inc @@ -0,0 +1,105 @@ +--source ../../include/init_spider.inc +let $VERSION_COMPILE_OS_WIN= + `SELECT IF(@@version_compile_os like 'Win%', 1, 0)`; +if ($VERSION_COMPILE_OS_WIN) +{ + eval DROP SERVER s_2_1; + eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_2_2; + eval CREATE SERVER s_2_2 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_2_3; + eval CREATE SERVER s_2_3 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_3_1; + eval CREATE SERVER s_3_1 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD3_1_MYPORT + ); + eval DROP SERVER s_3_2; + eval CREATE SERVER s_3_2 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD3_2_MYPORT + ); + eval DROP SERVER s_3_3; + eval CREATE SERVER s_3_3 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD2_3_MYPORT + ); +} +if (!$VERSION_COMPILE_OS_WIN) +{ + eval DROP SERVER s_2_1; + eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_2_2; + eval CREATE SERVER s_2_2 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_2_3; + eval CREATE SERVER s_2_3 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_3_1; + eval CREATE SERVER s_3_1 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_1_MYSOCK' + ); + eval DROP SERVER s_3_2; + eval CREATE SERVER s_3_2 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_2_MYSOCK' + ); + eval DROP SERVER s_3_3; + eval CREATE SERVER s_3_3 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_3_MYSOCK' + ); +} diff --git a/storage/spider/mysql-test/spider/oracle/my.cnf b/storage/spider/mysql-test/spider/oracle/my.cnf new file mode 100644 index 00000000000..e24985bb8d4 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/my.cnf @@ -0,0 +1,146 @@ +# Use default setting for mysqld processes +!include include/default_mysqld.cnf + +[mysqld.1.1] +log-bin= master-bin +loose_handlersocket_port= 20000 +loose_handlersocket_port_wr= 20001 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 +loose_partition= 1 + +[mysqld.3.1] +loose_partition= 1 + +[mysqld.3.2] +loose_partition= 1 + +[mysqld.3.3] +loose_partition= 1 + +[mysqld.4.1] +loose_partition= 1 + + +[ENV] +USE_GEOMETRY_TEST= 0 +USE_FULLTEXT_TEST= 0 +USE_HA_TEST= 1 +USE_GENERAL_LOG= 1 +USE_REPLICATION= 0 +MASTER_1_MYPORT= @mysqld.1.1.port +MASTER_1_HSRPORT= 20000 +MASTER_1_HSWPORT= 20001 +MASTER_1_MYSOCK= @mysqld.1.1.socket +MASTER_1_ENGINE_TYPE= Spider +#MASTER_1_ENGINE_TYPE= MyISAM +MASTER_1_ENGINE= ENGINE=Spider +MASTER_1_CHARSET= DEFAULT CHARSET=utf8 +MASTER_1_ENGINE2= ENGINE=MyISAM +MASTER_1_CHARSET2= DEFAULT CHARSET=utf8 +MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +SLAVE1_1_MYPORT= @mysqld.4.1.port +SLAVE1_1_MYSOCK= @mysqld.4.1.socket +SLAVE1_1_ENGINE_TYPE= MyISAM +SLAVE1_1_ENGINE= ENGINE=MyISAM +SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP2= 1 +OUTPUT_CHILD_GROUP2= 0 +CHILD2_1_MYPORT= @mysqld.1.1.port +CHILD2_1_MYSOCK= @mysqld.1.1.socket +CHILD2_1_ENGINE_TYPE= InnoDB +CHILD2_1_ENGINE= ENGINE=InnoDB +CHILD2_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +CHILD2_2_MYPORT= @mysqld.1.1.port +CHILD2_2_MYSOCK= @mysqld.1.1.socket +CHILD2_2_ENGINE_TYPE= InnoDB +CHILD2_2_ENGINE= ENGINE=InnoDB +CHILD2_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_3_MYPORT= @mysqld.1.1.port +CHILD2_3_MYSOCK= @mysqld.1.1.socket +CHILD2_3_ENGINE_TYPE= InnoDB +CHILD2_3_ENGINE= ENGINE=InnoDB +CHILD2_3_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_FT_MYPORT= @mysqld.1.1.port +CHILD2_1_FT_MYSOCK= @mysqld.1.1.socket +CHILD2_1_FT_ENGINE_TYPE= MyISAM +CHILD2_1_FT_ENGINE= ENGINE=MyISAM +CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_FT_MYPORT= @mysqld.1.1.port +CHILD2_2_FT_MYSOCK= @mysqld.1.1.socket +CHILD2_2_FT_ENGINE_TYPE= MyISAM +CHILD2_2_FT_ENGINE= ENGINE=MyISAM +CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_GM_MYPORT= @mysqld.1.1.port +CHILD2_1_GM_MYSOCK= @mysqld.1.1.socket +CHILD2_1_GM_ENGINE_TYPE= MyISAM +CHILD2_1_GM_ENGINE= ENGINE=MyISAM +CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_GM_MYPORT= @mysqld.1.1.port +CHILD2_2_GM_MYSOCK= @mysqld.1.1.socket +CHILD2_2_GM_ENGINE_TYPE= MyISAM +CHILD2_2_GM_ENGINE= ENGINE=MyISAM +CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP3= 1 +OUTPUT_CHILD_GROUP3= 0 +CHILD3_1_MYPORT= @mysqld.3.1.port +CHILD3_1_MYSOCK= @mysqld.3.1.socket +CHILD3_1_ENGINE_TYPE= InnoDB +CHILD3_1_ENGINE= ENGINE=InnoDB +CHILD3_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_2_MYPORT= @mysqld.3.2.port +CHILD3_2_MYSOCK= @mysqld.3.2.socket +CHILD3_2_ENGINE_TYPE= InnoDB +CHILD3_2_ENGINE= ENGINE=InnoDB +CHILD3_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_3_MYPORT= @mysqld.3.3.port +CHILD3_3_MYSOCK= @mysqld.3.3.socket +CHILD3_3_ENGINE_TYPE= InnoDB +CHILD3_3_ENGINE= ENGINE=InnoDB +CHILD3_3_CHARSET= DEFAULT CHARSET=utf8 +ORACLE_HOST= xe +ORACLE_PORT= 1521 +ORACLE_USER= system +ORACLE_PASSWORD= oracle +ORACLE_DATABASE= SYSTEM + +STR_SEMICOLON= ; + +#The followings are setted in include/init_xxx.inc files +#MASTER_1_COMMENT_2_1 +#MASTER_1_COMMENT2_2_1 +#MASTER_1_COMMENT3_2_1 +#MASTER_1_COMMENT4_2_1 +#MASTER_1_COMMENT5_2_1 +#MASTER_1_COMMENT_P_2_1 +#CHILD2_1_DROP_TABLES +#CHILD2_1_CREATE_TABLES +#CHILD2_1_SELECT_TABLES +#CHILD2_1_DROP_TABLES2 +#CHILD2_1_CREATE_TABLES2 +#CHILD2_1_SELECT_TABLES2 +#CHILD2_1_DROP_TABLES3 +#CHILD2_1_CREATE_TABLES3 +#CHILD2_1_SELECT_TABLES3 +#CHILD2_1_DROP_TABLES4 +#CHILD2_1_CREATE_TABLES4 +#CHILD2_1_SELECT_TABLES4 +#CHILD2_1_DROP_TABLES5 +#CHILD2_1_CREATE_TABLES5 +#CHILD2_1_SELECT_TABLES5 +#CHILD2_1_DROP_TABLES6 +#CHILD2_1_CREATE_TABLES6 +#CHILD2_1_SELECT_TABLES6 +#CHILD2_2_DROP_TABLES +#CHILD2_2_CREATE_TABLES +#CHILD2_2_SELECT_TABLES diff --git a/storage/spider/mysql-test/spider/oracle/r/basic_sql.result b/storage/spider/mysql-test/spider/oracle/r/basic_sql.result new file mode 100644 index 00000000000..e6202327ef6 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/r/basic_sql.result @@ -0,0 +1,701 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'f', '2008-07-01 10:21:39'), +(2, 'g', '2000-02-01 00:00:00'), +(3, 'j', '2007-05-04 20:03:11'), +(4, 'i', '2003-10-30 05:01:03'), +(5, 'h', '2001-10-31 23:59:59'); +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l +Warnings: +Warning 1062 Duplicate entry '1' for key 'PRIMARY' +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +Warning 1062 Duplicate entry '3' for key 'PRIMARY' +Warning 1062 Duplicate entry '4' for key 'PRIMARY' +Warning 1062 Duplicate entry '5' for key 'PRIMARY' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create table with partition and select test +CREATE TABLE ta_l2 ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create no index table +DROP TABLE IF EXISTS ta_l_no_idx; +CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table shared mode +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table for update +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table join +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table straight_join +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_small_result +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_big_result +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_buffer_result +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_cache +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_no_cache +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_calc_found_rows +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +SELECT found_rows(); +found_rows() +5 + +select high_priority +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select distinct +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select count +SELECT count(*) FROM ta_l ORDER BY a; +count(*) +5 + +select table join not use index +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select using index and pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using index pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +insert +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +insert select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 + +insert low_priority +TRUNCATE TABLE ta_l; +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert high_priority +TRUNCATE TABLE ta_l; +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert ignore +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +Warnings: +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (insert) +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (update) +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2005-08-08 11:11:11 + +replace +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2008-02-02 02:02:02 + +replace select +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace select a +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace low_priority +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 g 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 f 2008-02-02 02:02:02 + +update select +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update select a +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 h 2010-04-04 04:04:04 +2 g 2009-03-03 03:03:03 + +update join +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 + +update join a +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update low_priority +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update ignore +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update pushdown +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 j 2009-03-03 03:03:03 + +update index pushdown +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update partition pushdown +UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 e 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update partition index pushdown +UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete all +DELETE FROM ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE IGNORE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE QUICK FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete partition pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete partition index pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +truncate +TRUNCATE TABLE ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle/r/direct_aggregate.result b/storage/spider/mysql-test/spider/oracle/r/direct_aggregate.result new file mode 100644 index 00000000000..26860959718 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/r/direct_aggregate.result @@ -0,0 +1,132 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_aggregating test +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 0 +SELECT COUNT(*) FROM ta_l; +COUNT(*) +5 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l; +MAX(a) +5 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MIN(a) FROM ta_l; +MIN(a) +1 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l WHERE a < 5; +MAX(a) +4 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MIN(a) FROM ta_l WHERE a > 1; +MIN(a) +2 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 + +with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT COUNT(*) FROM ta_l2; +COUNT(*) +5 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l2; +MAX(a) +5 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MIN(a) FROM ta_l2; +MIN(a) +1 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l2 WHERE a < 5; +MAX(a) +4 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MIN(a) FROM ta_l2 WHERE a > 1; +MIN(a) +2 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle/r/direct_update.result b/storage/spider/mysql-test/spider/oracle/r/direct_update.result new file mode 100644 index 00000000000..db6066a6e46 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/r/direct_update.result @@ -0,0 +1,226 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_updating test +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-03 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l WHERE a = 3; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l2 SET c = ADDDATE(c, 1); +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l2 SET b = 'x' WHERE a = 3; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-03 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l2 WHERE b = 'c'; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l2 WHERE a = 3; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle/r/function.result b/storage/spider/mysql-test/spider/oracle/r/function.result new file mode 100644 index 00000000000..764c774514b --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/r/function.result @@ -0,0 +1,149 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +in() +CREATE TABLE t1 ( +a VARCHAR(255), +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1 +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +select a from t1 where a in ('15', '120'); +a +120 +15 + +date_sub() +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-08-01 10:21:39 +2 b 1999-01-01 00:00:00 +3 e 2006-06-04 20:03:11 +4 d 2002-11-30 05:01:03 +5 c 2000-12-31 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-11-01 10:21:39 +2 b 1999-04-01 00:00:00 +3 e 2006-09-04 20:03:11 +4 d 2003-02-28 05:01:03 +5 c 2001-03-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-01 10:21:39 +2 b 1999-03-01 00:00:00 +3 e 2006-08-04 20:03:11 +4 d 2003-01-28 05:01:03 +5 c 2001-02-28 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-08 10:21:39 +2 b 1999-03-08 00:00:00 +3 e 2006-08-11 20:03:11 +4 d 2003-02-04 05:01:03 +5 c 2001-03-07 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 10:21:39 +2 b 1999-03-07 00:00:00 +3 e 2006-08-10 20:03:11 +4 d 2003-02-03 05:01:03 +5 c 2001-03-06 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:21:39 +2 b 1999-03-07 01:00:00 +3 e 2006-08-10 21:03:11 +4 d 2003-02-03 06:01:03 +5 c 2001-03-07 00:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:39 +2 b 1999-03-07 00:59:00 +3 e 2006-08-10 21:02:11 +4 d 2003-02-03 06:00:03 +5 c 2001-03-07 00:58:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:40 +2 b 1999-03-07 00:59:01 +3 e 2006-08-10 21:02:12 +4 d 2003-02-03 06:00:04 +5 c 2001-03-07 00:59:00 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle/r/ha.result b/storage/spider/mysql-test/spider/oracle/r/ha.result new file mode 100644 index 00000000000..95b428eb1ff --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/r/ha.result @@ -0,0 +1,431 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +CREATE DATABASE auto_test_remote3; +USE auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; + +test select 1 +SELECT 1; +1 +1 + +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 0 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'SYSTEM.ta_r3' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "xe", user "system", + password "oracle", msi "2", mkd "2", + database "SYSTEM", lst "0 2"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 2 +SELECT spider_copy_tables('ta_l', '0', '1'); +spider_copy_tables('ta_l', '0', '1') +1 +ALTER TABLE ta_l +CONNECTION='host "xe", user "system", + password "oracle", msi "2", mkd "2", + database "SYSTEM", lst "0 1"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'SYSTEM.ta_r4' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 2 +SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +spider_copy_tables('ta_l2#P#pt2', '0', '1') +1 +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +active standby test +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'SYSTEM.ta_r' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 3 +auto_test_local ta_l 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "xe", user "system", + password "oracle", msi "2", mkd "2", alc "1", + database "SYSTEM", lst "1 0"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'SYSTEM.ta_r2' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 3 +auto_test_local ta_l2#P#pt2 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +auto_test_local ta_l2#P#pt2 0 +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 3 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle/r/spider3_fixes.result b/storage/spider/mysql-test/spider/oracle/r/spider3_fixes.result new file mode 100644 index 00000000000..eb0c18da831 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/r/spider3_fixes.result @@ -0,0 +1,343 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +3.1 +auto_increment +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t2; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1555 +SELECT MAX(id) FROM t1; +MAX(id) +1555 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t2; +MAX(id) +2331 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2332 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +1555 +2331 +2332 +3109 +3886 +4663 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5439 +SELECT id FROM t2 ORDER BY id; +id +777 +1554 +1555 +2331 +2332 +3109 +3886 +4663 +5439 +6216 +6993 +7770 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t2 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +6993 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +10000 +auto_increment with partition +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t2; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +778 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t2; +MAX(id) +2331 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1555 +SELECT id FROM t1 ORDER BY id; +id +777 +778 +1554 +1555 +2331 +2332 +3109 +3886 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT id FROM t2 ORDER BY id; +id +777 +778 +1554 +1555 +2331 +2332 +3108 +3109 +3885 +3886 +4662 +5439 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t2 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +6993 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +10000 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle/r/spider_fixes.result b/storage/spider/mysql-test/spider/oracle/r/spider_fixes.result new file mode 100644 index 00000000000..43f0709e2e3 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/r/spider_fixes.result @@ -0,0 +1,670 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +2.13 +select table with "order by desc" and "<" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 +2 b 2000-01-01 00:00:00 + +select table with "order by desc" and "<=" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +5 c 2001-12-31 23:59:59 +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 + +2.14 +update table with range scan and split_read +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-02-02 00:00:00 +3 e 2000-02-02 00:00:00 +4 d 2000-02-02 00:00:00 +5 c 2000-02-02 00:00:00 + +2.15 +select table with range scan +TRUNCATE TABLE ta_l; +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a int(11) NOT NULL DEFAULT '0', +b char(1) DEFAULT NULL, +c datetime DEFAULT NULL, +PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +a b c +5 c 2001-12-31 23:59:59 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 + +2.16 +auto_increment insert with trigger +CREATE TABLE ta_l_auto_inc ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tc_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;; +INSERT INTO ta_l_auto_inc (a, b, c) VALUES +(NULL, 's', '2008-12-31 20:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 s 2008-12-31 20:59:59 + +2.17 +engine-condition-pushdown with "or" and joining +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +partition with sort +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +2.23 +partition update with moving partition +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); +UPDATE ta_l2 SET a = 4 WHERE a = 3; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 B 2010-09-26 00:00:00 +index merge +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 +index merge with partition +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 + +2.24 +index scan update without PK +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT NOT NULL, +b INT DEFAULT 10, +c INT DEFAULT 11, +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +UPDATE ta_l_int SET c = 4 WHERE b = 2; +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +0 2 4 +1 2 4 +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 + +2.25 +direct order limit +SHOW GLOBAL STATUS LIKE 'Spider_direct_order_limit%'; +Variable_name Value +Spider_direct_order_limit 0 +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +a b c +2 3 4 +4 5 6 +6 7 8 +SHOW GLOBAL STATUS LIKE 'Spider_direct_order_limit%'; +Variable_name Value +Spider_direct_order_limit 0 + +2.26 +lock tables +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1 +CREATE TABLE t2 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2 +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + +auto_increment +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t1; +MAX(id) +2331 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT MAX(id) FROM t1; +MAX(id) +3108 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 + +auto_increment with partition +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t1; +MAX(id) +2331 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT MAX(id) FROM t1; +MAX(id) +3108 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 + +read only +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1 +SELECT id FROM t1 ORDER BY id; +id +1000 +1554 +3108 +4662 +5000 +6216 +10000 +INSERT INTO t1 (id) VALUES (1); +ERROR HY000: Table 'auto_test_local.t1' is read only +UPDATE t1 SET id = 4 WHERE id = 1000; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1 WHERE id = 1000; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1; +ERROR HY000: Table 'auto_test_local.t1' is read only +TRUNCATE t1; +ERROR HY000: Table 'auto_test_local.t1' is read only + +2.27 +error mode +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1 +SELECT id FROM t1 ORDER BY id; +id +Warnings: +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error +INSERT INTO t1 (id) VALUES (1); +Warnings: +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error +DELETE FROM t1; +Warnings: +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error +TRUNCATE t1; +Warnings: +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error + +3.0 +is null +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +a VARCHAR(255), +b VARCHAR(255), +c VARCHAR(255), +KEY idx1(a,b), +KEY idx2(b), +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1 +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +select a from t1 where a is null order by a limit 30; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +select b from t1 where b is null order by b limit 30; +b +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL + +direct_order_limit +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +a b c +10 74 74 +10 42 42 +10 234 234 +10 202 202 +10 170 170 +select a, c from t1 where a = '10' order by b desc limit 5; +a c +10 74 +10 42 +10 234 +10 202 +10 170 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle/r/vp_fixes.result b/storage/spider/mysql-test/spider/oracle/r/vp_fixes.result new file mode 100644 index 00000000000..15dd29aa4d3 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/r/vp_fixes.result @@ -0,0 +1,80 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +0.9 +create different primary key table +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT AUTO_INCREMENT, +c INT DEFAULT 11, +PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +create un-correspond primary key table +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT DEFAULT 12, +c INT DEFAULT 11, +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle/t/basic_sql.test b/storage/spider/mysql-test/spider/oracle/t/basic_sql.test new file mode 100644 index 00000000000..2264b0e4e37 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/basic_sql.test @@ -0,0 +1,3189 @@ +# This test tests by executing basic SQL +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'f', '2008-07-01 10:21:39'), + (2, 'g', '2000-02-01 00:00:00'), + (3, 'j', '2007-05-04 20:03:11'), + (4, 'i', '2003-10-30 05:01:03'), + (5, 'h', '2001-10-31 23:59:59'); +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT IGNORE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + REPLACE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table with partition and select test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + } + --enable_query_log + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo create no index table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_no_idx; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_NEEDPK) +{ + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + } +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES3; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; + +--echo +--echo select table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table shared mode +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table for update +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table straight_join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_small_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_big_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_buffer_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_no_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_calc_found_rows +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT found_rows(); + +--echo +--echo select high_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select distinct +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select count +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT count(*) FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join not use index +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using index and pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select partition using pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo select partition using index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.a > 0 AND a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo insert +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select a +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert low_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert high_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (insert) +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (update) +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace +--connection master_1 +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update index pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update partition pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo update partition index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete all +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE IGNORE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE QUICK FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete partition pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete partition index pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo truncate +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle/t/connect_child2_1.inc b/storage/spider/mysql-test/spider/oracle/t/connect_child2_1.inc new file mode 100644 index 00000000000..cd9b0c9ca9b --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/connect_child2_1.inc @@ -0,0 +1 @@ +--connect (child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle/t/connect_child2_2.inc b/storage/spider/mysql-test/spider/oracle/t/connect_child2_2.inc new file mode 100644 index 00000000000..e145f66b630 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/connect_child2_2.inc @@ -0,0 +1 @@ +--connect (child2_2, localhost, root, , , $CHILD2_2_MYPORT, $CHILD2_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle/t/connect_child2_3.inc b/storage/spider/mysql-test/spider/oracle/t/connect_child2_3.inc new file mode 100644 index 00000000000..d356348d8ea --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/connect_child2_3.inc @@ -0,0 +1 @@ +--connect (child2_3, localhost, root, , , $CHILD2_3_MYPORT, $CHILD2_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle/t/connect_child3_1.inc b/storage/spider/mysql-test/spider/oracle/t/connect_child3_1.inc new file mode 100644 index 00000000000..03e5c188c89 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/connect_child3_1.inc @@ -0,0 +1 @@ +--connect (child3_1, localhost, root, , , $CHILD3_1_MYPORT, $CHILD3_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle/t/connect_child3_2.inc b/storage/spider/mysql-test/spider/oracle/t/connect_child3_2.inc new file mode 100644 index 00000000000..d62a7ada824 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/connect_child3_2.inc @@ -0,0 +1 @@ +--connect (child3_2, localhost, root, , , $CHILD3_2_MYPORT, $CHILD3_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle/t/connect_child3_3.inc b/storage/spider/mysql-test/spider/oracle/t/connect_child3_3.inc new file mode 100644 index 00000000000..fb49f5bfdac --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/connect_child3_3.inc @@ -0,0 +1 @@ +--connect (child3_3, localhost, root, , , $CHILD3_3_MYPORT, $CHILD3_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle/t/connect_master_1.inc b/storage/spider/mysql-test/spider/oracle/t/connect_master_1.inc new file mode 100644 index 00000000000..0c129ce5775 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/connect_master_1.inc @@ -0,0 +1 @@ +--connect (master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle/t/connect_slave1_1.inc b/storage/spider/mysql-test/spider/oracle/t/connect_slave1_1.inc new file mode 100644 index 00000000000..45a822743e0 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/connect_slave1_1.inc @@ -0,0 +1 @@ +--connect (slave1_1, localhost, root, , , $SLAVE1_1_MYPORT, $SLAVE1_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle/t/direct_aggregate.test b/storage/spider/mysql-test/spider/oracle/t/direct_aggregate.test new file mode 100644 index 00000000000..59c45f3f190 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/direct_aggregate.test @@ -0,0 +1,316 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_aggregating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT COUNT(*) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l WHERE a < 5; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l WHERE a > 1; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT COUNT(*) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2 WHERE a < 5; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2 WHERE a > 1; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle/t/direct_update.test b/storage/spider/mysql-test/spider/oracle/t/direct_update.test new file mode 100644 index 00000000000..1c3ce91ff3f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/direct_update.test @@ -0,0 +1,354 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_updating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key +DELETE FROM ta_l WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update all rows with function + UPDATE ta_l2 SET c = ADDDATE(c, 1); + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key + UPDATE ta_l2 SET b = 'x' WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by a column without index + UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key with order and limit + UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key with order and limit + DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by a column without index + DELETE FROM ta_l2 WHERE b = 'c'; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key + DELETE FROM ta_l2 WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle/t/function.test b/storage/spider/mysql-test/spider/oracle/t/function.test new file mode 100644 index 00000000000..2b1b53c8a4f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/function.test @@ -0,0 +1,276 @@ +# This test tests for using functions +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo in() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_PK_TABLES1; + echo CHILD2_1_CREATE_TEXT_PK_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_PK_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_PK_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET3 $MASTER_1_COMMENT_TEXT_PK1_1; +--enable_query_log +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a in ('15', '120'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo date_sub() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle/t/ha.test b/storage/spider/mysql-test/spider/oracle/t/ha.test new file mode 100644 index 00000000000..319b1793753 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/ha.test @@ -0,0 +1,1794 @@ +# This test tests for ha features +--let $SKIP_REASON= +if ($USE_HA_TEST) +{ +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source ha_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + CREATE DATABASE auto_test_remote3; + USE auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + } + if ($USE_CHILD_GROUP3) + { + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + } + --disable_query_log + --disable_result_log + --source ha_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + --connection child2_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + SELECT 1; + --connection child3_2 + SELECT 1; + --connection child3_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_2_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_CREATE_TABLES; + } + eval $CHILD2_2_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_RECOVERY_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_COPY_TABLES_2_1; +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_3_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_CREATE_TABLES; + } + eval $CHILD2_3_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_COPY_TABLES_P_2_1; + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo active standby test +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_AS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES2; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES2; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES2; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_AS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; +} +--disable_query_log +--disable_result_log +--source ha_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +} +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle/t/ha_test_deinit.inc b/storage/spider/mysql-test/spider/oracle/t/ha_test_deinit.inc new file mode 100644 index 00000000000..53d0409d066 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/ha_test_deinit.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_deinit_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_deinit_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_deinit_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_deinit_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/oracle/t/ha_test_init.inc b/storage/spider/mysql-test/spider/oracle/t/ha_test_init.inc new file mode 100644 index 00000000000..70576ab16dc --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/ha_test_init.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_init_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_init_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_init_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_init_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/oracle/t/have_engine.inc b/storage/spider/mysql-test/spider/oracle/t/have_engine.inc new file mode 100644 index 00000000000..64bef7499cb --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/have_engine.inc @@ -0,0 +1,7 @@ +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = '$TEST_ENGINE_TYPE'`) +{ + SELECT engine, support FROM information_schema.engines; + --let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine" +} diff --git a/storage/spider/mysql-test/spider/oracle/t/have_func.inc b/storage/spider/mysql-test/spider/oracle/t/have_func.inc new file mode 100644 index 00000000000..e0823e73fc8 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/have_func.inc @@ -0,0 +1,5 @@ +if (!`SELECT count(*) FROM mysql.func WHERE name = '$TEST_FUNC_NAME'`) +{ + SELECT name FROM mysql.func; + --let $SKIP_REASON= "Need $TEST_FUNC_NAME function" +} diff --git a/storage/spider/mysql-test/spider/oracle/t/have_partition.inc b/storage/spider/mysql-test/spider/oracle/t/have_partition.inc new file mode 100644 index 00000000000..573c76ab43b --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/have_partition.inc @@ -0,0 +1,7 @@ +let $HAVE_PARTITION= 0; +if (`SELECT count(*) FROM information_schema.plugins WHERE + plugin_status = 'ACTIVE' AND + plugin_name = 'partition'`) +{ + let $HAVE_PARTITION= 1; +} diff --git a/storage/spider/mysql-test/spider/oracle/t/have_trigger.inc b/storage/spider/mysql-test/spider/oracle/t/have_trigger.inc new file mode 100644 index 00000000000..10c0871dd5f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/have_trigger.inc @@ -0,0 +1,2 @@ +let $HAVE_TRIGGER= `SELECT COUNT(*) FROM information_schema.tables + WHERE TABLE_SCHEMA = 'information_schema' AND TABLE_NAME = 'TRIGGERS'`; diff --git a/storage/spider/mysql-test/spider/oracle/t/hs_test_deinit.inc b/storage/spider/mysql-test/spider/oracle/t/hs_test_deinit.inc new file mode 100644 index 00000000000..7ec2e981fd2 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/hs_test_deinit.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_deinit_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/oracle/t/hs_test_init.inc b/storage/spider/mysql-test/spider/oracle/t/hs_test_init.inc new file mode 100644 index 00000000000..831bf479524 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/hs_test_init.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_init_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/oracle/t/slave_test_deinit.inc b/storage/spider/mysql-test/spider/oracle/t/slave_test_deinit.inc new file mode 100644 index 00000000000..e9d99b7a960 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/slave_test_deinit.inc @@ -0,0 +1,6 @@ +# get connection and exist engine test +--echo for slave1_1 +--connection slave1_1 +STOP SLAVE; +--source ../include/deinit_slave1_1.inc +--disconnect slave1_1 diff --git a/storage/spider/mysql-test/spider/oracle/t/slave_test_init.inc b/storage/spider/mysql-test/spider/oracle/t/slave_test_init.inc new file mode 100644 index 00000000000..739d88970c5 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/slave_test_init.inc @@ -0,0 +1,44 @@ +# get connection and exist engine test +--echo for slave1_1 +--source connect_slave1_1.inc +--connection slave1_1 +SET SESSION sql_log_bin= 0; +--let $SLAVE1_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $SLAVE1_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_slave1_1.inc +--source have_engine.inc +--let $SLAVE1_1_SLAVE_STATUS=`SHOW SLAVE STATUS` +if (!$SLAVE1_1_SLAVE_STATUS) +{ + eval CHANGE MASTER TO + MASTER_HOST = '127.0.0.1', + MASTER_USER = 'root', + MASTER_PASSWORD = '', + MASTER_PORT = $MASTER_1_MYPORT + ; +} +START SLAVE; +--connection master_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +--connection slave1_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} diff --git a/storage/spider/mysql-test/spider/oracle/t/spider3_fixes.test b/storage/spider/mysql-test/spider/oracle/t/spider3_fixes.test new file mode 100644 index 00000000000..4139f3af955 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/spider3_fixes.test @@ -0,0 +1,570 @@ +# This test tests for Spider 3.0's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo 3.1 +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +SET INSERT_ID=5000; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + TRUNCATE TABLE t1; + TRUNCATE TABLE t2; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + SET INSERT_ID=5000; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle/t/spider_fixes.test b/storage/spider/mysql-test/spider/oracle/t/spider_fixes.test new file mode 100644 index 00000000000..b9ff61abcb4 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/spider_fixes.test @@ -0,0 +1,1967 @@ +# This test tests for Spider's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 2.13 +--echo select table with "order by desc" and "<" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table with "order by desc" and "<=" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.14 +--echo update table with range scan and split_read +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo 2.15 +--echo select table with range scan +TRUNCATE TABLE ta_l; +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_CREATE_TABLES6; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES6; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES6; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.16 +--echo auto_increment insert with trigger +if ($HAVE_TRIGGER) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_CREATE_TABLES4; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES4; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES4; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; + eval CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; + echo CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE2 MASTER_1_CHARSET2; + eval CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; + --enable_query_log + --eval CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + INSERT INTO ta_l_auto_inc (a, b, c) VALUES + (NULL, 's', '2008-12-31 20:59:59'); + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES4; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +} + +--echo +--echo 2.17 +--echo engine-condition-pushdown with "or" and joining +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo partition with sort +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 + ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.23 +--echo partition update with moving partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); + UPDATE ta_l2 SET a = 4 WHERE a = 3; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo index merge +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo index merge with partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l_int; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_2_DROP_TABLES5; + echo CHILD2_2_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES5; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES5; + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1; + eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_P_2_1; + --enable_query_log + INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); + INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) + WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.24 +--echo index scan update without PK +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +if (!$MASTER_1_NEEDPK) +{ + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +--enable_query_log +SELECT a, b, c FROM ta_l_int ORDER BY a; +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l_int SET c = 4 WHERE b = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; + + +--echo +--echo 2.25 +--echo direct order limit +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; + + +--echo +--echo 2.26 +--echo lock tables +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_LOCK_TABLES1; + echo CHILD2_1_DROP_LOCK_TABLES2; + echo CHILD2_1_CREATE_LOCK_TABLES1; + echo CHILD2_1_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_LOCK_TABLES1; + eval $CHILD2_1_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_LOCK_TABLES1; + eval $CHILD2_1_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_LOCK_TABLES1; + echo CHILD2_2_DROP_LOCK_TABLES2; + echo CHILD2_2_CREATE_LOCK_TABLES1; + echo CHILD2_2_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_2_DROP_LOCK_TABLES1; + eval $CHILD2_2_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_2_CREATE_LOCK_TABLES1; + eval $CHILD2_2_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1; +eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2; +eval CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK2; +--enable_query_log +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + + +--echo +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + SET INSERT_ID=5000; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo read only +let $MASTER_1_ENGINE_IS_SPIDER= + `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'Spider' OR + '$MASTER_1_HIDDEN_ENGINE_TYPE' = 'Spider', 1, 0)`; +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_READONLY1_1; + --let $MIN_VAL= `SELECT MIN(id) FROM t1` + --enable_query_log + SELECT id FROM t1 ORDER BY id; + --error 12518 + INSERT INTO t1 (id) VALUES (1); + --error 12518 + eval UPDATE t1 SET id = 4 WHERE id = $MIN_VAL; + --error 12518 + eval DELETE FROM t1 WHERE id = $MIN_VAL; + --error 12518 + DELETE FROM t1; + --error 12518 + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 2.27 +--echo error mode +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_ERROR_MODE1_1; + --enable_query_log + SELECT id FROM t1 ORDER BY id; + INSERT INTO t1 (id) VALUES (1); + DELETE FROM t1; + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 3.0 +--echo is null +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_KEY_TABLES1; + echo CHILD2_1_CREATE_TEXT_KEY_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_KEY_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_KEY_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_TEXT_KEY1_1; +--enable_query_log +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a is null order by a limit 30; +select b from t1 where b is null order by b limit 30; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo direct_order_limit +--connection master_1 +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +select a, c from t1 where a = '10' order by b desc limit 5; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle/t/test_deinit.inc b/storage/spider/mysql-test/spider/oracle/t/test_deinit.inc new file mode 100644 index 00000000000..989bde26d3c --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/test_deinit.inc @@ -0,0 +1,37 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/deinit_master_1.inc +--disconnect master_1 +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/deinit_child2_1.inc + --disconnect child2_1 + --echo child2_2 + --connection child2_2 + --source ../include/deinit_child2_2.inc + --disconnect child2_2 + --echo child2_3 + --connection child2_3 + --source ../include/deinit_child2_3.inc + --disconnect child2_3 +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/deinit_child3_1.inc + --disconnect child3_1 + --echo child3_2 + --connection child3_2 + --source ../include/deinit_child3_2.inc + --disconnect child3_2 + --echo child3_3 + --connection child3_3 + --source ../include/deinit_child3_3.inc + --disconnect child3_3 +} diff --git a/storage/spider/mysql-test/spider/oracle/t/test_init.inc b/storage/spider/mysql-test/spider/oracle/t/test_init.inc new file mode 100644 index 00000000000..f2cd6c0269f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/test_init.inc @@ -0,0 +1,74 @@ +# get connection and exist engine test +--echo for master_1 +--source connect_master_1.inc +--connection master_1 +CALL mtr.add_suppression("unknown variable"); +SET SESSION sql_log_bin= 0; +--let $MASTER_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $MASTER_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_master_1.inc +--source have_engine.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --source connect_child2_1.inc + --connection child2_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE + --source ../include/init_child2_1.inc + --source have_engine.inc + --echo child2_2 + --source connect_child2_2.inc + --connection child2_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE + --source ../include/init_child2_2.inc + --source have_engine.inc + --echo child2_3 + --source connect_child2_3.inc + --connection child2_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE + --source ../include/init_child2_3.inc + --source have_engine.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --source connect_child3_1.inc + --connection child3_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE + --source ../include/init_child3_1.inc + --source have_engine.inc + --echo child3_2 + --source connect_child3_2.inc + --connection child3_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE + --source ../include/init_child3_2.inc + --source have_engine.inc + --echo child3_3 + --source connect_child3_3.inc + --connection child3_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE + --source ../include/init_child3_3.inc + --source have_engine.inc +} diff --git a/storage/spider/mysql-test/spider/oracle/t/vp_fixes.test b/storage/spider/mysql-test/spider/oracle/t/vp_fixes.test new file mode 100644 index 00000000000..46e7b0afc36 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle/t/vp_fixes.test @@ -0,0 +1,358 @@ +# This test tests for VP's bug fixes +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 0.9 +--echo create different primary key table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--let $MASTER_1_IS_VP= `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'VP', 1, 0)` +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo create un-correspond primary key table +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle2/include/deinit_child2_1.inc b/storage/spider/mysql-test/spider/oracle2/include/deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/deinit_child2_2.inc b/storage/spider/mysql-test/spider/oracle2/include/deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/deinit_child2_3.inc b/storage/spider/mysql-test/spider/oracle2/include/deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_1.inc b/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_1.inc new file mode 100644 index 00000000000..9b6a9851ccb --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_1.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_1_ENGINE +--source ../../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_2.inc b/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_2.inc new file mode 100644 index 00000000000..ac0bcdaa938 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_2.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_2_ENGINE +--source ../../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_3.inc b/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_3.inc new file mode 100644 index 00000000000..c93a9822d90 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/deinit_child3_3.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE +--let $INIT_TEST_ENGINE= $INIT_CHILD3_3_ENGINE +--source ../../include/deinit_engine.inc diff --git a/storage/spider/mysql-test/spider/oracle2/include/deinit_master_1.inc b/storage/spider/mysql-test/spider/oracle2/include/deinit_master_1.inc new file mode 100644 index 00000000000..c19e376d10a --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/deinit_master_1.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/oracle2/include/deinit_slave1_1.inc b/storage/spider/mysql-test/spider/oracle2/include/deinit_slave1_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_1.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_2.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_3.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_1.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_1.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_1.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_2.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_2.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_2.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_3.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_3.inc new file mode 100644 index 00000000000..8fd2ff8a777 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_child3_3.inc @@ -0,0 +1 @@ +--source ../../include/deinit_spider.inc diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_master_1.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_1.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_1.inc new file mode 100644 index 00000000000..59c0175d349 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_1.inc @@ -0,0 +1,8 @@ +let $CHILD2_1_HA_AS_DROP_TABLES= + $CHILD2_1_DROP_TABLES; +let $CHILD2_1_HA_AS_CREATE_TABLES= + $CHILD2_1_CREATE_TABLES; +let $CHILD2_1_HA_AS_DROP_TABLES2= + $CHILD2_1_DROP_TABLES2; +let $CHILD2_1_HA_AS_CREATE_TABLES2= + $CHILD2_1_CREATE_TABLES2; diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_2.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_2.inc new file mode 100644 index 00000000000..90d27ed704d --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_2.inc @@ -0,0 +1,4 @@ +let $CHILD2_2_HA_DROP_TABLES= + $CHILD2_2_DROP_TABLES; +let $CHILD2_2_HA_CREATE_TABLES= + $CHILD2_2_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_3.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_3.inc new file mode 100644 index 00000000000..11abf112b1f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child2_3.inc @@ -0,0 +1,4 @@ +let $CHILD2_3_HA_DROP_TABLES= + $CHILD2_3_DROP_TABLES; +let $CHILD2_3_HA_CREATE_TABLES= + $CHILD2_3_CREATE_TABLES; diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_1.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_1.inc new file mode 100644 index 00000000000..67f6676a07a --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_1.inc @@ -0,0 +1,140 @@ +--let $CHILD3_1_ENGINE_TYPE=Spider +--let $CHILD3_1_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_1_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_1_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_1_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_1_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_1_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_1_ENGINE $CHILD3_1_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_2.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_2.inc new file mode 100644 index 00000000000..9b61a2e2b73 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_2.inc @@ -0,0 +1,140 @@ +--let $CHILD3_2_ENGINE_TYPE=Spider +--let $CHILD3_2_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_2_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_2_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_2_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_2_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_2_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_2_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_2_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_2_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_2_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_2_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_2_ENGINE $CHILD3_2_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_2_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_2_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_2_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_3.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_3.inc new file mode 100644 index 00000000000..5724a50b3d9 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_init_child3_3.inc @@ -0,0 +1,140 @@ +--let $CHILD3_3_ENGINE_TYPE=Spider +--let $CHILD3_3_ENGINE=ENGINE=Spider +--source ../include/init_spider.inc +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $CHILD3_3_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $CHILD3_3_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $CHILD3_3_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +let $CHILD3_3_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +let $CHILD3_3_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; + +let $CHILD3_3_DROP_TABLES_HA_2_1= + DROP TABLE IF EXISTS ta_l; +if ($VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $CHILD3_3_CREATE_TABLES_HA_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", + database "auto_test_remote auto_test_remote2"'; + let $CHILD3_3_CREATE_TABLES_HA_AS_2_1= + CREATE TABLE ta_l ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"' + CONNECTION='host "localhost", user "root", password "", + msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2"'; +} +let $CHILD3_3_DROP_TABLES_HA_P_2_1= + DROP TABLE IF EXISTS ta_l2; +let $CHILD3_3_CREATE_TABLES_HA_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1= + CREATE TABLE ta_l2 ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $CHILD3_3_ENGINE $CHILD3_3_CHARSET + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $CHILD3_3_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $CHILD3_3_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $CHILD3_3_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); diff --git a/storage/spider/mysql-test/spider/oracle2/include/ha_init_master_1.inc b/storage/spider/mysql-test/spider/oracle2/include/ha_init_master_1.inc new file mode 100644 index 00000000000..8ace39ab641 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/ha_init_master_1.inc @@ -0,0 +1,109 @@ +eval INSERT INTO mysql.spider_link_mon_servers +(db_name, table_name, link_id, sid, server, scheme, host, port, socket, + username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key, + ssl_verify_server_cert, default_file, default_group) VALUES +('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), +('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); +let $MASTER_1_CHECK_LINK_STATUS= + SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables + ORDER BY db_name, table_name, link_id; +let $MASTER_1_CHECK_LINK_FAILED_LOG= + SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +let $MASTER_1_SET_RECOVERY_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", + database "$ORACLE_DATABASE", lst "0 2"'; +let $MASTER_1_SET_OK_STATUS_2_1= + ALTER TABLE ta_l + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", + database "$ORACLE_DATABASE", lst "0 1"'; +let $MASTER_1_SET_OK_STATUS_AS_2_1= + ALTER TABLE ta_l + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "$ORACLE_DATABASE", lst "1 0"'; +let $MASTER_1_COPY_TABLES_2_1= + SELECT spider_copy_tables('ta_l', '0', '1'); + +if ($VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", + database "$ORACLE_DATABASE"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "$ORACLE_DATABASE"'; +} +if (!$VERSION_COMPILE_OS_WIN) +{ + let $MASTER_1_COMMENT_HA_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", + database "$ORACLE_DATABASE"'; + let $MASTER_1_COMMENT_HA_AS_2_1= + COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1", + database "$ORACLE_DATABASE"'; +} +let $MASTER_1_COMMENT_HA_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_COMMENT_HA_AS_P_2_1= + COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001"' + ); +let $MASTER_1_SET_RECOVERY_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +let $MASTER_1_SET_OK_STATUS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +let $MASTER_1_SET_OK_STATUS_AS_P_2_1= + ALTER TABLE ta_l2 + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', + PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +let $MASTER_1_COPY_TABLES_P_2_1= + SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +let $MASTER_1_CHECK_HA_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +let $MASTER_1_CHANGE_HA_MON= + SELECT spider_flush_table_mon_cache(); diff --git a/storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_1.inc b/storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_2.inc b/storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_2.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_3.inc b/storage/spider/mysql-test/spider/oracle2/include/hs_deinit_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/hs_deinit_master_1.inc b/storage/spider/mysql-test/spider/oracle2/include/hs_deinit_master_1.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_1.inc b/storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_1.inc new file mode 100644 index 00000000000..e0467b92307 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_1.inc @@ -0,0 +1,24 @@ +let $CHILD2_1_HS_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "hs_r"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "hs_r" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + "d" INT DEFAULT 11, + CONSTRAINT "pk_s_2_1_hs_r" PRIMARY KEY("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\'), "d" FROM "hs_r" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_DROP_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "hs_r2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_CREATE_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "hs_r2" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + "d" INT DEFAULT 11, + CONSTRAINT "pk_s_2_1_hs_r2" PRIMARY KEY("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_HS_SELECT_TABLES2= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\'), "d" FROM "hs_r2" ORDER BY "a"', '', 'srv "s_2_1"'); diff --git a/storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_2.inc b/storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_2.inc new file mode 100644 index 00000000000..0466acbc66b --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_2.inc @@ -0,0 +1,12 @@ +let $CHILD2_2_HS_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "hs_r3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_HS_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "hs_r3" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + "d" INT DEFAULT 11, + CONSTRAINT "pk_s_2_2_hs_r3" PRIMARY KEY("a") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_HS_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\'), "d" FROM "hs_r3" ORDER BY "a"', '', 'srv "s_2_2"'); diff --git a/storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_3.inc b/storage/spider/mysql-test/spider/oracle2/include/hs_init_child2_3.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/storage/spider/mysql-test/spider/oracle2/include/hs_init_master_1.inc b/storage/spider/mysql-test/spider/oracle2/include/hs_init_master_1.inc new file mode 100644 index 00000000000..0ff5e2a10d9 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/hs_init_master_1.inc @@ -0,0 +1,12 @@ +let $MASTER_1_HS_COMMENT_TMP= + COMMENT=''; +let $MASTER_1_HS_COMMENT_2_1= + COMMENT='srv "s_2_1", table "hs_r", uhr "1", uhw "1", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"'; +let $MASTER_1_HS_COMMENT_P_2_1= + COMMENT='uhr "1", uhw "1"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) + COMMENT='srv "s_2_1", table "hs_r2", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", table "hs_r3", hrp "$CHILD2_2_HSRPORT", hwp "$CHILD2_2_HSWPORT"' + ); diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_child2_1.inc b/storage/spider/mysql-test/spider/oracle2/include/init_child2_1.inc new file mode 100644 index 00000000000..18dcc7159cc --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_child2_1.inc @@ -0,0 +1,192 @@ +--connection master_1 +SELECT spider_direct_sql('ALTER SESSION SET NLS_DATE_FORMAT=\'YYYY-MM-DD HH24:MI:SS\'', '', 'srv "s_2_1"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIME_FORMAT=\'HH24:MI:SSXFF\'', '', 'srv "s_2_1"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'YYYY-MM-DD HH24:MI:SSXFF\'', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ta_r" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_1_ta_r" PRIMARY KEY("a") + )', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx1" ON "ta_r"("b")', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "ta_r2" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_1_ta_r2" PRIMARY KEY("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES2= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r2" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES3= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r_no_idx"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES3= + SELECT spider_direct_sql('CREATE TABLE "ta_r_no_idx" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\') + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES3= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r_no_idx" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES4= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r_auto_inc"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES4= + SELECT spider_direct_sql('CREATE TABLE "ta_r_auto_inc" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_1_ta_r_auto_inc" PRIMARY KEY("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES4= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r_auto_inc" + ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES5= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "s_2_1_ta_r_int"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES5= + SELECT spider_direct_sql('CREATE TABLE "s_2_1_ta_r_int" ( + "a" INT DEFAULT 3, + "b" INT DEFAULT 10, + "c" INT DEFAULT 11, + CONSTRAINT "pk_s_2_1_ta_r_int" PRIMARY KEY("a") + )', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx1_s_2_1_ta_r_int" ON "s_2_1_ta_r_int"("b")', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx2_s_2_1_ta_r_int" ON "s_2_1_ta_r_int"("c")', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES5= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "s_2_1_ta_r_int" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TABLES6= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r_3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TABLES6= + SELECT spider_direct_sql('CREATE TABLE "ta_r_3" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\') + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TABLES6= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r_3" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_FT_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ft_r"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_FT_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ft_r" ( + "a" INT DEFAULT 0, + "b" TEXT, + "c" TEXT, + "d" TEXT, + CONSTRAINT "pk_s_2_1_ft_r" PRIMARY KEY("a"), + FULLTEXT INDEX "ft_idx1"("b"), + FULLTEXT INDEX "ft_idx2"("c") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_FT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", "c", "d" FROM "ft_r" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_FT_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ft_r2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_FT_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "ft_r2" ( + "a" INT DEFAULT 0, + "b" TEXT, + "c" TEXT, + "d" TEXT, + CONSTRAINT "pk_s_2_1_ft_r2" PRIMARY KEY("a"), + FULLTEXT INDEX "ft_idx1"("b"), + FULLTEXT INDEX "ft_idx2"("c") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_FT_TABLES2= + SELECT spider_direct_sql('SELECT "a", "b", "c", "d" FROM "ft_r2" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_GM_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "gm_r"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_GM_TABLES= + SELECT spider_direct_sql('CREATE TABLE "gm_r" ( + "a" INT DEFAULT 0, + "b" GEOMETRY NOT NULL, + "c" GEOMETRY NOT NULL, + CONSTRAINT "pk_s_2_1_gm_r" PRIMARY KEY("a"), + SPATIAL INDEX "sp_idx1"("b"), + SPATIAL INDEX "sp_idx2"("c") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_GM_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "gm_r" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_GM_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "gm_r2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_GM_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "gm_r2" ( + "a" INT DEFAULT 0, + "b" GEOMETRY NOT NULL, + "c" GEOMETRY NOT NULL, + CONSTRAINT "pk_s_2_1_gm_r2" PRIMARY KEY("a"), + SPATIAL INDEX "sp_idx1"("b"), + SPATIAL INDEX "sp_idx2"("c") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_GM_TABLES2= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "gm_r2" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_LOCK_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_LOCK_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1_1" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_1_t1_1" PRIMARY KEY ("id") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_LOCK_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t2_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_LOCK_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "t2_2" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_1_t2_2" PRIMARY KEY ("id") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_INCREMENT_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_INCREMENT_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1_1" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_1_t1_1" PRIMARY KEY ("id") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_INCREMENT_TABLES1= + SELECT spider_direct_sql('SELECT "id" FROM "t1_1" ORDER BY "id"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TEXT_PK_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TEXT_PK_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1" ( + "a" VARCHAR(255), + CONSTRAINT "pk_s_2_1_t1" PRIMARY KEY ("a") + )', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TEXT_PK_TABLES1= + SELECT spider_direct_sql('SELECT "a" FROM "t1" ORDER BY "a"', '', 'srv "s_2_1"'); +let $CHILD2_1_DROP_TEXT_KEY_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"'); +let $CHILD2_1_CREATE_TEXT_KEY_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1" ( + "a" VARCHAR(255), + "b" VARCHAR(255), + "c" VARCHAR(255), + CONSTRAINT "pk_s_2_1_t1" PRIMARY KEY ("c") + )', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx1_t1" ON "t1"("a","b")', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx2_t1" ON "t1"("b")', '', 'srv "s_2_1"'); +let $CHILD2_1_SELECT_TEXT_KEY_TABLES1= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "t1" ORDER BY "c"', '', 'srv "s_2_1"'); +let $CHILD2_1_AUTO_INCREMENT_INCREMENT1= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_1"'); +let $CHILD2_1_AUTO_INCREMENT_INCREMENT2= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"'); +let $CHILD2_1_AUTO_INCREMENT_OFFSET1= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_1"'); +let $CHILD2_1_AUTO_INCREMENT_OFFSET2= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"'); diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_child2_2.inc b/storage/spider/mysql-test/spider/oracle2/include/init_child2_2.inc new file mode 100644 index 00000000000..117040dcca6 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_child2_2.inc @@ -0,0 +1,94 @@ +--connection master_1 +SELECT spider_direct_sql('ALTER SESSION SET NLS_DATE_FORMAT=\'YYYY-MM-DD HH24:MI:SS\'', '', 'srv "s_2_2"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIME_FORMAT=\'HH24:MI:SSXFF\'', '', 'srv "s_2_2"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'YYYY-MM-DD HH24:MI:SSXFF\'', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ta_r3" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_2_ta_r3" PRIMARY KEY("a") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_TABLES5= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "s_2_2_ta_r_int"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_TABLES5= + SELECT spider_direct_sql('CREATE TABLE "s_2_2_ta_r_int" ( + "a" INT DEFAULT 3, + "b" INT DEFAULT 10, + "c" INT DEFAULT 11, + CONSTRAINT "pk_s_2_2_ta_r_int" PRIMARY KEY("a") + )', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx1_s_2_2_ta_r_int" ON "s_2_2_ta_r_int"("b")', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE INDEX "idx2_s_2_2_ta_r_int" ON "s_2_2_ta_r_int"("c")', '', 'srv "s_2_2"'); +let $CHILD2_2_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r3" ORDER BY "a"', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_FT_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ft_r3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_FT_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ft_r3" ( + "a" INT DEFAULT 0, + "b" TEXT, + "c" TEXT, + "d" TEXT, + CONSTRAINT "pk_s_2_2_ft_r3" PRIMARY KEY("a"), + FULLTEXT INDEX "ft_idx1"("b"), + FULLTEXT INDEX "ft_idx2"("c") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_SELECT_FT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", "c", "d" FROM "ft_r3" ORDER BY "a"', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_GM_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "gm_r3"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_GM_TABLES= + SELECT spider_direct_sql('CREATE TABLE "gm_r3" ( + "a" INT DEFAULT 0, + "b" GEOMETRY NOT NULL, + "c" GEOMETRY NOT NULL, + CONSTRAINT "pk_s_2_2_gm_r3" PRIMARY KEY("a"), + SPATIAL INDEX "sp_idx1"("b"), + SPATIAL INDEX "sp_idx2"("c") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_SELECT_GM_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", "c" FROM "gm_r3" ORDER BY "a"', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_LOCK_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_LOCK_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1_2" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_2_t1_2" PRIMARY KEY ("id") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_LOCK_TABLES2= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t2_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_LOCK_TABLES2= + SELECT spider_direct_sql('CREATE TABLE "t2_1" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_2_t2_1" PRIMARY KEY ("id") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_DROP_INCREMENT_TABLES1= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"'); +let $CHILD2_2_CREATE_INCREMENT_TABLES1= + SELECT spider_direct_sql('CREATE TABLE "t1_2" ( + "id" INT NOT NULL, + CONSTRAINT "pk_s_2_2_t1_2" PRIMARY KEY ("id") + )', '', 'srv "s_2_2"'); +let $CHILD2_2_SELECT_INCREMENT_TABLES1= + SELECT spider_direct_sql('SELECT "id" FROM "t1_2" ORDER BY "id"', '', 'srv "s_2_2"'); +let $CHILD2_2_AUTO_INCREMENT_INCREMENT1= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_2"'); +let $CHILD2_2_AUTO_INCREMENT_INCREMENT2= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"'); +let $CHILD2_2_AUTO_INCREMENT_OFFSET1= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_2"'); +let $CHILD2_2_AUTO_INCREMENT_OFFSET2= + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"'); diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_child2_3.inc b/storage/spider/mysql-test/spider/oracle2/include/init_child2_3.inc new file mode 100644 index 00000000000..5c06a9f6a73 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_child2_3.inc @@ -0,0 +1,15 @@ +--connection master_1 +SELECT spider_direct_sql('ALTER SESSION SET NLS_DATE_FORMAT=\'YYYY-MM-DD HH24:MI:SS\'', '', 'srv "s_2_3"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIME_FORMAT=\'HH24:MI:SSXFF\'', '', 'srv "s_2_3"'); +SELECT spider_direct_sql('ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'YYYY-MM-DD HH24:MI:SSXFF\'', '', 'srv "s_2_3"'); +let $CHILD2_3_DROP_TABLES= + SELECT spider_direct_sql('begin execute immediate \'DROP TABLE "ta_r4"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_3"'); +let $CHILD2_3_CREATE_TABLES= + SELECT spider_direct_sql('CREATE TABLE "ta_r4" ( + "a" INT DEFAULT 10, + "b" CHAR(1) DEFAULT \'c\', + "c" DATE DEFAULT TO_DATE(\'1999-10-10 10:10:10\', \'YYYY-MM-DD HH24:MI:SS\'), + CONSTRAINT "pk_s_2_3_ta_r4" PRIMARY KEY("a") + )', '', 'srv "s_2_3"'); +let $CHILD2_3_SELECT_TABLES= + SELECT spider_direct_sql('SELECT "a", "b", TO_CHAR("c", \'YYYY-MM-DD HH24:MI:SS\') FROM "ta_r4" ORDER BY "a"', '', 'srv "s_2_3"'); diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_child3_1.inc b/storage/spider/mysql-test/spider/oracle2/include/init_child3_1.inc new file mode 100644 index 00000000000..f70afeb58de --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_child3_1.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE +--source ../../include/init_engine.inc +--let $INIT_CHILD3_1_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_child3_2.inc b/storage/spider/mysql-test/spider/oracle2/include/init_child3_2.inc new file mode 100644 index 00000000000..e84567f2243 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_child3_2.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE +--source ../../include/init_engine.inc +--let $INIT_CHILD3_2_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_child3_3.inc b/storage/spider/mysql-test/spider/oracle2/include/init_child3_3.inc new file mode 100644 index 00000000000..d3f31049ff6 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_child3_3.inc @@ -0,0 +1,3 @@ +--let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE +--source ../../include/init_engine.inc +--let $INIT_CHILD3_3_ENGINE= $INIT_TEST_ENGINE diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_master_1.inc b/storage/spider/mysql-test/spider/oracle2/include/init_master_1.inc new file mode 100644 index 00000000000..00c6f544992 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_master_1.inc @@ -0,0 +1,150 @@ +--source ../include/init_spider.inc +SET spider_direct_order_limit= 10000; +SET spider_init_sql_alloc_size= 1; +SET spider_conn_recycle_mode= 2; +let $MASTER_1_COMMENT_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ta_r", wrapper "oracle", + pk_name "pk_s_2_1_ta_r"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD"'; +let $MASTER_1_COMMENT2_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ta_r_no_idx", wrapper "oracle", + pk_name "pk_s_2_1_ta_r_no_idx"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", prt "2000000"'; +let $MASTER_1_COMMENT_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY KEY(a) ( + PARTITION pt1 COMMENT='srv "s_2_1", table "ta_r2", + priority "1000", pk_name "pk_s_2_1_ta_r2"', + PARTITION pt2 COMMENT='srv "s_2_2", priority "1000001", + pk_name "pk_s_2_2_ta_r3"' + ); +let $MASTER_1_COMMENT2_P_2_1= + COMMENT='table "ta_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ta_r2", priority "1000", pk_name "pk_s_2_1_ta_r2"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001", pk_name "pk_s_2_2_ta_r3"' + ); +let $MASTER_1_COMMENT3_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ta_r_auto_inc", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", pk_name "pk_s_2_1_ta_r_auto_inc"'; +let $MASTER_1_COMMENT3_P_2_1= + COMMENT='table "s_2_1_ta_r_int"' + PARTITION BY LIST(MOD(a, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='srv "s_2_1", priority "1000", pk_name "pk_s_2_1_ta_r_int"', + PARTITION pt2 VALUES IN (1) + COMMENT='srv "s_2_2", priority "1000001", pk_name "pk_s_2_2_ta_r_int", + table "s_2_2_ta_r_int"' + ); +let $MASTER_1_COMMENT4_2_1= + COMMENT='database "$ORACLE_DATABASE", table "s_2_1_ta_r_int", + wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", pk_name "pk_s_2_1_ta_r_int"'; +let $MASTER_1_COMMENT5_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ta_r_3", wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", pk_name "pk_s_2_1_ta_r_3"'; +let $MASTER_1_COMMENT_FT_2_1= + COMMENT='database "$ORACLE_DATABASE", table "ft_r", wrapper "oracle"' + CONNECTION='host "$ORACLE_HOST", port "$ORACLE_PORT", user "$ORACLE_USER", + password "$ORACLE_PASSWORD", pk_name "pk_s_2_1_ft_r"'; +let $MASTER_1_COMMENT2_FT_P_2_1= + COMMENT='table "ft_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "ft_r2", priority "1000", pk_name "pk_s_2_1_ft_r2"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001", pk_name "pk_s_2_2_ft_r3"' + ); +let $MASTER_1_COMMENT_GM_2_1= + COMMENT='srv "s_2_1", table "gm_r", pk_name "pk_s_2_1_gm_r"'; +let $MASTER_1_COMMENT2_GM_P_2_1= + COMMENT='table "gm_r3"' + PARTITION BY RANGE(a) ( + PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1", + table "gm_r2", priority "1000", pk_name "pk_s_2_1_gm_r2"', + PARTITION pt2 VALUES LESS THAN MAXVALUE + COMMENT='srv "s_2_2", priority "1000001", pk_name "pk_s_2_2_gm_r3"' + ); +let $MASTER_1_COMMENT_LOCK1= + COMMENT 'tbl "t1_1 t1_2", srv "s_2_1 s_2_2", + pk_name "pk_s_2_1_t1_1 pk_s_2_2_t1_2"'; +let $MASTER_1_COMMENT_LOCK2= + COMMENT 'tbl "t2_1 t2_2", srv "s_2_2 s_2_1", + pk_name "pk_s_2_2_t2_1 pk_s_2_1_t2_2"'; +let $MASTER_1_COMMENT_INCREMENT1_1= + COMMENT 'aim "2", sqn "seq_t1_1", tbl "t1_1", srv "s_2_1", + pk_name "pk_s_2_1_t1_1"'; +let $MASTER_1_COMMENT_INCREMENT1_P_1= + COMMENT 'aim "2"' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='sqn "seq_t1_1", tbl "t1_1", srv "s_2_1", pk_name "pk_s_2_1_t1_1"', + PARTITION pt2 VALUES IN (1) + COMMENT='sqn "seq_t1_2", tbl "t1_2", srv "s_2_2", pk_name "pk_s_2_2_t1_2"' + ); +let $MASTER_1_COMMENT_READONLY1_1= + COMMENT 'read_only_mode "1", tbl "t1_1", srv "s_2_1", + pk_name "pk_s_2_1_t1_1"'; +let $MASTER_1_COMMENT_ERROR_MODE1_1= + COMMENT 'erm "1", ewm "1", tbl "ter1_1", srv "s_2_1", + pk_name "pk_s_2_1_ter1_1"'; +let $MASTER_1_COMMENT_TEXT_PK1_1= + COMMENT 'tbl "t1", srv "s_2_1", pk_name "pk_s_2_1_t1"'; +let $MASTER_1_COMMENT_TEXT_KEY1_1= + COMMENT 'tbl "t1", srv "s_2_1", pk_name "pk_s_2_1_t1"'; +let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +let $MASTER_1_CHECK_DIRECT_DELETE_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +let $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_direct_order_limit%'; +let $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS= + SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +let $MASTER_1_AUTO_INCREMENT_INCREMENT1= + SET SESSION AUTO_INCREMENT_INCREMENT = 1 $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_INCREMENT2= + SET SESSION AUTO_INCREMENT_INCREMENT = 777 $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET1= + SET SESSION AUTO_INCREMENT_OFFSET = 1 $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 1 INCREMENT BY 1', '', 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET2= + SET SESSION AUTO_INCREMENT_OFFSET = 777 $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') + $STR_SEMICOLON + SELECT spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'$STR_SEMICOLON exception when others then null$STR_SEMICOLON end$STR_SEMICOLON', '', 'srv "s_2_2"') + $STR_SEMICOLON + SELECT spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"'); +let $MASTER_1_AUTO_INCREMENT_OFFSET3= + SET SESSION AUTO_INCREMENT_OFFSET = 1; +let $MASTER_1_AUTO_INCREMENT_OFFSET4= + SET SESSION AUTO_INCREMENT_OFFSET = 777; diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_slave1_1.inc b/storage/spider/mysql-test/spider/oracle2/include/init_slave1_1.inc new file mode 100644 index 00000000000..87c05f1f690 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_slave1_1.inc @@ -0,0 +1,10 @@ +let $SLAVE1_1_COMMENT_INCREMENT1_1= + COMMENT ''; +let $SLAVE1_1_COMMENT_INCREMENT1_P_1= + COMMENT '' + PARTITION BY LIST(MOD(id, 2)) ( + PARTITION pt1 VALUES IN (0) + COMMENT='', + PARTITION pt2 VALUES IN (1) + COMMENT='' + ); diff --git a/storage/spider/mysql-test/spider/oracle2/include/init_spider.inc b/storage/spider/mysql-test/spider/oracle2/include/init_spider.inc new file mode 100644 index 00000000000..ff9ac9aee29 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/include/init_spider.inc @@ -0,0 +1,105 @@ +--source ../../include/init_spider.inc +let $VERSION_COMPILE_OS_WIN= + `SELECT IF(@@version_compile_os like 'Win%', 1, 0)`; +if ($VERSION_COMPILE_OS_WIN) +{ + eval DROP SERVER s_2_1; + eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_2_2; + eval CREATE SERVER s_2_2 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_2_3; + eval CREATE SERVER s_2_3 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_3_1; + eval CREATE SERVER s_3_1 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD3_1_MYPORT + ); + eval DROP SERVER s_3_2; + eval CREATE SERVER s_3_2 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD3_2_MYPORT + ); + eval DROP SERVER s_3_3; + eval CREATE SERVER s_3_3 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + PORT $CHILD2_3_MYPORT + ); +} +if (!$VERSION_COMPILE_OS_WIN) +{ + eval DROP SERVER s_2_1; + eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_2_2; + eval CREATE SERVER s_2_2 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_2_3; + eval CREATE SERVER s_2_3 FOREIGN DATA WRAPPER oracle OPTIONS ( + HOST '$ORACLE_HOST', + DATABASE '$ORACLE_DATABASE', + USER '$ORACLE_USER', + PASSWORD '$ORACLE_PASSWORD', + PORT $ORACLE_PORT + ); + eval DROP SERVER s_3_1; + eval CREATE SERVER s_3_1 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_1_MYSOCK' + ); + eval DROP SERVER s_3_2; + eval CREATE SERVER s_3_2 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_2_MYSOCK' + ); + eval DROP SERVER s_3_3; + eval CREATE SERVER s_3_3 FOREIGN DATA WRAPPER mysql OPTIONS ( + HOST 'localhost', + DATABASE 'auto_test_local', + USER 'root', + PASSWORD '', + SOCKET '$CHILD3_3_MYSOCK' + ); +} diff --git a/storage/spider/mysql-test/spider/oracle2/my.cnf b/storage/spider/mysql-test/spider/oracle2/my.cnf new file mode 100644 index 00000000000..e24985bb8d4 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/my.cnf @@ -0,0 +1,146 @@ +# Use default setting for mysqld processes +!include include/default_mysqld.cnf + +[mysqld.1.1] +log-bin= master-bin +loose_handlersocket_port= 20000 +loose_handlersocket_port_wr= 20001 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 +loose_partition= 1 + +[mysqld.3.1] +loose_partition= 1 + +[mysqld.3.2] +loose_partition= 1 + +[mysqld.3.3] +loose_partition= 1 + +[mysqld.4.1] +loose_partition= 1 + + +[ENV] +USE_GEOMETRY_TEST= 0 +USE_FULLTEXT_TEST= 0 +USE_HA_TEST= 1 +USE_GENERAL_LOG= 1 +USE_REPLICATION= 0 +MASTER_1_MYPORT= @mysqld.1.1.port +MASTER_1_HSRPORT= 20000 +MASTER_1_HSWPORT= 20001 +MASTER_1_MYSOCK= @mysqld.1.1.socket +MASTER_1_ENGINE_TYPE= Spider +#MASTER_1_ENGINE_TYPE= MyISAM +MASTER_1_ENGINE= ENGINE=Spider +MASTER_1_CHARSET= DEFAULT CHARSET=utf8 +MASTER_1_ENGINE2= ENGINE=MyISAM +MASTER_1_CHARSET2= DEFAULT CHARSET=utf8 +MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +SLAVE1_1_MYPORT= @mysqld.4.1.port +SLAVE1_1_MYSOCK= @mysqld.4.1.socket +SLAVE1_1_ENGINE_TYPE= MyISAM +SLAVE1_1_ENGINE= ENGINE=MyISAM +SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP2= 1 +OUTPUT_CHILD_GROUP2= 0 +CHILD2_1_MYPORT= @mysqld.1.1.port +CHILD2_1_MYSOCK= @mysqld.1.1.socket +CHILD2_1_ENGINE_TYPE= InnoDB +CHILD2_1_ENGINE= ENGINE=InnoDB +CHILD2_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +CHILD2_2_MYPORT= @mysqld.1.1.port +CHILD2_2_MYSOCK= @mysqld.1.1.socket +CHILD2_2_ENGINE_TYPE= InnoDB +CHILD2_2_ENGINE= ENGINE=InnoDB +CHILD2_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_3_MYPORT= @mysqld.1.1.port +CHILD2_3_MYSOCK= @mysqld.1.1.socket +CHILD2_3_ENGINE_TYPE= InnoDB +CHILD2_3_ENGINE= ENGINE=InnoDB +CHILD2_3_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_FT_MYPORT= @mysqld.1.1.port +CHILD2_1_FT_MYSOCK= @mysqld.1.1.socket +CHILD2_1_FT_ENGINE_TYPE= MyISAM +CHILD2_1_FT_ENGINE= ENGINE=MyISAM +CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_FT_MYPORT= @mysqld.1.1.port +CHILD2_2_FT_MYSOCK= @mysqld.1.1.socket +CHILD2_2_FT_ENGINE_TYPE= MyISAM +CHILD2_2_FT_ENGINE= ENGINE=MyISAM +CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_GM_MYPORT= @mysqld.1.1.port +CHILD2_1_GM_MYSOCK= @mysqld.1.1.socket +CHILD2_1_GM_ENGINE_TYPE= MyISAM +CHILD2_1_GM_ENGINE= ENGINE=MyISAM +CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_GM_MYPORT= @mysqld.1.1.port +CHILD2_2_GM_MYSOCK= @mysqld.1.1.socket +CHILD2_2_GM_ENGINE_TYPE= MyISAM +CHILD2_2_GM_ENGINE= ENGINE=MyISAM +CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8 +USE_CHILD_GROUP3= 1 +OUTPUT_CHILD_GROUP3= 0 +CHILD3_1_MYPORT= @mysqld.3.1.port +CHILD3_1_MYSOCK= @mysqld.3.1.socket +CHILD3_1_ENGINE_TYPE= InnoDB +CHILD3_1_ENGINE= ENGINE=InnoDB +CHILD3_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_2_MYPORT= @mysqld.3.2.port +CHILD3_2_MYSOCK= @mysqld.3.2.socket +CHILD3_2_ENGINE_TYPE= InnoDB +CHILD3_2_ENGINE= ENGINE=InnoDB +CHILD3_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD3_3_MYPORT= @mysqld.3.3.port +CHILD3_3_MYSOCK= @mysqld.3.3.socket +CHILD3_3_ENGINE_TYPE= InnoDB +CHILD3_3_ENGINE= ENGINE=InnoDB +CHILD3_3_CHARSET= DEFAULT CHARSET=utf8 +ORACLE_HOST= xe +ORACLE_PORT= 1521 +ORACLE_USER= system +ORACLE_PASSWORD= oracle +ORACLE_DATABASE= SYSTEM + +STR_SEMICOLON= ; + +#The followings are setted in include/init_xxx.inc files +#MASTER_1_COMMENT_2_1 +#MASTER_1_COMMENT2_2_1 +#MASTER_1_COMMENT3_2_1 +#MASTER_1_COMMENT4_2_1 +#MASTER_1_COMMENT5_2_1 +#MASTER_1_COMMENT_P_2_1 +#CHILD2_1_DROP_TABLES +#CHILD2_1_CREATE_TABLES +#CHILD2_1_SELECT_TABLES +#CHILD2_1_DROP_TABLES2 +#CHILD2_1_CREATE_TABLES2 +#CHILD2_1_SELECT_TABLES2 +#CHILD2_1_DROP_TABLES3 +#CHILD2_1_CREATE_TABLES3 +#CHILD2_1_SELECT_TABLES3 +#CHILD2_1_DROP_TABLES4 +#CHILD2_1_CREATE_TABLES4 +#CHILD2_1_SELECT_TABLES4 +#CHILD2_1_DROP_TABLES5 +#CHILD2_1_CREATE_TABLES5 +#CHILD2_1_SELECT_TABLES5 +#CHILD2_1_DROP_TABLES6 +#CHILD2_1_CREATE_TABLES6 +#CHILD2_1_SELECT_TABLES6 +#CHILD2_2_DROP_TABLES +#CHILD2_2_CREATE_TABLES +#CHILD2_2_SELECT_TABLES diff --git a/storage/spider/mysql-test/spider/oracle2/r/basic_sql.result b/storage/spider/mysql-test/spider/oracle2/r/basic_sql.result new file mode 100644 index 00000000000..e6202327ef6 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/r/basic_sql.result @@ -0,0 +1,701 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'f', '2008-07-01 10:21:39'), +(2, 'g', '2000-02-01 00:00:00'), +(3, 'j', '2007-05-04 20:03:11'), +(4, 'i', '2003-10-30 05:01:03'), +(5, 'h', '2001-10-31 23:59:59'); +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l +Warnings: +Warning 1062 Duplicate entry '1' for key 'PRIMARY' +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +Warning 1062 Duplicate entry '3' for key 'PRIMARY' +Warning 1062 Duplicate entry '4' for key 'PRIMARY' +Warning 1062 Duplicate entry '5' for key 'PRIMARY' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create table with partition and select test +CREATE TABLE ta_l2 ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create no index table +DROP TABLE IF EXISTS ta_l_no_idx; +CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table shared mode +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table for update +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table join +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table straight_join +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_small_result +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_big_result +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_buffer_result +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_cache +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_no_cache +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_calc_found_rows +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +SELECT found_rows(); +found_rows() +5 + +select high_priority +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select distinct +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select count +SELECT count(*) FROM ta_l ORDER BY a; +count(*) +5 + +select table join not use index +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select using index and pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using index pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +insert +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +insert select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 + +insert low_priority +TRUNCATE TABLE ta_l; +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert high_priority +TRUNCATE TABLE ta_l; +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert ignore +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +Warnings: +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (insert) +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (update) +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2005-08-08 11:11:11 + +replace +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2008-02-02 02:02:02 + +replace select +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace select a +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace low_priority +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 g 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 f 2008-02-02 02:02:02 + +update select +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update select a +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 h 2010-04-04 04:04:04 +2 g 2009-03-03 03:03:03 + +update join +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 + +update join a +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update low_priority +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update ignore +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update pushdown +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 j 2009-03-03 03:03:03 + +update index pushdown +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update partition pushdown +UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 e 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update partition index pushdown +UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete all +DELETE FROM ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE IGNORE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE QUICK FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete partition pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete partition index pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +truncate +TRUNCATE TABLE ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle2/r/direct_aggregate.result b/storage/spider/mysql-test/spider/oracle2/r/direct_aggregate.result new file mode 100644 index 00000000000..26860959718 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/r/direct_aggregate.result @@ -0,0 +1,132 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_aggregating test +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 0 +SELECT COUNT(*) FROM ta_l; +COUNT(*) +5 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l; +MAX(a) +5 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MIN(a) FROM ta_l; +MIN(a) +1 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l WHERE a < 5; +MAX(a) +4 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MIN(a) FROM ta_l WHERE a > 1; +MIN(a) +2 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 + +with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT COUNT(*) FROM ta_l2; +COUNT(*) +5 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l2; +MAX(a) +5 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MIN(a) FROM ta_l2; +MIN(a) +1 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l2 WHERE a < 5; +MAX(a) +4 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MIN(a) FROM ta_l2 WHERE a > 1; +MIN(a) +2 +SHOW GLOBAL STATUS LIKE 'Spider_direct_aggregate%'; +Variable_name Value +Spider_direct_aggregate 3 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle2/r/direct_update.result b/storage/spider/mysql-test/spider/oracle2/r/direct_update.result new file mode 100644 index 00000000000..db6066a6e46 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/r/direct_update.result @@ -0,0 +1,226 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_updating test +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-03 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l WHERE a = 3; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l2 SET c = ADDDATE(c, 1); +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l2 SET b = 'x' WHERE a = 3; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW GLOBAL STATUS LIKE 'Spider_direct_update%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-03 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l2 WHERE b = 'c'; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l2 WHERE a = 3; +SHOW GLOBAL STATUS LIKE 'Spider_direct_delete%'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle2/r/function.result b/storage/spider/mysql-test/spider/oracle2/r/function.result new file mode 100644 index 00000000000..764c774514b --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/r/function.result @@ -0,0 +1,149 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +in() +CREATE TABLE t1 ( +a VARCHAR(255), +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1 +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +select a from t1 where a in ('15', '120'); +a +120 +15 + +date_sub() +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-08-01 10:21:39 +2 b 1999-01-01 00:00:00 +3 e 2006-06-04 20:03:11 +4 d 2002-11-30 05:01:03 +5 c 2000-12-31 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-11-01 10:21:39 +2 b 1999-04-01 00:00:00 +3 e 2006-09-04 20:03:11 +4 d 2003-02-28 05:01:03 +5 c 2001-03-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-01 10:21:39 +2 b 1999-03-01 00:00:00 +3 e 2006-08-04 20:03:11 +4 d 2003-01-28 05:01:03 +5 c 2001-02-28 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-08 10:21:39 +2 b 1999-03-08 00:00:00 +3 e 2006-08-11 20:03:11 +4 d 2003-02-04 05:01:03 +5 c 2001-03-07 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 10:21:39 +2 b 1999-03-07 00:00:00 +3 e 2006-08-10 20:03:11 +4 d 2003-02-03 05:01:03 +5 c 2001-03-06 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:21:39 +2 b 1999-03-07 01:00:00 +3 e 2006-08-10 21:03:11 +4 d 2003-02-03 06:01:03 +5 c 2001-03-07 00:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:39 +2 b 1999-03-07 00:59:00 +3 e 2006-08-10 21:02:11 +4 d 2003-02-03 06:00:03 +5 c 2001-03-07 00:58:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:40 +2 b 1999-03-07 00:59:01 +3 e 2006-08-10 21:02:12 +4 d 2003-02-03 06:00:04 +5 c 2001-03-07 00:59:00 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle2/r/ha.result b/storage/spider/mysql-test/spider/oracle2/r/ha.result new file mode 100644 index 00000000000..95b428eb1ff --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/r/ha.result @@ -0,0 +1,431 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +CREATE DATABASE auto_test_remote3; +USE auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; + +test select 1 +SELECT 1; +1 +1 + +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 0 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'SYSTEM.ta_r3' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "xe", user "system", + password "oracle", msi "2", mkd "2", + database "SYSTEM", lst "0 2"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 2 +SELECT spider_copy_tables('ta_l', '0', '1'); +spider_copy_tables('ta_l', '0', '1') +1 +ALTER TABLE ta_l +CONNECTION='host "xe", user "system", + password "oracle", msi "2", mkd "2", + database "SYSTEM", lst "0 1"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'SYSTEM.ta_r4' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 2 +SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +spider_copy_tables('ta_l2#P#pt2', '0', '1') +1 +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +active standby test +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'SYSTEM.ta_r' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 3 +auto_test_local ta_l 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "xe", user "system", + password "oracle", msi "2", mkd "2", alc "1", + database "SYSTEM", lst "1 0"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'SYSTEM.ta_r2' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 3 +auto_test_local ta_l2#P#pt2 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +auto_test_local ta_l2#P#pt2 0 +SHOW GLOBAL STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 3 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle2/r/spider3_fixes.result b/storage/spider/mysql-test/spider/oracle2/r/spider3_fixes.result new file mode 100644 index 00000000000..e7fbceb3933 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/r/spider3_fixes.result @@ -0,0 +1,375 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +3.1 +auto_increment +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT MAX(id) FROM t1; +MAX(id) +2 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6 +SELECT MAX(id) FROM t2; +MAX(id) +6 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT MAX(id) FROM t1; +MAX(id) +10 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +14 +SELECT MAX(id) FROM t2; +MAX(id) +14 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT id FROM t1 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +30 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +34 +SELECT id FROM t2 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +30 +34 +38 +42 +46 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +50 +SELECT id FROM t1 ORDER BY id; +id +50 +54 +58 +62 +INSERT INTO t2 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +66 +SELECT id FROM t2 ORDER BY id; +id +50 +54 +58 +62 +66 +70 +74 +78 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +82 +SELECT MAX(id) FROM t1; +MAX(id) +82 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +86 +SELECT MAX(id) FROM t2; +MAX(id) +86 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +90 +SELECT MAX(id) FROM t1; +MAX(id) +90 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +94 +SELECT MAX(id) FROM t2; +MAX(id) +94 +auto_increment with partition +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT MAX(id) FROM t1; +MAX(id) +2 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +SELECT MAX(id) FROM t2; +MAX(id) +3 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6 +SELECT MAX(id) FROM t1; +MAX(id) +6 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT MAX(id) FROM t2; +MAX(id) +10 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +7 +SELECT id FROM t1 ORDER BY id; +id +2 +3 +6 +7 +10 +11 +14 +18 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +15 +SELECT id FROM t2 ORDER BY id; +id +2 +3 +6 +7 +10 +11 +14 +15 +18 +19 +22 +26 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +23 +SELECT id FROM t1 ORDER BY id; +id +23 +27 +30 +34 +INSERT INTO t2 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +31 +SELECT id FROM t2 ORDER BY id; +id +23 +27 +30 +31 +34 +35 +38 +42 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +46 +SELECT MAX(id) FROM t1; +MAX(id) +46 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +39 +SELECT MAX(id) FROM t2; +MAX(id) +46 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +50 +SELECT MAX(id) FROM t1; +MAX(id) +50 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +54 +SELECT MAX(id) FROM t2; +MAX(id) +54 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle2/r/spider_fixes.result b/storage/spider/mysql-test/spider/oracle2/r/spider_fixes.result new file mode 100644 index 00000000000..d23ba9aeec8 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/r/spider_fixes.result @@ -0,0 +1,678 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +2.13 +select table with "order by desc" and "<" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 +2 b 2000-01-01 00:00:00 + +select table with "order by desc" and "<=" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +5 c 2001-12-31 23:59:59 +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 + +2.14 +update table with range scan and split_read +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-02-02 00:00:00 +3 e 2000-02-02 00:00:00 +4 d 2000-02-02 00:00:00 +5 c 2000-02-02 00:00:00 + +2.15 +select table with range scan +TRUNCATE TABLE ta_l; +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a int(11) NOT NULL DEFAULT '0', +b char(1) DEFAULT NULL, +c datetime DEFAULT NULL, +PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +a b c +5 c 2001-12-31 23:59:59 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 + +2.16 +auto_increment insert with trigger +CREATE TABLE ta_l_auto_inc ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tc_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;; +INSERT INTO ta_l_auto_inc (a, b, c) VALUES +(NULL, 's', '2008-12-31 20:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 s 2008-12-31 20:59:59 + +2.17 +engine-condition-pushdown with "or" and joining +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +partition with sort +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +2.23 +partition update with moving partition +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); +UPDATE ta_l2 SET a = 4 WHERE a = 3; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 B 2010-09-26 00:00:00 +index merge +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 +index merge with partition +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 + +2.24 +index scan update without PK +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT NOT NULL, +b INT DEFAULT 10, +c INT DEFAULT 11, +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +UPDATE ta_l_int SET c = 4 WHERE b = 2; +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +0 2 4 +1 2 4 +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 + +2.25 +direct order limit +SHOW GLOBAL STATUS LIKE 'Spider_direct_order_limit%'; +Variable_name Value +Spider_direct_order_limit 0 +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +a b c +2 3 4 +4 5 6 +6 7 8 +SHOW GLOBAL STATUS LIKE 'Spider_direct_order_limit%'; +Variable_name Value +Spider_direct_order_limit 0 + +2.26 +lock tables +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1 +CREATE TABLE t2 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2 +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + +auto_increment +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT MAX(id) FROM t1; +MAX(id) +2 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6 +SELECT MAX(id) FROM t1; +MAX(id) +6 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT MAX(id) FROM t1; +MAX(id) +10 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +14 +SELECT MAX(id) FROM t1; +MAX(id) +14 +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT id FROM t1 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +30 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +34 +SELECT MAX(id) FROM t1; +MAX(id) +34 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +38 +SELECT MAX(id) FROM t1; +MAX(id) +38 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +42 +SELECT MAX(id) FROM t1; +MAX(id) +42 + +auto_increment with partition +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_1"\'; exception when others then null; end;', '', 'srv "s_2_1"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_1" START WITH 2 INCREMENT BY 4', '', 'srv "s_2_1"') +1 +spider_direct_sql('begin execute immediate \'DROP SEQUENCE "seq_t1_2"\'; exception when others then null; end;', '', 'srv "s_2_2"') +1 +spider_direct_sql('CREATE SEQUENCE "seq_t1_2" START WITH 3 INCREMENT BY 4', '', 'srv "s_2_2"') +1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT MAX(id) FROM t1; +MAX(id) +2 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +SELECT MAX(id) FROM t1; +MAX(id) +3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6 +SELECT MAX(id) FROM t1; +MAX(id) +6 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +7 +SELECT MAX(id) FROM t1; +MAX(id) +7 +INSERT INTO t1 () VALUES (),(),(),(); +Warnings: +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +10 +SELECT id FROM t1 ORDER BY id; +id +2 +3 +6 +7 +10 +11 +14 +15 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +18 +SELECT MAX(id) FROM t1; +MAX(id) +18 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +22 +SELECT MAX(id) FROM t1; +MAX(id) +22 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +26 +SELECT MAX(id) FROM t1; +MAX(id) +26 + +read only +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1 +SELECT id FROM t1 ORDER BY id; +id +2 +6 +10 +14 +18 +22 +26 +INSERT INTO t1 (id) VALUES (1); +ERROR HY000: Table 'auto_test_local.t1' is read only +UPDATE t1 SET id = 4 WHERE id = 2; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1 WHERE id = 2; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1; +ERROR HY000: Table 'auto_test_local.t1' is read only +TRUNCATE t1; +ERROR HY000: Table 'auto_test_local.t1' is read only + +2.27 +error mode +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1 +SELECT id FROM t1 ORDER BY id; +id +Warnings: +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error +INSERT INTO t1 (id) VALUES (1); +Warnings: +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error +DELETE FROM t1; +Warnings: +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error +TRUNCATE t1; +Warnings: +Error 12712 Error from Oracle -1 942 ORA-00942: ??????????????? + +Error 12712 Oracle error + +3.0 +is null +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +a VARCHAR(255), +b VARCHAR(255), +c VARCHAR(255), +KEY idx1(a,b), +KEY idx2(b), +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1 +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +select a from t1 where a is null order by a limit 30; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +select b from t1 where b is null order by b limit 30; +b +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL + +direct_order_limit +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +a b c +10 74 74 +10 42 42 +10 234 234 +10 202 202 +10 170 170 +select a, c from t1 where a = '10' order by b desc limit 5; +a c +10 74 +10 42 +10 234 +10 202 +10 170 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle2/r/vp_fixes.result b/storage/spider/mysql-test/spider/oracle2/r/vp_fixes.result new file mode 100644 index 00000000000..15dd29aa4d3 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/r/vp_fixes.result @@ -0,0 +1,80 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +0.9 +create different primary key table +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT AUTO_INCREMENT, +c INT DEFAULT 11, +PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +create un-correspond primary key table +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT DEFAULT 12, +c INT DEFAULT 11, +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/oracle2/t/basic_sql.test b/storage/spider/mysql-test/spider/oracle2/t/basic_sql.test new file mode 100644 index 00000000000..2264b0e4e37 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/basic_sql.test @@ -0,0 +1,3189 @@ +# This test tests by executing basic SQL +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'f', '2008-07-01 10:21:39'), + (2, 'g', '2000-02-01 00:00:00'), + (3, 'j', '2007-05-04 20:03:11'), + (4, 'i', '2003-10-30 05:01:03'), + (5, 'h', '2001-10-31 23:59:59'); +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT IGNORE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + REPLACE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table with partition and select test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + } + --enable_query_log + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo create no index table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_no_idx; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_NEEDPK) +{ + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + } +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES3; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; + +--echo +--echo select table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table shared mode +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table for update +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table straight_join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_small_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_big_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_buffer_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_no_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_calc_found_rows +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT found_rows(); + +--echo +--echo select high_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select distinct +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select count +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT count(*) FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join not use index +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using index and pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select partition using pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo select partition using index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.a > 0 AND a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo insert +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select a +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert low_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert high_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (insert) +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (update) +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace +--connection master_1 +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update index pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update partition pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo update partition index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete all +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE IGNORE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE QUICK FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete partition pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete partition index pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo truncate +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle2/t/connect_child2_1.inc b/storage/spider/mysql-test/spider/oracle2/t/connect_child2_1.inc new file mode 100644 index 00000000000..cd9b0c9ca9b --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/connect_child2_1.inc @@ -0,0 +1 @@ +--connect (child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle2/t/connect_child2_2.inc b/storage/spider/mysql-test/spider/oracle2/t/connect_child2_2.inc new file mode 100644 index 00000000000..e145f66b630 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/connect_child2_2.inc @@ -0,0 +1 @@ +--connect (child2_2, localhost, root, , , $CHILD2_2_MYPORT, $CHILD2_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle2/t/connect_child2_3.inc b/storage/spider/mysql-test/spider/oracle2/t/connect_child2_3.inc new file mode 100644 index 00000000000..d356348d8ea --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/connect_child2_3.inc @@ -0,0 +1 @@ +--connect (child2_3, localhost, root, , , $CHILD2_3_MYPORT, $CHILD2_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle2/t/connect_child3_1.inc b/storage/spider/mysql-test/spider/oracle2/t/connect_child3_1.inc new file mode 100644 index 00000000000..03e5c188c89 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/connect_child3_1.inc @@ -0,0 +1 @@ +--connect (child3_1, localhost, root, , , $CHILD3_1_MYPORT, $CHILD3_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle2/t/connect_child3_2.inc b/storage/spider/mysql-test/spider/oracle2/t/connect_child3_2.inc new file mode 100644 index 00000000000..d62a7ada824 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/connect_child3_2.inc @@ -0,0 +1 @@ +--connect (child3_2, localhost, root, , , $CHILD3_2_MYPORT, $CHILD3_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle2/t/connect_child3_3.inc b/storage/spider/mysql-test/spider/oracle2/t/connect_child3_3.inc new file mode 100644 index 00000000000..fb49f5bfdac --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/connect_child3_3.inc @@ -0,0 +1 @@ +--connect (child3_3, localhost, root, , , $CHILD3_3_MYPORT, $CHILD3_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle2/t/connect_master_1.inc b/storage/spider/mysql-test/spider/oracle2/t/connect_master_1.inc new file mode 100644 index 00000000000..0c129ce5775 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/connect_master_1.inc @@ -0,0 +1 @@ +--connect (master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle2/t/connect_slave1_1.inc b/storage/spider/mysql-test/spider/oracle2/t/connect_slave1_1.inc new file mode 100644 index 00000000000..45a822743e0 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/connect_slave1_1.inc @@ -0,0 +1 @@ +--connect (slave1_1, localhost, root, , , $SLAVE1_1_MYPORT, $SLAVE1_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate.test b/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate.test new file mode 100644 index 00000000000..59c45f3f190 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate.test @@ -0,0 +1,316 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_aggregating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT COUNT(*) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l WHERE a < 5; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l WHERE a > 1; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT COUNT(*) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2 WHERE a < 5; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2 WHERE a > 1; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle2/t/direct_update.test b/storage/spider/mysql-test/spider/oracle2/t/direct_update.test new file mode 100644 index 00000000000..1c3ce91ff3f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/direct_update.test @@ -0,0 +1,354 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_updating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key +DELETE FROM ta_l WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update all rows with function + UPDATE ta_l2 SET c = ADDDATE(c, 1); + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key + UPDATE ta_l2 SET b = 'x' WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by a column without index + UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key with order and limit + UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key with order and limit + DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by a column without index + DELETE FROM ta_l2 WHERE b = 'c'; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key + DELETE FROM ta_l2 WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle2/t/function.test b/storage/spider/mysql-test/spider/oracle2/t/function.test new file mode 100644 index 00000000000..2b1b53c8a4f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/function.test @@ -0,0 +1,276 @@ +# This test tests for using functions +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo in() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_PK_TABLES1; + echo CHILD2_1_CREATE_TEXT_PK_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_PK_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_PK_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET3 $MASTER_1_COMMENT_TEXT_PK1_1; +--enable_query_log +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a in ('15', '120'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo date_sub() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle2/t/ha.test b/storage/spider/mysql-test/spider/oracle2/t/ha.test new file mode 100644 index 00000000000..319b1793753 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/ha.test @@ -0,0 +1,1794 @@ +# This test tests for ha features +--let $SKIP_REASON= +if ($USE_HA_TEST) +{ +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source ha_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + CREATE DATABASE auto_test_remote3; + USE auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + } + if ($USE_CHILD_GROUP3) + { + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + } + --disable_query_log + --disable_result_log + --source ha_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + --connection child2_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + SELECT 1; + --connection child3_2 + SELECT 1; + --connection child3_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_2_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_CREATE_TABLES; + } + eval $CHILD2_2_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_RECOVERY_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_COPY_TABLES_2_1; +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_3_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_CREATE_TABLES; + } + eval $CHILD2_3_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_COPY_TABLES_P_2_1; + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo active standby test +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_AS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES2; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES2; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES2; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_AS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; +} +--disable_query_log +--disable_result_log +--source ha_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +} +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle2/t/ha_test_deinit.inc b/storage/spider/mysql-test/spider/oracle2/t/ha_test_deinit.inc new file mode 100644 index 00000000000..53d0409d066 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/ha_test_deinit.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_deinit_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_deinit_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_deinit_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_deinit_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/ha_test_init.inc b/storage/spider/mysql-test/spider/oracle2/t/ha_test_init.inc new file mode 100644 index 00000000000..70576ab16dc --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/ha_test_init.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_init_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_init_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_init_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_init_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/have_engine.inc b/storage/spider/mysql-test/spider/oracle2/t/have_engine.inc new file mode 100644 index 00000000000..64bef7499cb --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/have_engine.inc @@ -0,0 +1,7 @@ +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = '$TEST_ENGINE_TYPE'`) +{ + SELECT engine, support FROM information_schema.engines; + --let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine" +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/have_func.inc b/storage/spider/mysql-test/spider/oracle2/t/have_func.inc new file mode 100644 index 00000000000..e0823e73fc8 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/have_func.inc @@ -0,0 +1,5 @@ +if (!`SELECT count(*) FROM mysql.func WHERE name = '$TEST_FUNC_NAME'`) +{ + SELECT name FROM mysql.func; + --let $SKIP_REASON= "Need $TEST_FUNC_NAME function" +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/have_partition.inc b/storage/spider/mysql-test/spider/oracle2/t/have_partition.inc new file mode 100644 index 00000000000..573c76ab43b --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/have_partition.inc @@ -0,0 +1,7 @@ +let $HAVE_PARTITION= 0; +if (`SELECT count(*) FROM information_schema.plugins WHERE + plugin_status = 'ACTIVE' AND + plugin_name = 'partition'`) +{ + let $HAVE_PARTITION= 1; +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/have_trigger.inc b/storage/spider/mysql-test/spider/oracle2/t/have_trigger.inc new file mode 100644 index 00000000000..10c0871dd5f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/have_trigger.inc @@ -0,0 +1,2 @@ +let $HAVE_TRIGGER= `SELECT COUNT(*) FROM information_schema.tables + WHERE TABLE_SCHEMA = 'information_schema' AND TABLE_NAME = 'TRIGGERS'`; diff --git a/storage/spider/mysql-test/spider/oracle2/t/hs_test_deinit.inc b/storage/spider/mysql-test/spider/oracle2/t/hs_test_deinit.inc new file mode 100644 index 00000000000..7ec2e981fd2 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/hs_test_deinit.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_deinit_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/hs_test_init.inc b/storage/spider/mysql-test/spider/oracle2/t/hs_test_init.inc new file mode 100644 index 00000000000..831bf479524 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/hs_test_init.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_init_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/slave_test_deinit.inc b/storage/spider/mysql-test/spider/oracle2/t/slave_test_deinit.inc new file mode 100644 index 00000000000..e9d99b7a960 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/slave_test_deinit.inc @@ -0,0 +1,6 @@ +# get connection and exist engine test +--echo for slave1_1 +--connection slave1_1 +STOP SLAVE; +--source ../include/deinit_slave1_1.inc +--disconnect slave1_1 diff --git a/storage/spider/mysql-test/spider/oracle2/t/slave_test_init.inc b/storage/spider/mysql-test/spider/oracle2/t/slave_test_init.inc new file mode 100644 index 00000000000..739d88970c5 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/slave_test_init.inc @@ -0,0 +1,44 @@ +# get connection and exist engine test +--echo for slave1_1 +--source connect_slave1_1.inc +--connection slave1_1 +SET SESSION sql_log_bin= 0; +--let $SLAVE1_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $SLAVE1_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_slave1_1.inc +--source have_engine.inc +--let $SLAVE1_1_SLAVE_STATUS=`SHOW SLAVE STATUS` +if (!$SLAVE1_1_SLAVE_STATUS) +{ + eval CHANGE MASTER TO + MASTER_HOST = '127.0.0.1', + MASTER_USER = 'root', + MASTER_PASSWORD = '', + MASTER_PORT = $MASTER_1_MYPORT + ; +} +START SLAVE; +--connection master_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +--connection slave1_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes.test b/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes.test new file mode 100644 index 00000000000..4139f3af955 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes.test @@ -0,0 +1,570 @@ +# This test tests for Spider 3.0's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo 3.1 +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +SET INSERT_ID=5000; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + TRUNCATE TABLE t1; + TRUNCATE TABLE t2; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + SET INSERT_ID=5000; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle2/t/spider_fixes.test b/storage/spider/mysql-test/spider/oracle2/t/spider_fixes.test new file mode 100644 index 00000000000..b9ff61abcb4 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/spider_fixes.test @@ -0,0 +1,1967 @@ +# This test tests for Spider's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 2.13 +--echo select table with "order by desc" and "<" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table with "order by desc" and "<=" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.14 +--echo update table with range scan and split_read +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo 2.15 +--echo select table with range scan +TRUNCATE TABLE ta_l; +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_CREATE_TABLES6; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES6; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES6; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.16 +--echo auto_increment insert with trigger +if ($HAVE_TRIGGER) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_CREATE_TABLES4; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES4; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES4; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; + eval CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; + echo CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE2 MASTER_1_CHARSET2; + eval CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; + --enable_query_log + --eval CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + INSERT INTO ta_l_auto_inc (a, b, c) VALUES + (NULL, 's', '2008-12-31 20:59:59'); + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES4; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +} + +--echo +--echo 2.17 +--echo engine-condition-pushdown with "or" and joining +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo partition with sort +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 + ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.23 +--echo partition update with moving partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); + UPDATE ta_l2 SET a = 4 WHERE a = 3; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo index merge +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo index merge with partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l_int; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_2_DROP_TABLES5; + echo CHILD2_2_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES5; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES5; + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1; + eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_P_2_1; + --enable_query_log + INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); + INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) + WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.24 +--echo index scan update without PK +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +if (!$MASTER_1_NEEDPK) +{ + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +--enable_query_log +SELECT a, b, c FROM ta_l_int ORDER BY a; +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l_int SET c = 4 WHERE b = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; + + +--echo +--echo 2.25 +--echo direct order limit +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; + + +--echo +--echo 2.26 +--echo lock tables +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_LOCK_TABLES1; + echo CHILD2_1_DROP_LOCK_TABLES2; + echo CHILD2_1_CREATE_LOCK_TABLES1; + echo CHILD2_1_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_LOCK_TABLES1; + eval $CHILD2_1_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_LOCK_TABLES1; + eval $CHILD2_1_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_LOCK_TABLES1; + echo CHILD2_2_DROP_LOCK_TABLES2; + echo CHILD2_2_CREATE_LOCK_TABLES1; + echo CHILD2_2_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_2_DROP_LOCK_TABLES1; + eval $CHILD2_2_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_2_CREATE_LOCK_TABLES1; + eval $CHILD2_2_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1; +eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2; +eval CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK2; +--enable_query_log +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + + +--echo +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + SET INSERT_ID=5000; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo read only +let $MASTER_1_ENGINE_IS_SPIDER= + `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'Spider' OR + '$MASTER_1_HIDDEN_ENGINE_TYPE' = 'Spider', 1, 0)`; +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_READONLY1_1; + --let $MIN_VAL= `SELECT MIN(id) FROM t1` + --enable_query_log + SELECT id FROM t1 ORDER BY id; + --error 12518 + INSERT INTO t1 (id) VALUES (1); + --error 12518 + eval UPDATE t1 SET id = 4 WHERE id = $MIN_VAL; + --error 12518 + eval DELETE FROM t1 WHERE id = $MIN_VAL; + --error 12518 + DELETE FROM t1; + --error 12518 + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 2.27 +--echo error mode +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_ERROR_MODE1_1; + --enable_query_log + SELECT id FROM t1 ORDER BY id; + INSERT INTO t1 (id) VALUES (1); + DELETE FROM t1; + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 3.0 +--echo is null +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_KEY_TABLES1; + echo CHILD2_1_CREATE_TEXT_KEY_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_KEY_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_KEY_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_TEXT_KEY1_1; +--enable_query_log +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a is null order by a limit 30; +select b from t1 where b is null order by b limit 30; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo direct_order_limit +--connection master_1 +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +select a, c from t1 where a = '10' order by b desc limit 5; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/oracle2/t/test_deinit.inc b/storage/spider/mysql-test/spider/oracle2/t/test_deinit.inc new file mode 100644 index 00000000000..989bde26d3c --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/test_deinit.inc @@ -0,0 +1,37 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/deinit_master_1.inc +--disconnect master_1 +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/deinit_child2_1.inc + --disconnect child2_1 + --echo child2_2 + --connection child2_2 + --source ../include/deinit_child2_2.inc + --disconnect child2_2 + --echo child2_3 + --connection child2_3 + --source ../include/deinit_child2_3.inc + --disconnect child2_3 +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/deinit_child3_1.inc + --disconnect child3_1 + --echo child3_2 + --connection child3_2 + --source ../include/deinit_child3_2.inc + --disconnect child3_2 + --echo child3_3 + --connection child3_3 + --source ../include/deinit_child3_3.inc + --disconnect child3_3 +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/test_init.inc b/storage/spider/mysql-test/spider/oracle2/t/test_init.inc new file mode 100644 index 00000000000..f2cd6c0269f --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/test_init.inc @@ -0,0 +1,74 @@ +# get connection and exist engine test +--echo for master_1 +--source connect_master_1.inc +--connection master_1 +CALL mtr.add_suppression("unknown variable"); +SET SESSION sql_log_bin= 0; +--let $MASTER_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $MASTER_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_master_1.inc +--source have_engine.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --source connect_child2_1.inc + --connection child2_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE + --source ../include/init_child2_1.inc + --source have_engine.inc + --echo child2_2 + --source connect_child2_2.inc + --connection child2_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE + --source ../include/init_child2_2.inc + --source have_engine.inc + --echo child2_3 + --source connect_child2_3.inc + --connection child2_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE + --source ../include/init_child2_3.inc + --source have_engine.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --source connect_child3_1.inc + --connection child3_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE + --source ../include/init_child3_1.inc + --source have_engine.inc + --echo child3_2 + --source connect_child3_2.inc + --connection child3_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE + --source ../include/init_child3_2.inc + --source have_engine.inc + --echo child3_3 + --source connect_child3_3.inc + --connection child3_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE + --source ../include/init_child3_3.inc + --source have_engine.inc +} diff --git a/storage/spider/mysql-test/spider/oracle2/t/vp_fixes.test b/storage/spider/mysql-test/spider/oracle2/t/vp_fixes.test new file mode 100644 index 00000000000..46e7b0afc36 --- /dev/null +++ b/storage/spider/mysql-test/spider/oracle2/t/vp_fixes.test @@ -0,0 +1,358 @@ +# This test tests for VP's bug fixes +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 0.9 +--echo create different primary key table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--let $MASTER_1_IS_VP= `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'VP', 1, 0)` +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo create un-correspond primary key table +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/r/basic_sql.result b/storage/spider/mysql-test/spider/r/basic_sql.result new file mode 100644 index 00000000000..e6202327ef6 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/basic_sql.result @@ -0,0 +1,701 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'f', '2008-07-01 10:21:39'), +(2, 'g', '2000-02-01 00:00:00'), +(3, 'j', '2007-05-04 20:03:11'), +(4, 'i', '2003-10-30 05:01:03'), +(5, 'h', '2001-10-31 23:59:59'); +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l +Warnings: +Warning 1062 Duplicate entry '1' for key 'PRIMARY' +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +Warning 1062 Duplicate entry '3' for key 'PRIMARY' +Warning 1062 Duplicate entry '4' for key 'PRIMARY' +Warning 1062 Duplicate entry '5' for key 'PRIMARY' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +create table ignore select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create table with partition and select test +CREATE TABLE ta_l2 ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +create no index table +DROP TABLE IF EXISTS ta_l_no_idx; +CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table shared mode +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table for update +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table join +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select table straight_join +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +a b date_format(b.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_small_result +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_big_result +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_buffer_result +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_cache +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_no_cache +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select sql_calc_found_rows +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +SELECT found_rows(); +found_rows() +5 + +select high_priority +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select distinct +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select count +SELECT count(*) FROM ta_l ORDER BY a; +count(*) +5 + +select table join not use index +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +select using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select using index and pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +select partition using index pushdown +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +a b date_format(a.c, '%Y-%m-%d %H:%i:%s') +2 g 2000-02-01 00:00:00 + +insert +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +insert select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 + +insert low_priority +TRUNCATE TABLE ta_l; +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert high_priority +TRUNCATE TABLE ta_l; +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert ignore +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +Warnings: +Warning 1062 Duplicate entry '2' for key 'PRIMARY' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (insert) +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 + +insert update (update) +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2005-08-08 11:11:11 + +replace +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 f 2008-02-02 02:02:02 + +replace select +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace select a +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +replace low_priority +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 g 2000-02-01 00:00:00 +3 g 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +2 f 2008-02-02 02:02:02 + +update select +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update select a +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 h 2010-04-04 04:04:04 +2 g 2009-03-03 03:03:03 + +update join +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 + +update join a +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update low_priority +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update ignore +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 f 2008-02-02 02:02:02 + +update pushdown +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 j 2009-03-03 03:03:03 + +update index pushdown +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 g 2009-03-03 03:03:03 +2 g 2009-03-03 03:03:03 + +update partition pushdown +UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 e 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +update partition index pushdown +UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +2 g 2000-02-01 00:00:00 +3 j 2009-03-03 03:03:03 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete all +DELETE FROM ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE IGNORE FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE QUICK FROM ta_l WHERE a = 2; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 e 2008-01-01 23:59:59 +3 e 2008-01-01 23:59:59 +4 e 2008-01-01 23:59:59 +5 e 2008-01-01 23:59:59 +6 e 2008-01-01 23:59:59 +7 e 2008-01-01 23:59:59 +8 e 2008-01-01 23:59:59 +9 e 2008-01-01 23:59:59 +10 j 2008-01-01 23:59:59 + +delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +10 j 2008-01-01 23:59:59 + +delete partition pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +delete partition index pushdown +TRUNCATE TABLE ta_l2; +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 f 2008-07-01 10:21:39 +3 j 2007-05-04 20:03:11 +4 i 2003-10-30 05:01:03 +5 h 2001-10-31 23:59:59 + +truncate +TRUNCATE TABLE ta_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_aggregate.result b/storage/spider/mysql-test/spider/r/direct_aggregate.result new file mode 100644 index 00000000000..7bf1cb4aea7 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_aggregate.result @@ -0,0 +1,132 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_aggregating test +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 0 +SELECT COUNT(*) FROM ta_l; +COUNT(*) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l; +MAX(a) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MIN(a) FROM ta_l; +MIN(a) +1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MAX(a) FROM ta_l WHERE a < 5; +MAX(a) +4 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT MIN(a) FROM ta_l WHERE a > 1; +MIN(a) +2 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 + +with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 1 +SELECT COUNT(*) FROM ta_l2; +COUNT(*) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l2; +MAX(a) +5 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MIN(a) FROM ta_l2; +MIN(a) +1 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MAX(a) FROM ta_l2 WHERE a < 5; +MAX(a) +4 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 +SELECT MIN(a) FROM ta_l2 WHERE a > 1; +MIN(a) +2 +SHOW STATUS LIKE 'Spider_direct_aggregate'; +Variable_name Value +Spider_direct_aggregate 3 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_update.result b/storage/spider/mysql-test/spider/r/direct_update.result new file mode 100644 index 00000000000..135734641c1 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_update.result @@ -0,0 +1,226 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table select test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +direct_updating test +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +with partition test +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +update all rows with function +UPDATE ta_l2 SET c = ADDDATE(c, 1); +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 e 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key +UPDATE ta_l2 SET b = 'x' WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2007-06-05 20:03:11 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by a column without index +UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-17 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +update by primary key with order and limit +UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_update'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +2 b 2000-01-02 00:00:00 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by primary key with order and limit +DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +5 c 2002-01-01 23:59:59 +delete by a column without index +DELETE FROM ta_l2 WHERE b = 'c'; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +3 x 2011-10-18 00:00:00 +4 d 2003-12-01 05:01:03 +delete by primary key +DELETE FROM ta_l2 WHERE a = 3; +SHOW STATUS LIKE 'Spider_direct_delete'; +Variable_name Value +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-02 10:21:39 +4 d 2003-12-01 05:01:03 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/function.result b/storage/spider/mysql-test/spider/r/function.result new file mode 100644 index 00000000000..764c774514b --- /dev/null +++ b/storage/spider/mysql-test/spider/r/function.result @@ -0,0 +1,149 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +in() +CREATE TABLE t1 ( +a VARCHAR(255), +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1 +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +select a from t1 where a in ('15', '120'); +a +120 +15 + +date_sub() +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-08-01 10:21:39 +2 b 1999-01-01 00:00:00 +3 e 2006-06-04 20:03:11 +4 d 2002-11-30 05:01:03 +5 c 2000-12-31 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-11-01 10:21:39 +2 b 1999-04-01 00:00:00 +3 e 2006-09-04 20:03:11 +4 d 2003-02-28 05:01:03 +5 c 2001-03-31 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-01 10:21:39 +2 b 1999-03-01 00:00:00 +3 e 2006-08-04 20:03:11 +4 d 2003-01-28 05:01:03 +5 c 2001-02-28 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-08 10:21:39 +2 b 1999-03-08 00:00:00 +3 e 2006-08-11 20:03:11 +4 d 2003-02-04 05:01:03 +5 c 2001-03-07 23:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 10:21:39 +2 b 1999-03-07 00:00:00 +3 e 2006-08-10 20:03:11 +4 d 2003-02-03 05:01:03 +5 c 2001-03-06 23:59:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:21:39 +2 b 1999-03-07 01:00:00 +3 e 2006-08-10 21:03:11 +4 d 2003-02-03 06:01:03 +5 c 2001-03-07 00:59:59 +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:39 +2 b 1999-03-07 00:59:00 +3 e 2006-08-10 21:02:11 +4 d 2003-02-03 06:00:03 +5 c 2001-03-07 00:58:59 +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2007-10-07 11:20:40 +2 b 1999-03-07 00:59:01 +3 e 2006-08-10 21:02:12 +4 d 2003-02-03 06:00:04 +5 c 2001-03-07 00:59:00 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/ha.result b/storage/spider/mysql-test/spider/r/ha.result new file mode 100644 index 00000000000..e05ecb32e1b --- /dev/null +++ b/storage/spider/mysql-test/spider/r/ha.result @@ -0,0 +1,431 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +CREATE DATABASE auto_test_remote3; +USE auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; + +test select 1 +SELECT 1; +1 +1 + +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 0 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote2.ta_r3' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 1 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 2"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 2 +SELECT spider_copy_tables('ta_l', '0', '1'); +spider_copy_tables('ta_l', '0', '1') +1 +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", + database "auto_test_remote auto_test_remote2", lst "0 1"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 1 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote3.ta_r4' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 3 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 2"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 2 +SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1'); +spider_copy_tables('ta_l2#P#pt2', '0', '1') +1 +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "0 1"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +active standby test +create table test +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1 +INSERT INTO ta_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote.ta_r' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 3 +auto_test_local ta_l 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 2 +INSERT INTO ta_l (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l +CONNECTION='host "localhost", user "root", password "", + msi "5", mkd "2", alc "1", + database "auto_test_remote auto_test_remote2", lst "1 0"'; +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l 0 1 +auto_test_local ta_l 1 1 +INSERT INTO ta_l (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +8 g 2011-05-05 21:33:30 +DROP TABLE ta_l; +SELECT spider_flush_table_mon_cache(); +spider_flush_table_mon_cache() +1 + +create table with partition test +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); + +select test +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +fail-over test +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 2 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +ERROR HY000: Table 'auto_test_remote.ta_r2' get a problem +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 3 +auto_test_local ta_l2#P#pt2 1 1 +SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log; +db_name table_name link_id +auto_test_local ta_l 1 +auto_test_local ta_l2#P#pt2 1 +auto_test_local ta_l 0 +auto_test_local ta_l2#P#pt2 0 +SHOW STATUS LIKE 'Spider_mon_table_cache_version%'; +Variable_name Value +Spider_mon_table_cache_version 3 +Spider_mon_table_cache_version_req 3 +INSERT INTO ta_l2 (a, b, c) VALUES +(6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +6 e 2011-05-05 20:04:05 + +recovery test +ALTER TABLE ta_l2 +PARTITION BY KEY(a) ( +PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3", + priority "1000"', +PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4", + priority "1000001", lst "1 0"' + ); +SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables +ORDER BY db_name, table_name, link_id; +db_name table_name link_id link_status +auto_test_local ta_l2#P#pt1 0 1 +auto_test_local ta_l2#P#pt1 1 1 +auto_test_local ta_l2#P#pt2 0 1 +auto_test_local ta_l2#P#pt2 1 1 +INSERT INTO ta_l2 (a, b, c) VALUES +(8, 'g', '2011-05-05 21:33:30'), +(9, 'h', '2011-05-05 22:32:10'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +3 e 2007-06-04 20:03:11 +5 c 2001-12-31 23:59:59 +8 g 2011-05-05 21:33:30 +9 h 2011-05-05 22:32:10 +DROP TABLE ta_l2; + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +DROP DATABASE IF EXISTS auto_test_remote3; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/spider3_fixes.result b/storage/spider/mysql-test/spider/r/spider3_fixes.result new file mode 100644 index 00000000000..34a8f3cf933 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/spider3_fixes.result @@ -0,0 +1,371 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +3.1 +auto_increment +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t2; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1555 +SELECT MAX(id) FROM t1; +MAX(id) +1555 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t2; +MAX(id) +2331 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2332 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +1555 +2331 +2332 +3109 +3886 +4663 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5439 +SELECT id FROM t2 ORDER BY id; +id +777 +1554 +1555 +2331 +2332 +3109 +3886 +4663 +5439 +6216 +6993 +7770 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t2 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +6993 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +10000 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +5000 +10000 +auto_increment with partition +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +CREATE TABLE t2 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t2; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +778 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t2; +MAX(id) +2331 +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1555 +SELECT id FROM t1 ORDER BY id; +id +777 +778 +1554 +1555 +2331 +2332 +3109 +3886 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT id FROM t2 ORDER BY id; +id +777 +778 +1554 +1555 +2331 +2332 +3108 +3109 +3885 +3886 +4662 +5439 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t2 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +MASTER_1_AUTO_INCREMENT_OFFSET3 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +MASTER_1_AUTO_INCREMENT_OFFSET4 +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +6993 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +6993 +SELECT MAX(id) FROM t2; +MAX(id) +10000 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +5000 +10000 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/spider_fixes.result b/storage/spider/mysql-test/spider/r/spider_fixes.result new file mode 100644 index 00000000000..aedde01e178 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/spider_fixes.result @@ -0,0 +1,692 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +2.13 +select table with "order by desc" and "<" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 +2 b 2000-01-01 00:00:00 + +select table with "order by desc" and "<=" +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +5 c 2001-12-31 23:59:59 +4 d 2003-11-30 05:01:03 +3 e 2007-06-04 20:03:11 + +2.14 +update table with range scan and split_read +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-02-02 00:00:00 +3 e 2000-02-02 00:00:00 +4 d 2000-02-02 00:00:00 +5 c 2000-02-02 00:00:00 + +2.15 +select table with range scan +TRUNCATE TABLE ta_l; +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +a int(11) NOT NULL DEFAULT '0', +b char(1) DEFAULT NULL, +c datetime DEFAULT NULL, +PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +a b c +5 c 2001-12-31 23:59:59 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +a b c +4 d 2003-11-30 05:01:03 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +a b c +2 b 2000-01-01 00:00:00 + +2.16 +auto_increment insert with trigger +CREATE TABLE ta_l_auto_inc ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tc_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;; +INSERT INTO ta_l_auto_inc (a, b, c) VALUES +(NULL, 's', '2008-12-31 20:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 s 2008-12-31 20:59:59 + +2.17 +engine-condition-pushdown with "or" and joining +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2008-08-01 10:21:39 +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 +partition with sort +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 +ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +2 b 2000-01-01 00:00:00 +3 e 2007-06-04 20:03:11 +4 d 2003-11-30 05:01:03 +5 c 2001-12-31 23:59:59 + +2.23 +partition update with moving partition +DROP TABLE IF EXISTS ta_l2; +CREATE TABLE ta_l2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1 +INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); +UPDATE ta_l2 SET a = 4 WHERE a = 3; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +4 B 2010-09-26 00:00:00 +index merge +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 +index merge with partition +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +a b c +3 4 5 +4 5 6 +5 6 7 + +2.24 +index scan update without PK +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT NOT NULL, +b INT DEFAULT 10, +c INT DEFAULT 11, +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +UPDATE ta_l_int SET c = 4 WHERE b = 2; +SELECT a, b, c FROM ta_l_int ORDER BY a; +a b c +1 2 4 +2 3 4 +4 5 6 +6 7 8 +8 9 10 +10 11 12 +12 13 14 +14 15 16 +16 17 18 +17 2 4 + +2.25 +direct order limit +SHOW STATUS LIKE 'Spider_direct_order_limit'; +Variable_name Value +Spider_direct_order_limit 0 +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +a b c +1 2 4 +2 3 4 +4 5 6 +SHOW STATUS LIKE 'Spider_direct_order_limit'; +Variable_name Value +Spider_direct_order_limit 0 + +2.26 +lock tables +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1 +CREATE TABLE t2 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2 +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + +auto_increment +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t1; +MAX(id) +2331 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT MAX(id) FROM t1; +MAX(id) +3108 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +SELECT id FROM t1 ORDER BY id; +id +777 +1000 +1554 +2331 +3108 +3885 +4662 +5000 +5439 +6216 +10000 + +auto_increment with partition +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1 +MASTER_1_AUTO_INCREMENT_INCREMENT2 +MASTER_1_AUTO_INCREMENT_OFFSET2 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_1"') +1 +spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '', +'srv "s_2_2"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '', +'srv "s_2_1"') +1 +spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '', +'srv "s_2_2"') +1 +CREATE TABLE t1 ( +id int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +777 +SELECT MAX(id) FROM t1; +MAX(id) +777 +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1554 +SELECT MAX(id) FROM t1; +MAX(id) +1554 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2331 +SELECT MAX(id) FROM t1; +MAX(id) +2331 +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3108 +SELECT MAX(id) FROM t1; +MAX(id) +3108 +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3885 +SELECT id FROM t1 ORDER BY id; +id +777 +1554 +2331 +3108 +3885 +4662 +5439 +6216 +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +6216 +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5000 +SELECT MAX(id) FROM t1; +MAX(id) +10000 +SELECT id FROM t1 ORDER BY id; +id +777 +1000 +1554 +2331 +3108 +3885 +4662 +5000 +5439 +6216 +10000 + +read only +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1 +SELECT id FROM t1 ORDER BY id; +id +1000 +1554 +3108 +4662 +5000 +6216 +10000 +INSERT INTO t1 (id) VALUES (1); +ERROR HY000: Table 'auto_test_local.t1' is read only +UPDATE t1 SET id = 4 WHERE id = 1000; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1 WHERE id = 1000; +ERROR HY000: Table 'auto_test_local.t1' is read only +DELETE FROM t1; +ERROR HY000: Table 'auto_test_local.t1' is read only +TRUNCATE t1; +ERROR HY000: Table 'auto_test_local.t1' is read only + +2.27 +error mode +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1 +SELECT id FROM t1 ORDER BY id; +id +Warnings: +Error 12702 Remote table 'auto_test_remote.ter1_1' is not found +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +INSERT INTO t1 (id) VALUES (1); +Warnings: +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +DELETE FROM t1; +Warnings: +Error 12702 Remote table 'auto_test_remote.ter1_1' is not found +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist +TRUNCATE t1; +Warnings: +Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist + +3.0 +is null +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +a VARCHAR(255), +b VARCHAR(255), +c VARCHAR(255), +KEY idx1(a,b), +KEY idx2(b), +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1 +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +select a from t1 where a is null order by a limit 30; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +select b from t1 where b is null order by b limit 30; +b +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL + +direct_order_limit +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +a b c +10 74 74 +10 42 42 +10 234 234 +10 202 202 +10 170 170 +select a, c from t1 where a = '10' order by b desc limit 5; +a c +10 74 +10 42 +10 234 +10 202 +10 170 + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/vp_fixes.result b/storage/spider/mysql-test/spider/r/vp_fixes.result new file mode 100644 index 00000000000..15dd29aa4d3 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/vp_fixes.result @@ -0,0 +1,80 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +test select 1 +SELECT 1; +1 +1 + +create table and insert +DROP TABLE IF EXISTS tb_l; +CREATE TABLE tb_l ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2 +INSERT INTO tb_l (a, b, c) VALUES +(1, 'a', '2008-08-01 10:21:39'), +(2, 'b', '2000-01-01 00:00:00'), +(3, 'e', '2007-06-04 20:03:11'), +(4, 'd', '2003-11-30 05:01:03'), +(5, 'c', '2001-12-31 23:59:59'); +DROP TABLE IF EXISTS ta_l; +CREATE TABLE ta_l ( +PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +0.9 +create different primary key table +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT AUTO_INCREMENT, +c INT DEFAULT 11, +PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +create un-correspond primary key table +DROP TABLE IF EXISTS ta_l_int; +CREATE TABLE ta_l_int ( +a INT DEFAULT 10, +b INT DEFAULT 12, +c INT DEFAULT 11, +PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + +deinit +DROP DATABASE IF EXISTS auto_test_local; +DROP DATABASE IF EXISTS auto_test_remote; +DROP DATABASE IF EXISTS auto_test_remote2; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/suite.opt b/storage/spider/mysql-test/spider/suite.opt new file mode 100644 index 00000000000..48457b17309 --- /dev/null +++ b/storage/spider/mysql-test/spider/suite.opt @@ -0,0 +1 @@ +--loose-innodb diff --git a/storage/spider/mysql-test/spider/suite.pm b/storage/spider/mysql-test/spider/suite.pm new file mode 100644 index 00000000000..5569c57bec9 --- /dev/null +++ b/storage/spider/mysql-test/spider/suite.pm @@ -0,0 +1,9 @@ +package My::Suite::Spider; + +@ISA = qw(My::Suite); + +return "No Spider engine" unless $ENV{HA_SPIDER_SO}; +return "Not run for embedded server" if $::opt_embedded_server; + +bless { }; + diff --git a/storage/spider/mysql-test/spider/t/basic_sql.test b/storage/spider/mysql-test/spider/t/basic_sql.test new file mode 100644 index 00000000000..2264b0e4e37 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/basic_sql.test @@ -0,0 +1,3189 @@ +# This test tests by executing basic SQL +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'f', '2008-07-01 10:21:39'), + (2, 'g', '2000-02-01 00:00:00'), + (3, 'j', '2007-05-04 20:03:11'), + (4, 'i', '2003-10-30 05:01:03'), + (5, 'h', '2001-10-31 23:59:59'); +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +IGNORE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + INSERT IGNORE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + IGNORE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table ignore select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +REPLACE SELECT a, b, c FROM tb_l; +if ($MASTER_1_MERGE) +{ + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + REPLACE INTO ta_l SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_MERGE) +{ + eval CREATE TABLE ta_l ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1 + REPLACE SELECT a, b, c FROM tb_l; +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo create table with partition and select test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l2 ( + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1 + SELECT a, b, c FROM tb_l; + } + --enable_query_log + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo create no index table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_no_idx; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_no_idx +MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +SELECT a, b, c FROM tb_l; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; +} +if (!$MASTER_1_NEEDPK) +{ + if ($MASTER_1_MERGE) + { + --error ER_WRONG_OBJECT + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + eval CREATE TABLE ta_l_no_idx ( + a INT, + b CHAR(1), + c DATETIME + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; + INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l; + } + if (!$MASTER_1_MERGE) + { + eval CREATE TABLE ta_l_no_idx + $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1 + SELECT a, b, c FROM tb_l; + } +} +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES3; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a; + +--echo +--echo select table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table shared mode +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +LOCK IN SHARE MODE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table for update +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a +FOR UPDATE; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b +WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table straight_join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') +FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_small_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_big_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_buffer_result +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_no_cache +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select sql_calc_found_rows +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a LIMIT 4; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT found_rows(); + +--echo +--echo select high_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select distinct +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select count +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT count(*) FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table join not use index +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE +EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select using index and pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE +a.a > 0 AND a.b = 'g' ORDER BY a.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select partition using pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo select partition using index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE + a.a > 0 AND a.b = 'g' ORDER BY a.a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo insert +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert select a +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert low_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert high_priority +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e', +'2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (insert) +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo insert update (update) +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE +KEY UPDATE b = 'f', c = '2005-08-08 11:11:11'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace +--connection master_1 +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1), +'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo replace low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g', +'2009-03-03 03:03:03'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM +tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update select a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM +tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update join a +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE +a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update low_priority +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update ignore +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update index pushdown +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo update partition pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo update partition index pushdown +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete all +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete select a +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete join +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete low_priority +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE LOW_PRIORITY FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete ignore +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE IGNORE FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete quick +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE QUICK FROM ta_l WHERE a = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete index pushdown +TRUNCATE TABLE ta_l; +INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'), +(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'), +(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'), +(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'), +(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'), +(10, 'j', '2008-01-01 23:59:59'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +DELETE FROM ta_l WHERE a > 0 AND b = 'e'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo delete partition pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo delete partition index pushdown +if ($HAVE_PARTITION) +{ + TRUNCATE TABLE ta_l2; + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + DELETE FROM ta_l2 WHERE a > 0 AND b = 'g'; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; +} + +--echo +--echo truncate +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +TRUNCATE TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/connect_child2_1.inc b/storage/spider/mysql-test/spider/t/connect_child2_1.inc new file mode 100644 index 00000000000..cd9b0c9ca9b --- /dev/null +++ b/storage/spider/mysql-test/spider/t/connect_child2_1.inc @@ -0,0 +1 @@ +--connect (child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/t/connect_child2_2.inc b/storage/spider/mysql-test/spider/t/connect_child2_2.inc new file mode 100644 index 00000000000..e145f66b630 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/connect_child2_2.inc @@ -0,0 +1 @@ +--connect (child2_2, localhost, root, , , $CHILD2_2_MYPORT, $CHILD2_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/t/connect_child2_3.inc b/storage/spider/mysql-test/spider/t/connect_child2_3.inc new file mode 100644 index 00000000000..d356348d8ea --- /dev/null +++ b/storage/spider/mysql-test/spider/t/connect_child2_3.inc @@ -0,0 +1 @@ +--connect (child2_3, localhost, root, , , $CHILD2_3_MYPORT, $CHILD2_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/t/connect_child3_1.inc b/storage/spider/mysql-test/spider/t/connect_child3_1.inc new file mode 100644 index 00000000000..03e5c188c89 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/connect_child3_1.inc @@ -0,0 +1 @@ +--connect (child3_1, localhost, root, , , $CHILD3_1_MYPORT, $CHILD3_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/t/connect_child3_2.inc b/storage/spider/mysql-test/spider/t/connect_child3_2.inc new file mode 100644 index 00000000000..d62a7ada824 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/connect_child3_2.inc @@ -0,0 +1 @@ +--connect (child3_2, localhost, root, , , $CHILD3_2_MYPORT, $CHILD3_2_MYSOCK) diff --git a/storage/spider/mysql-test/spider/t/connect_child3_3.inc b/storage/spider/mysql-test/spider/t/connect_child3_3.inc new file mode 100644 index 00000000000..fb49f5bfdac --- /dev/null +++ b/storage/spider/mysql-test/spider/t/connect_child3_3.inc @@ -0,0 +1 @@ +--connect (child3_3, localhost, root, , , $CHILD3_3_MYPORT, $CHILD3_3_MYSOCK) diff --git a/storage/spider/mysql-test/spider/t/connect_master_1.inc b/storage/spider/mysql-test/spider/t/connect_master_1.inc new file mode 100644 index 00000000000..0c129ce5775 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/connect_master_1.inc @@ -0,0 +1 @@ +--connect (master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/t/connect_slave1_1.inc b/storage/spider/mysql-test/spider/t/connect_slave1_1.inc new file mode 100644 index 00000000000..45a822743e0 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/connect_slave1_1.inc @@ -0,0 +1 @@ +--connect (slave1_1, localhost, root, , , $SLAVE1_1_MYPORT, $SLAVE1_1_MYSOCK) diff --git a/storage/spider/mysql-test/spider/t/direct_aggregate.test b/storage/spider/mysql-test/spider/t/direct_aggregate.test new file mode 100644 index 00000000000..59c45f3f190 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_aggregate.test @@ -0,0 +1,316 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_aggregating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT COUNT(*) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MAX(a) FROM ta_l WHERE a < 5; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +SELECT MIN(a) FROM ta_l WHERE a > 1; +eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT COUNT(*) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MAX(a) FROM ta_l2 WHERE a < 5; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + SELECT MIN(a) FROM ta_l2 WHERE a > 1; + eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_update.test b/storage/spider/mysql-test/spider/t/direct_update.test new file mode 100644 index 00000000000..1c3ce91ff3f --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_update.test @@ -0,0 +1,354 @@ +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo direct_updating test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update all rows with function +UPDATE ta_l SET c = ADDDATE(c, 1); +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key +UPDATE ta_l SET b = 'x' WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by a column without index +UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x'; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo update by primary key with order and limit +UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key with order and limit +DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by a column without index +DELETE FROM ta_l WHERE b = 'c'; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--echo delete by primary key +DELETE FROM ta_l WHERE a = 3; +eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo with partition test +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + --enable_query_log + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update all rows with function + UPDATE ta_l2 SET c = ADDDATE(c, 1); + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key + UPDATE ta_l2 SET b = 'x' WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by a column without index + UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x'; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo update by primary key with order and limit + UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key with order and limit + DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by a column without index + DELETE FROM ta_l2 WHERE b = 'c'; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + --echo delete by primary key + DELETE FROM ta_l2 WHERE a = 3; + eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/function.test b/storage/spider/mysql-test/spider/t/function.test new file mode 100644 index 00000000000..2b1b53c8a4f --- /dev/null +++ b/storage/spider/mysql-test/spider/t/function.test @@ -0,0 +1,276 @@ +# This test tests for using functions +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo in() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_PK_TABLES1; + echo CHILD2_1_CREATE_TEXT_PK_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_PK_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_PK_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET3 $MASTER_1_COMMENT_TEXT_PK1_1; +--enable_query_log +insert into t1 values ('1'); +insert into t1 select a + 1 from t1; +insert into t1 select a + 2 from t1; +insert into t1 select a + 4 from t1; +insert into t1 select a + 8 from t1; +insert into t1 select a + 16 from t1; +insert into t1 select a + 32 from t1; +insert into t1 select a + 64 from t1; +insert into t1 select a + 128 from t1; +insert into t1 select a + 256 from t1; +insert into t1 select a + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a in ('15', '120'); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo date_sub() +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/ha.test b/storage/spider/mysql-test/spider/t/ha.test new file mode 100644 index 00000000000..319b1793753 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/ha.test @@ -0,0 +1,1794 @@ +# This test tests for ha features +--let $SKIP_REASON= +if ($USE_HA_TEST) +{ +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source ha_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + CREATE DATABASE auto_test_remote3; + USE auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; + } + if ($USE_CHILD_GROUP3) + { + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; + } + --disable_query_log + --disable_result_log + --source ha_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + --connection child2_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + SELECT 1; + --connection child3_2 + SELECT 1; + --connection child3_3 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_2_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_HA_CREATE_TABLES; + } + eval $CHILD2_2_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_RECOVERY_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_COPY_TABLES_2_1; +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_3_HA_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_HA_CREATE_TABLES; + } + eval $CHILD2_3_HA_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_RECOVERY_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_COPY_TABLES_P_2_1; + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo active standby test +--echo create table test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_2_1; +--enable_query_log +INSERT INTO ta_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo fail-over test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_CHECK_HA_STATUS; +--error 12511 +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +eval $MASTER_1_CHECK_LINK_STATUS; +eval $MASTER_1_CHECK_LINK_FAILED_LOG; +eval $MASTER_1_CHECK_HA_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo recovery test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +eval $MASTER_1_SET_OK_STATUS_AS_2_1; +eval $MASTER_1_CHECK_LINK_STATUS; +INSERT INTO ta_l (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'); +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +DROP TABLE ta_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_CHILD_GROUP3) +{ + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_CHANGE_HA_MON; + +if ($HAVE_PARTITION) +{ + --echo + --echo create table with partition test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_3_DROP_TABLES; + echo CHILD2_3_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_3_DROP_TABLES; + --enable_warnings + eval $CHILD2_3_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1; + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + eval $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); + + --echo + --echo select test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo fail-over test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_DROP_TABLES2; + } + --disable_warnings + eval $CHILD2_1_HA_AS_DROP_TABLES2; + --enable_warnings + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_CHECK_HA_STATUS; + --error 12511 + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + eval $MASTER_1_CHECK_LINK_STATUS; + eval $MASTER_1_CHECK_LINK_FAILED_LOG; + eval $MASTER_1_CHECK_HA_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (6, 'e', '2011-05-05 20:04:05'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_CHECK_LINK_STATUS; + eval $CHILD3_1_CHECK_LINK_FAILED_LOG; + --connection child3_2 + eval $CHILD3_2_CHECK_LINK_STATUS; + eval $CHILD3_2_CHECK_LINK_FAILED_LOG; + --connection child3_3 + eval $CHILD3_3_CHECK_LINK_STATUS; + eval $CHILD3_3_CHECK_LINK_FAILED_LOG; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + + --echo + --echo recovery test + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_HA_AS_CREATE_TABLES2; + } + eval $CHILD2_1_HA_AS_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_3 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + eval $CHILD3_1_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_1_CHECK_LINK_STATUS; + --connection child3_2 + eval $CHILD3_2_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_2_CHECK_LINK_STATUS; + --connection child3_3 + eval $CHILD3_3_SET_OK_STATUS_AS_P_2_1; + eval $CHILD3_3_CHECK_LINK_STATUS; + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + eval $MASTER_1_SET_OK_STATUS_AS_P_2_1; + eval $MASTER_1_CHECK_LINK_STATUS; + INSERT INTO ta_l2 (a, b, c) VALUES + (8, 'g', '2011-05-05 21:33:30'), + (9, 'h', '2011-05-05 22:32:10'); + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a; + DROP TABLE ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES; + eval $CHILD2_1_SELECT_TABLES2; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_3 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_3_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + if ($USE_CHILD_GROUP3) + { + if (!$OUTPUT_CHILD_GROUP3) + { + --disable_query_log + --disable_result_log + } + --connection child3_1 + --disable_warnings + eval $CHILD3_1_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_2 + --disable_warnings + eval $CHILD3_2_DROP_TABLES_HA_P_2_1; + --enable_warnings + --connection child3_3 + --disable_warnings + eval $CHILD3_3_DROP_TABLES_HA_P_2_1; + --enable_warnings + if (!$OUTPUT_CHILD_GROUP3) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + --connection child2_3 + DROP DATABASE IF EXISTS auto_test_remote3; +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_2 + DROP DATABASE IF EXISTS auto_test_local; + --connection child3_3 + DROP DATABASE IF EXISTS auto_test_local; +} +--disable_query_log +--disable_result_log +--source ha_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +} +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/ha_test_deinit.inc b/storage/spider/mysql-test/spider/t/ha_test_deinit.inc new file mode 100644 index 00000000000..53d0409d066 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/ha_test_deinit.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_deinit_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_deinit_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_deinit_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_deinit_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/t/ha_test_init.inc b/storage/spider/mysql-test/spider/t/ha_test_init.inc new file mode 100644 index 00000000000..70576ab16dc --- /dev/null +++ b/storage/spider/mysql-test/spider/t/ha_test_init.inc @@ -0,0 +1,30 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/ha_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/ha_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/ha_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/ha_init_child2_3.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/ha_init_child3_1.inc + --echo child3_2 + --connection child3_2 + --source ../include/ha_init_child3_2.inc + --echo child3_3 + --connection child3_3 + --source ../include/ha_init_child3_3.inc +} diff --git a/storage/spider/mysql-test/spider/t/have_engine.inc b/storage/spider/mysql-test/spider/t/have_engine.inc new file mode 100644 index 00000000000..64bef7499cb --- /dev/null +++ b/storage/spider/mysql-test/spider/t/have_engine.inc @@ -0,0 +1,7 @@ +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = '$TEST_ENGINE_TYPE'`) +{ + SELECT engine, support FROM information_schema.engines; + --let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine" +} diff --git a/storage/spider/mysql-test/spider/t/have_func.inc b/storage/spider/mysql-test/spider/t/have_func.inc new file mode 100644 index 00000000000..e0823e73fc8 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/have_func.inc @@ -0,0 +1,5 @@ +if (!`SELECT count(*) FROM mysql.func WHERE name = '$TEST_FUNC_NAME'`) +{ + SELECT name FROM mysql.func; + --let $SKIP_REASON= "Need $TEST_FUNC_NAME function" +} diff --git a/storage/spider/mysql-test/spider/t/have_partition.inc b/storage/spider/mysql-test/spider/t/have_partition.inc new file mode 100644 index 00000000000..573c76ab43b --- /dev/null +++ b/storage/spider/mysql-test/spider/t/have_partition.inc @@ -0,0 +1,7 @@ +let $HAVE_PARTITION= 0; +if (`SELECT count(*) FROM information_schema.plugins WHERE + plugin_status = 'ACTIVE' AND + plugin_name = 'partition'`) +{ + let $HAVE_PARTITION= 1; +} diff --git a/storage/spider/mysql-test/spider/t/have_plugin.inc b/storage/spider/mysql-test/spider/t/have_plugin.inc new file mode 100644 index 00000000000..316ede9ec46 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/have_plugin.inc @@ -0,0 +1,5 @@ +if (!`SELECT count(*) FROM information_schema.plugins WHERE plugin_name = '$TEST_PLUGIN_NAME'`) +{ + SELECT plugin_name FROM information_schema.plugins; + --let $SKIP_REASON= "Need $TEST_PLUGIN_NAME plugin" +} diff --git a/storage/spider/mysql-test/spider/t/have_trigger.inc b/storage/spider/mysql-test/spider/t/have_trigger.inc new file mode 100644 index 00000000000..10c0871dd5f --- /dev/null +++ b/storage/spider/mysql-test/spider/t/have_trigger.inc @@ -0,0 +1,2 @@ +let $HAVE_TRIGGER= `SELECT COUNT(*) FROM information_schema.tables + WHERE TABLE_SCHEMA = 'information_schema' AND TABLE_NAME = 'TRIGGERS'`; diff --git a/storage/spider/mysql-test/spider/t/hs_test_deinit.inc b/storage/spider/mysql-test/spider/t/hs_test_deinit.inc new file mode 100644 index 00000000000..7ec2e981fd2 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/hs_test_deinit.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_deinit_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_deinit_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_deinit_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_deinit_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/t/hs_test_init.inc b/storage/spider/mysql-test/spider/t/hs_test_init.inc new file mode 100644 index 00000000000..831bf479524 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/hs_test_init.inc @@ -0,0 +1,17 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/hs_init_master_1.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/hs_init_child2_1.inc + --echo child2_2 + --connection child2_2 + --source ../include/hs_init_child2_2.inc + --echo child2_3 + --connection child2_3 + --source ../include/hs_init_child2_3.inc +} diff --git a/storage/spider/mysql-test/spider/t/slave_test_deinit.inc b/storage/spider/mysql-test/spider/t/slave_test_deinit.inc new file mode 100644 index 00000000000..e9d99b7a960 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/slave_test_deinit.inc @@ -0,0 +1,6 @@ +# get connection and exist engine test +--echo for slave1_1 +--connection slave1_1 +STOP SLAVE; +--source ../include/deinit_slave1_1.inc +--disconnect slave1_1 diff --git a/storage/spider/mysql-test/spider/t/slave_test_init.inc b/storage/spider/mysql-test/spider/t/slave_test_init.inc new file mode 100644 index 00000000000..739d88970c5 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/slave_test_init.inc @@ -0,0 +1,44 @@ +# get connection and exist engine test +--echo for slave1_1 +--source connect_slave1_1.inc +--connection slave1_1 +SET SESSION sql_log_bin= 0; +--let $SLAVE1_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $SLAVE1_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_slave1_1.inc +--source have_engine.inc +--let $SLAVE1_1_SLAVE_STATUS=`SHOW SLAVE STATUS` +if (!$SLAVE1_1_SLAVE_STATUS) +{ + eval CHANGE MASTER TO + MASTER_HOST = '127.0.0.1', + MASTER_USER = 'root', + MASTER_PASSWORD = '', + MASTER_PORT = $MASTER_1_MYPORT + ; +} +START SLAVE; +--connection master_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +--connection slave1_1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child2_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} +if ($USE_CHILD_GROUP3) +{ + --connection child3_1 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_2 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + --connection child3_3 + call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +} diff --git a/storage/spider/mysql-test/spider/t/spider3_fixes.test b/storage/spider/mysql-test/spider/t/spider3_fixes.test new file mode 100644 index 00000000000..4139f3af955 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/spider3_fixes.test @@ -0,0 +1,570 @@ +# This test tests for Spider 3.0's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo 3.1 +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +INSERT INTO t2 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t2 ORDER BY id; +SET INSERT_ID=5000; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET3; +eval $MASTER_1_AUTO_INCREMENT_OFFSET3; +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +--disable_query_log +echo MASTER_1_AUTO_INCREMENT_OFFSET4; +eval $MASTER_1_AUTO_INCREMENT_OFFSET4; +--enable_query_log +INSERT INTO t2 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t2 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t2; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + echo CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t2 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + TRUNCATE TABLE t1; + TRUNCATE TABLE t2; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + INSERT INTO t2 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t2 ORDER BY id; + SET INSERT_ID=5000; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET3; + eval $MASTER_1_AUTO_INCREMENT_OFFSET3; + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + --disable_query_log + echo MASTER_1_AUTO_INCREMENT_OFFSET4; + eval $MASTER_1_AUTO_INCREMENT_OFFSET4; + --enable_query_log + INSERT INTO t2 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t2 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t2; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/spider_fixes.test b/storage/spider/mysql-test/spider/t/spider_fixes.test new file mode 100644 index 00000000000..b9ff61abcb4 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/spider_fixes.test @@ -0,0 +1,1967 @@ +# This test tests for Spider's bug fixes +--let $SKIP_REASON= +source include/have_log_bin.inc; +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--source slave_test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_REPLICATION) + { + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + } + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source slave_test_deinit.inc + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 2.13 +--echo select table with "order by desc" and "<" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a < 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo select table with "order by desc" and "<=" +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l +WHERE a <= 5 ORDER BY a DESC LIMIT 3; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.14 +--echo update table with range scan and split_read +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; + +--echo +--echo 2.15 +--echo select table with range scan +TRUNCATE TABLE ta_l; +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_CREATE_TABLES6; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES6; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES6; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE ta_l ( + a int(11) NOT NULL DEFAULT '0', + b char(1) DEFAULT NULL, + c datetime DEFAULT NULL, + PRIMARY KEY (a, b, c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c' +AND c = '2001-12-31 23:59:59'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e' +AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b' +AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b' +AND b <= 'd' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b' +AND b < 'e' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1 +AND b >= 'b' AND c = '2003-11-30 05:01:03'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1 +AND b >= 'b' AND c = '2000-01-01 00:00:00'; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo 2.16 +--echo auto_increment insert with trigger +if ($HAVE_TRIGGER) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_CREATE_TABLES4; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES4; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES4; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; + eval CREATE TABLE ta_l_auto_inc ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; + echo CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE2 MASTER_1_CHARSET2; + eval CREATE TABLE tc_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; + --enable_query_log + --eval CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + INSERT INTO ta_l_auto_inc (a, b, c) VALUES + (NULL, 's', '2008-12-31 20:59:59'); + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES4; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a; +} + +--echo +--echo 2.17 +--echo engine-condition-pushdown with "or" and joining +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo partition with sort +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 SELECT a, b, c FROM tb_l; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1 + ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.23 +--echo partition update with moving partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l2; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES2; + echo CHILD2_1_CREATE_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1; + eval CREATE TABLE ta_l2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1; + --enable_query_log + INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00'); + UPDATE ta_l2 SET a = 4 WHERE a = 3; + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_2_SELECT_TABLES; + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + } + eval $CHILD2_1_SELECT_TABLES2; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo index merge +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; +INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) +WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo index merge with partition +if ($HAVE_PARTITION) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS ta_l_int; + --enable_warnings + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_2_DROP_TABLES5; + echo CHILD2_2_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES5; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES5; + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } + } + --connection master_1 + --disable_query_log + echo CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1; + eval CREATE TABLE ta_l_int ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_P_2_1; + --enable_query_log + INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); + INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int; + INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2) + WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + +--echo +--echo 2.24 +--echo index scan update without PK +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +if ($MASTER_1_NEEDPK) +{ + --error ER_REQUIRES_PRIMARY_KEY + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +if (!$MASTER_1_NEEDPK) +{ + eval CREATE TABLE ta_l_int ( + a INT NOT NULL, + b INT DEFAULT 10, + c INT DEFAULT 11, + KEY idx1(b), + KEY idx2(c) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +} +--enable_query_log +SELECT a, b, c FROM ta_l_int ORDER BY a; +INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3); +INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3); +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +UPDATE ta_l_int SET c = 4 WHERE b = 2; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a, b, c FROM ta_l_int ORDER BY a; + + +--echo +--echo 2.25 +--echo direct order limit +--connection master_1 +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; +SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3; +eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS; + + +--echo +--echo 2.26 +--echo lock tables +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_LOCK_TABLES1; + echo CHILD2_1_DROP_LOCK_TABLES2; + echo CHILD2_1_CREATE_LOCK_TABLES1; + echo CHILD2_1_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_1_DROP_LOCK_TABLES1; + eval $CHILD2_1_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_1_CREATE_LOCK_TABLES1; + eval $CHILD2_1_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_LOCK_TABLES1; + echo CHILD2_2_DROP_LOCK_TABLES2; + echo CHILD2_2_CREATE_LOCK_TABLES1; + echo CHILD2_2_CREATE_LOCK_TABLES2; + } + --disable_warnings + eval $CHILD2_2_DROP_LOCK_TABLES1; + eval $CHILD2_2_DROP_LOCK_TABLES2; + --enable_warnings + eval $CHILD2_2_CREATE_LOCK_TABLES1; + eval $CHILD2_2_CREATE_LOCK_TABLES2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1; +eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK1; +echo CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2; +eval CREATE TABLE t2 ( + id int(11) NOT NULL, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK2; +--enable_query_log +LOCK TABLES t1 READ, t2 READ; +UNLOCK TABLES; + + +--echo +--echo auto_increment +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1; +echo MASTER_1_AUTO_INCREMENT_INCREMENT2; +echo MASTER_1_AUTO_INCREMENT_OFFSET2; +eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; +eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1; + --connection master_1 +} +--enable_query_log +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (null); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 () VALUES (),(),(),(); +SELECT LAST_INSERT_ID(); +SELECT id FROM t1 ORDER BY id; +SET INSERT_ID=5000; +INSERT INTO t1 () VALUES (); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (10000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +INSERT INTO t1 (id) VALUES (1000); +SELECT LAST_INSERT_ID(); +SELECT MAX(id) FROM t1; +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo auto_increment with partition +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_INCREMENT_TABLES1; + echo CHILD2_1_CREATE_INCREMENT_TABLES1; + echo CHILD2_1_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_1_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_1_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_INCREMENT_TABLES1; + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_INCREMENT_TABLES1; + echo CHILD2_2_CREATE_INCREMENT_TABLES1; + echo CHILD2_2_AUTO_INCREMENT_INCREMENT2; + echo CHILD2_2_AUTO_INCREMENT_OFFSET2; + } + --disable_warnings + eval $CHILD2_2_DROP_INCREMENT_TABLES1; + --enable_warnings + eval $CHILD2_2_CREATE_INCREMENT_TABLES1; + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET2; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1; + echo MASTER_1_AUTO_INCREMENT_INCREMENT2; + echo MASTER_1_AUTO_INCREMENT_OFFSET2; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; + eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + if ($USE_REPLICATION) + { + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + echo CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) + ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1; + --connection master_1 + } + --enable_query_log + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (null); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 () VALUES (),(),(),(); + SELECT LAST_INSERT_ID(); + SELECT id FROM t1 ORDER BY id; + SET INSERT_ID=5000; + INSERT INTO t1 () VALUES (); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (10000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + INSERT INTO t1 (id) VALUES (1000); + SELECT LAST_INSERT_ID(); + SELECT MAX(id) FROM t1; + if ($USE_REPLICATION) + { + save_master_pos; + --connection slave1_1 + sync_with_master; + SELECT id FROM t1 ORDER BY id; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log + } + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_1_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_1_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_2_SELECT_INCREMENT_TABLES1; + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_AUTO_INCREMENT_INCREMENT1; + echo CHILD2_2_AUTO_INCREMENT_OFFSET1; + } + eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1; + eval $CHILD2_2_AUTO_INCREMENT_OFFSET1; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} + + +--echo +--echo read only +let $MASTER_1_ENGINE_IS_SPIDER= + `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'Spider' OR + '$MASTER_1_HIDDEN_ENGINE_TYPE' = 'Spider', 1, 0)`; +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_READONLY1_1; + --let $MIN_VAL= `SELECT MIN(id) FROM t1` + --enable_query_log + SELECT id FROM t1 ORDER BY id; + --error 12518 + INSERT INTO t1 (id) VALUES (1); + --error 12518 + eval UPDATE t1 SET id = 4 WHERE id = $MIN_VAL; + --error 12518 + eval DELETE FROM t1 WHERE id = $MIN_VAL; + --error 12518 + DELETE FROM t1; + --error 12518 + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 2.27 +--echo error mode +if ($MASTER_1_ENGINE_IS_SPIDER) +{ + --connection master_1 + --disable_warnings + DROP TABLE IF EXISTS t1; + --enable_warnings + --disable_query_log + echo CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1; + eval CREATE TABLE t1 ( + id int(11) NOT NULL, + PRIMARY KEY (id) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_ERROR_MODE1_1; + --enable_query_log + SELECT id FROM t1 ORDER BY id; + INSERT INTO t1 (id) VALUES (1); + DELETE FROM t1; + TRUNCATE t1; +} +if (!$MASTER_1_ENGINE_IS_SPIDER) +{ + --echo skipped +} + + +--echo +--echo 3.0 +--echo is null +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TEXT_KEY_TABLES1; + echo CHILD2_1_CREATE_TEXT_KEY_TABLES1; + } + --disable_warnings + eval $CHILD2_1_DROP_TEXT_KEY_TABLES1; + --enable_warnings + eval $CHILD2_1_CREATE_TEXT_KEY_TABLES1; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +--disable_query_log +echo CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1; +eval CREATE TABLE t1 ( + a VARCHAR(255), + b VARCHAR(255), + c VARCHAR(255), + KEY idx1(a,b), + KEY idx2(b), + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_TEXT_KEY1_1; +--enable_query_log +insert into t1 values (null, null, '2048'); +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a + 32, b + 32, c + 32 from t1; +insert into t1 select a + 64, b + 64, c + 64 from t1; +insert into t1 select a + 128, b + 128, c + 128 from t1; +insert into t1 select a + 256, b + 256, c + 256 from t1; +insert into t1 select a + 512, b + 512, c + 512 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a from t1 where a is null order by a limit 30; +select b from t1 where b is null order by b limit 30; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo direct_order_limit +--connection master_1 +TRUNCATE TABLE t1; +insert into t1 values ('1', '1', '1'); +insert into t1 select a + 1, b + 1, c + 1 from t1; +insert into t1 select a + 2, b + 2, c + 2 from t1; +insert into t1 select a + 4, b + 4, c + 4 from t1; +insert into t1 select a + 8, b + 8, c + 8 from t1; +insert into t1 select a + 16, b + 16, c + 16 from t1; +insert into t1 select a, b + 32, c + 32 from t1; +insert into t1 select a, b + 64, c + 64 from t1; +insert into t1 select a, b + 128, c + 128 from t1; +flush tables; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5; +select a, c from t1 where a = '10' order by b desc limit 5; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source slave_test_deinit.inc +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/test_deinit.inc b/storage/spider/mysql-test/spider/t/test_deinit.inc new file mode 100644 index 00000000000..989bde26d3c --- /dev/null +++ b/storage/spider/mysql-test/spider/t/test_deinit.inc @@ -0,0 +1,37 @@ +# get connection and exist engine test +--echo for master_1 +--connection master_1 +--source ../include/deinit_master_1.inc +--disconnect master_1 +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --connection child2_1 + --source ../include/deinit_child2_1.inc + --disconnect child2_1 + --echo child2_2 + --connection child2_2 + --source ../include/deinit_child2_2.inc + --disconnect child2_2 + --echo child2_3 + --connection child2_3 + --source ../include/deinit_child2_3.inc + --disconnect child2_3 +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --connection child3_1 + --source ../include/deinit_child3_1.inc + --disconnect child3_1 + --echo child3_2 + --connection child3_2 + --source ../include/deinit_child3_2.inc + --disconnect child3_2 + --echo child3_3 + --connection child3_3 + --source ../include/deinit_child3_3.inc + --disconnect child3_3 +} diff --git a/storage/spider/mysql-test/spider/t/test_init.inc b/storage/spider/mysql-test/spider/t/test_init.inc new file mode 100644 index 00000000000..f2cd6c0269f --- /dev/null +++ b/storage/spider/mysql-test/spider/t/test_init.inc @@ -0,0 +1,74 @@ +# get connection and exist engine test +--echo for master_1 +--source connect_master_1.inc +--connection master_1 +CALL mtr.add_suppression("unknown variable"); +SET SESSION sql_log_bin= 0; +--let $MASTER_1_SERVER_ID=`SELECT @@global.server_id` +--let $TEST_ENGINE_TYPE= $MASTER_1_ENGINE_TYPE +--source have_partition.inc +--source have_trigger.inc +--source ../include/init_master_1.inc +--source have_engine.inc +--echo for child2 +if ($USE_CHILD_GROUP2) +{ + --echo child2_1 + --source connect_child2_1.inc + --connection child2_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE + --source ../include/init_child2_1.inc + --source have_engine.inc + --echo child2_2 + --source connect_child2_2.inc + --connection child2_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE + --source ../include/init_child2_2.inc + --source have_engine.inc + --echo child2_3 + --source connect_child2_3.inc + --connection child2_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD2_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE + --source ../include/init_child2_3.inc + --source have_engine.inc +} +--echo for child3 +if ($USE_CHILD_GROUP3) +{ + --echo child3_1 + --source connect_child3_1.inc + --connection child3_1 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_1_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE + --source ../include/init_child3_1.inc + --source have_engine.inc + --echo child3_2 + --source connect_child3_2.inc + --connection child3_2 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_2_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE + --source ../include/init_child3_2.inc + --source have_engine.inc + --echo child3_3 + --source connect_child3_3.inc + --connection child3_3 + CALL mtr.add_suppression("unknown variable *"); + SET SESSION sql_log_bin= 0; + --let $CHILD3_3_SERVER_ID=`SELECT @@global.server_id` + --let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE + --source ../include/init_child3_3.inc + --source have_engine.inc +} diff --git a/storage/spider/mysql-test/spider/t/vp_fixes.test b/storage/spider/mysql-test/spider/t/vp_fixes.test new file mode 100644 index 00000000000..46e7b0afc36 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/vp_fixes.test @@ -0,0 +1,358 @@ +# This test tests for VP's bug fixes +--let $SKIP_REASON= +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log + +--echo +--echo drop and create databases +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +if ($SKIP_REASON) +{ + --echo deinit + --disable_warnings + --connection master_1 + DROP DATABASE IF EXISTS auto_test_local; + if ($USE_CHILD_GROUP2) + { + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + } + --disable_query_log + --disable_result_log + --source test_deinit.inc + --enable_result_log + --enable_query_log + --enable_warnings + --skip $SKIP_REASON +} + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + --connection child2_2 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tb_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) MASTER_1_ENGINE2 MASTER_1_CHARSET2; +eval CREATE TABLE tb_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2; +--enable_query_log +INSERT INTO tb_l (a, b, c) VALUES + (1, 'a', '2008-08-01 10:21:39'), + (2, 'b', '2000-01-01 00:00:00'), + (3, 'e', '2007-06-04 20:03:11'), + (4, 'd', '2003-11-30 05:01:03'), + (5, 'c', '2001-12-31 23:59:59'); +--disable_warnings +DROP TABLE IF EXISTS ta_l; +--enable_warnings +--disable_query_log +echo CREATE TABLE ta_l ( + PRIMARY KEY(a) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE ta_l ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO ta_l SELECT a, b, c FROM tb_l; + +--echo +--echo 0.9 +--echo create different primary key table +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT AUTO_INCREMENT, + c INT DEFAULT 11, + PRIMARY KEY(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--let $MASTER_1_IS_VP= `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'VP', 1, 0)` +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo create un-correspond primary key table +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS ta_l_int; +--enable_warnings +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_result_log + } + --disable_query_log + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES5; + --enable_query_log + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE ta_l_int ( + a INT DEFAULT 10, + b INT DEFAULT 12, + c INT DEFAULT 11, + PRIMARY KEY(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($MASTER_1_IS_VP) +{ + --error 14514 + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); +} +if (!$MASTER_1_IS_VP) +{ + INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3); + --disable_query_log + --disable_result_log + TRUNCATE TABLE ta_l_int; + --enable_query_log + --enable_result_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + } + eval $CHILD2_1_SELECT_TABLES5; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; +} +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/plug.in b/storage/spider/plug.in new file mode 100644 index 00000000000..7bbfff37688 --- /dev/null +++ b/storage/spider/plug.in @@ -0,0 +1,6 @@ +MYSQL_STORAGE_ENGINE(spider,,[Spider Storage Engine], + [Access transactional/nontransactional objects on remote servers], + [max,max-no-ndb]) +MYSQL_PLUGIN_DIRECTORY(spider, [storage/spider]) +MYSQL_PLUGIN_STATIC(spider, [libspider.a]) +MYSQL_PLUGIN_DYNAMIC(spider, [ha_spider.la]) diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc new file mode 100644 index 00000000000..13003207f9b --- /dev/null +++ b/storage/spider/spd_conn.cc @@ -0,0 +1,3988 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#include "tztime.h" +#endif +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "ha_spider.h" +#include "spd_db_conn.h" +#include "spd_trx.h" +#include "spd_conn.h" +#include "spd_table.h" +#include "spd_direct_sql.h" +#include "spd_ping_table.h" +#include "spd_malloc.h" + +extern ulong *spd_db_att_thread_id; + +extern handlerton *spider_hton_ptr; +extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; +pthread_mutex_t spider_conn_id_mutex; +ulonglong spider_conn_id = 1; + +#ifndef WITHOUT_SPIDER_BG_SEARCH +extern pthread_attr_t spider_pt_attr; + +#ifdef HAVE_PSI_INTERFACE +extern PSI_mutex_key spd_key_mutex_mta_conn; +#ifndef WITHOUT_SPIDER_BG_SEARCH +extern PSI_mutex_key spd_key_mutex_bg_conn_chain; +extern PSI_mutex_key spd_key_mutex_bg_conn_sync; +extern PSI_mutex_key spd_key_mutex_bg_conn; +extern PSI_mutex_key spd_key_mutex_bg_job_stack; +extern PSI_mutex_key spd_key_mutex_bg_mon; +extern PSI_cond_key spd_key_cond_bg_conn_sync; +extern PSI_cond_key spd_key_cond_bg_conn; +extern PSI_cond_key spd_key_cond_bg_sts; +extern PSI_cond_key spd_key_cond_bg_sts_sync; +extern PSI_cond_key spd_key_cond_bg_crd; +extern PSI_cond_key spd_key_cond_bg_crd_sync; +extern PSI_cond_key spd_key_cond_bg_mon; +extern PSI_thread_key spd_key_thd_bg; +extern PSI_thread_key spd_key_thd_bg_sts; +extern PSI_thread_key spd_key_thd_bg_crd; +extern PSI_thread_key spd_key_thd_bg_mon; +#endif +#endif + +extern pthread_mutex_t spider_global_trx_mutex; +extern SPIDER_TRX *spider_global_trx; +#endif + +HASH spider_open_connections; +uint spider_open_connections_id; +const char *spider_open_connections_func_name; +const char *spider_open_connections_file_name; +ulong spider_open_connections_line_no; +pthread_mutex_t spider_conn_mutex; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +HASH spider_hs_r_conn_hash; +uint spider_hs_r_conn_hash_id; +const char *spider_hs_r_conn_hash_func_name; +const char *spider_hs_r_conn_hash_file_name; +ulong spider_hs_r_conn_hash_line_no; +pthread_mutex_t spider_hs_r_conn_mutex; +HASH spider_hs_w_conn_hash; +uint spider_hs_w_conn_hash_id; +const char *spider_hs_w_conn_hash_func_name; +const char *spider_hs_w_conn_hash_file_name; +ulong spider_hs_w_conn_hash_line_no; +pthread_mutex_t spider_hs_w_conn_mutex; +#endif + +/* for spider_open_connections and trx_conn_hash */ +uchar *spider_conn_get_key( + SPIDER_CONN *conn, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_conn_get_key"); + *length = conn->conn_key_length; + DBUG_PRINT("info",("spider conn_kind=%u", conn->conn_kind)); +#ifndef DBUG_OFF + spider_print_keys(conn->conn_key, conn->conn_key_length); +#endif + DBUG_RETURN((uchar*) conn->conn_key); +} + +int spider_reset_conn_setted_parameter( + SPIDER_CONN *conn, + THD *thd +) { + DBUG_ENTER("spider_reset_conn_setted_parameter"); + conn->autocommit = spider_param_remote_autocommit(); + conn->sql_log_off = spider_param_remote_sql_log_off(); + if (thd && spider_param_remote_time_zone()) + { + int tz_length = strlen(spider_param_remote_time_zone()); + String tz_str(spider_param_remote_time_zone(), tz_length, + &my_charset_latin1); + conn->time_zone = my_tz_find(thd, &tz_str); + } else + conn->time_zone = NULL; + conn->trx_isolation = spider_param_remote_trx_isolation(); + DBUG_PRINT("info",("spider conn->trx_isolation=%d", conn->trx_isolation)); + if (spider_param_remote_access_charset()) + { + if (!(conn->access_charset = + get_charset_by_csname(spider_param_remote_access_charset(), + MY_CS_PRIMARY, MYF(MY_WME)))) + DBUG_RETURN(ER_UNKNOWN_CHARACTER_SET); + } else + conn->access_charset = NULL; + char *default_database = spider_param_remote_default_database(); + if (default_database) + { + uint default_database_length = strlen(default_database); + if (conn->default_database.reserve(default_database_length + 1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + conn->default_database.q_append(default_database, + default_database_length + 1); + conn->default_database.length(default_database_length); + } else + conn->default_database.length(0); + DBUG_RETURN(0); +} + +int spider_free_conn_alloc( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_free_conn_alloc"); + spider_db_disconnect(conn); +#ifndef WITHOUT_SPIDER_BG_SEARCH + spider_free_conn_thread(conn); +#endif + if (conn->db_conn) + { + delete conn->db_conn; + conn->db_conn = NULL; + } + DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name); + pthread_mutex_destroy(&conn->mta_conn_mutex); + conn->default_database.free(); + DBUG_RETURN(0); +} + +void spider_free_conn_from_trx( + SPIDER_TRX *trx, + SPIDER_CONN *conn, + bool another, + bool trx_free, + int *roop_count +) { + ha_spider *spider; + DBUG_ENTER("spider_free_conn_from_trx"); + spider_conn_clear_queue(conn); + conn->use_for_active_standby = FALSE; + conn->error_mode = 1; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if ( + trx_free || + ( + ( + conn->server_lost || + spider_param_conn_recycle_mode(trx->thd) != 2 + ) && + !conn->opened_handlers + ) + ) { + conn->thd = NULL; + if (another) + { + ha_spider *next_spider; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&trx->trx_another_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&trx->trx_another_conn_hash, (uchar*) conn); +#endif + spider = (ha_spider*) conn->another_ha_first; + while (spider) + { + next_spider = spider->next; + spider_free_tmp_dbton_handler(spider); + spider_free_tmp_dbton_share(spider->share); + spider_free_tmp_share_alloc(spider->share); + spider_free(spider_current_trx, spider->share, MYF(0)); + delete spider; + spider = next_spider; + } + conn->another_ha_first = NULL; + conn->another_ha_last = NULL; + } else { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&trx->trx_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&trx->trx_conn_hash, (uchar*) conn); +#endif + } + + if ( + !trx_free && + !conn->server_lost && + !conn->queued_connect && + spider_param_conn_recycle_mode(trx->thd) == 1 + ) { + /* conn_recycle_mode == 1 */ + *conn->conn_key = '0'; + if ( + conn->quick_target && + spider_db_free_result((ha_spider *) conn->quick_target, FALSE) + ) { + spider_free_conn(conn); + } else { + pthread_mutex_lock(&spider_conn_mutex); + uint old_elements = spider_open_connections.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&spider_open_connections, + conn->conn_key_hash_value, (uchar*) conn)) +#else + if (my_hash_insert(&spider_open_connections, (uchar*) conn)) +#endif + { + pthread_mutex_unlock(&spider_conn_mutex); + spider_free_conn(conn); + } else { + if (spider_open_connections.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + spider_open_connections, + (spider_open_connections.array.max_element - old_elements) * + spider_open_connections.array.size_of_element); + } + pthread_mutex_unlock(&spider_conn_mutex); + } + } + } else { + /* conn_recycle_mode == 0 */ + spider_free_conn(conn); + } + } else if (roop_count) + (*roop_count)++; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) + { + spider_db_hs_request_buf_reset(conn); + if ( + trx_free || + ( + ( + conn->server_lost || + spider_param_hs_r_conn_recycle_mode(trx->thd) != 2 + ) && + !conn->opened_handlers + ) + ) { + conn->thd = NULL; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&trx->trx_hs_r_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&trx->trx_hs_r_conn_hash, (uchar*) conn); +#endif + + DBUG_ASSERT(conn->opened_handlers == + conn->db_conn->get_opened_handler_count()); + if (conn->db_conn->get_opened_handler_count()) + { + conn->db_conn->reset_opened_handler(); + } + + if ( + !trx_free && + !conn->server_lost && + !conn->queued_connect && + spider_param_hs_r_conn_recycle_mode(trx->thd) == 1 + ) { + /* conn_recycle_mode == 1 */ + *conn->conn_key = '0'; + pthread_mutex_lock(&spider_hs_r_conn_mutex); + uint old_elements = spider_hs_r_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&spider_hs_r_conn_hash, + conn->conn_key_hash_value, (uchar*) conn)) +#else + if (my_hash_insert(&spider_hs_r_conn_hash, (uchar*) conn)) +#endif + { + pthread_mutex_unlock(&spider_hs_r_conn_mutex); + spider_free_conn(conn); + } else { + if (spider_hs_r_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + spider_hs_r_conn_hash, + (spider_hs_r_conn_hash.array.max_element - old_elements) * + spider_hs_r_conn_hash.array.size_of_element); + } + pthread_mutex_unlock(&spider_hs_r_conn_mutex); + } + } else { + /* conn_recycle_mode == 0 */ + spider_free_conn(conn); + } + } else if (roop_count) + (*roop_count)++; + } else { + spider_db_hs_request_buf_reset(conn); + if ( + trx_free || + ( + ( + conn->server_lost || + spider_param_hs_w_conn_recycle_mode(trx->thd) != 2 + ) && + !conn->opened_handlers + ) + ) { + conn->thd = NULL; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&trx->trx_hs_w_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&trx->trx_hs_w_conn_hash, (uchar*) conn); +#endif + + DBUG_ASSERT(conn->opened_handlers == + conn->db_conn->get_opened_handler_count()); + if (conn->db_conn->get_opened_handler_count()) + { + conn->db_conn->reset_opened_handler(); + } + + if ( + !trx_free && + !conn->server_lost && + !conn->queued_connect && + spider_param_hs_w_conn_recycle_mode(trx->thd) == 1 + ) { + /* conn_recycle_mode == 1 */ + *conn->conn_key = '0'; + pthread_mutex_lock(&spider_hs_w_conn_mutex); + uint old_elements = spider_hs_w_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&spider_hs_w_conn_hash, + conn->conn_key_hash_value, (uchar*) conn)) +#else + if (my_hash_insert(&spider_hs_w_conn_hash, (uchar*) conn)) +#endif + { + pthread_mutex_unlock(&spider_hs_w_conn_mutex); + spider_free_conn(conn); + } else { + if (spider_hs_w_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + spider_hs_w_conn_hash, + (spider_hs_w_conn_hash.array.max_element - old_elements) * + spider_hs_w_conn_hash.array.size_of_element); + } + pthread_mutex_unlock(&spider_hs_w_conn_mutex); + } + } else { + /* conn_recycle_mode == 0 */ + spider_free_conn(conn); + } + } else if (roop_count) + (*roop_count)++; + } +#endif + DBUG_VOID_RETURN; +} + +SPIDER_CONN *spider_create_conn( + SPIDER_SHARE *share, + ha_spider *spider, + int link_idx, + int base_link_idx, + uint conn_kind, + int *error_num +) { + int *need_mon; + SPIDER_CONN *conn; + char *tmp_name, *tmp_host, *tmp_username, *tmp_password, *tmp_socket; + char *tmp_wrapper, *tmp_ssl_ca, *tmp_ssl_capath, *tmp_ssl_cert; + char *tmp_ssl_cipher, *tmp_ssl_key, *tmp_default_file, *tmp_default_group; + DBUG_ENTER("spider_create_conn"); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (!(conn = (SPIDER_CONN *) + spider_bulk_malloc(spider_current_trx, 18, MYF(MY_WME | MY_ZEROFILL), + &conn, sizeof(*conn), + &tmp_name, share->conn_keys_lengths[link_idx] + 1, + &tmp_host, share->tgt_hosts_lengths[link_idx] + 1, + &tmp_username, + share->tgt_usernames_lengths[link_idx] + 1, + &tmp_password, + share->tgt_passwords_lengths[link_idx] + 1, + &tmp_socket, share->tgt_sockets_lengths[link_idx] + 1, + &tmp_wrapper, + share->tgt_wrappers_lengths[link_idx] + 1, + &tmp_ssl_ca, share->tgt_ssl_cas_lengths[link_idx] + 1, + &tmp_ssl_capath, + share->tgt_ssl_capaths_lengths[link_idx] + 1, + &tmp_ssl_cert, + share->tgt_ssl_certs_lengths[link_idx] + 1, + &tmp_ssl_cipher, + share->tgt_ssl_ciphers_lengths[link_idx] + 1, + &tmp_ssl_key, + share->tgt_ssl_keys_lengths[link_idx] + 1, + &tmp_default_file, + share->tgt_default_files_lengths[link_idx] + 1, + &tmp_default_group, + share->tgt_default_groups_lengths[link_idx] + 1, + &need_mon, sizeof(int), + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn; + } + + conn->default_database.init_calc_mem(75); + conn->conn_key_length = share->conn_keys_lengths[link_idx]; + conn->conn_key = tmp_name; + memcpy(conn->conn_key, share->conn_keys[link_idx], + share->conn_keys_lengths[link_idx]); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + conn->conn_key_hash_value = share->conn_keys_hash_value[link_idx]; +#endif + conn->tgt_host_length = share->tgt_hosts_lengths[link_idx]; + conn->tgt_host = tmp_host; + memcpy(conn->tgt_host, share->tgt_hosts[link_idx], + share->tgt_hosts_lengths[link_idx]); + conn->tgt_username_length = share->tgt_usernames_lengths[link_idx]; + conn->tgt_username = tmp_username; + memcpy(conn->tgt_username, share->tgt_usernames[link_idx], + share->tgt_usernames_lengths[link_idx]); + conn->tgt_password_length = share->tgt_passwords_lengths[link_idx]; + conn->tgt_password = tmp_password; + memcpy(conn->tgt_password, share->tgt_passwords[link_idx], + share->tgt_passwords_lengths[link_idx]); + conn->tgt_socket_length = share->tgt_sockets_lengths[link_idx]; + conn->tgt_socket = tmp_socket; + memcpy(conn->tgt_socket, share->tgt_sockets[link_idx], + share->tgt_sockets_lengths[link_idx]); + conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx]; + conn->tgt_wrapper = tmp_wrapper; + memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], + share->tgt_wrappers_lengths[link_idx]); + conn->tgt_ssl_ca_length = share->tgt_ssl_cas_lengths[link_idx]; + if (conn->tgt_ssl_ca_length) + { + conn->tgt_ssl_ca = tmp_ssl_ca; + memcpy(conn->tgt_ssl_ca, share->tgt_ssl_cas[link_idx], + share->tgt_ssl_cas_lengths[link_idx]); + } else + conn->tgt_ssl_ca = NULL; + conn->tgt_ssl_capath_length = share->tgt_ssl_capaths_lengths[link_idx]; + if (conn->tgt_ssl_capath_length) + { + conn->tgt_ssl_capath = tmp_ssl_capath; + memcpy(conn->tgt_ssl_capath, share->tgt_ssl_capaths[link_idx], + share->tgt_ssl_capaths_lengths[link_idx]); + } else + conn->tgt_ssl_capath = NULL; + conn->tgt_ssl_cert_length = share->tgt_ssl_certs_lengths[link_idx]; + if (conn->tgt_ssl_cert_length) + { + conn->tgt_ssl_cert = tmp_ssl_cert; + memcpy(conn->tgt_ssl_cert, share->tgt_ssl_certs[link_idx], + share->tgt_ssl_certs_lengths[link_idx]); + } else + conn->tgt_ssl_cert = NULL; + conn->tgt_ssl_cipher_length = share->tgt_ssl_ciphers_lengths[link_idx]; + if (conn->tgt_ssl_cipher_length) + { + conn->tgt_ssl_cipher = tmp_ssl_cipher; + memcpy(conn->tgt_ssl_cipher, share->tgt_ssl_ciphers[link_idx], + share->tgt_ssl_ciphers_lengths[link_idx]); + } else + conn->tgt_ssl_cipher = NULL; + conn->tgt_ssl_key_length = share->tgt_ssl_keys_lengths[link_idx]; + if (conn->tgt_ssl_key_length) + { + conn->tgt_ssl_key = tmp_ssl_key; + memcpy(conn->tgt_ssl_key, share->tgt_ssl_keys[link_idx], + share->tgt_ssl_keys_lengths[link_idx]); + } else + conn->tgt_ssl_key = NULL; + conn->tgt_default_file_length = share->tgt_default_files_lengths[link_idx]; + if (conn->tgt_default_file_length) + { + conn->tgt_default_file = tmp_default_file; + memcpy(conn->tgt_default_file, share->tgt_default_files[link_idx], + share->tgt_default_files_lengths[link_idx]); + } else + conn->tgt_default_file = NULL; + conn->tgt_default_group_length = + share->tgt_default_groups_lengths[link_idx]; + if (conn->tgt_default_group_length) + { + conn->tgt_default_group = tmp_default_group; + memcpy(conn->tgt_default_group, share->tgt_default_groups[link_idx], + share->tgt_default_groups_lengths[link_idx]); + } else + conn->tgt_default_group = NULL; + conn->tgt_port = share->tgt_ports[link_idx]; + conn->tgt_ssl_vsc = share->tgt_ssl_vscs[link_idx]; + conn->dbton_id = share->sql_dbton_ids[link_idx]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) { + if (!(conn = (SPIDER_CONN *) + spider_bulk_malloc(spider_current_trx, 19, MYF(MY_WME | MY_ZEROFILL), + &conn, sizeof(*conn), + &tmp_name, share->hs_read_conn_keys_lengths[link_idx] + 1, + &tmp_host, share->tgt_hosts_lengths[link_idx] + 1, + &tmp_socket, share->hs_read_socks_lengths[link_idx] + 1, + &tmp_wrapper, + share->tgt_wrappers_lengths[link_idx] + 1, + &need_mon, sizeof(int), + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn; + } + + conn->default_database.init_calc_mem(76); + conn->conn_key_length = share->hs_read_conn_keys_lengths[link_idx]; + conn->conn_key = tmp_name; + memcpy(conn->conn_key, share->hs_read_conn_keys[link_idx], + share->hs_read_conn_keys_lengths[link_idx]); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + conn->conn_key_hash_value = share->hs_read_conn_keys_hash_value[link_idx]; +#endif + conn->tgt_host_length = share->tgt_hosts_lengths[link_idx]; + conn->tgt_host = tmp_host; + memcpy(conn->tgt_host, share->tgt_hosts[link_idx], + share->tgt_hosts_lengths[link_idx]); + conn->hs_sock_length = share->hs_read_socks_lengths[link_idx]; + if (conn->hs_sock_length) + { + conn->hs_sock = tmp_socket; + memcpy(conn->hs_sock, share->hs_read_socks[link_idx], + share->hs_read_socks_lengths[link_idx]); + } else + conn->hs_sock = NULL; + conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx]; + conn->tgt_wrapper = tmp_wrapper; + memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], + share->tgt_wrappers_lengths[link_idx]); + conn->hs_port = share->hs_read_ports[link_idx]; + conn->dbton_id = share->hs_dbton_ids[link_idx]; + } else { + if (!(conn = (SPIDER_CONN *) + spider_bulk_malloc(spider_current_trx, 20, MYF(MY_WME | MY_ZEROFILL), + &conn, sizeof(*conn), + &tmp_name, share->hs_write_conn_keys_lengths[link_idx] + 1, + &tmp_host, share->tgt_hosts_lengths[link_idx] + 1, + &tmp_socket, share->hs_write_socks_lengths[link_idx] + 1, + &tmp_wrapper, + share->tgt_wrappers_lengths[link_idx] + 1, + &need_mon, sizeof(int), + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn; + } + + conn->default_database.init_calc_mem(77); + conn->conn_key_length = share->hs_write_conn_keys_lengths[link_idx]; + conn->conn_key = tmp_name; + memcpy(conn->conn_key, share->hs_write_conn_keys[link_idx], + share->hs_write_conn_keys_lengths[link_idx]); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + conn->conn_key_hash_value = share->hs_write_conn_keys_hash_value[link_idx]; +#endif + conn->tgt_host_length = share->tgt_hosts_lengths[link_idx]; + conn->tgt_host = tmp_host; + memcpy(conn->tgt_host, share->tgt_hosts[link_idx], + share->tgt_hosts_lengths[link_idx]); + conn->hs_sock_length = share->hs_write_socks_lengths[link_idx]; + if (conn->hs_sock_length) + { + conn->hs_sock = tmp_socket; + memcpy(conn->hs_sock, share->hs_write_socks[link_idx], + share->hs_write_socks_lengths[link_idx]); + } else + conn->hs_sock = NULL; + conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx]; + conn->tgt_wrapper = tmp_wrapper; + memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], + share->tgt_wrappers_lengths[link_idx]); + conn->hs_port = share->hs_write_ports[link_idx]; + conn->dbton_id = share->hs_dbton_ids[link_idx]; + } +#endif + if (!(conn->db_conn = spider_dbton[conn->dbton_id].create_db_conn(conn))) + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_db_conn_create; + } + if ((*error_num = conn->db_conn->init())) + { + goto error_db_conn_init; + } + conn->join_trx = 0; + conn->thd = NULL; + conn->table_lock = 0; + conn->semi_trx_isolation = -2; + conn->semi_trx_isolation_chk = FALSE; + conn->semi_trx_chk = FALSE; + conn->link_idx = base_link_idx; + conn->conn_kind = conn_kind; + conn->conn_need_mon = need_mon; + if (spider) + conn->need_mon = &spider->need_mons[base_link_idx]; + else + conn->need_mon = need_mon; + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex, + MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_mta_conn_mutex_init; + } + + spider_conn_queue_connect(share, conn, link_idx); + conn->ping_time = (time_t) time((time_t*) 0); + pthread_mutex_lock(&spider_conn_id_mutex); + conn->conn_id = spider_conn_id; + ++spider_conn_id; + pthread_mutex_unlock(&spider_conn_id_mutex); + + DBUG_RETURN(conn); + +/* +error_init_lock_table_hash: + DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name); + pthread_mutex_destroy(&conn->mta_conn_mutex); +*/ +error_mta_conn_mutex_init: +error_db_conn_init: + delete conn->db_conn; +error_db_conn_create: + spider_free(spider_current_trx, conn, MYF(0)); +error_alloc_conn: + DBUG_RETURN(NULL); +} + +SPIDER_CONN *spider_get_conn( + SPIDER_SHARE *share, + int link_idx, + char *conn_key, + SPIDER_TRX *trx, + ha_spider *spider, + bool another, + bool thd_chg, + uint conn_kind, + int *error_num +) { + SPIDER_CONN *conn = NULL; + int base_link_idx = link_idx; + DBUG_ENTER("spider_get_conn"); + DBUG_PRINT("info",("spider conn_kind=%u", conn_kind)); + + if (spider) + link_idx = spider->conn_link_idx[base_link_idx]; + DBUG_PRINT("info",("spider link_idx=%u", link_idx)); + DBUG_PRINT("info",("spider base_link_idx=%u", base_link_idx)); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif +#ifndef DBUG_OFF + spider_print_keys(conn_key, share->conn_keys_lengths[link_idx]); +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) + { + conn_key = share->hs_read_conn_keys[link_idx]; +#ifndef DBUG_OFF + spider_print_keys(conn_key, share->hs_read_conn_keys_lengths[link_idx]); +#endif + } else { + conn_key = share->hs_write_conn_keys[link_idx]; +#ifndef DBUG_OFF + spider_print_keys(conn_key, share->hs_write_conn_keys_lengths[link_idx]); +#endif + } +#endif +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (conn_kind == SPIDER_CONN_KIND_MYSQL && + ( +#endif + (another && + !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &trx->trx_another_conn_hash, + share->conn_keys_hash_value[link_idx], + (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) || + (!another && + !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &trx->trx_conn_hash, + share->conn_keys_hash_value[link_idx], + (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) + ) || + (conn_kind == SPIDER_CONN_KIND_HS_READ && + !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &trx->trx_hs_r_conn_hash, + share->hs_read_conn_keys_hash_value[link_idx], + (uchar*) conn_key, share->hs_read_conn_keys_lengths[link_idx])) + ) || + (conn_kind == SPIDER_CONN_KIND_HS_WRITE && + !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &trx->trx_hs_w_conn_hash, + share->hs_write_conn_keys_hash_value[link_idx], + (uchar*) conn_key, share->hs_write_conn_keys_lengths[link_idx])) + ) +#endif + ) +#else + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (conn_kind == SPIDER_CONN_KIND_MYSQL && + ( +#endif + (another && + !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_another_conn_hash, + (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) || + (!another && + !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash, + (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) + ) || + (conn_kind == SPIDER_CONN_KIND_HS_READ && + !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_hs_r_conn_hash, + (uchar*) conn_key, share->hs_read_conn_keys_lengths[link_idx])) + ) || + (conn_kind == SPIDER_CONN_KIND_HS_WRITE && + !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_hs_w_conn_hash, + (uchar*) conn_key, share->hs_write_conn_keys_lengths[link_idx])) + ) +#endif + ) +#endif + { + if ( + !trx->thd || +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (conn_kind == SPIDER_CONN_KIND_MYSQL && +#endif + ( + (spider_param_conn_recycle_mode(trx->thd) & 1) || + spider_param_conn_recycle_strict(trx->thd) + ) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) || + (conn_kind == SPIDER_CONN_KIND_HS_READ && + ( + (spider_param_hs_r_conn_recycle_mode(trx->thd) & 1) || + spider_param_hs_r_conn_recycle_strict(trx->thd) + ) + ) || + (conn_kind == SPIDER_CONN_KIND_HS_WRITE && + ( + (spider_param_hs_w_conn_recycle_mode(trx->thd) & 1) || + spider_param_hs_w_conn_recycle_strict(trx->thd) + ) + ) +#endif + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + pthread_mutex_lock(&spider_conn_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &spider_open_connections, share->conn_keys_hash_value[link_idx], + (uchar*) share->conn_keys[link_idx], + share->conn_keys_lengths[link_idx]))) +#else + if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_open_connections, + (uchar*) share->conn_keys[link_idx], + share->conn_keys_lengths[link_idx]))) +#endif + { + pthread_mutex_unlock(&spider_conn_mutex); + DBUG_PRINT("info",("spider create new conn")); + if (!(conn = spider_create_conn(share, spider, link_idx, + base_link_idx, conn_kind, error_num))) + goto error; + *conn->conn_key = *conn_key; + if (spider) + { + spider->conns[base_link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + conn->use_for_active_standby = TRUE; + } + } else { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_open_connections, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&spider_open_connections, (uchar*) conn); +#endif + pthread_mutex_unlock(&spider_conn_mutex); + DBUG_PRINT("info",("spider get global conn")); + if (spider) + { + spider->conns[base_link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + conn->use_for_active_standby = TRUE; + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) + { + pthread_mutex_lock(&spider_hs_r_conn_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &spider_hs_r_conn_hash, + share->hs_read_conn_keys_hash_value[link_idx], + (uchar*) share->hs_read_conn_keys[link_idx], + share->hs_read_conn_keys_lengths[link_idx]))) +#else + if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_hs_r_conn_hash, + (uchar*) share->hs_read_conn_keys[link_idx], + share->hs_read_conn_keys_lengths[link_idx]))) +#endif + { + pthread_mutex_unlock(&spider_hs_r_conn_mutex); + DBUG_PRINT("info",("spider create new hs r conn")); + if (!(conn = spider_create_conn(share, spider, link_idx, + base_link_idx, conn_kind, error_num))) + goto error; + *conn->conn_key = *conn_key; + if (spider) + { + spider->hs_r_conns[base_link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + conn->use_for_active_standby = TRUE; + } + } else { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_hs_r_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&spider_hs_r_conn_hash, (uchar*) conn); +#endif + pthread_mutex_unlock(&spider_hs_r_conn_mutex); + DBUG_PRINT("info",("spider get global hs r conn")); + if (spider) + { + spider->hs_r_conns[base_link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + conn->use_for_active_standby = TRUE; + } + } + } else { + pthread_mutex_lock(&spider_hs_w_conn_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &spider_hs_w_conn_hash, + share->hs_write_conn_keys_hash_value[link_idx], + (uchar*) share->hs_write_conn_keys[link_idx], + share->hs_write_conn_keys_lengths[link_idx]))) +#else + if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_hs_w_conn_hash, + (uchar*) share->hs_write_conn_keys[link_idx], + share->hs_write_conn_keys_lengths[link_idx]))) +#endif + { + pthread_mutex_unlock(&spider_hs_w_conn_mutex); + DBUG_PRINT("info",("spider create new hs w conn")); + if (!(conn = spider_create_conn(share, spider, link_idx, + base_link_idx, conn_kind, error_num))) + goto error; + *conn->conn_key = *conn_key; + if (spider) + { + spider->hs_w_conns[base_link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + conn->use_for_active_standby = TRUE; + } + } else { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_hs_w_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&spider_hs_w_conn_hash, (uchar*) conn); +#endif + pthread_mutex_unlock(&spider_hs_w_conn_mutex); + DBUG_PRINT("info",("spider get global hs w conn")); + if (spider) + { + spider->hs_w_conns[base_link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + conn->use_for_active_standby = TRUE; + } + } + } +#endif + } else { + DBUG_PRINT("info",("spider create new conn")); + /* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */ + if (!(conn = spider_create_conn(share, spider, link_idx, base_link_idx, + conn_kind, error_num))) + goto error; + *conn->conn_key = *conn_key; + if (spider) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + spider->conns[base_link_idx] = conn; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) + { + spider->hs_r_conns[base_link_idx] = conn; + } else { + spider->hs_w_conns[base_link_idx] = conn; + } +#endif + if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + conn->use_for_active_standby = TRUE; + } + } + conn->thd = trx->thd; + conn->priority = share->priority; + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (another) + { + uint old_elements = trx->trx_another_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_another_conn_hash, + share->conn_keys_hash_value[link_idx], + (uchar*) conn)) +#else + if (my_hash_insert(&trx->trx_another_conn_hash, (uchar*) conn)) +#endif + { + spider_free_conn(conn); + *error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (trx->trx_another_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_another_conn_hash, + (trx->trx_another_conn_hash.array.max_element - old_elements) * + trx->trx_another_conn_hash.array.size_of_element); + } + } else { + uint old_elements = trx->trx_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_conn_hash, + share->conn_keys_hash_value[link_idx], + (uchar*) conn)) +#else + if (my_hash_insert(&trx->trx_conn_hash, (uchar*) conn)) +#endif + { + spider_free_conn(conn); + *error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (trx->trx_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_conn_hash, + (trx->trx_conn_hash.array.max_element - old_elements) * + trx->trx_conn_hash.array.size_of_element); + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) + { + uint old_elements = trx->trx_hs_r_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_hs_r_conn_hash, + share->hs_read_conn_keys_hash_value[link_idx], + (uchar*) conn)) +#else + if (my_hash_insert(&trx->trx_hs_r_conn_hash, (uchar*) conn)) +#endif + { + spider_free_conn(conn); + *error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (trx->trx_hs_r_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_hs_r_conn_hash, + (trx->trx_hs_r_conn_hash.array.max_element - old_elements) * + trx->trx_hs_r_conn_hash.array.size_of_element); + } + } else { + uint old_elements = trx->trx_hs_w_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_hs_w_conn_hash, + share->hs_write_conn_keys_hash_value[link_idx], + (uchar*) conn)) +#else + if (my_hash_insert(&trx->trx_hs_w_conn_hash, (uchar*) conn)) +#endif + { + spider_free_conn(conn); + *error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (trx->trx_hs_w_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_hs_w_conn_hash, + (trx->trx_hs_w_conn_hash.array.max_element - old_elements) * + trx->trx_hs_w_conn_hash.array.size_of_element); + } + } +#endif + } else if (spider) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + spider->conns[base_link_idx] = conn; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) + { + spider->hs_r_conns[base_link_idx] = conn; + } else { + spider->hs_w_conns[base_link_idx] = conn; + } +#endif + if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + conn->use_for_active_standby = TRUE; + } + conn->link_idx = base_link_idx; + + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_RETURN(conn); + +error: + DBUG_RETURN(NULL); +} + +int spider_free_conn( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_free_conn"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + spider_free_conn_alloc(conn); + spider_free(spider_current_trx, conn, MYF(0)); + DBUG_RETURN(0); +} + +void spider_conn_queue_connect( + SPIDER_SHARE *share, + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_conn_queue_connect"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_connect = TRUE; + conn->queued_connect_share = share; + conn->queued_connect_link_idx = link_idx; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_connect_rewrite( + SPIDER_SHARE *share, + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_conn_queue_connect_rewrite"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_connect_share = share; + conn->queued_connect_link_idx = link_idx; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_ping( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_conn_queue_ping"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_ping = TRUE; + conn->queued_ping_spider = spider; + conn->queued_ping_link_idx = link_idx; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_trx_isolation( + SPIDER_CONN *conn, + int trx_isolation +) { + DBUG_ENTER("spider_conn_queue_trx_isolation"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_trx_isolation = TRUE; + conn->queued_trx_isolation_val = trx_isolation; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_semi_trx_isolation( + SPIDER_CONN *conn, + int trx_isolation +) { + DBUG_ENTER("spider_conn_queue_semi_trx_isolation"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_semi_trx_isolation = TRUE; + conn->queued_semi_trx_isolation_val = trx_isolation; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_autocommit( + SPIDER_CONN *conn, + bool autocommit +) { + DBUG_ENTER("spider_conn_queue_autocommit"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_autocommit = TRUE; + conn->queued_autocommit_val = autocommit; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_sql_log_off( + SPIDER_CONN *conn, + bool sql_log_off +) { + DBUG_ENTER("spider_conn_queue_sql_log_off"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_sql_log_off = TRUE; + conn->queued_sql_log_off_val = sql_log_off; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_time_zone( + SPIDER_CONN *conn, + Time_zone *time_zone +) { + DBUG_ENTER("spider_conn_queue_time_zone"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_time_zone = TRUE; + conn->queued_time_zone_val = time_zone; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_start_transaction( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_conn_queue_start_transaction"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_trx_start = TRUE; + conn->trx_start = TRUE; + DBUG_VOID_RETURN; +} + +void spider_conn_queue_xa_start( + SPIDER_CONN *conn, + XID *xid +) { + DBUG_ENTER("spider_conn_queue_xa_start"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_xa_start = TRUE; + conn->queued_xa_start_xid = xid; + DBUG_VOID_RETURN; +} + +void spider_conn_clear_queue( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_conn_clear_queue"); + DBUG_PRINT("info", ("spider conn=%p", conn)); +/* + conn->queued_connect = FALSE; +*/ + conn->queued_ping = FALSE; + conn->queued_trx_isolation = FALSE; + conn->queued_semi_trx_isolation = FALSE; + conn->queued_autocommit = FALSE; + conn->queued_sql_log_off = FALSE; + conn->queued_time_zone = FALSE; + conn->queued_trx_start = FALSE; + conn->queued_xa_start = FALSE; + DBUG_VOID_RETURN; +} + +void spider_conn_clear_queue_at_commit( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_conn_clear_queue_at_commit"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + conn->queued_trx_start = FALSE; + conn->queued_xa_start = FALSE; + DBUG_VOID_RETURN; +} + +void spider_conn_set_timeout( + SPIDER_CONN *conn, + uint net_read_timeout, + uint net_write_timeout +) { + DBUG_ENTER("spider_conn_set_timeout"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + if (net_read_timeout != conn->net_read_timeout) + { + DBUG_PRINT("info",("spider net_read_timeout set from %u to %u", + conn->net_read_timeout, net_read_timeout)); + conn->queued_net_timeout = TRUE; + conn->net_read_timeout = net_read_timeout; + } + if (net_write_timeout != conn->net_write_timeout) + { + DBUG_PRINT("info",("spider net_write_timeout set from %u to %u", + conn->net_write_timeout, net_write_timeout)); + conn->queued_net_timeout = TRUE; + conn->net_write_timeout = net_write_timeout; + } + DBUG_VOID_RETURN; +} + +void spider_conn_set_timeout_from_share( + SPIDER_CONN *conn, + int link_idx, + THD *thd, + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_conn_set_timeout_from_share"); + spider_conn_set_timeout( + conn, + spider_param_net_read_timeout(thd, share->net_read_timeouts[link_idx]), + spider_param_net_write_timeout(thd, share->net_write_timeouts[link_idx]) + ); + DBUG_VOID_RETURN; +} + +void spider_conn_set_timeout_from_direct_sql( + SPIDER_CONN *conn, + THD *thd, + SPIDER_DIRECT_SQL *direct_sql +) { + DBUG_ENTER("spider_conn_set_timeout_from_direct_sql"); + spider_conn_set_timeout( + conn, + spider_param_net_read_timeout(thd, direct_sql->net_read_timeout), + spider_param_net_write_timeout(thd, direct_sql->net_write_timeout) + ); + DBUG_VOID_RETURN; +} + +void spider_tree_insert( + SPIDER_CONN *top, + SPIDER_CONN *conn +) { + SPIDER_CONN *current = top; + longlong priority = conn->priority; + DBUG_ENTER("spider_tree_insert"); + while (TRUE) + { + if (priority < current->priority) + { + if (current->c_small == NULL) + { + conn->p_small = NULL; + conn->p_big = current; + conn->c_small = NULL; + conn->c_big = NULL; + current->c_small = conn; + break; + } else + current = current->c_small; + } else { + if (current->c_big == NULL) + { + conn->p_small = current; + conn->p_big = NULL; + conn->c_small = NULL; + conn->c_big = NULL; + current->c_big = conn; + break; + } else + current = current->c_big; + } + } + DBUG_VOID_RETURN; +} + +SPIDER_CONN *spider_tree_first( + SPIDER_CONN *top +) { + SPIDER_CONN *current = top; + DBUG_ENTER("spider_tree_first"); + while (current) + { + if (current->c_small == NULL) + break; + else + current = current->c_small; + } + DBUG_RETURN(current); +} + +SPIDER_CONN *spider_tree_last( + SPIDER_CONN *top +) { + SPIDER_CONN *current = top; + DBUG_ENTER("spider_tree_last"); + while (TRUE) + { + if (current->c_big == NULL) + break; + else + current = current->c_big; + } + DBUG_RETURN(current); +} + +SPIDER_CONN *spider_tree_next( + SPIDER_CONN *current +) { + DBUG_ENTER("spider_tree_next"); + if (current->c_big) + DBUG_RETURN(spider_tree_first(current->c_big)); + while (TRUE) + { + if (current->p_big) + DBUG_RETURN(current->p_big); + if (!current->p_small) + DBUG_RETURN(NULL); + current = current->p_small; + } +} + +SPIDER_CONN *spider_tree_delete( + SPIDER_CONN *conn, + SPIDER_CONN *top +) { + DBUG_ENTER("spider_tree_delete"); + if (conn->p_small) + { + if (conn->c_small) + { + conn->c_small->p_big = NULL; + conn->c_small->p_small = conn->p_small; + conn->p_small->c_big = conn->c_small; + if (conn->c_big) + { + SPIDER_CONN *last = spider_tree_last(conn->c_small); + conn->c_big->p_small = last; + last->c_big = conn->c_big; + } + } else if (conn->c_big) + { + conn->c_big->p_small = conn->p_small; + conn->p_small->c_big = conn->c_big; + } else + conn->p_small->c_big = NULL; + } else if (conn->p_big) + { + if (conn->c_small) + { + conn->c_small->p_big = conn->p_big; + conn->p_big->c_small = conn->c_small; + if (conn->c_big) + { + SPIDER_CONN *last = spider_tree_last(conn->c_small); + conn->c_big->p_small = last; + last->c_big = conn->c_big; + } + } else if (conn->c_big) + { + conn->c_big->p_big = conn->p_big; + conn->c_big->p_small = NULL; + conn->p_big->c_small = conn->c_big; + } else + conn->p_big->c_small = NULL; + } else { + if (conn->c_small) + { + conn->c_small->p_big = NULL; + conn->c_small->p_small = NULL; + if (conn->c_big) + { + SPIDER_CONN *last = spider_tree_last(conn->c_small); + conn->c_big->p_small = last; + last->c_big = conn->c_big; + } + DBUG_RETURN(conn->c_small); + } else if (conn->c_big) + { + conn->c_big->p_small = NULL; + DBUG_RETURN(conn->c_big); + } + DBUG_RETURN(NULL); + } + DBUG_RETURN(top); +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +int spider_set_conn_bg_param( + ha_spider *spider +) { + int error_num, roop_count, bgs_mode; + SPIDER_SHARE *share = spider->share; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + THD *thd = spider->trx->thd; + DBUG_ENTER("spider_set_conn_bg_param"); + bgs_mode = + spider_param_bgs_mode(thd, share->bgs_mode); + if (bgs_mode == 0) + result_list->bgs_phase = 0; + else if ( + bgs_mode <= 2 && + (result_list->lock_type == F_WRLCK || spider->lock_mode == 2) + ) + result_list->bgs_phase = 0; + else if (bgs_mode <= 1 && spider->lock_mode == 1) + result_list->bgs_phase = 0; + else { + result_list->bgs_phase = 1; + + result_list->bgs_first_read = + spider_param_bgs_first_read(thd, share->bgs_first_read); + result_list->bgs_second_read = + spider_param_bgs_second_read(thd, share->bgs_second_read); + result_list->bgs_split_read = spider_bg_split_read_param(spider); + + result_list->split_read = + result_list->bgs_first_read > 0 ? + result_list->bgs_first_read : + result_list->bgs_split_read; + } + + if (result_list->bgs_phase > 0) + { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + spider->lock_mode ? + SPIDER_LINK_STATUS_RECOVERY : SPIDER_LINK_STATUS_OK); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + spider->lock_mode ? + SPIDER_LINK_STATUS_RECOVERY : SPIDER_LINK_STATUS_OK) + ) { + if ((error_num = spider_create_conn_thread(spider->conns[roop_count]))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = spider_create_conn_thread( + spider->hs_r_conns[roop_count]))) + DBUG_RETURN(error_num); + if ((error_num = spider_create_conn_thread( + spider->hs_w_conns[roop_count]))) + DBUG_RETURN(error_num); +#endif + } + } + DBUG_RETURN(0); +} + +int spider_create_conn_thread( + SPIDER_CONN *conn +) { + int error_num; + DBUG_ENTER("spider_create_conn_thread"); + if (conn && !conn->bg_init) + { +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&conn->bg_conn_chain_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_bg_conn_chain, + &conn->bg_conn_chain_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_chain_mutex_init; + } + conn->bg_conn_chain_mutex_ptr = NULL; +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&conn->bg_conn_sync_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_bg_conn_sync, + &conn->bg_conn_sync_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_sync_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&conn->bg_conn_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_bg_conn, &conn->bg_conn_mutex, + MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&conn->bg_job_stack_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_bg_job_stack, &conn->bg_job_stack_mutex, + MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_job_stack_mutex_init; + } + if (SPD_INIT_DYNAMIC_ARRAY2(&conn->bg_job_stack, sizeof(void *), NULL, 16, + 16, MYF(MY_WME))) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_job_stack_init; + } + spider_alloc_calc_mem_init(conn->bg_job_stack, 163); + spider_alloc_calc_mem(spider_current_trx, + conn->bg_job_stack, + conn->bg_job_stack.max_element * + conn->bg_job_stack.size_of_element); + conn->bg_job_stack_cur_pos = 0; +#if MYSQL_VERSION_ID < 50500 + if (pthread_cond_init(&conn->bg_conn_sync_cond, NULL)) +#else + if (mysql_cond_init(spd_key_cond_bg_conn_sync, + &conn->bg_conn_sync_cond, NULL)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_sync_cond_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_cond_init(&conn->bg_conn_cond, NULL)) +#else + if (mysql_cond_init(spd_key_cond_bg_conn, + &conn->bg_conn_cond, NULL)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_cond_init; + } + pthread_mutex_lock(&conn->bg_conn_mutex); +#if MYSQL_VERSION_ID < 50500 + if (pthread_create(&conn->bg_thread, &spider_pt_attr, + spider_bg_conn_action, (void *) conn) + ) +#else + if (mysql_thread_create(spd_key_thd_bg, &conn->bg_thread, + &spider_pt_attr, spider_bg_conn_action, (void *) conn) + ) +#endif + { + pthread_mutex_unlock(&conn->bg_conn_mutex); + error_num = HA_ERR_OUT_OF_MEM; + goto error_thread_create; + } + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + if (!conn->bg_init) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_thread_create; + } + } + DBUG_RETURN(0); + +error_thread_create: + pthread_cond_destroy(&conn->bg_conn_cond); +error_cond_init: + pthread_cond_destroy(&conn->bg_conn_sync_cond); +error_sync_cond_init: + spider_free_mem_calc(spider_current_trx, + conn->bg_job_stack_id, + conn->bg_job_stack.max_element * + conn->bg_job_stack.size_of_element); + delete_dynamic(&conn->bg_job_stack); +error_job_stack_init: + pthread_mutex_destroy(&conn->bg_job_stack_mutex); +error_job_stack_mutex_init: + pthread_mutex_destroy(&conn->bg_conn_mutex); +error_mutex_init: + pthread_mutex_destroy(&conn->bg_conn_sync_mutex); +error_sync_mutex_init: + pthread_mutex_destroy(&conn->bg_conn_chain_mutex); +error_chain_mutex_init: + DBUG_RETURN(error_num); +} + +void spider_free_conn_thread( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_free_conn_thread"); + if (conn->bg_init) + { + spider_bg_conn_break(conn, NULL); + pthread_mutex_lock(&conn->bg_conn_mutex); + conn->bg_kill = TRUE; + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + pthread_join(conn->bg_thread, NULL); + pthread_cond_destroy(&conn->bg_conn_cond); + pthread_cond_destroy(&conn->bg_conn_sync_cond); + spider_free_mem_calc(spider_current_trx, + conn->bg_job_stack_id, + conn->bg_job_stack.max_element * + conn->bg_job_stack.size_of_element); + delete_dynamic(&conn->bg_job_stack); + pthread_mutex_destroy(&conn->bg_job_stack_mutex); + pthread_mutex_destroy(&conn->bg_conn_mutex); + pthread_mutex_destroy(&conn->bg_conn_sync_mutex); + pthread_mutex_destroy(&conn->bg_conn_chain_mutex); + conn->bg_kill = FALSE; + conn->bg_init = FALSE; + } + DBUG_VOID_RETURN; +} + +void spider_bg_conn_wait( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_bg_conn_wait"); + if (conn->bg_init) + { + pthread_mutex_lock(&conn->bg_conn_mutex); + pthread_mutex_unlock(&conn->bg_conn_mutex); + } + DBUG_VOID_RETURN; +} + +void spider_bg_all_conn_wait( + ha_spider *spider +) { + int roop_count; + SPIDER_CONN *conn; + SPIDER_SHARE *share = spider->share; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_bg_all_conn_wait"); + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (conn && result_list->bgs_working) + spider_bg_conn_wait(conn); +#endif + } + DBUG_VOID_RETURN; +} + +int spider_bg_all_conn_pre_next( + ha_spider *spider, + int link_idx +) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + int roop_start, roop_end, roop_count, lock_mode, link_ok, error_num; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_SHARE *share = spider->share; +#endif + DBUG_ENTER("spider_bg_all_conn_pre_next"); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list->bgs_phase > 0) + { + lock_mode = spider_conn_lock_mode(spider); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = spider->share->link_count; + } else { + link_ok = link_idx; + roop_start = link_idx; + roop_end = link_idx + 1; + } + + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if ((error_num = spider_bg_conn_search(spider, roop_count, roop_start, + TRUE, TRUE, (roop_count != link_ok)))) + DBUG_RETURN(error_num); + } + } +#endif + DBUG_RETURN(0); +} + +void spider_bg_conn_break( + SPIDER_CONN *conn, + ha_spider *spider +) { + DBUG_ENTER("spider_bg_conn_break"); + if ( + conn->bg_init && + conn->bg_thd != current_thd && + ( + !spider || + ( + spider->result_list.bgs_working && + conn->bg_target == spider + ) + ) + ) { + conn->bg_break = TRUE; + pthread_mutex_lock(&conn->bg_conn_mutex); + pthread_mutex_unlock(&conn->bg_conn_mutex); + conn->bg_break = FALSE; + } + DBUG_VOID_RETURN; +} + +void spider_bg_all_conn_break( + ha_spider *spider +) { + int roop_count; + SPIDER_CONN *conn; + SPIDER_SHARE *share = spider->share; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_bg_all_conn_break"); + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (conn && result_list->bgs_working) + spider_bg_conn_break(conn, spider); +#endif + if (spider->quick_targets[roop_count]) + { + DBUG_ASSERT(spider->quick_targets[roop_count] == conn->quick_target); + DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", conn)); + conn->quick_target = NULL; + spider->quick_targets[roop_count] = NULL; + } + } + DBUG_VOID_RETURN; +} + +bool spider_bg_conn_get_job( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_bg_conn_get_job"); + pthread_mutex_lock(&conn->bg_job_stack_mutex); + if (conn->bg_job_stack_cur_pos >= conn->bg_job_stack.elements) + { + DBUG_PRINT("info",("spider bg all jobs are completed")); + conn->bg_get_job_stack_off = FALSE; + pthread_mutex_unlock(&conn->bg_job_stack_mutex); + DBUG_RETURN(FALSE); + } + DBUG_PRINT("info",("spider bg get job %u", + conn->bg_job_stack_cur_pos)); + conn->bg_target = ((void **) (conn->bg_job_stack.buffer + + conn->bg_job_stack.size_of_element * conn->bg_job_stack_cur_pos))[0]; + conn->bg_job_stack_cur_pos++; + if (conn->bg_job_stack_cur_pos == conn->bg_job_stack.elements) + { + DBUG_PRINT("info",("spider bg shift job stack")); + conn->bg_job_stack_cur_pos = 0; + conn->bg_job_stack.elements = 0; + } + pthread_mutex_unlock(&conn->bg_job_stack_mutex); + DBUG_RETURN(TRUE); +} + +int spider_bg_conn_search( + ha_spider *spider, + int link_idx, + int first_link_idx, + bool first, + bool pre_next, + bool discard_result +) { + int error_num; + SPIDER_CONN *conn, *first_conn = NULL; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + bool with_lock = FALSE; + DBUG_ENTER("spider_bg_conn_search"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = spider->conns[link_idx]; + with_lock = (spider_conn_lock_mode(spider) != SPIDER_LOCK_MODE_NO_LOCK); + first_conn = spider->conns[first_link_idx]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) + conn = spider->hs_r_conns[link_idx]; + else + conn = spider->hs_w_conns[link_idx]; +#endif + if (first) + { + if (spider->use_pre_call) + { + DBUG_PRINT("info",("spider skip bg first search")); + } else { + DBUG_PRINT("info",("spider bg first search")); + pthread_mutex_lock(&conn->bg_conn_mutex); + result_list->bgs_working = TRUE; + conn->bg_search = TRUE; + conn->bg_caller_wait = TRUE; + conn->bg_target = spider; + conn->link_idx = link_idx; + conn->bg_discard_result = discard_result; + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + conn->bg_caller_wait = FALSE; + if (result_list->bgs_error) + { + if (result_list->bgs_error_with_message) + my_message(result_list->bgs_error, + result_list->bgs_error_msg, MYF(0)); + DBUG_RETURN(result_list->bgs_error); + } + } + if (!result_list->finish_flg) + { + pthread_mutex_lock(&conn->bg_conn_mutex); + if (!result_list->finish_flg) + { + DBUG_PRINT("info",("spider bg second search")); + if (!spider->use_pre_call || pre_next) + { + if (result_list->bgs_error) + { + pthread_mutex_unlock(&conn->bg_conn_mutex); + DBUG_PRINT("info",("spider bg error")); + if (result_list->bgs_error == HA_ERR_END_OF_FILE) + { + DBUG_PRINT("info",("spider bg current->finish_flg=%s", + result_list->current ? + (result_list->current->finish_flg ? "TRUE" : "FALSE") : "NULL")); + DBUG_RETURN(0); + } + if (result_list->bgs_error_with_message) + my_message(result_list->bgs_error, + result_list->bgs_error_msg, MYF(0)); + DBUG_RETURN(result_list->bgs_error); + } + if ( + result_list->quick_mode == 0 || + !result_list->bgs_current->result + ) { + result_list->split_read = + result_list->bgs_second_read > 0 ? + result_list->bgs_second_read : + result_list->bgs_split_read; + result_list->limit_num = + result_list->internal_limit - result_list->record_num >= + result_list->split_read ? + result_list->split_read : + result_list->internal_limit - result_list->record_num; + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = spider->reappend_limit_sql_part( + result_list->internal_offset + result_list->record_num, + result_list->limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + pthread_mutex_unlock(&conn->bg_conn_mutex); + DBUG_RETURN(error_num); + } + if ( + !result_list->use_union && + (error_num = spider->append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + pthread_mutex_unlock(&conn->bg_conn_mutex); + DBUG_RETURN(error_num); + } + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + spider_db_append_handler_next(spider); + if ((error_num = spider->reappend_limit_sql_part( + 0, result_list->limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + pthread_mutex_unlock(&conn->bg_conn_mutex); + DBUG_RETURN(error_num); + } + } + } + result_list->bgs_phase = 2; + } + result_list->bgs_working = TRUE; + conn->bg_search = TRUE; + if (with_lock) + conn->bg_conn_chain_mutex_ptr = &first_conn->bg_conn_chain_mutex; + conn->bg_caller_sync_wait = TRUE; + conn->bg_target = spider; + conn->link_idx = link_idx; + conn->bg_discard_result = discard_result; + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + conn->bg_caller_sync_wait = FALSE; + } else { + pthread_mutex_unlock(&conn->bg_conn_mutex); + DBUG_PRINT("info",("spider bg current->finish_flg=%s", + result_list->current ? + (result_list->current->finish_flg ? "TRUE" : "FALSE") : "NULL")); + } + } else { + DBUG_PRINT("info",("spider bg current->finish_flg=%s", + result_list->current ? + (result_list->current->finish_flg ? "TRUE" : "FALSE") : "NULL")); + } + } else { + DBUG_PRINT("info",("spider bg search")); + if (result_list->current->finish_flg) + { + DBUG_PRINT("info",("spider bg end of file")); + result_list->table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + if (result_list->bgs_working) + { + /* wait */ + DBUG_PRINT("info",("spider bg working wait")); + pthread_mutex_lock(&conn->bg_conn_mutex); + pthread_mutex_unlock(&conn->bg_conn_mutex); + } + if (result_list->bgs_error) + { + DBUG_PRINT("info",("spider bg error")); + if (result_list->bgs_error == HA_ERR_END_OF_FILE) + { + result_list->current = result_list->current->next; + result_list->current_row_num = 0; + result_list->table->status = STATUS_NOT_FOUND; + } + if (result_list->bgs_error_with_message) + my_message(result_list->bgs_error, + result_list->bgs_error_msg, MYF(0)); + DBUG_RETURN(result_list->bgs_error); + } + result_list->current = result_list->current->next; + result_list->current_row_num = 0; + if (result_list->current == result_list->bgs_current) + { + DBUG_PRINT("info",("spider bg next search")); + if (!result_list->current->finish_flg) + { + pthread_mutex_lock(&conn->bg_conn_mutex); + result_list->bgs_phase = 3; + if ( + result_list->quick_mode == 0 || + !result_list->bgs_current->result + ) { + result_list->split_read = result_list->bgs_split_read; + result_list->limit_num = + result_list->internal_limit - result_list->record_num >= + result_list->split_read ? + result_list->split_read : + result_list->internal_limit - result_list->record_num; + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = spider->reappend_limit_sql_part( + result_list->internal_offset + result_list->record_num, + result_list->limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + pthread_mutex_unlock(&conn->bg_conn_mutex); + DBUG_RETURN(error_num); + } + if ( + !result_list->use_union && + (error_num = spider->append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + pthread_mutex_unlock(&conn->bg_conn_mutex); + DBUG_RETURN(error_num); + } + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + spider_db_append_handler_next(spider); + if ((error_num = spider->reappend_limit_sql_part( + 0, result_list->limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + pthread_mutex_unlock(&conn->bg_conn_mutex); + DBUG_RETURN(error_num); + } + } + } + conn->bg_target = spider; + conn->link_idx = link_idx; + conn->bg_discard_result = discard_result; + result_list->bgs_working = TRUE; + conn->bg_search = TRUE; + if (with_lock) + conn->bg_conn_chain_mutex_ptr = &first_conn->bg_conn_chain_mutex; + conn->bg_caller_sync_wait = TRUE; + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + conn->bg_caller_sync_wait = FALSE; + } + } + } + DBUG_RETURN(0); +} + +void spider_bg_conn_simple_action( + SPIDER_CONN *conn, + uint simple_action +) { + DBUG_ENTER("spider_bg_conn_simple_action"); + pthread_mutex_lock(&conn->bg_conn_mutex); + conn->bg_caller_wait = TRUE; + conn->bg_simple_action = simple_action; + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + conn->bg_caller_wait = FALSE; + DBUG_VOID_RETURN; +} + +void *spider_bg_conn_action( + void *arg +) { + int error_num; + SPIDER_CONN *conn = (SPIDER_CONN*) arg; + SPIDER_TRX *trx; + ha_spider *spider; + SPIDER_RESULT_LIST *result_list; + THD *thd; + my_thread_init(); + DBUG_ENTER("spider_bg_conn_action"); + /* init start */ + if (!(thd = new THD())) + { + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_sync_cond); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + my_thread_end(); + DBUG_RETURN(NULL); + } + pthread_mutex_lock(&LOCK_thread_count); + thd->thread_id = (*spd_db_att_thread_id)++; + pthread_mutex_unlock(&LOCK_thread_count); +#ifdef HAVE_PSI_INTERFACE + mysql_thread_set_psi_id(thd->thread_id); +#endif + thd->thread_stack = (char*) &thd; + thd->store_globals(); + if (!(trx = spider_get_trx(thd, FALSE, &error_num))) + { + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_sync_cond); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); + DBUG_RETURN(NULL); + } + /* lex_start(thd); */ + conn->bg_thd = thd; + pthread_mutex_lock(&conn->bg_conn_mutex); + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_sync_cond); + conn->bg_init = TRUE; + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + /* init end */ + + while (TRUE) + { + if (conn->bg_conn_chain_mutex_ptr) + { + pthread_mutex_unlock(conn->bg_conn_chain_mutex_ptr); + conn->bg_conn_chain_mutex_ptr = NULL; + } + thd->clear_error(); + pthread_cond_wait(&conn->bg_conn_cond, &conn->bg_conn_mutex); + DBUG_PRINT("info",("spider bg roop start")); + if (conn->bg_caller_sync_wait) + { + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + if (conn->bg_direct_sql) + conn->bg_get_job_stack_off = TRUE; + pthread_cond_signal(&conn->bg_conn_sync_cond); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + if (conn->bg_conn_chain_mutex_ptr) + { + pthread_mutex_lock(conn->bg_conn_chain_mutex_ptr); + if ((&conn->bg_conn_chain_mutex) != conn->bg_conn_chain_mutex_ptr) + { + pthread_mutex_unlock(conn->bg_conn_chain_mutex_ptr); + conn->bg_conn_chain_mutex_ptr = NULL; + } + } + } + if (conn->bg_kill) + { + DBUG_PRINT("info",("spider bg kill start")); + if (conn->bg_conn_chain_mutex_ptr) + { + pthread_mutex_unlock(conn->bg_conn_chain_mutex_ptr); + conn->bg_conn_chain_mutex_ptr = NULL; + } + spider_free_trx(trx, TRUE); + /* lex_end(thd->lex); */ + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_sync_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); + DBUG_RETURN(NULL); + } + if (conn->bg_get_job_stack) + { + conn->bg_get_job_stack = FALSE; + if (!spider_bg_conn_get_job(conn)) + { + conn->bg_direct_sql = FALSE; + } + } + if (conn->bg_search) + { + SPIDER_SHARE *share; + spider_db_handler *dbton_handler; + DBUG_PRINT("info",("spider bg search start")); + spider = (ha_spider*) conn->bg_target; + share = spider->share; + dbton_handler = spider->dbton_handler[conn->dbton_id]; + result_list = &spider->result_list; + result_list->bgs_error = 0; + result_list->bgs_error_with_message = FALSE; + if ( + result_list->quick_mode == 0 || + result_list->bgs_phase == 1 || + !result_list->bgs_current->result + ) { + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (spider->sql_kind[conn->link_idx] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + sql_type = SPIDER_SQL_TYPE_SELECT_HS; + } +#endif + if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_handler->set_sql_for_exec(sql_type, + conn->link_idx))) + { + result_list->bgs_error = error_num; + if ((result_list->bgs_error_with_message = thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(result_list->bgs_error_msg, thd->main_da.message()); +#else + strmov(result_list->bgs_error_msg, thd->stmt_da->message()); +#endif + } + if (!dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); +#ifdef HA_CAN_BULK_ACCESS + if (spider->is_bulk_access_clone) + { + spider->connection_ids[conn->link_idx] = conn->connection_id; + spider_trx_add_bulk_access_conn(spider->trx, conn); + } +#endif + if (!result_list->bgs_error) + { + conn->need_mon = &spider->need_mons[conn->link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; +#ifdef HA_CAN_BULK_ACCESS + if (!spider->is_bulk_access_clone) + { +#endif + if (!(result_list->bgs_error = + spider_db_set_names(spider, conn, conn->link_idx))) + { + if ( + result_list->tmp_table_join && + spider_bit_is_set(result_list->tmp_table_join_first, + conn->link_idx) + ) { + spider_clear_bit(result_list->tmp_table_join_first, + conn->link_idx); + spider_set_bit(result_list->tmp_table_created, + conn->link_idx); + result_list->tmp_tables_created = TRUE; + spider_conn_set_timeout_from_share(conn, conn->link_idx, + spider->trx->thd, share); + if (dbton_handler->execute_sql( + SPIDER_SQL_TYPE_TMP_SQL, + conn, + -1, + &spider->need_mons[conn->link_idx]) + ) { + result_list->bgs_error = spider_db_errorno(conn); + if ((result_list->bgs_error_with_message = thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(result_list->bgs_error_msg, + thd->main_da.message()); +#else + strmov(result_list->bgs_error_msg, + thd->stmt_da->message()); +#endif + } else + spider_db_discard_multiple_result(spider, conn->link_idx, + conn); + } + if (!result_list->bgs_error) + { + spider_conn_set_timeout_from_share(conn, conn->link_idx, + spider->trx->thd, share); + if (dbton_handler->execute_sql( + sql_type, + conn, + result_list->quick_mode, + &spider->need_mons[conn->link_idx]) + ) { + result_list->bgs_error = spider_db_errorno(conn); + if ((result_list->bgs_error_with_message = thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(result_list->bgs_error_msg, + thd->main_da.message()); +#else + strmov(result_list->bgs_error_msg, + thd->stmt_da->message()); +#endif + } else { + spider->connection_ids[conn->link_idx] = conn->connection_id; + if (!conn->bg_discard_result) + { + if (!(result_list->bgs_error = + spider_db_store_result(spider, conn->link_idx, + result_list->table))) + spider->result_link_idx = conn->link_idx; + else { + if ((result_list->bgs_error_with_message = + thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(result_list->bgs_error_msg, + thd->main_da.message()); +#else + strmov(result_list->bgs_error_msg, + thd->stmt_da->message()); +#endif + } + } else { + result_list->bgs_error = 0; + spider_db_discard_result(spider, conn->link_idx, conn); + } + } + } + } else { + if ((result_list->bgs_error_with_message = thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(result_list->bgs_error_msg, thd->main_da.message()); +#else + strmov(result_list->bgs_error_msg, thd->stmt_da->message()); +#endif + } +#ifdef HA_CAN_BULK_ACCESS + } +#endif + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } else { + spider->connection_ids[conn->link_idx] = conn->connection_id; + conn->mta_conn_mutex_unlock_later = TRUE; + result_list->bgs_error = + spider_db_store_result(spider, conn->link_idx, result_list->table); + if ((result_list->bgs_error_with_message = thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(result_list->bgs_error_msg, thd->main_da.message()); +#else + strmov(result_list->bgs_error_msg, thd->stmt_da->message()); +#endif + conn->mta_conn_mutex_unlock_later = FALSE; + } + conn->bg_search = FALSE; + result_list->bgs_working = FALSE; + if (conn->bg_caller_wait) + { + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_sync_cond); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + } + continue; + } + if (conn->bg_direct_sql) + { + bool is_error = FALSE; + DBUG_PRINT("info",("spider bg direct sql start")); + do { + SPIDER_DIRECT_SQL *direct_sql = (SPIDER_DIRECT_SQL *) conn->bg_target; + if ( + (error_num = spider_db_udf_direct_sql(direct_sql)) + ) { + if (thd->is_error()) + { + SPIDER_BG_DIRECT_SQL *bg_direct_sql = + (SPIDER_BG_DIRECT_SQL *) direct_sql->parent; + pthread_mutex_lock(direct_sql->bg_mutex); +#if MYSQL_VERSION_ID < 50500 + bg_direct_sql->bg_error = thd->main_da.sql_errno(); + strmov((char *) bg_direct_sql->bg_error_msg, + thd->main_da.message()); +#else + bg_direct_sql->bg_error = thd->stmt_da->sql_errno(); + strmov((char *) bg_direct_sql->bg_error_msg, + thd->stmt_da->message()); +#endif + pthread_mutex_unlock(direct_sql->bg_mutex); + is_error = TRUE; + } + } + if (direct_sql->modified_non_trans_table) + { + SPIDER_BG_DIRECT_SQL *bg_direct_sql = + (SPIDER_BG_DIRECT_SQL *) direct_sql->parent; + pthread_mutex_lock(direct_sql->bg_mutex); + bg_direct_sql->modified_non_trans_table = TRUE; + pthread_mutex_unlock(direct_sql->bg_mutex); + } + spider_udf_free_direct_sql_alloc(direct_sql, TRUE); + } while (!is_error && spider_bg_conn_get_job(conn)); + if (is_error) + { + while (spider_bg_conn_get_job(conn)) + spider_udf_free_direct_sql_alloc( + (SPIDER_DIRECT_SQL *) conn->bg_target, TRUE); + } + conn->bg_direct_sql = FALSE; + continue; + } + if (conn->bg_exec_sql) + { + DBUG_PRINT("info",("spider bg exec sql start")); + spider = (ha_spider*) conn->bg_target; + *conn->bg_error_num = spider_db_query_with_set_names( + conn->bg_sql_type, + spider, + conn, + conn->link_idx + ); + conn->bg_exec_sql = FALSE; + continue; + } + if (conn->bg_simple_action) + { + switch (conn->bg_simple_action) + { + case SPIDER_BG_SIMPLE_CONNECT: + conn->db_conn->bg_connect(); + break; + case SPIDER_BG_SIMPLE_DISCONNECT: + conn->db_conn->bg_disconnect(); + break; + default: + break; + } + conn->bg_simple_action = SPIDER_BG_SIMPLE_NO_ACTION; + if (conn->bg_caller_wait) + { + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_sync_cond); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + } + continue; + } + if (conn->bg_break) + { + DBUG_PRINT("info",("spider bg break start")); + spider = (ha_spider*) conn->bg_target; + result_list = &spider->result_list; + result_list->bgs_working = FALSE; + continue; + } + } +} + +int spider_create_sts_thread( + SPIDER_SHARE *share +) { + int error_num; + DBUG_ENTER("spider_create_sts_thread"); + if (!share->bg_sts_init) + { +#if MYSQL_VERSION_ID < 50500 + if (pthread_cond_init(&share->bg_sts_cond, NULL)) +#else + if (mysql_cond_init(spd_key_cond_bg_sts, + &share->bg_sts_cond, NULL)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_cond_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_cond_init(&share->bg_sts_sync_cond, NULL)) +#else + if (mysql_cond_init(spd_key_cond_bg_sts_sync, + &share->bg_sts_sync_cond, NULL)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_sync_cond_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_create(&share->bg_sts_thread, &spider_pt_attr, + spider_bg_sts_action, (void *) share) + ) +#else + if (mysql_thread_create(spd_key_thd_bg_sts, &share->bg_sts_thread, + &spider_pt_attr, spider_bg_sts_action, (void *) share) + ) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_thread_create; + } + share->bg_sts_init = TRUE; + } + DBUG_RETURN(0); + +error_thread_create: + pthread_cond_destroy(&share->bg_sts_sync_cond); +error_sync_cond_init: + pthread_cond_destroy(&share->bg_sts_cond); +error_cond_init: + DBUG_RETURN(error_num); +} + +void spider_free_sts_thread( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_free_sts_thread"); + if (share->bg_sts_init) + { + pthread_mutex_lock(&share->sts_mutex); + share->bg_sts_kill = TRUE; + pthread_cond_signal(&share->bg_sts_cond); + pthread_cond_wait(&share->bg_sts_sync_cond, &share->sts_mutex); + pthread_mutex_unlock(&share->sts_mutex); + pthread_join(share->bg_sts_thread, NULL); + pthread_cond_destroy(&share->bg_sts_sync_cond); + pthread_cond_destroy(&share->bg_sts_cond); + share->bg_sts_thd_wait = FALSE; + share->bg_sts_kill = FALSE; + share->bg_sts_init = FALSE; + } + DBUG_VOID_RETURN; +} + +void *spider_bg_sts_action( + void *arg +) { + SPIDER_SHARE *share = (SPIDER_SHARE*) arg; + SPIDER_TRX *trx; + int error_num = 0, roop_count; + ha_spider spider; +#ifdef _MSC_VER + int *need_mons; + SPIDER_CONN **conns; + uint *conn_link_idx; + uchar *conn_can_fo; + char **conn_keys; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char **hs_r_conn_keys; + char **hs_w_conn_keys; +#endif + spider_db_handler **dbton_hdl; +#else + int need_mons[share->link_count]; + SPIDER_CONN *conns[share->link_count]; + uint conn_link_idx[share->link_count]; + uchar conn_can_fo[share->link_bitmap_size]; + char *conn_keys[share->link_count]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char *hs_r_conn_keys[share->link_count]; + char *hs_w_conn_keys[share->link_count]; +#endif + spider_db_handler *dbton_hdl[SPIDER_DBTON_SIZE]; +#endif + THD *thd; + my_thread_init(); + DBUG_ENTER("spider_bg_sts_action"); + /* init start */ +#ifdef _MSC_VER +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!(need_mons = (int *) + spider_bulk_malloc(spider_current_trx, 21, MYF(MY_WME), + &need_mons, sizeof(int) * share->link_count, + &conns, sizeof(SPIDER_CONN *) * share->link_count, + &conn_link_idx, sizeof(uint) * share->link_count, + &conn_can_fo, sizeof(uchar) * share->link_bitmap_size, + &conn_keys, sizeof(char *) * share->link_count, + &hs_r_conn_keys, sizeof(char *) * share->link_count, + &hs_w_conn_keys, sizeof(char *) * share->link_count, + &dbton_hdl, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + NullS)) + ) +#else + if (!(need_mons = (int *) + spider_bulk_malloc(spider_current_trx, 21, MYF(MY_WME), + &need_mons, sizeof(int) * share->link_count, + &conns, sizeof(SPIDER_CONN *) * share->link_count, + &conn_link_idx, sizeof(uint) * share->link_count, + &conn_can_fo, sizeof(uchar) * share->link_bitmap_size, + &conn_keys, sizeof(char *) * share->link_count, + &dbton_hdl, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + NullS)) + ) +#endif + { + pthread_mutex_lock(&share->sts_mutex); + share->bg_sts_thd_wait = FALSE; + share->bg_sts_kill = FALSE; + share->bg_sts_init = FALSE; + pthread_mutex_unlock(&share->sts_mutex); + my_thread_end(); + DBUG_RETURN(NULL); + } +#endif + pthread_mutex_lock(&share->sts_mutex); + if (!(thd = new THD())) + { + share->bg_sts_thd_wait = FALSE; + share->bg_sts_kill = FALSE; + share->bg_sts_init = FALSE; + pthread_mutex_unlock(&share->sts_mutex); + my_thread_end(); +#ifdef _MSC_VER + spider_free(NULL, need_mons, MYF(MY_WME)); +#endif + DBUG_RETURN(NULL); + } + pthread_mutex_lock(&LOCK_thread_count); + thd->thread_id = (*spd_db_att_thread_id)++; + pthread_mutex_unlock(&LOCK_thread_count); +#ifdef HAVE_PSI_INTERFACE + mysql_thread_set_psi_id(thd->thread_id); +#endif + thd->thread_stack = (char*) &thd; + thd->store_globals(); + if (!(trx = spider_get_trx(thd, FALSE, &error_num))) + { + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + share->bg_sts_thd_wait = FALSE; + share->bg_sts_kill = FALSE; + share->bg_sts_init = FALSE; + pthread_mutex_unlock(&share->sts_mutex); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); +#ifdef _MSC_VER + spider_free(NULL, need_mons, MYF(MY_WME)); +#endif + DBUG_RETURN(NULL); + } + share->bg_sts_thd = thd; +/* + spider.trx = spider_global_trx; +*/ + spider.trx = trx; + spider.share = share; + spider.conns = conns; + spider.conn_link_idx = conn_link_idx; + spider.conn_can_fo = conn_can_fo; + spider.need_mons = need_mons; + spider.conn_keys_first_ptr = share->conn_keys[0]; + spider.conn_keys = conn_keys; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider.hs_r_conn_keys = hs_r_conn_keys; + spider.hs_w_conn_keys = hs_w_conn_keys; +#endif + spider.dbton_handler = dbton_hdl; + memset(conns, 0, sizeof(SPIDER_CONN *) * share->link_count); + memset(need_mons, 0, sizeof(int) * share->link_count); + memset(dbton_hdl, 0, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE); + spider_trx_set_link_idx_for_all(&spider); + spider.search_link_idx = spider_conn_first_link_idx(thd, + share->link_statuses, share->access_balances, spider.conn_link_idx, + share->link_count, SPIDER_LINK_STATUS_OK); + for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++) + { + if ( + spider_bit_is_set(share->dbton_bitmap, roop_count) && + spider_dbton[roop_count].create_db_handler + ) { + if ((dbton_hdl[roop_count] = spider_dbton[roop_count].create_db_handler( + &spider, share->dbton_share[roop_count]))) + break; + if (dbton_hdl[roop_count]->init()) + break; + } + } + if (roop_count == SPIDER_DBTON_SIZE) + { + DBUG_PRINT("info",("spider handler init error")); + for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; --roop_count) + { + if ( + spider_bit_is_set(share->dbton_bitmap, roop_count) && + dbton_hdl[roop_count] + ) { + delete dbton_hdl[roop_count]; + dbton_hdl[roop_count] = NULL; + } + } + spider_free_trx(trx, TRUE); + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + share->bg_sts_thd_wait = FALSE; + share->bg_sts_kill = FALSE; + share->bg_sts_init = FALSE; + pthread_mutex_unlock(&share->sts_mutex); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); +#ifdef _MSC_VER + spider_free(NULL, need_mons, MYF(MY_WME)); +#endif + DBUG_RETURN(NULL); + } + /* init end */ + + while (TRUE) + { + DBUG_PRINT("info",("spider bg sts roop start")); + if (share->bg_sts_kill) + { + DBUG_PRINT("info",("spider bg sts kill start")); + for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; --roop_count) + { + if ( + spider_bit_is_set(share->dbton_bitmap, roop_count) && + dbton_hdl[roop_count] + ) { + delete dbton_hdl[roop_count]; + dbton_hdl[roop_count] = NULL; + } + } + spider_free_trx(trx, TRUE); + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + pthread_cond_signal(&share->bg_sts_sync_cond); + pthread_mutex_unlock(&share->sts_mutex); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); +#ifdef _MSC_VER + spider_free(NULL, need_mons, MYF(MY_WME)); +#endif + DBUG_RETURN(NULL); + } + if (spider.search_link_idx == -1) + { + spider_trx_set_link_idx_for_all(&spider); + spider.search_link_idx = spider_conn_next_link_idx( + thd, share->link_statuses, share->access_balances, + spider.conn_link_idx, spider.search_link_idx, share->link_count, + SPIDER_LINK_STATUS_OK); + } + if (spider.search_link_idx >= 0) + { + if (difftime(share->bg_sts_try_time, share->sts_get_time) >= + share->bg_sts_interval) + { + if (!conns[spider.search_link_idx]) + { + pthread_mutex_lock(&spider_global_trx_mutex); + spider_get_conn(share, spider.search_link_idx, + share->conn_keys[spider.search_link_idx], + spider_global_trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, + &error_num); + conns[spider.search_link_idx]->error_mode = 0; + pthread_mutex_unlock(&spider_global_trx_mutex); + if ( + error_num && + share->monitoring_kind[spider.search_link_idx] && + need_mons[spider.search_link_idx] + ) { + lex_start(thd); + error_num = spider_ping_table_mon_from_table( + spider_global_trx, + thd, + share, + (uint32) share->monitoring_sid[spider.search_link_idx], + share->table_name, + share->table_name_length, + spider.conn_link_idx[spider.search_link_idx], + NULL, + 0, + share->monitoring_kind[spider.search_link_idx], + share->monitoring_limit[spider.search_link_idx], + TRUE + ); + lex_end(thd->lex); + } + } + if (conns[spider.search_link_idx]) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (spider_get_sts(share, spider.search_link_idx, + share->bg_sts_try_time, &spider, + share->bg_sts_interval, share->bg_sts_mode, + share->bg_sts_sync, + 2, HA_STATUS_CONST | HA_STATUS_VARIABLE)) +#else + if (spider_get_sts(share, spider.search_link_idx, + share->bg_sts_try_time, &spider, + share->bg_sts_interval, share->bg_sts_mode, + 2, HA_STATUS_CONST | HA_STATUS_VARIABLE)) +#endif + { + if ( + share->monitoring_kind[spider.search_link_idx] && + need_mons[spider.search_link_idx] + ) { + lex_start(thd); + error_num = spider_ping_table_mon_from_table( + spider_global_trx, + thd, + share, + (uint32) share->monitoring_sid[spider.search_link_idx], + share->table_name, + share->table_name_length, + spider.conn_link_idx[spider.search_link_idx], + NULL, + 0, + share->monitoring_kind[spider.search_link_idx], + share->monitoring_limit[spider.search_link_idx], + TRUE + ); + lex_end(thd->lex); + } + spider.search_link_idx = -1; + } + } + } + } + memset(need_mons, 0, sizeof(int) * share->link_count); + share->bg_sts_thd_wait = TRUE; + pthread_cond_wait(&share->bg_sts_cond, &share->sts_mutex); + } +} + +int spider_create_crd_thread( + SPIDER_SHARE *share +) { + int error_num; + DBUG_ENTER("spider_create_crd_thread"); + if (!share->bg_crd_init) + { +#if MYSQL_VERSION_ID < 50500 + if (pthread_cond_init(&share->bg_crd_cond, NULL)) +#else + if (mysql_cond_init(spd_key_cond_bg_crd, + &share->bg_crd_cond, NULL)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_cond_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_cond_init(&share->bg_crd_sync_cond, NULL)) +#else + if (mysql_cond_init(spd_key_cond_bg_crd_sync, + &share->bg_crd_sync_cond, NULL)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_sync_cond_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_create(&share->bg_crd_thread, &spider_pt_attr, + spider_bg_crd_action, (void *) share) + ) +#else + if (mysql_thread_create(spd_key_thd_bg_crd, &share->bg_crd_thread, + &spider_pt_attr, spider_bg_crd_action, (void *) share) + ) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_thread_create; + } + share->bg_crd_init = TRUE; + } + DBUG_RETURN(0); + +error_thread_create: + pthread_cond_destroy(&share->bg_crd_sync_cond); +error_sync_cond_init: + pthread_cond_destroy(&share->bg_crd_cond); +error_cond_init: + DBUG_RETURN(error_num); +} + +void spider_free_crd_thread( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_free_crd_thread"); + if (share->bg_crd_init) + { + pthread_mutex_lock(&share->crd_mutex); + share->bg_crd_kill = TRUE; + pthread_cond_signal(&share->bg_crd_cond); + pthread_cond_wait(&share->bg_crd_sync_cond, &share->crd_mutex); + pthread_mutex_unlock(&share->crd_mutex); + pthread_join(share->bg_crd_thread, NULL); + pthread_cond_destroy(&share->bg_crd_sync_cond); + pthread_cond_destroy(&share->bg_crd_cond); + share->bg_crd_thd_wait = FALSE; + share->bg_crd_kill = FALSE; + share->bg_crd_init = FALSE; + } + DBUG_VOID_RETURN; +} + +void *spider_bg_crd_action( + void *arg +) { + SPIDER_SHARE *share = (SPIDER_SHARE*) arg; + SPIDER_TRX *trx; + int error_num = 0, roop_count; + ha_spider spider; + TABLE table; +#ifdef _MSC_VER + int *need_mons; + SPIDER_CONN **conns; + uint *conn_link_idx; + uchar *conn_can_fo; + char **conn_keys; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char **hs_r_conn_keys; + char **hs_w_conn_keys; +#endif + spider_db_handler **dbton_hdl; +#else + int need_mons[share->link_count]; + SPIDER_CONN *conns[share->link_count]; + uint conn_link_idx[share->link_count]; + uchar conn_can_fo[share->link_bitmap_size]; + char *conn_keys[share->link_count]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char *hs_r_conn_keys[share->link_count]; + char *hs_w_conn_keys[share->link_count]; +#endif + spider_db_handler *dbton_hdl[SPIDER_DBTON_SIZE]; +#endif + THD *thd; + my_thread_init(); + DBUG_ENTER("spider_bg_crd_action"); + /* init start */ +#ifdef _MSC_VER +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!(need_mons = (int *) + spider_bulk_malloc(spider_current_trx, 22, MYF(MY_WME), + &need_mons, sizeof(int) * share->link_count, + &conns, sizeof(SPIDER_CONN *) * share->link_count, + &conn_link_idx, sizeof(uint) * share->link_count, + &conn_can_fo, sizeof(uchar) * share->link_bitmap_size, + &conn_keys, sizeof(char *) * share->link_count, + &hs_r_conn_keys, sizeof(char *) * share->link_count, + &hs_w_conn_keys, sizeof(char *) * share->link_count, + &dbton_hdl, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + NullS)) + ) +#else + if (!(need_mons = (int *) + spider_bulk_malloc(spider_current_trx, 22, MYF(MY_WME), + &need_mons, sizeof(int) * share->link_count, + &conns, sizeof(SPIDER_CONN *) * share->link_count, + &conn_link_idx, sizeof(uint) * share->link_count, + &conn_can_fo, sizeof(uchar) * share->link_bitmap_size, + &conn_keys, sizeof(char *) * share->link_count, + &dbton_hdl, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + NullS)) + ) +#endif + { + pthread_mutex_lock(&share->crd_mutex); + share->bg_crd_thd_wait = FALSE; + share->bg_crd_kill = FALSE; + share->bg_crd_init = FALSE; + pthread_mutex_unlock(&share->crd_mutex); + my_thread_end(); + DBUG_RETURN(NULL); + } +#endif + pthread_mutex_lock(&share->crd_mutex); + if (!(thd = new THD())) + { + share->bg_crd_thd_wait = FALSE; + share->bg_crd_kill = FALSE; + share->bg_crd_init = FALSE; + pthread_mutex_unlock(&share->crd_mutex); + my_thread_end(); +#ifdef _MSC_VER + spider_free(NULL, need_mons, MYF(MY_WME)); +#endif + DBUG_RETURN(NULL); + } + pthread_mutex_lock(&LOCK_thread_count); + thd->thread_id = (*spd_db_att_thread_id)++; + pthread_mutex_unlock(&LOCK_thread_count); +#ifdef HAVE_PSI_INTERFACE + mysql_thread_set_psi_id(thd->thread_id); +#endif + thd->thread_stack = (char*) &thd; + thd->store_globals(); + if (!(trx = spider_get_trx(thd, FALSE, &error_num))) + { + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + share->bg_crd_thd_wait = FALSE; + share->bg_crd_kill = FALSE; + share->bg_crd_init = FALSE; + pthread_mutex_unlock(&share->crd_mutex); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); +#ifdef _MSC_VER + spider_free(NULL, need_mons, MYF(MY_WME)); +#endif + DBUG_RETURN(NULL); + } + share->bg_crd_thd = thd; + table.s = share->table_share; + table.field = share->table_share->field; + table.key_info = share->table_share->key_info; +/* + spider.trx = spider_global_trx; +*/ + spider.trx = trx; + spider.change_table_ptr(&table, share->table_share); + spider.share = share; + spider.conns = conns; + spider.conn_link_idx = conn_link_idx; + spider.conn_can_fo = conn_can_fo; + spider.need_mons = need_mons; + spider.conn_keys_first_ptr = share->conn_keys[0]; + spider.conn_keys = conn_keys; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider.hs_r_conn_keys = hs_r_conn_keys; + spider.hs_w_conn_keys = hs_w_conn_keys; +#endif + spider.dbton_handler = dbton_hdl; + memset(conns, 0, sizeof(SPIDER_CONN *) * share->link_count); + memset(need_mons, 0, sizeof(int) * share->link_count); + memset(dbton_hdl, 0, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE); + spider_trx_set_link_idx_for_all(&spider); + spider.search_link_idx = spider_conn_first_link_idx(thd, + share->link_statuses, share->access_balances, spider.conn_link_idx, + share->link_count, SPIDER_LINK_STATUS_OK); + for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++) + { + if ( + spider_bit_is_set(share->dbton_bitmap, roop_count) && + spider_dbton[roop_count].create_db_handler + ) { + if ((dbton_hdl[roop_count] = spider_dbton[roop_count].create_db_handler( + &spider, share->dbton_share[roop_count]))) + break; + if (dbton_hdl[roop_count]->init()) + break; + } + } + if (roop_count == SPIDER_DBTON_SIZE) + { + DBUG_PRINT("info",("spider handler init error")); + for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; --roop_count) + { + if ( + spider_bit_is_set(share->dbton_bitmap, roop_count) && + dbton_hdl[roop_count] + ) { + delete dbton_hdl[roop_count]; + dbton_hdl[roop_count] = NULL; + } + } + spider_free_trx(trx, TRUE); + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + share->bg_crd_thd_wait = FALSE; + share->bg_crd_kill = FALSE; + share->bg_crd_init = FALSE; + pthread_mutex_unlock(&share->crd_mutex); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); +#ifdef _MSC_VER + spider_free(NULL, need_mons, MYF(MY_WME)); +#endif + DBUG_RETURN(NULL); + } + /* init end */ + + while (TRUE) + { + DBUG_PRINT("info",("spider bg crd roop start")); + if (share->bg_crd_kill) + { + DBUG_PRINT("info",("spider bg crd kill start")); + for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; --roop_count) + { + if ( + spider_bit_is_set(share->dbton_bitmap, roop_count) && + dbton_hdl[roop_count] + ) { + delete dbton_hdl[roop_count]; + dbton_hdl[roop_count] = NULL; + } + } + spider_free_trx(trx, TRUE); + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + pthread_cond_signal(&share->bg_crd_sync_cond); + pthread_mutex_unlock(&share->crd_mutex); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); +#ifdef _MSC_VER + spider_free(NULL, need_mons, MYF(MY_WME)); +#endif + DBUG_RETURN(NULL); + } + if (spider.search_link_idx == -1) + { + spider_trx_set_link_idx_for_all(&spider); + spider.search_link_idx = spider_conn_next_link_idx( + thd, share->link_statuses, share->access_balances, + spider.conn_link_idx, spider.search_link_idx, share->link_count, + SPIDER_LINK_STATUS_OK); + } + if (spider.search_link_idx >= 0) + { + if (difftime(share->bg_crd_try_time, share->crd_get_time) >= + share->bg_crd_interval) + { + if (!conns[spider.search_link_idx]) + { + pthread_mutex_lock(&spider_global_trx_mutex); + spider_get_conn(share, spider.search_link_idx, + share->conn_keys[spider.search_link_idx], + spider_global_trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, + &error_num); + conns[spider.search_link_idx]->error_mode = 0; + pthread_mutex_unlock(&spider_global_trx_mutex); + if ( + error_num && + share->monitoring_kind[spider.search_link_idx] && + need_mons[spider.search_link_idx] + ) { + lex_start(thd); + error_num = spider_ping_table_mon_from_table( + spider_global_trx, + thd, + share, + (uint32) share->monitoring_sid[spider.search_link_idx], + share->table_name, + share->table_name_length, + spider.conn_link_idx[spider.search_link_idx], + NULL, + 0, + share->monitoring_kind[spider.search_link_idx], + share->monitoring_limit[spider.search_link_idx], + TRUE + ); + lex_end(thd->lex); + } + } + if (conns[spider.search_link_idx]) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (spider_get_crd(share, spider.search_link_idx, + share->bg_crd_try_time, &spider, &table, + share->bg_crd_interval, share->bg_crd_mode, + share->bg_crd_sync, + 2)) +#else + if (spider_get_crd(share, spider.search_link_idx, + share->bg_crd_try_time, &spider, &table, + share->bg_crd_interval, share->bg_crd_mode, + 2)) +#endif + { + if ( + share->monitoring_kind[spider.search_link_idx] && + need_mons[spider.search_link_idx] + ) { + lex_start(thd); + error_num = spider_ping_table_mon_from_table( + spider_global_trx, + thd, + share, + (uint32) share->monitoring_sid[spider.search_link_idx], + share->table_name, + share->table_name_length, + spider.conn_link_idx[spider.search_link_idx], + NULL, + 0, + share->monitoring_kind[spider.search_link_idx], + share->monitoring_limit[spider.search_link_idx], + TRUE + ); + lex_end(thd->lex); + } + spider.search_link_idx = -1; + } + } + } + } + memset(need_mons, 0, sizeof(int) * share->link_count); + share->bg_crd_thd_wait = TRUE; + pthread_cond_wait(&share->bg_crd_cond, &share->crd_mutex); + } +} + +int spider_create_mon_threads( + SPIDER_TRX *trx, + SPIDER_SHARE *share +) { + bool create_bg_mons = FALSE; + int error_num, roop_count, roop_count2; + SPIDER_LINK_PACK link_pack; + SPIDER_TABLE_MON_LIST *table_mon_list; + DBUG_ENTER("spider_create_mon_threads"); + if (!share->bg_mon_init) + { + for (roop_count = 0; roop_count < (int) share->all_link_count; + roop_count++) + { + if (share->monitoring_bg_kind[roop_count]) + { + create_bg_mons = TRUE; + break; + } + } + if (create_bg_mons) + { + char link_idx_str[SPIDER_SQL_INT_LEN]; + int link_idx_str_length; +#ifdef _MSC_VER + spider_string conv_name_str(share->table_name_length + + SPIDER_SQL_INT_LEN + 1); + conv_name_str.set_charset(system_charset_info); +#else + char buf[share->table_name_length + SPIDER_SQL_INT_LEN + 1]; + spider_string conv_name_str(buf, share->table_name_length + + SPIDER_SQL_INT_LEN + 1, system_charset_info); +#endif + conv_name_str.init_calc_mem(105); + conv_name_str.length(0); + conv_name_str.q_append(share->table_name, share->table_name_length); + for (roop_count = 0; roop_count < (int) share->all_link_count; + roop_count++) + { + if (share->monitoring_bg_kind[roop_count]) + { + conv_name_str.length(share->table_name_length); + link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, + "%010d", roop_count)); + conv_name_str.q_append(link_idx_str, link_idx_str_length + 1); + conv_name_str.length(conv_name_str.length() - 1); + if (!(table_mon_list = spider_get_ping_table_mon_list(trx, trx->thd, + &conv_name_str, share->table_name_length, roop_count, + (uint32) share->monitoring_sid[roop_count], FALSE, &error_num))) + goto error_get_ping_table_mon_list; + spider_free_ping_table_mon_list(table_mon_list); + } + } + if (!(share->bg_mon_thds = (THD **) + spider_bulk_malloc(spider_current_trx, 23, MYF(MY_WME | MY_ZEROFILL), + &share->bg_mon_thds, sizeof(THD *) * share->all_link_count, + &share->bg_mon_threads, sizeof(pthread_t) * share->all_link_count, + &share->bg_mon_mutexes, sizeof(pthread_mutex_t) * + share->all_link_count, + &share->bg_mon_conds, sizeof(pthread_cond_t) * share->all_link_count, + NullS)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_base; + } + for (roop_count = 0; roop_count < (int) share->all_link_count; + roop_count++) + { + if ( + share->monitoring_bg_kind[roop_count] && +#if MYSQL_VERSION_ID < 50500 + pthread_mutex_init(&share->bg_mon_mutexes[roop_count], + MY_MUTEX_INIT_FAST) +#else + mysql_mutex_init(spd_key_mutex_bg_mon, + &share->bg_mon_mutexes[roop_count], MY_MUTEX_INIT_FAST) +#endif + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_mutex_init; + } + } + for (roop_count = 0; roop_count < (int) share->all_link_count; + roop_count++) + { + if ( + share->monitoring_bg_kind[roop_count] && +#if MYSQL_VERSION_ID < 50500 + pthread_cond_init(&share->bg_mon_conds[roop_count], NULL) +#else + mysql_cond_init(spd_key_cond_bg_mon, + &share->bg_mon_conds[roop_count], NULL) +#endif + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_cond_init; + } + } + link_pack.share = share; + for (roop_count = 0; roop_count < (int) share->all_link_count; + roop_count++) + { + if (share->monitoring_bg_kind[roop_count]) + { + link_pack.link_idx = roop_count; + pthread_mutex_lock(&share->bg_mon_mutexes[roop_count]); +#if MYSQL_VERSION_ID < 50500 + if (pthread_create(&share->bg_mon_threads[roop_count], + &spider_pt_attr, spider_bg_mon_action, (void *) &link_pack) + ) +#else + if (mysql_thread_create(spd_key_thd_bg_mon, + &share->bg_mon_threads[roop_count], &spider_pt_attr, + spider_bg_mon_action, (void *) &link_pack) + ) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_thread_create; + } + pthread_cond_wait(&share->bg_mon_conds[roop_count], + &share->bg_mon_mutexes[roop_count]); + pthread_mutex_unlock(&share->bg_mon_mutexes[roop_count]); + } + } + share->bg_mon_init = TRUE; + } + } + DBUG_RETURN(0); + +error_thread_create: + roop_count2 = roop_count; + for (roop_count--; roop_count >= 0; roop_count--) + { + if (share->monitoring_bg_kind[roop_count]) + pthread_mutex_lock(&share->bg_mon_mutexes[roop_count]); + } + share->bg_mon_kill = TRUE; + for (roop_count = roop_count2 - 1; roop_count >= 0; roop_count--) + { + if (share->monitoring_bg_kind[roop_count]) + { + pthread_cond_wait(&share->bg_mon_conds[roop_count], + &share->bg_mon_mutexes[roop_count]); + pthread_mutex_unlock(&share->bg_mon_mutexes[roop_count]); + } + } + share->bg_mon_kill = FALSE; + roop_count = share->all_link_count; +error_cond_init: + for (roop_count--; roop_count >= 0; roop_count--) + { + if (share->monitoring_bg_kind[roop_count]) + pthread_cond_destroy(&share->bg_mon_conds[roop_count]); + } + roop_count = share->all_link_count; +error_mutex_init: + for (roop_count--; roop_count >= 0; roop_count--) + { + if (share->monitoring_bg_kind[roop_count]) + pthread_mutex_destroy(&share->bg_mon_mutexes[roop_count]); + } + spider_free(spider_current_trx, share->bg_mon_thds, MYF(0)); +error_alloc_base: +error_get_ping_table_mon_list: + DBUG_RETURN(error_num); +} + +void spider_free_mon_threads( + SPIDER_SHARE *share +) { + int roop_count; + DBUG_ENTER("spider_free_mon_threads"); + if (share->bg_mon_init) + { + for (roop_count = 0; roop_count < (int) share->all_link_count; + roop_count++) + { + if (share->monitoring_bg_kind[roop_count]) + pthread_mutex_lock(&share->bg_mon_mutexes[roop_count]); + } + share->bg_mon_kill = TRUE; + for (roop_count = 0; roop_count < (int) share->all_link_count; + roop_count++) + { + if (share->monitoring_bg_kind[roop_count]) + { + pthread_cond_wait(&share->bg_mon_conds[roop_count], + &share->bg_mon_mutexes[roop_count]); + pthread_mutex_unlock(&share->bg_mon_mutexes[roop_count]); + pthread_join(share->bg_mon_threads[roop_count], NULL); + pthread_cond_destroy(&share->bg_mon_conds[roop_count]); + pthread_mutex_destroy(&share->bg_mon_mutexes[roop_count]); + } + } + spider_free(spider_current_trx, share->bg_mon_thds, MYF(0)); + share->bg_mon_kill = FALSE; + share->bg_mon_init = FALSE; + } + DBUG_VOID_RETURN; +} + +void *spider_bg_mon_action( + void *arg +) { + SPIDER_LINK_PACK *link_pack = (SPIDER_LINK_PACK*) arg; + SPIDER_SHARE *share = link_pack->share; + SPIDER_TRX *trx; + int error_num, link_idx = link_pack->link_idx; + THD *thd; + my_thread_init(); + DBUG_ENTER("spider_bg_mon_action"); + /* init start */ + pthread_mutex_lock(&share->bg_mon_mutexes[link_idx]); + if (!(thd = new THD())) + { + share->bg_mon_kill = FALSE; + share->bg_mon_init = FALSE; + pthread_cond_signal(&share->bg_mon_conds[link_idx]); + pthread_mutex_unlock(&share->bg_mon_mutexes[link_idx]); + my_thread_end(); + DBUG_RETURN(NULL); + } + pthread_mutex_lock(&LOCK_thread_count); + thd->thread_id = (*spd_db_att_thread_id)++; + pthread_mutex_unlock(&LOCK_thread_count); +#ifdef HAVE_PSI_INTERFACE + mysql_thread_set_psi_id(thd->thread_id); +#endif + thd->thread_stack = (char*) &thd; + thd->store_globals(); + if (!(trx = spider_get_trx(thd, FALSE, &error_num))) + { + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif + share->bg_mon_kill = FALSE; + share->bg_mon_init = FALSE; + pthread_cond_signal(&share->bg_mon_conds[link_idx]); + pthread_mutex_unlock(&share->bg_mon_mutexes[link_idx]); +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); + DBUG_RETURN(NULL); + } + share->bg_mon_thds[link_idx] = thd; + pthread_cond_signal(&share->bg_mon_conds[link_idx]); + pthread_mutex_unlock(&share->bg_mon_mutexes[link_idx]); + /* init end */ + + while (TRUE) + { + DBUG_PRINT("info",("spider bg mon sleep %lld", + share->monitoring_bg_interval[link_idx])); + if (!share->bg_mon_kill) + my_sleep((ulong) share->monitoring_bg_interval[link_idx]); + DBUG_PRINT("info",("spider bg mon roop start")); + if (share->bg_mon_kill) + { + DBUG_PRINT("info",("spider bg mon kill start")); + pthread_mutex_lock(&share->bg_mon_mutexes[link_idx]); + pthread_cond_signal(&share->bg_mon_conds[link_idx]); + pthread_mutex_unlock(&share->bg_mon_mutexes[link_idx]); + spider_free_trx(trx, TRUE); + delete thd; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + set_current_thd(NULL); +#endif +#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32) + my_pthread_setspecific_ptr(THR_THD, NULL); +#endif + my_thread_end(); + DBUG_RETURN(NULL); + } + if (share->monitoring_bg_kind[link_idx]) + { + lex_start(thd); + error_num = spider_ping_table_mon_from_table( + spider_global_trx, + thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + link_idx, + NULL, + 0, + share->monitoring_bg_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + lex_end(thd->lex); + } + } +} +#endif + +int spider_conn_first_link_idx( + THD *thd, + long *link_statuses, + long *access_balances, + uint *conn_link_idx, + int link_count, + int link_status +) { + int roop_count, active_links = 0; + longlong balance_total = 0, balance_val; + double rand_val; +#ifdef _MSC_VER + int *link_idxs, link_idx; + long *balances; +#else + int link_idxs[link_count]; + long balances[link_count]; +#endif + DBUG_ENTER("spider_conn_first_link_idx"); +#ifdef _MSC_VER + if (!(link_idxs = (int *) + spider_bulk_malloc(spider_current_trx, 24, MYF(MY_WME), + &link_idxs, sizeof(int) * link_count, + &balances, sizeof(long) * link_count, + NullS)) + ) { + DBUG_PRINT("info",("spider out of memory")); + DBUG_RETURN(-1); + } +#endif + for (roop_count = 0; roop_count < link_count; roop_count++) + { + DBUG_ASSERT((conn_link_idx[roop_count] - roop_count) % link_count == 0); + if (link_statuses[conn_link_idx[roop_count]] <= link_status) + { + link_idxs[active_links] = roop_count; + balances[active_links] = access_balances[roop_count]; + balance_total += access_balances[roop_count]; + active_links++; + } + } + + if (active_links == 0) + { + DBUG_PRINT("info",("spider all links are failed")); +#ifdef _MSC_VER + spider_free(spider_current_trx, link_idxs, MYF(MY_WME)); +#endif + DBUG_RETURN(-1); + } +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 + DBUG_PRINT("info",("spider server_id=%lu", thd->variables.server_id)); +#else + DBUG_PRINT("info",("spider server_id=%u", thd->server_id)); +#endif + DBUG_PRINT("info",("spider thread_id=%lu", thd_get_thread_id(thd))); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 + rand_val = spider_rand(thd->variables.server_id + thd_get_thread_id(thd)); +#else + rand_val = spider_rand(thd->server_id + thd_get_thread_id(thd)); +#endif + DBUG_PRINT("info",("spider rand_val=%f", rand_val)); + balance_val = (longlong) (rand_val * balance_total); + DBUG_PRINT("info",("spider balance_val=%lld", balance_val)); + for (roop_count = 0; roop_count < active_links - 1; roop_count++) + { + DBUG_PRINT("info",("spider balances[%d]=%ld", + roop_count, balances[roop_count])); + if (balance_val < balances[roop_count]) + break; + balance_val -= balances[roop_count]; + } + + DBUG_PRINT("info",("spider first link_idx=%d", link_idxs[roop_count])); +#ifdef _MSC_VER + link_idx = link_idxs[roop_count]; + spider_free(spider_current_trx, link_idxs, MYF(MY_WME)); + DBUG_RETURN(link_idx); +#else + DBUG_RETURN(link_idxs[roop_count]); +#endif +} + +int spider_conn_next_link_idx( + THD *thd, + long *link_statuses, + long *access_balances, + uint *conn_link_idx, + int link_idx, + int link_count, + int link_status +) { + int tmp_link_idx; + DBUG_ENTER("spider_conn_next_link_idx"); + DBUG_ASSERT((conn_link_idx[link_idx] - link_idx) % link_count == 0); + tmp_link_idx = spider_conn_first_link_idx(thd, link_statuses, + access_balances, conn_link_idx, link_count, link_status); + if ( + tmp_link_idx >= 0 && + tmp_link_idx == link_idx + ) { + do { + tmp_link_idx++; + if (tmp_link_idx >= link_count) + tmp_link_idx = 0; + if (tmp_link_idx == link_idx) + break; + } while (link_statuses[conn_link_idx[tmp_link_idx]] > link_status); + DBUG_PRINT("info",("spider next link_idx=%d", tmp_link_idx)); + DBUG_RETURN(tmp_link_idx); + } + DBUG_PRINT("info",("spider next link_idx=%d", tmp_link_idx)); + DBUG_RETURN(tmp_link_idx); +} + +int spider_conn_link_idx_next( + long *link_statuses, + uint *conn_link_idx, + int link_idx, + int link_count, + int link_status +) { + DBUG_ENTER("spider_conn_link_idx_next"); + do { + link_idx++; + if (link_idx >= link_count) + break; + DBUG_ASSERT((conn_link_idx[link_idx] - link_idx) % link_count == 0); + } while (link_statuses[conn_link_idx[link_idx]] > link_status); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); + DBUG_RETURN(link_idx); +} + +int spider_conn_lock_mode( + ha_spider *spider +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_conn_lock_mode"); + if (result_list->lock_type == F_WRLCK || spider->lock_mode == 2) + DBUG_RETURN(SPIDER_LOCK_MODE_EXCLUSIVE); + else if (spider->lock_mode == 1) + DBUG_RETURN(SPIDER_LOCK_MODE_SHARED); + DBUG_RETURN(SPIDER_LOCK_MODE_NO_LOCK); +} + +bool spider_conn_check_recovery_link( + SPIDER_SHARE *share +) { + int roop_count; + DBUG_ENTER("spider_check_recovery_link"); + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + if (share->link_statuses[roop_count] == SPIDER_LINK_STATUS_RECOVERY) + DBUG_RETURN(TRUE); + } + DBUG_RETURN(FALSE); +} + +bool spider_conn_use_handler( + ha_spider *spider, + int lock_mode, + int link_idx +) { + THD *thd = spider->trx->thd; + int use_handler = spider_param_use_handler(thd, + spider->share->use_handlers[link_idx]); + DBUG_ENTER("spider_conn_use_handler"); + DBUG_PRINT("info",("spider use_handler=%d", use_handler)); + DBUG_PRINT("info",("spider spider->conn_kind[link_idx]=%u", + spider->conn_kind[link_idx])); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[link_idx] != SPIDER_CONN_KIND_MYSQL) + { + DBUG_PRINT("info",("spider TRUE by HS")); + spider->sql_kinds |= SPIDER_SQL_KIND_HS; + spider->sql_kind[link_idx] = SPIDER_SQL_KIND_HS; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if ( + spider->do_direct_update && + spider_bit_is_set(spider->do_hs_direct_update, link_idx) + ) { + DBUG_PRINT("info",("spider using HS direct_update")); + spider->direct_update_kinds |= SPIDER_SQL_KIND_HS; + } +#endif + DBUG_RETURN(TRUE); + } +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if (spider->do_direct_update) + { + spider->sql_kinds |= SPIDER_SQL_KIND_SQL; + spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL; + if (spider_bit_is_set(spider->do_hs_direct_update, link_idx)) + { + spider->direct_update_kinds |= SPIDER_SQL_KIND_HS; + DBUG_PRINT("info",("spider TRUE by using HS direct_update")); + DBUG_RETURN(TRUE); + } else + spider->direct_update_kinds |= SPIDER_SQL_KIND_SQL; + if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) + { + DBUG_PRINT("info",("spider FALSE by using direct_update")); + DBUG_RETURN(FALSE); + } else { + DBUG_PRINT("info",("spider TRUE by using BOTH")); + DBUG_RETURN(TRUE); + } + } +#endif +#endif + if (spider->use_spatial_index) + { + DBUG_PRINT("info",("spider FALSE by use_spatial_index")); + spider->sql_kinds |= SPIDER_SQL_KIND_SQL; + spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL; + DBUG_RETURN(FALSE); + } + uint dbton_id; + spider_db_handler *dbton_hdl; + dbton_id = spider->share->sql_dbton_ids[spider->conn_link_idx[link_idx]]; + dbton_hdl = spider->dbton_handler[dbton_id]; + if (!dbton_hdl->support_use_handler(use_handler)) + { + DBUG_PRINT("info",("spider FALSE by dbton")); + spider->sql_kinds |= SPIDER_SQL_KIND_SQL; + spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL; + DBUG_RETURN(FALSE); + } + if ( + spider->sql_command == SQLCOM_HA_READ && + ( + !(use_handler & 2) || + ( + spider_param_sync_trx_isolation(thd) && + thd_tx_isolation(thd) == ISO_SERIALIZABLE + ) + ) + ) { + DBUG_PRINT("info",("spider TRUE by HA")); + spider->sql_kinds |= SPIDER_SQL_KIND_HANDLER; + spider->sql_kind[link_idx] = SPIDER_SQL_KIND_HANDLER; + DBUG_RETURN(TRUE); + } + if ( + spider->sql_command != SQLCOM_HA_READ && + lock_mode == SPIDER_LOCK_MODE_NO_LOCK && + spider_param_sync_trx_isolation(thd) && + thd_tx_isolation(thd) != ISO_SERIALIZABLE && + (use_handler & 1) + ) { + DBUG_PRINT("info",("spider TRUE by PARAM")); + spider->sql_kinds |= SPIDER_SQL_KIND_HANDLER; + spider->sql_kind[link_idx] = SPIDER_SQL_KIND_HANDLER; + DBUG_RETURN(TRUE); + } + spider->sql_kinds |= SPIDER_SQL_KIND_SQL; + spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL; + DBUG_RETURN(FALSE); +} + +bool spider_conn_need_open_handler( + ha_spider *spider, + uint idx, + int link_idx +) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_CONN *conn; +#endif + DBUG_ENTER("spider_conn_need_open_handler"); + DBUG_PRINT("info",("spider spider=%p", spider)); + if (spider->handler_opened(link_idx, spider->conn_kind[link_idx])) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if ( + spider->do_direct_update && + spider_bit_is_set(spider->do_hs_direct_update, link_idx) + ) { + conn = spider->hs_w_conns[link_idx]; + if ( + !conn->server_lost && + conn->hs_pre_age == spider->hs_w_conn_ages[link_idx] + ) { + DBUG_PRINT("info",("spider hs_write is already opened")); + DBUG_RETURN(FALSE); + } + } else +#endif + if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) + { +#endif + DBUG_PRINT("info",("spider HA already opened")); + DBUG_RETURN(FALSE); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) + { + DBUG_PRINT("info",("spider r_handler_index[%d]=%d", + link_idx, spider->r_handler_index[link_idx])); + DBUG_PRINT("info",("spider idx=%d", idx)); + DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", + spider->hs_pushed_ret_fields_num)); + DBUG_PRINT("info",("spider hs_r_ret_fields_num[%d]=%lu", + link_idx, spider->hs_r_ret_fields_num[link_idx])); + DBUG_PRINT("info",("spider hs_r_ret_fields[%d]=%p", + link_idx, spider->hs_r_ret_fields[link_idx])); +#ifndef DBUG_OFF + if ( + spider->hs_pushed_ret_fields_num < MAX_FIELDS && + spider->hs_r_ret_fields[link_idx] && + spider->hs_pushed_ret_fields_num == + spider->hs_r_ret_fields_num[link_idx] + ) { + int roop_count; + for (roop_count = 0; roop_count < (int) spider->hs_pushed_ret_fields_num; + ++roop_count) + { + DBUG_PRINT("info",("spider hs_pushed_ret_fields[%d]=%u", + roop_count, spider->hs_pushed_ret_fields[roop_count])); + DBUG_PRINT("info",("spider hs_r_ret_fields[%d][%d]=%u", + link_idx, roop_count, + spider->hs_r_ret_fields[link_idx][roop_count])); + } + } +#endif + if ( + spider->r_handler_index[link_idx] == idx +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + && ( + ( + spider->hs_pushed_ret_fields_num == MAX_FIELDS && + spider->hs_r_ret_fields_num[link_idx] == MAX_FIELDS + ) || + ( + spider->hs_pushed_ret_fields_num < MAX_FIELDS && + spider->hs_r_ret_fields[link_idx] && + spider->hs_pushed_ret_fields_num == + spider->hs_r_ret_fields_num[link_idx] && + !memcmp(spider->hs_pushed_ret_fields, + spider->hs_r_ret_fields[link_idx], + sizeof(uint32) * spider->hs_pushed_ret_fields_num) + ) + ) +#endif + ) { + SPIDER_CONN *conn = spider->hs_r_conns[link_idx]; + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider conn->conn_id=%llu", conn->conn_id)); + DBUG_PRINT("info",("spider conn->connection_id=%llu", + conn->connection_id)); + DBUG_PRINT("info",("spider conn->server_lost=%s", + conn->server_lost ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider conn->hs_pre_age=%llu", conn->hs_pre_age)); + DBUG_PRINT("info",("spider hs_w_conn_ages[%d]=%llu", + link_idx, spider->hs_w_conn_ages[link_idx])); + if ( + !conn->server_lost && + conn->hs_pre_age == spider->hs_r_conn_ages[link_idx] + ) { + DBUG_PRINT("info",("spider hs_r same idx")); + DBUG_RETURN(FALSE); + } + } + } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_WRITE) + { + DBUG_PRINT("info",("spider w_handler_index[%d]=%d", + link_idx, spider->w_handler_index[link_idx])); + DBUG_PRINT("info",("spider idx=%d", idx)); + DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", + spider->hs_pushed_ret_fields_num)); + DBUG_PRINT("info",("spider hs_w_ret_fields_num[%d]=%lu", + link_idx, spider->hs_w_ret_fields_num[link_idx])); + DBUG_PRINT("info",("spider hs_w_ret_fields[%d]=%p", + link_idx, spider->hs_w_ret_fields[link_idx])); +#ifndef DBUG_OFF + if ( + spider->hs_pushed_ret_fields_num < MAX_FIELDS && + spider->hs_w_ret_fields[link_idx] && + spider->hs_pushed_ret_fields_num == + spider->hs_w_ret_fields_num[link_idx] + ) { + int roop_count; + for (roop_count = 0; roop_count < (int) spider->hs_pushed_ret_fields_num; + ++roop_count) + { + DBUG_PRINT("info",("spider hs_pushed_ret_fields[%d]=%u", + roop_count, spider->hs_pushed_ret_fields[roop_count])); + DBUG_PRINT("info",("spider hs_w_ret_fields[%d][%d]=%u", + link_idx, roop_count, + spider->hs_w_ret_fields[link_idx][roop_count])); + } + } +#endif + if ( + spider->w_handler_index[link_idx] == idx +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + && ( + ( + spider->hs_pushed_ret_fields_num == MAX_FIELDS && + spider->hs_w_ret_fields_num[link_idx] == MAX_FIELDS + ) || + ( + spider->hs_pushed_ret_fields_num < MAX_FIELDS && + spider->hs_w_ret_fields[link_idx] && + spider->hs_pushed_ret_fields_num == + spider->hs_w_ret_fields_num[link_idx] && + !memcmp(spider->hs_pushed_ret_fields, + spider->hs_w_ret_fields[link_idx], + sizeof(uint32) * spider->hs_pushed_ret_fields_num) + ) + ) +#endif + ) { + SPIDER_CONN *conn = spider->hs_w_conns[link_idx]; + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider conn->conn_id=%llu", conn->conn_id)); + DBUG_PRINT("info",("spider conn->connection_id=%llu", + conn->connection_id)); + DBUG_PRINT("info",("spider conn->server_lost=%s", + conn->server_lost ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider conn->hs_pre_age=%llu", conn->hs_pre_age)); + DBUG_PRINT("info",("spider hs_w_conn_ages[%d]=%llu", + link_idx, spider->hs_w_conn_ages[link_idx])); + if ( + !conn->server_lost && + conn->hs_pre_age == spider->hs_w_conn_ages[link_idx] + ) { + DBUG_PRINT("info",("spider hs_w same idx")); + DBUG_RETURN(FALSE); + } + } + } +#endif + } + DBUG_RETURN(TRUE); +} diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h new file mode 100644 index 00000000000..9dc8f3495fd --- /dev/null +++ b/storage/spider/spd_conn.h @@ -0,0 +1,313 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define SPIDER_LOCK_MODE_NO_LOCK 0 +#define SPIDER_LOCK_MODE_SHARED 1 +#define SPIDER_LOCK_MODE_EXCLUSIVE 2 + +#define SPIDER_BG_SIMPLE_NO_ACTION 0 +#define SPIDER_BG_SIMPLE_CONNECT 1 +#define SPIDER_BG_SIMPLE_DISCONNECT 2 + +uchar *spider_conn_get_key( + SPIDER_CONN *conn, + size_t *length, + my_bool not_used __attribute__ ((unused)) +); + +int spider_reset_conn_setted_parameter( + SPIDER_CONN *conn, + THD *thd +); + +int spider_free_conn_alloc( + SPIDER_CONN *conn +); + +void spider_free_conn_from_trx( + SPIDER_TRX *trx, + SPIDER_CONN *conn, + bool another, + bool trx_free, + int *roop_count +); + +SPIDER_CONN *spider_create_conn( + SPIDER_SHARE *share, + ha_spider *spider, + int link_id, + int base_link_id, + uint conn_kind, + int *error_num +); + +SPIDER_CONN *spider_get_conn( + SPIDER_SHARE *share, + int link_idx, + char *conn_key, + SPIDER_TRX *trx, + ha_spider *spider, + bool another, + bool thd_chg, + uint conn_kind, + int *error_num +); + +int spider_free_conn( + SPIDER_CONN *conn +); + +void spider_conn_queue_connect( + SPIDER_SHARE *share, + SPIDER_CONN *conn, + int link_idx +); + +void spider_conn_queue_connect_rewrite( + SPIDER_SHARE *share, + SPIDER_CONN *conn, + int link_idx +); + +void spider_conn_queue_ping( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +); + +void spider_conn_queue_trx_isolation( + SPIDER_CONN *conn, + int trx_isolation +); + +void spider_conn_queue_semi_trx_isolation( + SPIDER_CONN *conn, + int trx_isolation +); + +void spider_conn_queue_autocommit( + SPIDER_CONN *conn, + bool autocommit +); + +void spider_conn_queue_sql_log_off( + SPIDER_CONN *conn, + bool sql_log_off +); + +void spider_conn_queue_time_zone( + SPIDER_CONN *conn, + Time_zone *time_zone +); + +void spider_conn_queue_start_transaction( + SPIDER_CONN *conn +); + +void spider_conn_queue_xa_start( + SPIDER_CONN *conn, + XID *xid +); + +void spider_conn_clear_queue( + SPIDER_CONN *conn +); + +void spider_conn_clear_queue_at_commit( + SPIDER_CONN *conn +); + +void spider_conn_set_timeout( + SPIDER_CONN *conn, + uint net_read_timeout, + uint net_write_timeout +); + +void spider_conn_set_timeout_from_share( + SPIDER_CONN *conn, + int link_idx, + THD *thd, + SPIDER_SHARE *share +); + +void spider_conn_set_timeout_from_direct_sql( + SPIDER_CONN *conn, + THD *thd, + SPIDER_DIRECT_SQL *direct_sql +); + +void spider_tree_insert( + SPIDER_CONN *top, + SPIDER_CONN *conn +); + +SPIDER_CONN *spider_tree_first( + SPIDER_CONN *top +); + +SPIDER_CONN *spider_tree_last( + SPIDER_CONN *top +); + +SPIDER_CONN *spider_tree_next( + SPIDER_CONN *current +); + +SPIDER_CONN *spider_tree_delete( + SPIDER_CONN *conn, + SPIDER_CONN *top +); + +#ifndef WITHOUT_SPIDER_BG_SEARCH +int spider_set_conn_bg_param( + ha_spider *spider +); + +int spider_create_conn_thread( + SPIDER_CONN *conn +); + +void spider_free_conn_thread( + SPIDER_CONN *conn +); + +void spider_bg_conn_wait( + SPIDER_CONN *conn +); + +void spider_bg_all_conn_wait( + ha_spider *spider +); + +int spider_bg_all_conn_pre_next( + ha_spider *spider, + int link_idx +); + +void spider_bg_conn_break( + SPIDER_CONN *conn, + ha_spider *spider +); + +void spider_bg_all_conn_break( + ha_spider *spider +); + +bool spider_bg_conn_get_job( + SPIDER_CONN *conn +); + +int spider_bg_conn_search( + ha_spider *spider, + int link_idx, + int first_link_idx, + bool first, + bool pre_next, + bool discard_result +); + +void spider_bg_conn_simple_action( + SPIDER_CONN *conn, + uint simple_action +); + +void *spider_bg_conn_action( + void *arg +); + +int spider_create_sts_thread( + SPIDER_SHARE *share +); + +void spider_free_sts_thread( + SPIDER_SHARE *share +); + +void *spider_bg_sts_action( + void *arg +); + +int spider_create_crd_thread( + SPIDER_SHARE *share +); + +void spider_free_crd_thread( + SPIDER_SHARE *share +); + +void *spider_bg_crd_action( + void *arg +); + +int spider_create_mon_threads( + SPIDER_TRX *trx, + SPIDER_SHARE *share +); + +void spider_free_mon_threads( + SPIDER_SHARE *share +); + +void *spider_bg_mon_action( + void *arg +); +#endif + +int spider_conn_first_link_idx( + THD *thd, + long *link_statuses, + long *access_balances, + uint *conn_link_idx, + int link_count, + int link_status +); + +int spider_conn_next_link_idx( + THD *thd, + long *link_statuses, + long *access_balances, + uint *conn_link_idx, + int link_idx, + int link_count, + int link_status +); + +int spider_conn_link_idx_next( + long *link_statuses, + uint *conn_link_idx, + int link_idx, + int link_count, + int link_status +); + +int spider_conn_lock_mode( + ha_spider *spider +); + +bool spider_conn_check_recovery_link( + SPIDER_SHARE *share +); + +bool spider_conn_use_handler( + ha_spider *spider, + int lock_mode, + int link_idx +); + +bool spider_conn_need_open_handler( + ha_spider *spider, + uint idx, + int link_idx +); diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc new file mode 100644 index 00000000000..7c7d3836a00 --- /dev/null +++ b/storage/spider/spd_copy_tables.cc @@ -0,0 +1,1343 @@ +/* Copyright (C) 2009-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_base.h" +#include "sql_partition.h" +#include "transaction.h" +#endif +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "ha_spider.h" +#include "spd_db_conn.h" +#include "spd_trx.h" +#include "spd_conn.h" +#include "spd_sys_table.h" +#include "spd_table.h" +#include "spd_copy_tables.h" +#include "spd_udf.h" +#include "spd_malloc.h" + +extern handlerton *spider_hton_ptr; +extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; + +int spider_udf_set_copy_tables_param_default( + SPIDER_COPY_TABLES *copy_tables +) { + DBUG_ENTER("spider_udf_set_copy_tables_param_default"); + + if (!copy_tables->database) + { + DBUG_PRINT("info",("spider create default database")); + copy_tables->database_length = copy_tables->trx->thd->db_length; + if ( + !(copy_tables->database = spider_create_string( + copy_tables->trx->thd->db, + copy_tables->database_length)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (copy_tables->bulk_insert_interval == -1) + copy_tables->bulk_insert_interval = 10; + if (copy_tables->bulk_insert_rows == -1) + copy_tables->bulk_insert_rows = 100; + if (copy_tables->use_table_charset == -1) + copy_tables->use_table_charset = 1; + if (copy_tables->use_transaction == -1) + copy_tables->use_transaction = 1; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (copy_tables->bg_mode == -1) + copy_tables->bg_mode = 0; +#endif + DBUG_RETURN(0); +} + +#define SPIDER_PARAM_STR_LEN(name) name ## _length +#define SPIDER_PARAM_STR(title_name, param_name) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (!copy_tables->param_name) \ + { \ + if ((copy_tables->param_name = spider_get_string_between_quote( \ + start_ptr, TRUE))) \ + copy_tables->SPIDER_PARAM_STR_LEN(param_name) = \ + strlen(copy_tables->param_name); \ + else { \ + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%s", copy_tables->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_HINT_WITH_MAX(title_name, param_name, check_length, max_size, min_val, max_val) \ + if (!strncasecmp(tmp_ptr, title_name, check_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider max_size=%d", max_size)); \ + int hint_num = atoi(tmp_ptr + check_length) - 1; \ + DBUG_PRINT("info",("spider hint_num=%d", hint_num)); \ + DBUG_PRINT("info",("spider copy_tables->param_name=%x", \ + copy_tables->param_name)); \ + if (copy_tables->param_name) \ + { \ + if (hint_num < 0 || hint_num >= max_size) \ + { \ + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } else if (copy_tables->param_name[hint_num] != -1) \ + break; \ + char *hint_str = spider_get_string_between_quote(start_ptr, FALSE); \ + if (hint_str) \ + { \ + copy_tables->param_name[hint_num] = atoi(hint_str); \ + if (copy_tables->param_name[hint_num] < min_val) \ + copy_tables->param_name[hint_num] = min_val; \ + else if (copy_tables->param_name[hint_num] > max_val) \ + copy_tables->param_name[hint_num] = max_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"[%d]=%d", hint_num, \ + copy_tables->param_name[hint_num])); \ + } else { \ + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + break; \ + } +#define SPIDER_PARAM_INT_WITH_MAX(title_name, param_name, min_val, max_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (copy_tables->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + copy_tables->param_name = atoi(tmp_ptr2); \ + if (copy_tables->param_name < min_val) \ + copy_tables->param_name = min_val; \ + else if (copy_tables->param_name > max_val) \ + copy_tables->param_name = max_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%d", copy_tables->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_INT(title_name, param_name, min_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (copy_tables->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + copy_tables->param_name = atoi(tmp_ptr2); \ + if (copy_tables->param_name < min_val) \ + copy_tables->param_name = min_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%d", copy_tables->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_LONGLONG(title_name, param_name, min_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (copy_tables->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + copy_tables->param_name = \ + my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \ + if (copy_tables->param_name < min_val) \ + copy_tables->param_name = min_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%lld", \ + copy_tables->param_name)); \ + } \ + break; \ + } + +int spider_udf_parse_copy_tables_param( + SPIDER_COPY_TABLES *copy_tables, + char *param, + int param_length +) { + int error_num = 0; + char *param_string = NULL; + char *sprit_ptr[2]; + char *tmp_ptr, *tmp_ptr2, *start_ptr; + int title_length; + DBUG_ENTER("spider_udf_parse_copy_tables_param"); + copy_tables->bulk_insert_interval = -1; + copy_tables->bulk_insert_rows = -1; + copy_tables->use_table_charset = -1; + copy_tables->use_transaction = -1; +#ifndef WITHOUT_SPIDER_BG_SEARCH + copy_tables->bg_mode = -1; +#endif + + if (param_length == 0) + goto set_default; + DBUG_PRINT("info",("spider create param_string string")); + if ( + !(param_string = spider_create_string( + param, + param_length)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error_alloc_param_string; + } + DBUG_PRINT("info",("spider param_string=%s", param_string)); + + sprit_ptr[0] = param_string; + while (sprit_ptr[0]) + { + if ((sprit_ptr[1] = strchr(sprit_ptr[0], ','))) + { + *sprit_ptr[1] = '\0'; + sprit_ptr[1]++; + } + tmp_ptr = sprit_ptr[0]; + sprit_ptr[0] = sprit_ptr[1]; + while (*tmp_ptr == ' ' || *tmp_ptr == '\r' || + *tmp_ptr == '\n' || *tmp_ptr == '\t') + tmp_ptr++; + + if (*tmp_ptr == '\0') + continue; + + title_length = 0; + start_ptr = tmp_ptr; + while (*start_ptr != ' ' && *start_ptr != '\'' && + *start_ptr != '"' && *start_ptr != '\0' && + *start_ptr != '\r' && *start_ptr != '\n' && + *start_ptr != '\t') + { + title_length++; + start_ptr++; + } + + switch (title_length) + { + case 0: + continue; + case 3: +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_INT_WITH_MAX("bgm", bg_mode, 0, 1); +#endif + SPIDER_PARAM_INT("bii", bulk_insert_interval, 0); + SPIDER_PARAM_LONGLONG("bir", bulk_insert_rows, 1); + SPIDER_PARAM_STR("dtb", database); + SPIDER_PARAM_INT_WITH_MAX("utc", use_table_charset, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("utr", use_transaction, 0, 1); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; +#ifndef WITHOUT_SPIDER_BG_SEARCH + case 7: + SPIDER_PARAM_INT_WITH_MAX("bg_mode", bg_mode, 0, 1); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; +#endif + case 8: + SPIDER_PARAM_STR("database", database); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 15: + SPIDER_PARAM_INT_WITH_MAX("use_transaction", use_transaction, 0, 1); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 16: + SPIDER_PARAM_LONGLONG("bulk_insert_rows", bulk_insert_rows, 1); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 17: + SPIDER_PARAM_INT_WITH_MAX( + "use_table_charset", use_table_charset, 0, 1); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 20: + SPIDER_PARAM_INT("bulk_insert_interval", bulk_insert_interval, 0); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + default: + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + } + } + +set_default: + if ((error_num = spider_udf_set_copy_tables_param_default( + copy_tables + ))) + goto error; + + if (param_string) + spider_free(spider_current_trx, param_string, MYF(0)); + DBUG_RETURN(0); + +error: + if (param_string) + spider_free(spider_current_trx, param_string, MYF(0)); +error_alloc_param_string: + DBUG_RETURN(error_num); +} + +int spider_udf_get_copy_tgt_tables( + THD *thd, + SPIDER_COPY_TABLES *copy_tables, + MEM_ROOT *mem_root, + bool need_lock +) { + int error_num, roop_count; + TABLE *table_tables = NULL; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + char table_key[MAX_KEY_LENGTH]; + SPIDER_COPY_TABLE_CONN *table_conn = NULL, *src_table_conn_prev = NULL, + *dst_table_conn_prev = NULL; + SPIDER_SHARE *tmp_share; + char **tmp_connect_info; + uint *tmp_connect_info_length; + long *tmp_long; + longlong *tmp_longlong; + DBUG_ENTER("spider_udf_get_copy_tgt_tables"); + + if ( + !(table_tables = spider_open_sys_table( + thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup, + need_lock, &error_num)) + ) { + my_error(error_num, MYF(0)); + goto error; + } + spider_store_db_and_table_name(table_tables, + copy_tables->spider_db_name, copy_tables->spider_db_name_length, + copy_tables->spider_table_name, copy_tables->spider_table_name_length + ); + if ((error_num = spider_get_sys_table_by_idx(table_tables, table_key, + table_tables->s->primary_key, 2))) + { + table_tables->file->print_error(error_num, MYF(0)); + goto error; + } + do { + if (!(table_conn = (SPIDER_COPY_TABLE_CONN *) + spider_bulk_malloc(spider_current_trx, 25, MYF(MY_WME | MY_ZEROFILL), + &table_conn, sizeof(SPIDER_COPY_TABLE_CONN), + &tmp_share, sizeof(SPIDER_SHARE), + &tmp_connect_info, sizeof(char *) * SPIDER_TMP_SHARE_CHAR_PTR_COUNT, + &tmp_connect_info_length, sizeof(uint) * SPIDER_TMP_SHARE_UINT_COUNT, + &tmp_long, sizeof(long) * SPIDER_TMP_SHARE_LONG_COUNT, + &tmp_longlong, sizeof(longlong) * SPIDER_TMP_SHARE_LONGLONG_COUNT, + NullS)) + ) { + spider_sys_index_end(table_tables); + error_num = HA_ERR_OUT_OF_MEM; + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + goto error; + } + spider_set_tmp_share_pointer(tmp_share, tmp_connect_info, + tmp_connect_info_length, tmp_long, tmp_longlong); + tmp_share->link_statuses[0] = -1; + table_conn->share = tmp_share; + + if ( + (error_num = spider_get_sys_tables_connect_info( + table_tables, tmp_share, 0, mem_root)) || + (error_num = spider_get_sys_tables_link_status( + table_tables, tmp_share, 0, mem_root)) || + (error_num = spider_get_sys_tables_link_idx( + table_tables, &table_conn->link_idx, mem_root)) + ) { + table_tables->file->print_error(error_num, MYF(0)); + spider_sys_index_end(table_tables); + goto error; + } + if ( + (error_num = spider_set_connect_info_default( + tmp_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + NULL, + NULL, +#endif + NULL + )) || + (error_num = spider_set_connect_info_default_db_table( + tmp_share, + copy_tables->spider_db_name, copy_tables->spider_db_name_length, + copy_tables->spider_table_name, copy_tables->spider_table_name_length + )) || + (error_num = spider_create_conn_keys(tmp_share)) || + (error_num = spider_create_tmp_dbton_share(tmp_share)) + ) { + spider_sys_index_end(table_tables); + goto error; + } + +/* + if (spider_db_create_table_names_str(tmp_share)) + { + spider_sys_index_end(table_tables); + error_num = HA_ERR_OUT_OF_MEM; + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + goto error; + } +*/ + + for (roop_count = 0; roop_count < (int) tmp_share->use_dbton_count; + roop_count++) + { + uint dbton_id = tmp_share->use_dbton_ids[roop_count]; + + if (!spider_dbton[dbton_id].create_db_copy_table) + continue; + + if (!(table_conn->copy_table = + spider_dbton[dbton_id].create_db_copy_table( + tmp_share->dbton_share[dbton_id]))) + { + spider_sys_index_end(table_tables); + error_num = HA_ERR_OUT_OF_MEM; + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + goto error; + } + if ((error_num = table_conn->copy_table->init())) + goto error; + break; + } + + if ( + !copy_tables->use_auto_mode[0] + ) { + for (roop_count = 0; roop_count < copy_tables->link_idx_count[0]; + roop_count++) + { + if (table_conn->link_idx == copy_tables->link_idxs[0][roop_count]) + { + if (tmp_share->link_statuses[0] == SPIDER_LINK_STATUS_NG) + { + spider_sys_index_end(table_tables); + error_num = ER_SPIDER_UDF_COPY_TABLE_SRC_NG_STATUS_NUM; + my_printf_error(ER_SPIDER_UDF_COPY_TABLE_SRC_NG_STATUS_NUM, + ER_SPIDER_UDF_COPY_TABLE_SRC_NG_STATUS_STR, MYF(0)); + goto error; + } + if (src_table_conn_prev) + src_table_conn_prev->next = table_conn; + else + copy_tables->table_conn[0] = table_conn; + src_table_conn_prev = table_conn; + table_conn = NULL; + break; + } + } + } + if (table_conn && !copy_tables->use_auto_mode[1]) + { + for (roop_count = 0; roop_count < copy_tables->link_idx_count[1]; + roop_count++) + { + if (table_conn->link_idx == copy_tables->link_idxs[1][roop_count]) + { + if (tmp_share->link_statuses[0] == SPIDER_LINK_STATUS_NG) + { + spider_sys_index_end(table_tables); + error_num = ER_SPIDER_UDF_COPY_TABLE_SRC_NG_STATUS_NUM; + my_printf_error(ER_SPIDER_UDF_COPY_TABLE_SRC_NG_STATUS_NUM, + ER_SPIDER_UDF_COPY_TABLE_SRC_NG_STATUS_STR, MYF(0)); + goto error; + } + if (dst_table_conn_prev) + dst_table_conn_prev->next = table_conn; + else + copy_tables->table_conn[1] = table_conn; + dst_table_conn_prev = table_conn; + table_conn = NULL; + break; + } + } + } + if (table_conn && copy_tables->use_auto_mode[0] && + tmp_share->link_statuses[0] == SPIDER_LINK_STATUS_OK) + { + if (src_table_conn_prev) + src_table_conn_prev->next = table_conn; + else + copy_tables->table_conn[0] = table_conn; + src_table_conn_prev = table_conn; + copy_tables->link_idx_count[0]++; + table_conn = NULL; + } + if (table_conn && copy_tables->use_auto_mode[1] && + tmp_share->link_statuses[0] == SPIDER_LINK_STATUS_RECOVERY) + { + if (dst_table_conn_prev) + dst_table_conn_prev->next = table_conn; + else + copy_tables->table_conn[1] = table_conn; + dst_table_conn_prev = table_conn; + copy_tables->link_idx_count[1]++; + table_conn = NULL; + } + if (table_conn) + { + spider_free_tmp_dbton_share(tmp_share); + spider_free_tmp_share_alloc(tmp_share); + if (table_conn->copy_table) + delete table_conn->copy_table; + spider_free(spider_current_trx, table_conn, MYF(0)); + table_conn = NULL; + } + + error_num = spider_sys_index_next_same(table_tables, table_key); + } while (error_num == 0); + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, need_lock); + table_tables = NULL; + + if (!copy_tables->table_conn[0]) + { + error_num = ER_SPIDER_UDF_COPY_TABLE_SRC_NOT_FOUND_NUM; + my_printf_error(ER_SPIDER_UDF_COPY_TABLE_SRC_NOT_FOUND_NUM, + ER_SPIDER_UDF_COPY_TABLE_SRC_NOT_FOUND_STR, MYF(0)); + goto error; + } + if (!copy_tables->table_conn[1]) + { + error_num = ER_SPIDER_UDF_COPY_TABLE_DST_NOT_FOUND_NUM; + my_printf_error(ER_SPIDER_UDF_COPY_TABLE_DST_NOT_FOUND_NUM, + ER_SPIDER_UDF_COPY_TABLE_DST_NOT_FOUND_STR, MYF(0)); + goto error; + } + + DBUG_RETURN(0); + +error: + if (table_tables) + spider_close_sys_table(thd, table_tables, + &open_tables_backup, need_lock); + if (table_conn) + { + spider_free_tmp_dbton_share(tmp_share); + spider_free_tmp_share_alloc(tmp_share); + if (table_conn->copy_table) + delete table_conn->copy_table; + spider_free(spider_current_trx, table_conn, MYF(0)); + } + DBUG_RETURN(error_num); +} + +int spider_udf_get_copy_tgt_conns( + SPIDER_COPY_TABLES *copy_tables +) { + int error_num, roop_count; + SPIDER_TRX *trx = copy_tables->trx; + SPIDER_SHARE *share; + SPIDER_COPY_TABLE_CONN *table_conn; + DBUG_ENTER("spider_udf_get_copy_tgt_conns"); + for (roop_count = 0; roop_count < 2; roop_count++) + { + table_conn = copy_tables->table_conn[roop_count]; + while (table_conn) + { + share = table_conn->share; + if ( + !(table_conn->conn = spider_get_conn( + share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE, + SPIDER_CONN_KIND_MYSQL, &error_num)) + ) { + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]); + DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + } + table_conn->conn->error_mode = 0; + table_conn = table_conn->next; + } + } + DBUG_RETURN(0); +} + +void spider_udf_free_copy_tables_alloc( + SPIDER_COPY_TABLES *copy_tables +) { + int roop_count; + SPIDER_COPY_TABLE_CONN *table_conn, *table_conn_next; + DBUG_ENTER("spider_udf_free_copy_tables_alloc"); + for (roop_count = 0; roop_count < 2; roop_count++) + { + table_conn = copy_tables->table_conn[roop_count]; + while (table_conn) + { + table_conn_next = table_conn->next; + spider_free_tmp_dbton_share(table_conn->share); + spider_free_tmp_share_alloc(table_conn->share); + if (table_conn->copy_table) + delete table_conn->copy_table; + spider_free(spider_current_trx, table_conn, MYF(0)); + table_conn = table_conn_next; + } + } + if (copy_tables->link_idxs[0]) + spider_free(spider_current_trx, copy_tables->link_idxs[0], MYF(0)); + if (copy_tables->database) + spider_free(spider_current_trx, copy_tables->database, MYF(0)); + spider_free(spider_current_trx, copy_tables, MYF(0)); + DBUG_VOID_RETURN; +} + +int spider_udf_copy_tables_create_table_list( + SPIDER_COPY_TABLES *copy_tables, + char *spider_table_name, + uint spider_table_name_length, + char *src_link_idx_list, + uint src_link_idx_list_length, + char *dst_link_idx_list, + uint dst_link_idx_list_length +) { + int roop_count, roop_count2, length; + char *tmp_ptr, *tmp_ptr2, *tmp_ptr3, *tmp_name_ptr; + DBUG_ENTER("spider_udf_copy_tables_create_table_list"); + + if (!spider_table_name_length) + { + my_printf_error(ER_SPIDER_BLANK_UDF_ARGUMENT_NUM, + ER_SPIDER_BLANK_UDF_ARGUMENT_STR, MYF(0), 1); + DBUG_RETURN(ER_SPIDER_BLANK_UDF_ARGUMENT_NUM); + } + + for (roop_count2 = 0; roop_count2 < 2; roop_count2++) + { + if (roop_count2 == 0) + tmp_ptr = src_link_idx_list; + else + tmp_ptr = dst_link_idx_list; + + while (*tmp_ptr == ' ') + tmp_ptr++; + if (*tmp_ptr) + copy_tables->link_idx_count[roop_count2] = 1; + else { + /* use auto detect */ + copy_tables->use_auto_mode[roop_count2] = TRUE; + copy_tables->link_idx_count[roop_count2] = 0; + continue; + } + + while (TRUE) + { + if ((tmp_ptr2 = strchr(tmp_ptr, ' '))) + { + copy_tables->link_idx_count[roop_count2]++; + tmp_ptr = tmp_ptr2 + 1; + while (*tmp_ptr == ' ') + tmp_ptr++; + } else + break; + } + } + + if (!(copy_tables->link_idxs[0] = (int *) + spider_bulk_malloc(spider_current_trx, 26, MYF(MY_WME | MY_ZEROFILL), + ©_tables->link_idxs[0], + sizeof(int) * copy_tables->link_idx_count[0], + ©_tables->link_idxs[1], + sizeof(int) * copy_tables->link_idx_count[1], + &tmp_name_ptr, sizeof(char) * ( + spider_table_name_length * 2 + copy_tables->database_length + 2 + ), + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + copy_tables->spider_db_name = tmp_name_ptr; + if ((tmp_ptr3 = strchr(spider_table_name, '.'))) + { + /* exist database name */ + *tmp_ptr3 = '\0'; + length = strlen(spider_table_name); + memcpy(tmp_name_ptr, spider_table_name, length + 1); + copy_tables->spider_db_name_length = length; + tmp_name_ptr += length + 1; + tmp_ptr3++; + } else { + memcpy(tmp_name_ptr, copy_tables->database, + copy_tables->database_length + 1); + copy_tables->spider_db_name_length = copy_tables->database_length; + tmp_name_ptr += copy_tables->database_length + 1; + tmp_ptr3 = spider_table_name; + length = -1; + } + copy_tables->spider_table_name = tmp_name_ptr; + length = spider_table_name_length - length - 1; + memcpy(tmp_name_ptr, tmp_ptr3, length + 1); + copy_tables->spider_table_name_length = length; + tmp_name_ptr += length + 1; + memcpy(tmp_name_ptr, tmp_ptr3, length + 1); + copy_tables->spider_real_table_name = tmp_name_ptr; + if ((tmp_ptr2 = strstr(tmp_name_ptr, "#P#"))) + { + *tmp_ptr2 = '\0'; + copy_tables->spider_real_table_name_length = strlen(tmp_name_ptr); + } else + copy_tables->spider_real_table_name_length = length; + + DBUG_PRINT("info",("spider spider_db=%s", copy_tables->spider_db_name)); + DBUG_PRINT("info",("spider spider_table_name=%s", + copy_tables->spider_table_name)); + DBUG_PRINT("info",("spider spider_real_table_name=%s", + copy_tables->spider_real_table_name)); + + for (roop_count2 = 0; roop_count2 < 2; roop_count2++) + { + if (roop_count2 == 0) + tmp_ptr = src_link_idx_list; + else + tmp_ptr = dst_link_idx_list; + + while (*tmp_ptr == ' ') + tmp_ptr++; + roop_count = 0; + while (*tmp_ptr) + { + if ((tmp_ptr2 = strchr(tmp_ptr, ' '))) + *tmp_ptr2 = '\0'; + + copy_tables->link_idxs[roop_count2][roop_count] = atoi(tmp_ptr); + + DBUG_PRINT("info",("spider link_idx[%d][%d]=%d", + roop_count2, roop_count, + copy_tables->link_idxs[roop_count2][roop_count])); + if (!tmp_ptr2) + break; + + tmp_ptr = tmp_ptr2 + 1; + while (*tmp_ptr == ' ') + tmp_ptr++; + roop_count++; + } + } + DBUG_RETURN(0); +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +int spider_udf_bg_copy_exec_sql( + SPIDER_COPY_TABLE_CONN *table_conn +) { + int error_num; + SPIDER_CONN *conn = table_conn->conn; + ha_spider *spider = table_conn->spider; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + DBUG_ENTER("spider_udf_bg_copy_exec_sql"); + if ((error_num = spider_create_conn_thread(conn))) + DBUG_RETURN(error_num); + if ((error_num = dbton_hdl->set_sql_for_exec(table_conn->copy_table, + SPIDER_SQL_TYPE_INSERT_SQL))) + DBUG_RETURN(error_num); + pthread_mutex_lock(&conn->bg_conn_mutex); + conn->bg_target = spider; + conn->bg_error_num = &table_conn->bg_error_num; + conn->bg_sql_type = SPIDER_SQL_TYPE_INSERT_SQL; + conn->link_idx = 0; + conn->bg_exec_sql = TRUE; + conn->bg_caller_sync_wait = TRUE; + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + conn->bg_caller_sync_wait = FALSE; + DBUG_RETURN(0); +} +#endif + +long long spider_copy_tables_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +) { + int error_num, roop_count, all_link_cnt = 0, use_table_charset; + SPIDER_COPY_TABLES *copy_tables = NULL; + THD *thd = current_thd; + TABLE_LIST *table_list = NULL; + TABLE *table; + TABLE_SHARE *table_share; + KEY *key_info; + ha_spider *spider = NULL, *tmp_spider; + spider_string *tmp_sql = NULL; + SPIDER_COPY_TABLE_CONN *table_conn, *src_tbl_conn, *dst_tbl_conn; + SPIDER_CONN *tmp_conn; + spider_db_copy_table *select_ct, *insert_ct; + MEM_ROOT mem_root; + longlong bulk_insert_rows; + Reprepare_observer *reprepare_observer_backup; + DBUG_ENTER("spider_copy_tables_body"); + if ( + thd->open_tables != 0 || + thd->handler_tables_hash.records != 0 || + thd->derived_tables != 0 || + thd->lock != 0 || +#if MYSQL_VERSION_ID < 50500 + thd->locked_tables != 0 || + thd->prelocked_mode != NON_PRELOCKED +#else + thd->locked_tables_list.locked_tables() || + thd->locked_tables_mode != LTM_NONE +#endif + ) { + if (thd->open_tables != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->open_tables", thd->open_tables); + } else if (thd->handler_tables_hash.records != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), + "thd->handler_tables_hash.records", + (longlong) thd->handler_tables_hash.records); + } else if (thd->derived_tables != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->derived_tables", thd->derived_tables); + } else if (thd->lock != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->lock", thd->lock); +#if MYSQL_VERSION_ID < 50500 + } else if (thd->locked_tables != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->locked_tables", thd->locked_tables); + } else if (thd->prelocked_mode != NON_PRELOCKED) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), + "thd->prelocked_mode", (longlong) thd->prelocked_mode); +#else + } else if (thd->locked_tables_list.locked_tables()) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->locked_tables_list.locked_tables()", + thd->locked_tables_list.locked_tables()); + } else if (thd->locked_tables_mode != LTM_NONE) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), + "thd->locked_tables_mode", (longlong) thd->locked_tables_mode); +#endif + } + goto error; + } + + if (!(copy_tables = (SPIDER_COPY_TABLES *) + spider_bulk_malloc(spider_current_trx, 27, MYF(MY_WME | MY_ZEROFILL), + ©_tables, sizeof(SPIDER_COPY_TABLES), + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + if (!(copy_tables->trx = spider_get_trx(thd, TRUE, &error_num))) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + + if (args->arg_count == 4) + { + if (spider_udf_parse_copy_tables_param( + copy_tables, + args->args[3] ? args->args[3] : (char *) "", + args->args[3] ? args->lengths[3] : 0 + )) + goto error; + } else { + if (spider_udf_parse_copy_tables_param( + copy_tables, + (char *) "", + 0 + )) + goto error; + } + if ( + spider_udf_copy_tables_create_table_list( + copy_tables, + args->args[0], + args->lengths[0], + args->args[1] ? args->args[1] : (char *) "", + args->args[1] ? args->lengths[1] : 0, + args->args[2] ? args->args[2] : (char *) "", + args->args[2] ? args->lengths[2] : 0 + ) + ) + goto error; + + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + if ( + spider_udf_get_copy_tgt_tables( + thd, + copy_tables, + &mem_root, + TRUE + ) + ) { + free_root(&mem_root, MYF(0)); + goto error; + } + free_root(&mem_root, MYF(0)); + + if ( + spider_udf_get_copy_tgt_conns(copy_tables) + ) + goto error; + + table_list = ©_tables->spider_table_list; + table_list->db = copy_tables->spider_db_name; + table_list->db_length = copy_tables->spider_db_name_length; + table_list->alias = table_list->table_name = + copy_tables->spider_real_table_name; + table_list->table_name_length = copy_tables->spider_real_table_name_length; + table_list->lock_type = TL_READ; + + DBUG_PRINT("info",("spider db=%s", table_list->db)); + DBUG_PRINT("info",("spider db_length=%zd", table_list->db_length)); + DBUG_PRINT("info",("spider table_name=%s", table_list->table_name)); + DBUG_PRINT("info",("spider table_name_length=%zd", + table_list->table_name_length)); + reprepare_observer_backup = thd->m_reprepare_observer; + thd->m_reprepare_observer = NULL; +#if MYSQL_VERSION_ID < 50500 + if (open_and_lock_tables(thd, table_list)) +#else + table_list->mdl_request.init( + MDL_key::TABLE, + table_list->db, + table_list->table_name, + MDL_SHARED_READ, + MDL_TRANSACTION + ); + if (open_and_lock_tables(thd, table_list, FALSE, 0)) +#endif + { + thd->m_reprepare_observer = reprepare_observer_backup; + my_printf_error(ER_SPIDER_UDF_CANT_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_OPEN_TABLE_STR, MYF(0), table_list->db, + table_list->table_name); + goto error; + } + thd->m_reprepare_observer = reprepare_observer_backup; + + table = table_list->table; + table_share = table->s; + if (table_share->primary_key == MAX_KEY) + { + my_printf_error(ER_SPIDER_UDF_COPY_TABLE_NEED_PK_NUM, + ER_SPIDER_UDF_COPY_TABLE_NEED_PK_STR, MYF(0), + table_list->db, table_list->table_name); + goto error; + } + key_info = &table->key_info[table_share->primary_key]; + + use_table_charset = spider_param_use_table_charset( + copy_tables->use_table_charset); + if (use_table_charset) + copy_tables->access_charset = table_share->table_charset; + else + copy_tables->access_charset = system_charset_info; + + src_tbl_conn = copy_tables->table_conn[0]; + select_ct = src_tbl_conn->copy_table; + src_tbl_conn->share->access_charset = copy_tables->access_charset; + select_ct->set_sql_charset(copy_tables->access_charset); + if ( + select_ct->append_select_str() || + select_ct->append_table_columns(table_share) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + + if ( + select_ct->append_from_str() || + select_ct->append_table_name(0) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + + select_ct->set_sql_pos(); + + bulk_insert_rows = spider_param_udf_ct_bulk_insert_rows( + copy_tables->bulk_insert_rows); + if ( + select_ct->append_key_order_str(key_info, 0, FALSE) || + select_ct->append_limit(0, bulk_insert_rows) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + + for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + insert_ct = dst_tbl_conn->copy_table; + dst_tbl_conn->share->access_charset = copy_tables->access_charset; + insert_ct->set_sql_charset(copy_tables->access_charset); + if ( + insert_ct->append_insert_str(SPIDER_DB_INSERT_IGNORE) || + insert_ct->append_into_str() || + insert_ct->append_table_name(0) || + insert_ct->append_open_paren_str() || + insert_ct->append_table_columns(table_share) || + insert_ct->append_values_str() + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + + insert_ct->set_sql_pos(); + } + + all_link_cnt = + copy_tables->link_idx_count[0] + copy_tables->link_idx_count[1]; + if ( + !(tmp_sql = new spider_string[all_link_cnt]) || + !(spider = new ha_spider[all_link_cnt]) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + spider[roop_count].conns = NULL; + } + for (roop_count = 0, table_conn = copy_tables->table_conn[0]; + table_conn; roop_count++, table_conn = table_conn->next) + { + tmp_spider = &spider[roop_count]; + if (!(tmp_spider->dbton_handler = (spider_db_handler **) + spider_bulk_alloc_mem(spider_current_trx, 205, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &tmp_spider->dbton_handler, + sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + tmp_spider->share = table_conn->share; + tmp_spider->trx = copy_tables->trx; +/* + if (spider_db_append_set_names(table_conn->share)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error_append_set_names; + } +*/ + tmp_spider->conns = &table_conn->conn; + tmp_sql[roop_count].init_calc_mem(122); + tmp_sql[roop_count].set_charset(copy_tables->access_charset); + tmp_spider->result_list.sqls = &tmp_sql[roop_count]; + tmp_spider->need_mons = &table_conn->need_mon; + tmp_spider->lock_type = TL_READ; + uint dbton_id = tmp_spider->share->use_dbton_ids[0]; + if (!(tmp_spider->dbton_handler[dbton_id] = + spider_dbton[dbton_id].create_db_handler(tmp_spider, + tmp_spider->share->dbton_share[dbton_id]))) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error_create_dbton_handler; + } + if ((error_num = tmp_spider->dbton_handler[dbton_id]->init())) + { + goto error_init_dbton_handler; + } + table_conn->spider = tmp_spider; + } + for (table_conn = copy_tables->table_conn[1]; + table_conn; roop_count++, table_conn = table_conn->next) + { + tmp_spider = &spider[roop_count]; + if (!(tmp_spider->dbton_handler = (spider_db_handler **) + spider_bulk_alloc_mem(spider_current_trx, 206, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &tmp_spider->dbton_handler, + sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + tmp_spider->share = table_conn->share; + tmp_spider->trx = copy_tables->trx; +/* + if (spider_db_append_set_names(table_conn->share)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error_append_set_names; + } +*/ + tmp_spider->conns = &table_conn->conn; + tmp_sql[roop_count].init_calc_mem(201); + tmp_sql[roop_count].set_charset(copy_tables->access_charset); + tmp_spider->result_list.sqls = &tmp_sql[roop_count]; + tmp_spider->need_mons = &table_conn->need_mon; + tmp_spider->lock_type = TL_WRITE; + uint dbton_id = tmp_spider->share->use_dbton_ids[0]; + if (!(tmp_spider->dbton_handler[dbton_id] = + spider_dbton[dbton_id].create_db_handler(tmp_spider, + tmp_spider->share->dbton_share[dbton_id]))) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error_create_dbton_handler; + } + if ((error_num = tmp_spider->dbton_handler[dbton_id]->init())) + { + goto error_init_dbton_handler; + } + table_conn->spider = tmp_spider; + } + + if ( + copy_tables->use_transaction && + select_ct->append_select_lock_str(SPIDER_LOCK_MODE_SHARED) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + + if ((error_num = spider_db_udf_copy_tables(copy_tables, spider, table, + bulk_insert_rows))) + goto error_db_udf_copy_tables; + +/* + for (table_conn = copy_tables->table_conn[0]; + table_conn; table_conn = table_conn->next) + spider_db_free_set_names(table_conn->share); + for (table_conn = copy_tables->table_conn[1]; + table_conn; table_conn = table_conn->next) + spider_db_free_set_names(table_conn->share); +*/ + if (table_list->table) + { +#if MYSQL_VERSION_ID < 50500 + ha_autocommit_or_rollback(thd, 0); +#else + (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd)); +#endif + close_thread_tables(thd); + } + if (spider) + { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + if (spider[roop_count].share && spider[roop_count].dbton_handler) + { + uint dbton_id = spider[roop_count].share->use_dbton_ids[0]; + if (spider[roop_count].dbton_handler[dbton_id]) + delete spider[roop_count].dbton_handler[dbton_id]; + spider_free(spider_current_trx, spider[roop_count].dbton_handler, + MYF(0)); + } + } + delete [] spider; + } + if (tmp_sql) + delete [] tmp_sql; + spider_udf_free_copy_tables_alloc(copy_tables); + + DBUG_RETURN(1); + +error_db_udf_copy_tables: +error_create_dbton_handler: +error_init_dbton_handler: +/* +error_append_set_names: +*/ +/* + for (table_conn = copy_tables->table_conn[0]; + table_conn; table_conn = table_conn->next) + spider_db_free_set_names(table_conn->share); + for (table_conn = copy_tables->table_conn[1]; + table_conn; table_conn = table_conn->next) + spider_db_free_set_names(table_conn->share); +*/ +error: + if (spider) + { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + if (tmp_spider->conns) + { + tmp_conn = tmp_spider->conns[0]; + if (tmp_conn && tmp_conn->db_conn && + tmp_conn->db_conn->get_lock_table_hash_count() + ) { + tmp_conn->db_conn->reset_lock_table_hash(); + tmp_conn->table_lock = 0; + } + } + } + } + if (table_list && table_list->table) + { +#if MYSQL_VERSION_ID < 50500 + ha_autocommit_or_rollback(thd, 0); +#else + (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd)); +#endif + close_thread_tables(thd); + } + if (spider) + { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + if (tmp_spider->share && spider[roop_count].dbton_handler) + { + uint dbton_id = tmp_spider->share->use_dbton_ids[0]; + if (tmp_spider->dbton_handler[dbton_id]) + delete tmp_spider->dbton_handler[dbton_id]; + spider_free(spider_current_trx, spider[roop_count].dbton_handler, + MYF(0)); + } + } + delete [] spider; + } + if (tmp_sql) + { + delete [] tmp_sql; + } + if (copy_tables) + spider_udf_free_copy_tables_alloc(copy_tables); + *error = 1; + DBUG_RETURN(0); +} + +my_bool spider_copy_tables_init_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +) { + DBUG_ENTER("spider_copy_tables_init_body"); + if (args->arg_count != 3 && args->arg_count != 4) + { + strcpy(message, "spider_copy_tables() requires 3 or 4 arguments"); + goto error; + } + if ( + args->arg_type[0] != STRING_RESULT || + args->arg_type[1] != STRING_RESULT || + args->arg_type[2] != STRING_RESULT || + ( + args->arg_count == 4 && + args->arg_type[3] != STRING_RESULT + ) + ) { + strcpy(message, "spider_copy_tables() requires string arguments"); + goto error; + } + DBUG_RETURN(FALSE); + +error: + DBUG_RETURN(TRUE); +} + +void spider_copy_tables_deinit_body( + UDF_INIT *initid +) { + int error_num; + THD *thd = current_thd; + SPIDER_TRX *trx; + DBUG_ENTER("spider_copy_tables_deinit_body"); + if ( + !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) && + (trx = spider_get_trx(thd, TRUE, &error_num)) + ) + spider_free_trx_conn(trx, FALSE); + DBUG_VOID_RETURN; +} diff --git a/storage/spider/spd_copy_tables.h b/storage/spider/spd_copy_tables.h new file mode 100644 index 00000000000..88612d1dd12 --- /dev/null +++ b/storage/spider/spd_copy_tables.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2010-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +int spider_udf_set_copy_tables_param_default( + SPIDER_COPY_TABLES *copy_tables +); + +int spider_udf_parse_copy_tables_param( + SPIDER_COPY_TABLES *copy_tables, + char *param, + int param_length +); + +int spider_udf_get_copy_tgt_tables( + THD *thd, + SPIDER_COPY_TABLES *copy_tables, + MEM_ROOT *mem_root, + bool need_lock +); + +int spider_udf_get_copy_tgt_conns( + SPIDER_COPY_TABLES *copy_tables +); + +void spider_udf_free_copy_tables_alloc( + SPIDER_COPY_TABLES *copy_tables +); + +int spider_udf_copy_tables_create_table_list( + SPIDER_COPY_TABLES *copy_tables, + char *spider_table_name, + uint spider_table_name_length, + char *src_link_idx_list, + uint src_link_idx_list_length, + char *dst_link_idx_list, + uint dst_link_idx_list_length +); + +#ifndef WITHOUT_SPIDER_BG_SEARCH +int spider_udf_bg_copy_exec_sql( + SPIDER_COPY_TABLE_CONN *table_conn +); +#endif diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc new file mode 100644 index 00000000000..adf40c3ff94 --- /dev/null +++ b/storage/spider/spd_db_conn.cc @@ -0,0 +1,9729 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#include "sql_analyse.h" +#include "sql_base.h" +#include "tztime.h" +#endif +#include "sql_common.h" +#include +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_sys_table.h" +#include "ha_spider.h" +#include "spd_db_conn.h" +#include "spd_table.h" +#include "spd_trx.h" +#include "spd_conn.h" +#include "spd_direct_sql.h" +#include "spd_ping_table.h" +#include "spd_copy_tables.h" +#include "spd_malloc.h" + +extern handlerton *spider_hton_ptr; +extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; + +#define SPIDER_SQL_COALESCE_STR "coalesce(" +#define SPIDER_SQL_COALESCE_LEN (sizeof(SPIDER_SQL_COALESCE_STR) - 1) +#define SPIDER_SQL_HEX_STR "0x" +#define SPIDER_SQL_HEX_LEN (sizeof(SPIDER_SQL_HEX_STR) - 1) +#define SPIDER_SQL_SQL_FORCE_IDX_STR " force index(" +#define SPIDER_SQL_SQL_FORCE_IDX_LEN (sizeof(SPIDER_SQL_SQL_FORCE_IDX_STR) - 1) +#define SPIDER_SQL_SQL_USE_IDX_STR " use index(" +#define SPIDER_SQL_SQL_USE_IDX_LEN (sizeof(SPIDER_SQL_SQL_USE_IDX_STR) - 1) +#define SPIDER_SQL_SQL_IGNORE_IDX_STR " ignore index(" +#define SPIDER_SQL_SQL_IGNORE_IDX_LEN (sizeof(SPIDER_SQL_SQL_IGNORE_IDX_STR) - 1) + +#define SPIDER_SQL_SET_NAMES_STR "set names " +#define SPIDER_SQL_SET_NAMES_LEN sizeof(SPIDER_SQL_SET_NAMES_STR) - 1 + +#define SPIDER_SQL_PING_TABLE_STR "spider_ping_table(" +#define SPIDER_SQL_PING_TABLE_LEN (sizeof(SPIDER_SQL_PING_TABLE_STR) - 1) + +#ifdef SPIDER_HAS_HASH_VALUE_TYPE +extern HASH spider_open_connections; +#endif +pthread_mutex_t spider_open_conn_mutex; +const char spider_dig_upper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +int spider_db_connect( + const SPIDER_SHARE *share, + SPIDER_CONN *conn, + int link_idx +) { + int error_num, connect_retry_count; + THD* thd = current_thd; + longlong connect_retry_interval; + DBUG_ENTER("spider_db_connect"); + DBUG_ASSERT(conn->conn_kind != SPIDER_CONN_KIND_MYSQL || conn->need_mon); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); + + if (thd) + { + conn->connect_timeout = spider_param_connect_timeout(thd, + share->connect_timeouts[link_idx]); + conn->net_read_timeout = spider_param_net_read_timeout(thd, + share->net_read_timeouts[link_idx]); + conn->net_write_timeout = spider_param_net_write_timeout(thd, + share->net_write_timeouts[link_idx]); + connect_retry_interval = spider_param_connect_retry_interval(thd); + connect_retry_count = spider_param_connect_retry_count(thd); + } else { + conn->connect_timeout = spider_param_connect_timeout(NULL, + share->connect_timeouts[link_idx]); + conn->net_read_timeout = spider_param_net_read_timeout(NULL, + share->net_read_timeouts[link_idx]); + conn->net_write_timeout = spider_param_net_write_timeout(NULL, + share->net_write_timeouts[link_idx]); + connect_retry_interval = spider_param_connect_retry_interval(NULL); + connect_retry_count = spider_param_connect_retry_count(NULL); + } + DBUG_PRINT("info",("spider connect_timeout=%u", conn->connect_timeout)); + DBUG_PRINT("info",("spider net_read_timeout=%u", conn->net_read_timeout)); + DBUG_PRINT("info",("spider net_write_timeout=%u", conn->net_write_timeout)); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if ((error_num = spider_reset_conn_setted_parameter(conn, thd))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + + if (conn->dbton_id == SPIDER_DBTON_SIZE) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + my_printf_error( + ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, + ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, + MYF(0), conn->tgt_wrapper); + DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + my_printf_error( + ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, + ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, + MYF(0), conn->tgt_wrapper); + DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM); + } +#endif + } + + if ((error_num = conn->db_conn->connect( + share->tgt_hosts[link_idx], + share->tgt_usernames[link_idx], + share->tgt_passwords[link_idx], + share->tgt_ports[link_idx], + share->tgt_sockets[link_idx], + share->server_names[link_idx], + connect_retry_count, connect_retry_interval))) + { + DBUG_RETURN(error_num); + } + conn->opened_handlers = 0; + conn->db_conn->reset_opened_handler(); + ++conn->connection_id; + DBUG_RETURN(0); +} + +int spider_db_ping( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + DBUG_ENTER("spider_db_ping"); +#ifndef DBUG_OFF + if (spider->trx->thd) + DBUG_PRINT("info", ("spider thd->query_id is %lld", + spider->trx->thd->query_id)); +#endif + if (!conn->mta_conn_mutex_lock_already) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + } + DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); + if (conn->server_lost || conn->queued_connect) + { + if ((error_num = spider_db_connect(spider->share, conn, + spider->conn_link_idx[link_idx]))) + { + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); + } + conn->server_lost = FALSE; + conn->queued_connect = FALSE; + } + if ((error_num = conn->db_conn->ping())) + { + spider_db_disconnect(conn); + if ((error_num = spider_db_connect(spider->share, conn, + spider->conn_link_idx[link_idx]))) + { + DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); + conn->server_lost = TRUE; + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); + } + if((error_num = conn->db_conn->ping())) + { + spider_db_disconnect(conn); + DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); + conn->server_lost = TRUE; + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); + } + } + conn->ping_time = (time_t) time((time_t*) 0); + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(0); +} + +void spider_db_disconnect( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_db_disconnect"); + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider conn->conn_kind=%u", conn->conn_kind)); + if (conn->db_conn->is_connected()) + { + conn->db_conn->disconnect(); + } + DBUG_VOID_RETURN; +} + +int spider_db_conn_queue_action( + SPIDER_CONN *conn +) { + int error_num; + char sql_buf[MAX_FIELD_WIDTH * 2]; + spider_string sql_str(sql_buf, sizeof(sql_buf), system_charset_info); + DBUG_ENTER("spider_db_conn_queue_action"); + DBUG_PRINT("info", ("spider conn=%p", conn)); + sql_str.init_calc_mem(106); + sql_str.length(0); + if (conn->queued_connect) + { + if ((error_num = spider_db_connect(conn->queued_connect_share, conn, + conn->queued_connect_link_idx))) + { + DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); + conn->server_lost = TRUE; + DBUG_RETURN(error_num); + } + conn->server_lost = FALSE; + conn->queued_connect = FALSE; + } + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (conn->queued_ping) + { + if ((error_num = spider_db_ping(conn->queued_ping_spider, conn, + conn->queued_ping_link_idx))) + DBUG_RETURN(error_num); + conn->queued_ping = FALSE; + } + + if (conn->server_lost) + { + DBUG_PRINT("info", ("spider no reconnect queue")); + DBUG_RETURN(CR_SERVER_GONE_ERROR); + } + + if (conn->queued_net_timeout) + { + conn->db_conn->set_net_timeout(); + conn->queued_net_timeout = FALSE; + } + if ( + ( + conn->queued_trx_isolation && + !conn->queued_semi_trx_isolation && + conn->queued_trx_isolation_val != conn->trx_isolation && + conn->db_conn->set_trx_isolation_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_trx_isolation(&sql_str, conn->queued_trx_isolation_val)) + ) || + ( + conn->queued_semi_trx_isolation && + conn->queued_semi_trx_isolation_val != conn->trx_isolation && + conn->db_conn->set_trx_isolation_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_trx_isolation(&sql_str, conn->queued_semi_trx_isolation_val)) + ) || + ( + conn->queued_autocommit && + ( + (conn->queued_autocommit_val && conn->autocommit != 1) || + (!conn->queued_autocommit_val && conn->autocommit != 0) + ) && + conn->db_conn->set_autocommit_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_autocommit(&sql_str, conn->queued_autocommit_val)) + ) || + ( + conn->queued_sql_log_off && + ( + (conn->queued_sql_log_off_val && conn->sql_log_off != 1) || + (!conn->queued_sql_log_off_val && conn->sql_log_off != 0) + ) && + conn->db_conn->set_sql_log_off_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_sql_log_off(&sql_str, conn->queued_sql_log_off_val)) + ) || + ( + conn->queued_time_zone && + conn->queued_time_zone_val != conn->time_zone && + conn->db_conn->set_time_zone_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_time_zone(&sql_str, conn->queued_time_zone_val)) + ) || + ( + conn->queued_trx_start && + conn->db_conn->trx_start_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_start_transaction(&sql_str)) + ) || + ( + conn->queued_xa_start && + conn->db_conn->xa_start_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_xa_start(&sql_str, conn->queued_xa_start_xid)) + ) + ) + DBUG_RETURN(error_num); + if (sql_str.length()) + { + if ((error_num = conn->db_conn->exec_query(sql_str.ptr(), + sql_str.length(), -1))) + DBUG_RETURN(error_num); + spider_db_result *result; + do { + st_spider_db_request_key request_key; + request_key.spider_thread_id = 1; + request_key.query_id = 1; + request_key.handler = NULL; + request_key.request_id = 1; + request_key.next = NULL; + if ((result = conn->db_conn->store_result(NULL, &request_key, + &error_num))) + { + result->free_result(); + delete result; + } else if ((error_num = conn->db_conn->get_errno())) + { + break; + } + } while (!(error_num = conn->db_conn->next_result())); + if (error_num > 0) + DBUG_RETURN(error_num); + } + + if ( + conn->queued_autocommit && + ( + (conn->queued_autocommit_val && conn->autocommit != 1) || + (!conn->queued_autocommit_val && conn->autocommit != 0) + ) && + !conn->db_conn->set_autocommit_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_autocommit(&sql_str, conn->queued_autocommit_val)) + ) { + DBUG_RETURN(error_num); + } + if ( + conn->queued_sql_log_off && + ( + (conn->queued_sql_log_off_val && conn->sql_log_off != 1) || + (!conn->queued_sql_log_off_val && conn->sql_log_off != 0) + ) && + !conn->db_conn->set_sql_log_off_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_sql_log_off(&sql_str, conn->queued_sql_log_off_val)) + ) { + DBUG_RETURN(error_num); + } + if ( + conn->queued_time_zone && + conn->queued_time_zone_val != conn->time_zone && + !conn->db_conn->set_time_zone_in_bulk_sql() && + (error_num = spider_dbton[conn->dbton_id].db_util-> + append_time_zone(&sql_str, conn->queued_time_zone_val)) + ) { + DBUG_RETURN(error_num); + } + if ( + conn->queued_trx_isolation && + !conn->queued_semi_trx_isolation && + conn->queued_trx_isolation_val != conn->trx_isolation && + !conn->db_conn->set_trx_isolation_in_bulk_sql() && + (error_num = conn->db_conn->set_trx_isolation( + conn->queued_trx_isolation_val, (int *) conn->need_mon)) + ) { + DBUG_RETURN(error_num); + } + if ( + conn->queued_semi_trx_isolation && + conn->queued_semi_trx_isolation_val != conn->trx_isolation && + !conn->db_conn->set_trx_isolation_in_bulk_sql() && + (error_num = conn->db_conn->set_trx_isolation( + conn->queued_semi_trx_isolation_val, (int *) conn->need_mon)) + ) { + DBUG_RETURN(error_num); + } + if ( + conn->queued_trx_start && + !conn->db_conn->trx_start_in_bulk_sql() && + (error_num = conn->db_conn-> + start_transaction((int *) conn->need_mon)) + ) { + DBUG_RETURN(error_num); + } + if ( + conn->queued_xa_start && + !conn->db_conn->xa_start_in_bulk_sql() && + (error_num = conn->db_conn-> + xa_start(conn->queued_xa_start_xid, (int *) conn->need_mon)) + ) { + DBUG_RETURN(error_num); + } + + if ( + conn->queued_trx_isolation && + !conn->queued_semi_trx_isolation && + conn->queued_trx_isolation_val != conn->trx_isolation + ) { + conn->trx_isolation = conn->queued_trx_isolation_val; + DBUG_PRINT("info", ("spider conn->trx_isolation=%d", + conn->trx_isolation)); + } + + if ( + conn->queued_semi_trx_isolation && + conn->queued_semi_trx_isolation_val != conn->trx_isolation + ) { + conn->semi_trx_isolation = conn->queued_semi_trx_isolation_val; + DBUG_PRINT("info", ("spider conn->semi_trx_isolation=%d", + conn->semi_trx_isolation)); + conn->trx_isolation = thd_tx_isolation(conn->thd); + DBUG_PRINT("info", ("spider conn->trx_isolation=%d", + conn->trx_isolation)); + } + + if (conn->queued_autocommit) + { + if (conn->queued_autocommit_val && conn->autocommit != 1) + { + conn->autocommit = 1; + } else if (!conn->queued_autocommit_val && conn->autocommit != 0) + { + conn->autocommit = 0; + } + DBUG_PRINT("info", ("spider conn->autocommit=%d", + conn->autocommit)); + } + + if (conn->queued_sql_log_off) + { + if (conn->queued_sql_log_off_val && conn->sql_log_off != 1) + { + conn->sql_log_off = 1; + } else if (!conn->queued_sql_log_off_val && conn->sql_log_off != 0) + { + conn->sql_log_off = 0; + } + DBUG_PRINT("info", ("spider conn->sql_log_off=%d", + conn->sql_log_off)); + } + + if ( + conn->queued_time_zone && + conn->queued_time_zone_val != conn->time_zone + ) { + conn->time_zone = conn->queued_time_zone_val; + DBUG_PRINT("info", ("spider conn->time_zone=%p", + conn->time_zone)); + } + spider_conn_clear_queue(conn); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (conn->server_lost) + { + DBUG_PRINT("info", ("spider no connect queue")); + DBUG_RETURN(CR_SERVER_GONE_ERROR); + } +#endif + DBUG_RETURN(0); +} + +int spider_db_before_query( + SPIDER_CONN *conn, + int *need_mon +) { + int error_num; + DBUG_ENTER("spider_db_before_query"); + DBUG_ASSERT(need_mon); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (conn->bg_search) + spider_bg_conn_break(conn, NULL); +#endif + conn->in_before_query = TRUE; + if (!conn->mta_conn_mutex_lock_already) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = need_mon; + } + DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); + if ((error_num = spider_db_conn_queue_action(conn))) + { + conn->in_before_query = FALSE; + DBUG_RETURN(error_num); + } + if (conn->server_lost) + { + conn->in_before_query = FALSE; + DBUG_RETURN(CR_SERVER_GONE_ERROR); + } + DBUG_PRINT("info", ("spider conn[%p]->quick_target=%p", + conn, conn->quick_target)); + if (conn->quick_target) + { + bool tmp_mta_conn_mutex_unlock_later; + ha_spider *spider = (ha_spider*) conn->quick_target; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_PRINT("info", ("spider result_list->quick_mode=%d", + result_list->quick_mode)); + if (result_list->quick_mode == 2) + { + result_list->quick_phase = 1; + spider->connection_ids[conn->link_idx] = conn->connection_id; + tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later; + conn->mta_conn_mutex_unlock_later = TRUE; + while (conn->quick_target) + { + if ( + (error_num = spider_db_store_result(spider, conn->link_idx, + result_list->table)) && + error_num != HA_ERR_END_OF_FILE + ) { + conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; + conn->in_before_query = FALSE; + DBUG_RETURN(error_num); + } + } + conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; + result_list->quick_phase = 2; + } else { + result_list->bgs_current->result->free_result(); + delete result_list->bgs_current->result; + result_list->bgs_current->result = NULL; + DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", conn)); + conn->quick_target = NULL; + spider->quick_targets[conn->link_idx] = NULL; + } + } + conn->in_before_query = FALSE; + DBUG_RETURN(0); +} + +int spider_db_query( + SPIDER_CONN *conn, + const char *query, + uint length, + int quick_mode, + int *need_mon +) { + int error_num; + DBUG_ENTER("spider_db_query"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + DBUG_PRINT("info", ("spider conn->db_conn %p", conn->db_conn)); + if ( + !conn->in_before_query && + (error_num = spider_db_before_query(conn, need_mon)) + ) + DBUG_RETURN(error_num); +#ifndef DBUG_OFF + spider_string tmp_query_str(sizeof(char) * (length + 1)); + tmp_query_str.init_calc_mem(107); + char *tmp_query = (char *) tmp_query_str.c_ptr_safe(); + memcpy(tmp_query, query, length); + tmp_query[length] = '\0'; + query = (const char *) tmp_query; + DBUG_PRINT("info", ("spider query=%s", query)); + DBUG_PRINT("info", ("spider length=%u", length)); +#endif + if ((error_num = conn->db_conn->exec_query(query, length, quick_mode))) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn->queued_net_timeout) + { + if (conn->db_conn->set_net_timeout()) + DBUG_RETURN(ER_SPIDER_HS_NUM); + conn->queued_net_timeout = FALSE; + } + DBUG_RETURN(conn->db_conn->exec_query(NULL, 0, quick_mode)); + } +#endif +} + +int spider_db_errorno( + SPIDER_CONN *conn +) { + int error_num; + DBUG_ENTER("spider_db_errorno"); + DBUG_ASSERT(conn->need_mon); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (conn->server_lost) + { + *conn->need_mon = ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM; + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + if ((error_num = conn->db_conn->get_errno())) + { + DBUG_PRINT("info",("spider error_num = %d", error_num)); + if (conn->db_conn->is_server_gone_error(error_num)) + { + spider_db_disconnect(conn); + DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); + conn->server_lost = TRUE; + if (conn->disable_reconnect) + { + *conn->need_mon = ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM; + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + } + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } else if ( + conn->ignore_dup_key && + conn->db_conn->is_dup_entry_error(error_num) + ) { + conn->error_str = (char*) conn->db_conn->get_error(); + conn->error_length = strlen(conn->error_str); + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); + } else if ( + conn->db_conn->is_xa_nota_error(error_num) && + current_thd && + spider_param_force_commit(current_thd) == 1 + ) { + push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + error_num, conn->db_conn->get_error()); + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); + } + *conn->need_mon = error_num; + my_message(error_num, conn->db_conn->get_error(), MYF(0)); + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (conn->db_conn->is_server_gone_error(0)) + { + my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), + conn->db_conn->get_errno(), conn->db_conn->get_error()); + *conn->need_mon = ER_SPIDER_HS_NUM; + DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); + conn->server_lost = TRUE; + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(ER_SPIDER_HS_NUM); + } else if (conn->db_conn->is_dup_entry_error(0)) + { + *conn->need_mon = 0; + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); + } + my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), + conn->db_conn->get_errno(), conn->db_conn->get_error()); + *conn->need_mon = ER_SPIDER_HS_NUM; + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(ER_SPIDER_HS_NUM); + } +#endif + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(0); +} + +int spider_db_set_trx_isolation( + SPIDER_CONN *conn, + int trx_isolation, + int *need_mon +) { + DBUG_ENTER("spider_db_set_trx_isolation"); + DBUG_RETURN(conn->db_conn->set_trx_isolation(trx_isolation, need_mon)); +} + +int spider_db_set_names_internal( + SPIDER_TRX *trx, + SPIDER_SHARE *share, + SPIDER_CONN *conn, + int all_link_idx, + int *need_mon +) { + bool tmp_mta_conn_mutex_lock_already; + DBUG_ENTER("spider_db_set_names_internal"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (!conn->mta_conn_mutex_lock_already) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = need_mon; + } + DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); + if ( + !conn->access_charset || + share->access_charset->cset != conn->access_charset->cset + ) { + tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already; + conn->mta_conn_mutex_lock_already = TRUE; + if ( + spider_db_before_query(conn, need_mon) || + conn->db_conn->set_character_set(share->access_charset->csname) + ) { + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + DBUG_RETURN(spider_db_errorno(conn)); + } + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + conn->access_charset = share->access_charset; + } + if ( + spider_param_use_default_database(trx->thd) && + ( + !conn->default_database.length() || + conn->default_database.length() != + share->tgt_dbs_lengths[all_link_idx] || + memcmp(share->tgt_dbs[all_link_idx], conn->default_database.ptr(), + share->tgt_dbs_lengths[all_link_idx]) + ) + ) { + DBUG_PRINT("info",("spider all_link_idx=%d db=%s", all_link_idx, + share->tgt_dbs[all_link_idx])); + tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already; + conn->mta_conn_mutex_lock_already = TRUE; + if ( + spider_db_before_query(conn, need_mon) || + conn->db_conn->select_db(share->tgt_dbs[all_link_idx]) + ) { + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + DBUG_RETURN(spider_db_errorno(conn)); + } + conn->default_database.length(0); + if (conn->default_database.reserve( + share->tgt_dbs_lengths[all_link_idx] + 1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + conn->default_database.q_append(share->tgt_dbs[all_link_idx], + share->tgt_dbs_lengths[all_link_idx] + 1); + conn->default_database.length(share->tgt_dbs_lengths[all_link_idx]); + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + } + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + DBUG_RETURN(0); +} + +int spider_db_set_names( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_db_set_names"); + DBUG_RETURN(spider_db_set_names_internal(spider->trx, spider->share, conn, + spider->conn_link_idx[link_idx], &spider->need_mons[link_idx])); +} + +int spider_db_query_with_set_names( + ulong sql_type, + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + DBUG_ENTER("spider_db_query_with_set_names"); + +/* + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); +*/ + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + share->monitoring_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + share->monitoring_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + } + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_db_query_for_bulk_update( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx, + uint *dup_key_found +) { + int error_num; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_db_query_for_bulk_update"); + +/* + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); +*/ + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + share->monitoring_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL, + conn, + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + error_num != ER_DUP_ENTRY && + error_num != ER_DUP_KEY && + error_num != HA_ERR_FOUND_DUPP_KEY && + share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + share->monitoring_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + } + if ( + error_num == ER_DUP_ENTRY || + error_num == ER_DUP_KEY || + error_num == HA_ERR_FOUND_DUPP_KEY + ) { + ++(*dup_key_found); + DBUG_RETURN(0); + } + DBUG_RETURN(error_num); + } + while (!(error_num = conn->db_conn->next_result())) + { + ; + } + if (error_num > 0 && !conn->db_conn->is_dup_entry_error(error_num)) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[link_idx], + share->table_name, + share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + share->monitoring_kind[link_idx], + share->monitoring_limit[link_idx], + TRUE + ); + } + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +size_t spider_db_real_escape_string( + SPIDER_CONN *conn, + char *to, + const char *from, + size_t from_length +) { + DBUG_ENTER("spider_db_real_escape_string"); + DBUG_RETURN(conn->db_conn->escape_string(to, from, from_length)); +} + +int spider_db_consistent_snapshot( + SPIDER_CONN *conn, + int *need_mon +) { + int error_num; + DBUG_ENTER("spider_db_consistent_snapshot"); + if ((error_num = conn->db_conn->consistent_snapshot(need_mon))) + { + DBUG_RETURN(error_num); + } + conn->trx_start = TRUE; + DBUG_RETURN(0); +} + +int spider_db_start_transaction( + SPIDER_CONN *conn, + int *need_mon +) { + int error_num; + DBUG_ENTER("spider_db_start_transaction"); + if ((error_num = conn->db_conn->start_transaction(need_mon))) + { + DBUG_RETURN(error_num); + } + conn->trx_start = TRUE; + DBUG_RETURN(0); +} + +int spider_db_commit( + SPIDER_CONN *conn +) { + int need_mon = 0, error_num; + DBUG_ENTER("spider_db_commit"); + if (!conn->queued_connect && !conn->queued_trx_start) + { + if (conn->use_for_active_standby && conn->server_lost) + { + my_message(ER_SPIDER_LINK_IS_FAILOVER_NUM, + ER_SPIDER_LINK_IS_FAILOVER_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_LINK_IS_FAILOVER_NUM); + } + if ((error_num = conn->db_conn->commit(&need_mon))) + { + DBUG_RETURN(error_num); + } + conn->trx_start = FALSE; + } else + conn->trx_start = FALSE; + DBUG_RETURN(0); +} + +int spider_db_rollback( + SPIDER_CONN *conn +) { + int error_num, need_mon = 0; + DBUG_ENTER("spider_db_rollback"); + if (!conn->queued_connect && !conn->queued_trx_start) + { + if ((error_num = conn->db_conn->rollback(&need_mon))) + { + DBUG_RETURN(error_num); + } + conn->trx_start = FALSE; + } else + conn->trx_start = FALSE; + DBUG_RETURN(0); +} + +int spider_db_append_hex_string( + spider_string *str, + uchar *hex_ptr, + int hex_ptr_length +) { + uchar *end_ptr; + char *str_ptr; + DBUG_ENTER("spider_db_append_hex_string"); + if (hex_ptr_length) + { + if (str->reserve(SPIDER_SQL_HEX_LEN + hex_ptr_length * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HEX_STR, SPIDER_SQL_HEX_LEN); + str_ptr = (char *) str->ptr() + str->length(); + for (end_ptr = hex_ptr + hex_ptr_length; hex_ptr < end_ptr; hex_ptr++) + { + *str_ptr++ = spider_dig_upper[(*hex_ptr) >> 4]; + *str_ptr++ = spider_dig_upper[(*hex_ptr) & 0x0F]; + } + str->length(str->length() + hex_ptr_length * 2); + } else { + if (str->reserve((SPIDER_SQL_VALUE_QUOTE_LEN) * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } + DBUG_RETURN(0); +} + +void spider_db_append_xid_str( + spider_string *tmp_str, + XID *xid +) { + char format_id[sizeof(long) + 3]; + uint format_id_length; + DBUG_ENTER("spider_db_append_xid_str"); + + format_id_length = + my_sprintf(format_id, (format_id, "0x%lx", xid->formatID)); + spider_db_append_hex_string(tmp_str, (uchar *) xid->data, xid->gtrid_length); +/* + tmp_str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + tmp_str->q_append(xid->data, xid->gtrid_length); + tmp_str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); +*/ + tmp_str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + spider_db_append_hex_string(tmp_str, + (uchar *) xid->data + xid->gtrid_length, xid->bqual_length); +/* + tmp_str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + tmp_str->q_append(xid->data + xid->gtrid_length, xid->bqual_length); + tmp_str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); +*/ + tmp_str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + tmp_str->q_append(format_id, format_id_length); +#ifndef DBUG_OFF + ((char *) tmp_str->ptr())[tmp_str->length()] = '\0'; +#endif + + DBUG_VOID_RETURN; +} + +int spider_db_xa_end( + SPIDER_CONN *conn, + XID *xid +) { + int need_mon = 0; + DBUG_ENTER("spider_db_xa_end"); + if (!conn->queued_connect && !conn->queued_xa_start) + { + DBUG_RETURN(conn->db_conn->xa_end(xid, &need_mon)); + } + DBUG_RETURN(0); +} + +int spider_db_xa_prepare( + SPIDER_CONN *conn, + XID *xid +) { + int need_mon = 0; + DBUG_ENTER("spider_db_xa_prepare"); + if (!conn->queued_connect && !conn->queued_xa_start) + { + if (conn->use_for_active_standby && conn->server_lost) + { + my_message(ER_SPIDER_LINK_IS_FAILOVER_NUM, + ER_SPIDER_LINK_IS_FAILOVER_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_LINK_IS_FAILOVER_NUM); + } + DBUG_RETURN(conn->db_conn->xa_prepare(xid, &need_mon)); + } + DBUG_RETURN(0); +} + +int spider_db_xa_commit( + SPIDER_CONN *conn, + XID *xid +) { + int need_mon = 0; + DBUG_ENTER("spider_db_xa_commit"); + if (!conn->queued_connect && !conn->queued_xa_start) + { + DBUG_RETURN(conn->db_conn->xa_commit(xid, &need_mon)); + } + DBUG_RETURN(0); +} + +int spider_db_xa_rollback( + SPIDER_CONN *conn, + XID *xid +) { + int need_mon = 0; + DBUG_ENTER("spider_db_xa_rollback"); + if (!conn->queued_connect && !conn->queued_xa_start) + { + DBUG_RETURN(conn->db_conn->xa_rollback(xid, &need_mon)); + } + DBUG_RETURN(0); +} + +int spider_db_lock_tables( + ha_spider *spider, + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + DBUG_ENTER("spider_db_lock_tables"); + error_num = spider->dbton_handler[conn->dbton_id]->lock_tables(link_idx); + DBUG_RETURN(error_num); +} + +int spider_db_unlock_tables( + ha_spider *spider, + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + DBUG_ENTER("spider_db_unlock_tables"); + error_num = spider->dbton_handler[conn->dbton_id]->unlock_tables(link_idx); + DBUG_RETURN(error_num); +} + +int spider_db_append_name_with_quote_str( + spider_string *str, + char *name, + uint dbton_id +) { + int error_num, length = strlen(name); + char *name_end, head_code; + DBUG_ENTER("spider_db_append_name_with_quote_str"); + for (name_end = name + length; name < name_end; name += length) + { + head_code = *name; + if (!(length = my_mbcharlen(system_charset_info, (uchar) head_code))) + { + my_message(ER_SPIDER_WRONG_CHARACTER_IN_NAME_NUM, + ER_SPIDER_WRONG_CHARACTER_IN_NAME_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_WRONG_CHARACTER_IN_NAME_NUM); + } + if ( + length == 1 && + spider_dbton[dbton_id].db_util->is_name_quote(head_code) + ) { + if ((error_num = spider_dbton[dbton_id].db_util-> + append_escaped_name_quote(str))) + { + DBUG_RETURN(error_num); + } + } else { + if (str->append(name, length, system_charset_info)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + DBUG_RETURN(0); +} + +int spider_db_append_select( + ha_spider *spider +) { + int error_num; + DBUG_ENTER("spider_db_append_select"); + + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = spider->append_select_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = spider->append_select_sql_part( + SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_db_append_select_columns( + ha_spider *spider +) { + int error_num; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_db_append_select_columns"); + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = spider->append_match_select_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL, NULL, 0))) + DBUG_RETURN(error_num); + if (!spider->select_column_mode) + { + if (result_list->keyread) + { + if ((error_num = spider->append_key_select_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL, spider->active_index))) + DBUG_RETURN(error_num); + } else { + if ((error_num = spider->append_table_select_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + } else { + if ((error_num = spider->append_minimum_select_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = spider->append_from_sql_part(SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_db_append_null_value( + spider_string *str, + KEY_PART_INFO *key_part, + const uchar **ptr +) { + DBUG_ENTER("spider_db_append_null_value"); + if (key_part->null_bit) + { + if (*(*ptr)++) + { + if (str->reserve(SPIDER_SQL_NULL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + DBUG_RETURN(-1); + } + } + DBUG_RETURN(0); +} + +int spider_db_append_key_columns( + const key_range *start_key, + ha_spider *spider, + spider_string *str +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + KEY *key_info = result_list->key_info; + uint key_name_length, key_count; + key_part_map full_key_part_map = make_prev_keypart_map(key_info->key_parts); + key_part_map start_key_part_map; + char tmp_buf[MAX_FIELD_WIDTH]; + DBUG_ENTER("spider_db_append_key_columns"); + + start_key_part_map = start_key->keypart_map & full_key_part_map; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", key_info->key_parts)); + DBUG_PRINT("info", ("spider full_key_part_map=%lu", full_key_part_map)); + DBUG_PRINT("info", ("spider start_key_part_map=%lu", start_key_part_map)); + + if (!start_key_part_map) + DBUG_RETURN(0); + + for ( + key_count = 0; + start_key_part_map; + start_key_part_map >>= 1, + key_count++ + ) { + key_name_length = my_sprintf(tmp_buf, (tmp_buf, "c%u", key_count)); + if (str->reserve(key_name_length + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(tmp_buf, key_name_length); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + + DBUG_RETURN(0); +} + +int spider_db_append_key_hint( + spider_string *str, + char *hint_str +) { + int hint_str_len = strlen(hint_str); + DBUG_ENTER("spider_db_append_key_hint"); + if (hint_str_len >= 2 && + (hint_str[0] == 'f' || hint_str[0] == 'F') && hint_str[1] == ' ' + ) { + if (str->reserve(hint_str_len - 2 + + SPIDER_SQL_SQL_FORCE_IDX_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + hint_str += 2; + str->q_append(SPIDER_SQL_SQL_FORCE_IDX_STR, SPIDER_SQL_SQL_FORCE_IDX_LEN); + str->q_append(hint_str, hint_str_len - 2); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } else if (hint_str_len >= 2 && + (hint_str[0] == 'u' || hint_str[0] == 'U') && hint_str[1] == ' ' + ) { + if (str->reserve(hint_str_len - 2 + + SPIDER_SQL_SQL_USE_IDX_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + hint_str += 2; + str->q_append(SPIDER_SQL_SQL_USE_IDX_STR, SPIDER_SQL_SQL_USE_IDX_LEN); + str->q_append(hint_str, hint_str_len - 2); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } else if (hint_str_len >= 3 && + (hint_str[0] == 'i' || hint_str[0] == 'I') && + (hint_str[1] == 'g' || hint_str[1] == 'G') && hint_str[2] == ' ' + ) { + if (str->reserve(hint_str_len - 3 + + SPIDER_SQL_SQL_IGNORE_IDX_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + hint_str += 3; + str->q_append( + SPIDER_SQL_SQL_IGNORE_IDX_STR, SPIDER_SQL_SQL_IGNORE_IDX_LEN); + str->q_append(hint_str, hint_str_len - 3); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } else if (str->reserve(hint_str_len + SPIDER_SQL_SPACE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + else + { + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + str->q_append(hint_str, hint_str_len); + } + DBUG_RETURN(0); +} + +int spider_db_append_hint_after_table( + ha_spider *spider, + spider_string *str, + spider_string *hint +) { + DBUG_ENTER("spider_db_append_hint_after_table"); + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + if (str->append(*hint)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + DBUG_RETURN(0); +} + +int spider_db_append_key_where_internal( + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + const key_range *start_key, + const key_range *end_key, + ha_spider *spider, + bool set_order, + ulong sql_type, + uint dbton_id +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_SHARE *share = spider->share; +#ifndef DBUG_OFF + TABLE *table = spider->get_table(); +#endif + KEY *key_info = result_list->key_info; + int error_num; + uint key_name_length; + key_part_map full_key_part_map; + key_part_map start_key_part_map; + key_part_map end_key_part_map; + key_part_map tgt_key_part_map; + int key_count; + uint length; + uint store_length; + const uchar *ptr, *another_ptr; + const key_range *use_key, *another_key; + KEY_PART_INFO *key_part; + Field *field; + bool use_both = TRUE, key_eq; + uint sql_kind; + spider_db_handler *dbton_hdl = spider->dbton_handler[dbton_id]; + spider_db_share *dbton_share = share->dbton_share[dbton_id]; + DBUG_ENTER("spider_db_append_key_where_internal"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_HANDLER: + sql_kind = SPIDER_SQL_KIND_HANDLER; + break; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + case SPIDER_SQL_TYPE_SELECT_HS: + case SPIDER_SQL_TYPE_INSERT_HS: + case SPIDER_SQL_TYPE_UPDATE_HS: + case SPIDER_SQL_TYPE_DELETE_HS: + sql_kind = SPIDER_SQL_KIND_HS; + break; +#endif + default: + sql_kind = SPIDER_SQL_KIND_SQL; + break; + } + + if (key_info) + full_key_part_map = make_prev_keypart_map(key_info->key_parts); + else + full_key_part_map = 0; + + if (start_key) + start_key_part_map = start_key->keypart_map & full_key_part_map; + else { + start_key_part_map = 0; + use_both = FALSE; + } + if (end_key) + end_key_part_map = end_key->keypart_map & full_key_part_map; + else { + end_key_part_map = 0; + use_both = FALSE; + } + DBUG_PRINT("info", ("spider key_info->key_parts=%u", key_info ? + key_info->key_parts : 0)); + DBUG_PRINT("info", ("spider full_key_part_map=%lu", full_key_part_map)); + DBUG_PRINT("info", ("spider start_key_part_map=%lu", start_key_part_map)); + DBUG_PRINT("info", ("spider end_key_part_map=%lu", end_key_part_map)); + +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, table->read_set); +#endif + + if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + char *key_name = key_info->name; + key_name_length = strlen(key_name); + if (str->reserve(SPIDER_SQL_READ_LEN + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + key_name_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_READ_STR, SPIDER_SQL_READ_LEN); + if ((error_num = spider_dbton[dbton_id].db_util-> + append_name(str, key_name, key_name_length))) + { + DBUG_RETURN(error_num); + } + dbton_hdl->set_order_pos(SPIDER_SQL_TYPE_HANDLER); + if (start_key_part_map || end_key_part_map) + { + if (str_part->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str_part->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + result_list->ha_read_kind = 0; + } else if (!result_list->desc_flg) + { + if (str->reserve(SPIDER_SQL_FIRST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FIRST_STR, SPIDER_SQL_FIRST_LEN); + result_list->ha_read_kind = 1; + } else { + if (str->reserve(SPIDER_SQL_LAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LAST_STR, SPIDER_SQL_LAST_LEN); + result_list->ha_read_kind = 2; + } + } + if (!start_key_part_map && !end_key_part_map) + goto end; + else if (start_key_part_map >= end_key_part_map) + { + use_key = start_key; + another_key = end_key; + tgt_key_part_map = start_key_part_map; + } else { + use_key = end_key; + another_key = start_key; + tgt_key_part_map = end_key_part_map; + } + DBUG_PRINT("info", ("spider tgt_key_part_map=%lu", tgt_key_part_map)); + + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + if (str_part2->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str_part2->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + } + + for ( + key_part = key_info->key_part, + length = 0, + key_count = 0; + tgt_key_part_map; + length += store_length, + tgt_key_part_map >>= 1, + start_key_part_map >>= 1, + end_key_part_map >>= 1, + key_part++, + key_count++ + ) { + store_length = key_part->store_length; + field = key_part->field; + key_name_length = dbton_share->get_column_name_length(field->field_index); + ptr = use_key->key + length; + if (use_both) + { + another_ptr = another_key->key + length; + if ( + start_key_part_map && + end_key_part_map && + !memcmp(ptr, another_ptr, store_length) + ) + key_eq = TRUE; + else { + key_eq = FALSE; +#ifndef DBUG_OFF + if ( + start_key_part_map && + end_key_part_map + ) + DBUG_PRINT("info", ("spider memcmp=%d", + memcmp(ptr, another_ptr, store_length))); +#endif + } + } else { + if (tgt_key_part_map > 1) + key_eq = TRUE; + else + key_eq = FALSE; + } + if ( + (key_eq && use_key == start_key) || + (!key_eq && start_key_part_map) + ) { + ptr = start_key->key + length; + if ( + (error_num = dbton_hdl->append_is_null_part(sql_type, key_part, + start_key, &ptr, key_eq)) + ) { + if (error_num > 0) + DBUG_RETURN(error_num); + if ( + !set_order && + start_key->flag != HA_READ_KEY_EXACT && + sql_kind == SPIDER_SQL_KIND_SQL + ) { + result_list->key_order = key_count; + set_order = TRUE; + } + } else if (key_eq) + { + DBUG_PRINT("info", ("spider key_eq")); + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else { + if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> + append_column_value(spider, NULL, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#endif + } else { + DBUG_PRINT("info", ("spider start_key->flag=%d", start_key->flag)); + switch (start_key->flag) + { +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + case HA_READ_PREFIX_LAST: + result_list->desc_flg = TRUE; + /* fall through */ +#endif + case HA_READ_KEY_EXACT: + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve(SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else { + if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> + append_column_value(spider, NULL, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->reserve(SPIDER_SQL_HS_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HS_EQUAL_STR, SPIDER_SQL_HS_EQUAL_LEN); + } +#endif + break; + case HA_READ_AFTER_KEY: + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_GT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (use_both) + start_key_part_map = 0; + if (!set_order) + { + result_list->key_order = key_count; + set_order = TRUE; + } + } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_GT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve(SPIDER_SQL_GT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else { + if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> + append_column_value(spider, NULL, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->reserve(SPIDER_SQL_HS_GT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HS_GT_STR, SPIDER_SQL_HS_GT_LEN); + } +#endif + break; + case HA_READ_BEFORE_KEY: + result_list->desc_flg = TRUE; + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_LT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (use_both) + start_key_part_map = 0; + if (!set_order) + { + result_list->key_order = key_count; + set_order = TRUE; + } + } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_LT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve(SPIDER_SQL_LT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else { + if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> + append_column_value(spider, NULL, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->reserve(SPIDER_SQL_HS_LT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HS_LT_STR, SPIDER_SQL_HS_LT_LEN); + } +#endif + break; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +#else + case HA_READ_PREFIX_LAST: + result_list->limit_num = 1; + /* fall through */ +#endif + case HA_READ_KEY_OR_PREV: + case HA_READ_PREFIX_LAST_OR_PREV: + result_list->desc_flg = TRUE; + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_LTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (!set_order) + { + result_list->key_order = key_count; + set_order = TRUE; + } + } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_LTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_LTEQUAL_STR, + SPIDER_SQL_LTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve(SPIDER_SQL_LTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else { + if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> + append_column_value(spider, NULL, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->reserve(SPIDER_SQL_HS_LTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HS_LTEQUAL_STR, + SPIDER_SQL_HS_LTEQUAL_LEN); + } +#endif + break; + case HA_READ_MBR_CONTAIN: + if (str->reserve(SPIDER_SQL_MBR_CONTAIN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MBR_CONTAIN_STR, + SPIDER_SQL_MBR_CONTAIN_LEN); + if ( + spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + break; + case HA_READ_MBR_INTERSECT: + if (str->reserve(SPIDER_SQL_MBR_INTERSECT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MBR_INTERSECT_STR, + SPIDER_SQL_MBR_INTERSECT_LEN); + if ( + spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + break; + case HA_READ_MBR_WITHIN: + if (str->reserve(SPIDER_SQL_MBR_WITHIN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MBR_WITHIN_STR, + SPIDER_SQL_MBR_WITHIN_LEN); + if ( + spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + break; + case HA_READ_MBR_DISJOINT: + if (str->reserve(SPIDER_SQL_MBR_DISJOINT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MBR_DISJOINT_STR, + SPIDER_SQL_MBR_DISJOINT_LEN); + if ( + spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + break; + case HA_READ_MBR_EQUAL: + if (str->reserve(SPIDER_SQL_MBR_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MBR_EQUAL_STR, SPIDER_SQL_MBR_EQUAL_LEN); + if ( + spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + break; + default: + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_GTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_GTEQUAL_STR, SPIDER_SQL_GTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (!set_order) + { + result_list->key_order = key_count; + set_order = TRUE; + } + } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_GTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_GTEQUAL_STR, + SPIDER_SQL_GTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve(SPIDER_SQL_GTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_GTEQUAL_STR, SPIDER_SQL_GTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else { + if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> + append_column_value(spider, NULL, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->reserve(SPIDER_SQL_HS_GTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HS_GTEQUAL_STR, + SPIDER_SQL_HS_GTEQUAL_LEN); + } +#endif + break; + } + } + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AND_STR, + SPIDER_SQL_AND_LEN); + } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) + { + if (str_part2->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str_part2->q_append(SPIDER_SQL_AND_STR, + SPIDER_SQL_AND_LEN); + + if (str_part->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str_part->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (sql_kind != SPIDER_SQL_KIND_HS) + { +#endif + if ( + (key_eq && use_key == end_key) || + (!key_eq && end_key_part_map) + ) { + ptr = end_key->key + length; + if ((error_num = dbton_hdl->append_is_null_part(sql_type, key_part, + end_key, &ptr, key_eq))) + { + if (error_num > 0) + DBUG_RETURN(error_num); + if ( + !set_order && + end_key->flag != HA_READ_KEY_EXACT && + sql_kind == SPIDER_SQL_KIND_SQL + ) { + result_list->key_order = key_count; + set_order = TRUE; + } + } else if (key_eq) + { + DBUG_PRINT("info", ("spider key_eq")); + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } else { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve(SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } else { + DBUG_PRINT("info", ("spider end_key->flag=%d", end_key->flag)); + switch (end_key->flag) + { + case HA_READ_BEFORE_KEY: + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_LT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (use_both) + end_key_part_map = 0; + if (!set_order) + { + result_list->key_order = key_count; + set_order = TRUE; + } + } else { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_LT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve(SPIDER_SQL_LT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + break; + default: + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_LTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (!set_order) + { + result_list->key_order = key_count; + set_order = TRUE; + } + } else { + if (str_part2->reserve(store_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_LTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str_part2, field->field_index); + str_part2->q_append(SPIDER_SQL_LTEQUAL_STR, + SPIDER_SQL_LTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part2, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve(SPIDER_SQL_LTEQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); + if (spider_dbton[dbton_id].db_util-> + append_column_value(spider, str_part, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + break; + } + } + if (sql_kind == SPIDER_SQL_KIND_SQL) + { + if (str->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AND_STR, + SPIDER_SQL_AND_LEN); + } else { + if (str_part2->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str_part2->q_append(SPIDER_SQL_AND_STR, + SPIDER_SQL_AND_LEN); + + if (str_part->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str_part->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if (use_both && (!start_key_part_map || !end_key_part_map)) + break; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + } + if ((error_num = dbton_hdl->append_where_terminator_part(sql_type, + set_order, key_count))) + DBUG_RETURN(error_num); + +end: + /* use condition */ + if (dbton_hdl->append_condition_part(NULL, 0, sql_type, FALSE)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (sql_kind == SPIDER_SQL_KIND_SQL) + dbton_hdl->set_order_pos(sql_type); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + DBUG_RETURN(0); +} + +int spider_db_append_key_where( + const key_range *start_key, + const key_range *end_key, + ha_spider *spider +) { + int error_num; + DBUG_ENTER("spider_db_append_key_where"); + if ((spider->sql_kinds & SPIDER_SQL_KIND_SQL)) + { + DBUG_PRINT("info",("spider call internal by SPIDER_SQL_KIND_SQL")); + if ((error_num = spider->append_key_where_sql_part(start_key, end_key, + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + DBUG_PRINT("info",("spider call internal by SPIDER_SQL_KIND_HANDLER")); + if ((error_num = spider->append_key_where_sql_part(start_key, end_key, + SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((spider->sql_kinds & SPIDER_SQL_KIND_HS)) + { + DBUG_PRINT("info",("spider call internal by SPIDER_SQL_KIND_HS")); + if ((error_num = spider->append_key_where_hs_part(start_key, end_key, + SPIDER_SQL_TYPE_SELECT_HS))) + DBUG_RETURN(error_num); + } +#endif + DBUG_RETURN(0); +} + +int spider_db_append_match_fetch( + ha_spider *spider, + st_spider_ft_info *ft_first, + st_spider_ft_info *ft_current, + SPIDER_DB_ROW *row +) { + DBUG_ENTER("spider_db_append_match_fetch"); + if (ft_current) + { + st_spider_ft_info *ft_info = ft_first; + while (TRUE) + { + DBUG_PRINT("info",("spider ft_info=%p", ft_info)); + if (!row->is_null()) + ft_info->score = (float) row->val_real(); + else + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + row->next(); + if (ft_info == ft_current) + break; + ft_info = ft_info->next; + } + } + DBUG_RETURN(0); +} + +int spider_db_append_match_where( + ha_spider *spider +) { + int error_num; + DBUG_ENTER("spider_db_append_match_where"); + if ((error_num = spider->append_match_where_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + + /* use condition */ + if ((error_num = spider->append_condition_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL, FALSE))) + DBUG_RETURN(error_num); + + spider->set_order_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + DBUG_RETURN(0); +} + +void spider_db_append_handler_next( + ha_spider *spider +) { + const char *alias; + uint alias_length; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_db_append_handler_next"); + if (result_list->sorted && result_list->desc_flg) + { + alias = SPIDER_SQL_PREV_STR; + alias_length = SPIDER_SQL_PREV_LEN; + } else { + alias = SPIDER_SQL_NEXT_STR; + alias_length = SPIDER_SQL_NEXT_LEN; + } + spider->set_order_to_pos_sql(SPIDER_SQL_TYPE_HANDLER); + spider->append_key_order_with_alias_sql_part(alias, alias_length, + SPIDER_SQL_TYPE_HANDLER); + DBUG_VOID_RETURN; +} + +void spider_db_get_row_from_tmp_tbl_rec( + SPIDER_RESULT *current, + SPIDER_DB_ROW **row +) { + DBUG_ENTER("spider_db_get_row_from_tmp_tbl_rec"); + *row = current->result->fetch_row_from_tmp_table(current->result_tmp_tbl); + DBUG_VOID_RETURN; +} + +int spider_db_get_row_from_tmp_tbl( + SPIDER_RESULT *current, + SPIDER_DB_ROW **row +) { + int error_num; + DBUG_ENTER("spider_db_get_row_from_tmp_tbl"); + if (current->result_tmp_tbl_inited == 2) + { + current->result_tmp_tbl->file->ha_rnd_end(); + current->result_tmp_tbl_inited = 0; + } + if (current->result_tmp_tbl_inited == 0) + { + current->result_tmp_tbl->file->extra(HA_EXTRA_CACHE); + if ((error_num = current->result_tmp_tbl->file->ha_rnd_init(TRUE))) + DBUG_RETURN(error_num); + current->result_tmp_tbl_inited = 1; + } + if ( +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + (error_num = current->result_tmp_tbl->file->ha_rnd_next( + current->result_tmp_tbl->record[0])) +#else + (error_num = current->result_tmp_tbl->file->rnd_next( + current->result_tmp_tbl->record[0])) +#endif + ) { + DBUG_RETURN(error_num); + } + spider_db_get_row_from_tmp_tbl_rec(current, row); + DBUG_RETURN(0); +} + +int spider_db_get_row_from_tmp_tbl_pos( + SPIDER_POSITION *pos, + SPIDER_DB_ROW **row +) { + int error_num; + SPIDER_RESULT *result = pos->result; + TABLE *tmp_tbl = result->result_tmp_tbl; + DBUG_ENTER("spider_db_get_row_from_tmp_tbl_pos"); + if (result->result_tmp_tbl_inited == 1) + { + tmp_tbl->file->ha_rnd_end(); + result->result_tmp_tbl_inited = 0; + } + if (result->result_tmp_tbl_inited == 0) + { + if ((error_num = tmp_tbl->file->ha_rnd_init(FALSE))) + DBUG_RETURN(error_num); + result->result_tmp_tbl_inited = 2; + } + if ( +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + (error_num = tmp_tbl->file->ha_rnd_pos(tmp_tbl->record[0], + (uchar *) &pos->tmp_tbl_pos)) +#else + (error_num = tmp_tbl->file->rnd_pos(tmp_tbl->record[0], + (uchar *) &pos->tmp_tbl_pos)) +#endif + ) { + DBUG_RETURN(error_num); + } + spider_db_get_row_from_tmp_tbl_rec(result, row); + DBUG_RETURN(0); +} + +int spider_db_fetch_row( + SPIDER_SHARE *share, + Field *field, + SPIDER_DB_ROW *row, + my_ptrdiff_t ptr_diff +) { + int error_num; + DBUG_ENTER("spider_db_fetch_row"); + DBUG_PRINT("info", ("spider field_name %s", field->field_name)); + DBUG_PRINT("info", ("spider fieldcharset %s", field->charset()->csname)); + field->move_field_offset(ptr_diff); + error_num = row->store_to_field(field, share->access_charset); + field->move_field_offset(-ptr_diff); + DBUG_RETURN(error_num); +} + +int spider_db_fetch_table( + ha_spider *spider, + uchar *buf, + TABLE *table, + SPIDER_RESULT_LIST *result_list +) { + int error_num; + SPIDER_SHARE *share = spider->share; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]); + SPIDER_RESULT *current = (SPIDER_RESULT*) result_list->current; + SPIDER_DB_ROW *row; + Field **field; + DBUG_ENTER("spider_db_fetch_table"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (result_list->quick_mode == 0) + { + SPIDER_DB_RESULT *result = current->result; + if (!(row = result->fetch_row())) + { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + } else { + if (result_list->current_row_num < result_list->quick_page_size) + { + row = current->first_position[result_list->current_row_num].row; + } else { + if ((error_num = spider_db_get_row_from_tmp_tbl( + current, &row))) + { + if (error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(error_num); + } + } + } + + /* for mrr */ + if (spider->mrr_with_cnt) + { + DBUG_PRINT("info", ("spider mrr_with_cnt")); + if (spider->sql_kind[spider->result_link_idx] == SPIDER_SQL_KIND_SQL) + { + if (!row->is_null()) + spider->multi_range_hit_point = row->val_int(); + else + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + row->next(); + } else + spider->multi_range_hit_point = 0; + } + + if ((error_num = spider_db_append_match_fetch(spider, + spider->ft_first, spider->ft_current, row))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (!(row = result_list->hs_result->fetch_row_from_result_buffer( + result_list->hs_result_buf))) + { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + } +#endif + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) + { +#endif + for ( + field = table->field; + *field; + field++ + ) { + if (( + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + )) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->field_name)); + if ((error_num = + spider_db_fetch_row(share, *field, row, ptr_diff))) + DBUG_RETURN(error_num); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + } + row->next(); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if (spider->hs_pushed_ret_fields_num == MAX_FIELDS) + { +#endif + for ( + field = table->field; + *field; + field++ + ) { + if ( + spider_bit_is_set(spider->searched_bitmap, (*field)->field_index) | + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + ) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + if ((error_num = spider_db_fetch_row(share, *field, row, ptr_diff))) + DBUG_RETURN(error_num); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + row->next(); + } + } +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + } else { + uint32 *field_idxs = spider->hs_pushed_ret_fields; + size_t field_idxs_num = spider->hs_pushed_ret_fields_num; + Field *tf; + int roop_count; + if (spider->hs_pushed_lcl_fields_num != + result_list->hs_result->num_fields()) + { + DBUG_PRINT("info", ("spider different field_num %zu %u", + spider->hs_pushed_lcl_fields_num, + result_list->hs_result->num_fields())); + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + } + for (roop_count = 0; roop_count < (int) field_idxs_num; + roop_count++) + { + tf = spider->get_top_table_field(field_idxs[roop_count]); + if ((tf = spider->field_exchange(tf))) + { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + if ((error_num = spider_db_fetch_row(share, tf, row, ptr_diff))) + DBUG_RETURN(error_num); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + row->next(); + } + } + } +#endif + } +#endif + table->status = 0; + DBUG_RETURN(0); +} + +int spider_db_fetch_key( + ha_spider *spider, + uchar *buf, + TABLE *table, + const KEY *key_info, + SPIDER_RESULT_LIST *result_list +) { + int error_num; + SPIDER_SHARE *share = spider->share; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]); + SPIDER_RESULT *current = (SPIDER_RESULT*) result_list->current; + KEY_PART_INFO *key_part; + uint part_num; + SPIDER_DB_ROW *row; + Field *field; + DBUG_ENTER("spider_db_fetch_key"); + if (result_list->quick_mode == 0) + { + SPIDER_DB_RESULT *result = current->result; + if (!(row = result->fetch_row())) + { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + } else { + if (result_list->current_row_num < result_list->quick_page_size) + { + row = current->first_position[result_list->current_row_num].row; + } else { + if ((error_num = spider_db_get_row_from_tmp_tbl( + current, &row))) + { + if (error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(error_num); + } + } + } + + /* for mrr */ + if (spider->mrr_with_cnt) + { + DBUG_PRINT("info", ("spider mrr_with_cnt")); + if (!row->is_null()) + spider->multi_range_hit_point = row->val_int(); + else + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + row->next(); + } + if ((error_num = spider_db_append_match_fetch(spider, + spider->ft_first, spider->ft_current, row))) + DBUG_RETURN(error_num); + + for ( + key_part = key_info->key_part, + part_num = 0; + part_num < key_info->key_parts; + key_part++, + part_num++ + ) { + field = key_part->field; + if (( + bitmap_is_set(table->read_set, field->field_index) | + bitmap_is_set(table->write_set, field->field_index) + )) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + DBUG_PRINT("info", ("spider bitmap is set %s", field->field_name)); + if ((error_num = + spider_db_fetch_row(share, field, row, ptr_diff))) + DBUG_RETURN(error_num); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + } + row->next(); + } + table->status = 0; + DBUG_RETURN(0); +} + +int spider_db_fetch_minimum_columns( + ha_spider *spider, + uchar *buf, + TABLE *table, + SPIDER_RESULT_LIST *result_list +) { + int error_num; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]); + SPIDER_SHARE *share = spider->share; + SPIDER_RESULT *current = (SPIDER_RESULT*) result_list->current; + SPIDER_DB_ROW *row; + Field **field; + DBUG_ENTER("spider_db_fetch_minimum_columns"); + if (result_list->quick_mode == 0) + { + SPIDER_DB_RESULT *result = current->result; + if (!(row = result->fetch_row())) + { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + } else { + if (result_list->current_row_num < result_list->quick_page_size) + { + row = current->first_position[result_list->current_row_num].row; + } else { + if ((error_num = spider_db_get_row_from_tmp_tbl( + current, &row))) + { + if (error_num == HA_ERR_END_OF_FILE) + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(error_num); + } + } + } + + /* for mrr */ + if (spider->mrr_with_cnt) + { + DBUG_PRINT("info", ("spider mrr_with_cnt")); + if (!row->is_null()) + spider->multi_range_hit_point = row->val_int(); + else + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + row->next(); + } + if ((error_num = spider_db_append_match_fetch(spider, + spider->ft_first, spider->ft_current, row))) + DBUG_RETURN(error_num); + + for ( + field = table->field; + *field; + field++ + ) { + DBUG_PRINT("info", ("spider field_index %u", (*field)->field_index)); + DBUG_PRINT("info", ("spider searched_bitmap %u", + spider_bit_is_set(spider->searched_bitmap, (*field)->field_index))); + DBUG_PRINT("info", ("spider read_set %u", + bitmap_is_set(table->read_set, (*field)->field_index))); + DBUG_PRINT("info", ("spider write_set %u", + bitmap_is_set(table->write_set, (*field)->field_index))); + if ( + spider_bit_is_set(spider->searched_bitmap, (*field)->field_index) | + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + ) { + if (( + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + )) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->field_name)); + if ((error_num = spider_db_fetch_row(share, *field, row, ptr_diff))) + DBUG_RETURN(error_num); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + } + row->next(); + } + } + table->status = 0; + DBUG_RETURN(0); +} + +void spider_db_free_one_result_for_start_next( + ha_spider *spider +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_RESULT *result = (SPIDER_RESULT *) result_list->current; + DBUG_ENTER("spider_db_free_one_result_for_start_next"); + spider_bg_all_conn_break(spider); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (result_list->low_mem_read) + { + if (result) + { + do { + spider_db_free_one_result(result_list, result); + DBUG_PRINT("info",("spider result=%p", result)); + DBUG_PRINT("info",("spider result->finish_flg = FALSE")); + result->finish_flg = FALSE; + result = (SPIDER_RESULT *) result->next; + } while (result && (result->result || result->first_position)); + result = (SPIDER_RESULT *) result_list->current; + if ( + !result->result && + !result->first_position + ) + result_list->current = result->prev; + } + } else { + while ( + result && result->next && + (result->next->result || result->next->first_position) + ) { + result_list->current = result->next; + result = (SPIDER_RESULT *) result->next; + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (result_list->hs_has_result) + { + if (result_list->hs_result) + { + result_list->hs_result->free_result(); + delete result_list->hs_result; + result_list->hs_result = NULL; + } + if (result_list->hs_result_buf) + { + result_list->hs_result_buf->clear(); + } + result_list->hs_has_result = FALSE; + } + } +#endif + DBUG_VOID_RETURN; +} + +void spider_db_free_one_result( + SPIDER_RESULT_LIST *result_list, + SPIDER_RESULT *result +) { + DBUG_ENTER("spider_db_free_one_result"); + if (result_list->quick_mode == 0) + { + if ( + !result->use_position && + result->result + ) { + result->result->free_result(); + delete result->result; + result->result = NULL; + } + } else { + int roop_count; + SPIDER_POSITION *position = result->first_position; + if (position) + { + for (roop_count = 0; roop_count < result->pos_page_size; roop_count++) + { + if ( + position[roop_count].row && + !position[roop_count].use_position + ) { + delete position[roop_count].row; + position[roop_count].row = NULL; + } + } + } + } + DBUG_VOID_RETURN; +} + +int spider_db_free_result( + ha_spider *spider, + bool final +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_RESULT *result; + SPIDER_RESULT *prev; + SPIDER_SHARE *share = spider->share; + SPIDER_TRX *trx = spider->trx; + SPIDER_POSITION *position; + int roop_count, error_num; + DBUG_ENTER("spider_db_free_result"); + spider_bg_all_conn_break(spider); + result = (SPIDER_RESULT*) result_list->first; + + while (result_list->tmp_pos_row_first) + { + SPIDER_DB_ROW *tmp_pos_row = result_list->tmp_pos_row_first; + result_list->tmp_pos_row_first = tmp_pos_row->next_pos; + delete tmp_pos_row; + } + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (result_list->hs_has_result) + { + if (result_list->hs_result) + { + result_list->hs_result->free_result(); + delete result_list->hs_result; + result_list->hs_result = NULL; + } + if (result_list->hs_result_buf) + { + if (result_list->hs_result_buf->check_size( + spider_param_hs_result_free_size(trx->thd, share->hs_result_free_size)) + ) { + trx->hs_result_free_count++; + } + result_list->hs_result_buf->clear(); + } + result_list->hs_has_result = FALSE; + } +#endif + + if ( + final || + spider_param_reset_sql_alloc(trx->thd, share->reset_sql_alloc) == 1 + ) { + int alloc_size = final ? 0 : + (spider_param_init_sql_alloc_size(trx->thd, share->init_sql_alloc_size)); + while (result) + { + position = result->first_position; + if (position) + { + for (roop_count = 0; roop_count < result->pos_page_size; roop_count++) + { + if (position[roop_count].row) + { + delete position[roop_count].row; + } + } + spider_free(spider_current_trx, position, MYF(0)); + } + if (result->result) + { + result->result->free_result(); + delete result->result; + result->result = NULL; + } + if (result->result_tmp_tbl) + { + if (result->result_tmp_tbl_inited) + { + result->result_tmp_tbl->file->ha_rnd_end(); + result->result_tmp_tbl_inited = 0; + } + spider_rm_sys_tmp_table_for_result(result->result_tmp_tbl_thd, + result->result_tmp_tbl, &result->result_tmp_tbl_prm); + result->result_tmp_tbl = NULL; + result->result_tmp_tbl_thd = NULL; + } + prev = result; + result = (SPIDER_RESULT*) result->next; + spider_free(spider_current_trx, prev, MYF(0)); + } + result_list->first = NULL; + result_list->last = NULL; + if (!final) + { + ulong realloced = 0; + int init_sql_alloc_size = + spider_param_init_sql_alloc_size(trx->thd, share->init_sql_alloc_size); + for (roop_count = 0; roop_count < (int) share->use_dbton_count; + roop_count++) + { + uint dbton_id = share->use_dbton_ids[roop_count]; + if ((error_num = spider->dbton_handler[dbton_id]-> + realloc_sql(&realloced))) + { + DBUG_RETURN(error_num); + } + } + if (realloced & (SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER)) + { + for (roop_count = 0; roop_count < (int) share->link_count; + roop_count++) + { + if ((int) result_list->sqls[roop_count].alloced_length() > + alloc_size * 2) + { + result_list->sqls[roop_count].free(); + if (result_list->sqls[roop_count].real_alloc( + init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + } + if (realloced & SPIDER_SQL_TYPE_INSERT_SQL) + { + for (roop_count = 0; roop_count < (int) share->link_count; + roop_count++) + { + if ((int) result_list->insert_sqls[roop_count].alloced_length() > + alloc_size * 2) + { + result_list->insert_sqls[roop_count].free(); + if (result_list->insert_sqls[roop_count].real_alloc( + init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + } + if (realloced & SPIDER_SQL_TYPE_UPDATE_SQL) + { + for (roop_count = 0; roop_count < (int) share->link_count; + roop_count++) + { + if ((int) result_list->update_sqls[roop_count].alloced_length() > + alloc_size * 2) + { + result_list->update_sqls[roop_count].free(); + if (result_list->update_sqls[roop_count].real_alloc( + init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + } + if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_BULK_UPDATE_SQL))) + DBUG_RETURN(error_num); + + if (realloced & SPIDER_SQL_TYPE_TMP_SQL) + { + for (roop_count = 0; roop_count < (int) share->link_count; + roop_count++) + { + if ((int) result_list->tmp_sqls[roop_count].alloced_length() > + alloc_size * 2) + { + result_list->tmp_sqls[roop_count].free(); + if (result_list->tmp_sqls[roop_count].real_alloc( + init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + } + } + } else { + while (result) + { + position = result->first_position; + if (position) + { + for (roop_count = 0; roop_count < result->pos_page_size; roop_count++) + { + if (position[roop_count].row) + { + delete position[roop_count].row; + } + } + spider_free(spider_current_trx, position, MYF(0)); + } + result->first_position = NULL; + if (result->result) + { + result->result->free_result(); + delete result->result; + result->result = NULL; + } + if (result->result_tmp_tbl) + { + if (result->result_tmp_tbl_inited) + { + result->result_tmp_tbl->file->ha_rnd_end(); + result->result_tmp_tbl_inited = 0; + } + spider_rm_sys_tmp_table_for_result(result->result_tmp_tbl_thd, + result->result_tmp_tbl, &result->result_tmp_tbl_prm); + result->result_tmp_tbl = NULL; + result->result_tmp_tbl_thd = NULL; + } + result->record_num = 0; + DBUG_PRINT("info",("spider result->finish_flg = FALSE")); + result->finish_flg = FALSE; + result->use_position = FALSE; + result = (SPIDER_RESULT*) result->next; + } + } + result_list->current = NULL; + result_list->record_num = 0; + DBUG_PRINT("info",("spider result_list->finish_flg = FALSE")); + result_list->finish_flg = FALSE; + result_list->quick_phase = 0; +#ifndef WITHOUT_SPIDER_BG_SEARCH + result_list->bgs_phase = 0; +#endif + DBUG_RETURN(0); +} + +int spider_db_store_result( + ha_spider *spider, + int link_idx, + TABLE *table +) { + int error_num; + SPIDER_CONN *conn; + SPIDER_DB_CONN *db_conn; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_RESULT *current; + DBUG_ENTER("spider_db_store_result"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = spider->conns[link_idx]; + DBUG_PRINT("info",("spider conn->connection_id=%llu", + conn->connection_id)); + DBUG_PRINT("info",("spider spider->connection_ids[%d]=%llu", + link_idx, spider->connection_ids[link_idx])); + if (conn->connection_id != spider->connection_ids[link_idx]) + { + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + db_conn = conn->db_conn; + if (!result_list->current) + { + if (!result_list->first) + { + if (!(result_list->first = (SPIDER_RESULT *) + spider_malloc(spider_current_trx, 4, sizeof(*result_list->first), + MYF(MY_WME | MY_ZEROFILL))) + ) { + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + TMP_TABLE_PARAM *tmp_tbl_prm = (TMP_TABLE_PARAM *) + &result_list->first->result_tmp_tbl_prm; + tmp_tbl_prm->init(); + tmp_tbl_prm->field_count = 3; + result_list->last = result_list->first; + result_list->current = result_list->first; + } else { + result_list->current = result_list->first; + } + result_list->bgs_current = result_list->current; + current = (SPIDER_RESULT*) result_list->current; + } else { + if ( +#ifndef WITHOUT_SPIDER_BG_SEARCH + result_list->bgs_phase > 0 || +#endif + result_list->quick_phase > 0 + ) { + if (result_list->bgs_current == result_list->last) + { + if (!(result_list->last = (SPIDER_RESULT *) + spider_malloc(spider_current_trx, 5, sizeof(*result_list->last), + MYF(MY_WME | MY_ZEROFILL))) + ) { + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + TMP_TABLE_PARAM *tmp_tbl_prm = (TMP_TABLE_PARAM *) + &result_list->last->result_tmp_tbl_prm; + tmp_tbl_prm->init(); + tmp_tbl_prm->field_count = 3; + result_list->bgs_current->next = result_list->last; + result_list->last->prev = result_list->bgs_current; + result_list->bgs_current = result_list->last; + } else { + result_list->bgs_current = result_list->bgs_current->next; + } + if ( +#ifndef WITHOUT_SPIDER_BG_SEARCH + result_list->bgs_phase == 1 || +#endif + result_list->quick_phase == 2 + ) { + if (result_list->low_mem_read) + { + do { + spider_db_free_one_result(result_list, + (SPIDER_RESULT*) result_list->current); + result_list->current = result_list->current->next; + } while (result_list->current != result_list->bgs_current); + } else { + result_list->current = result_list->bgs_current; + } + result_list->quick_phase = 0; + } + current = (SPIDER_RESULT*) result_list->bgs_current; + } else { + if (result_list->current == result_list->last) + { + if (!(result_list->last = (SPIDER_RESULT *) + spider_malloc(spider_current_trx, 6, sizeof(*result_list->last), + MYF(MY_WME | MY_ZEROFILL))) + ) { + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + TMP_TABLE_PARAM *tmp_tbl_prm = (TMP_TABLE_PARAM *) + &result_list->last->result_tmp_tbl_prm; + tmp_tbl_prm->init(); + tmp_tbl_prm->field_count = 3; + result_list->current->next = result_list->last; + result_list->last->prev = result_list->current; + result_list->current = result_list->last; + } else { + result_list->current = result_list->current->next; + } + result_list->bgs_current = result_list->current; + current = (SPIDER_RESULT*) result_list->current; + } + } + + if (result_list->quick_mode == 0) + { + if (spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_clear_bit(spider->db_request_phase, link_idx); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + if (!(current->result = db_conn->store_result(NULL, &request_key, + &error_num))) + { + if (error_num && error_num != HA_ERR_END_OF_FILE) + { + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); + } + if ( + error_num != HA_ERR_END_OF_FILE && + (error_num = spider_db_errorno(conn)) + ) + DBUG_RETURN(error_num); + else { + DBUG_PRINT("info",("spider set finish_flg point 1")); + DBUG_PRINT("info",("spider current->finish_flg = TRUE")); + DBUG_PRINT("info",("spider result_list->finish_flg = TRUE")); + current->finish_flg = TRUE; + result_list->finish_flg = TRUE; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list->bgs_phase <= 1) + { +#endif + result_list->current_row_num = 0; + table->status = STATUS_NOT_FOUND; +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + } else { + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + current->record_num = current->result->num_rows(); + result_list->record_num += current->record_num; + DBUG_PRINT("info",("spider current->record_num=%lld", + current->record_num)); + DBUG_PRINT("info",("spider result_list->record_num=%lld", + result_list->record_num)); + if ( + result_list->internal_limit <= result_list->record_num || + result_list->split_read > current->record_num + ) { + DBUG_PRINT("info",("spider result_list->internal_limit=%lld", + result_list->internal_limit)); + DBUG_PRINT("info",("spider result_list->split_read=%lld", + result_list->split_read)); + DBUG_PRINT("info",("spider set finish_flg point 2")); + DBUG_PRINT("info",("spider current->finish_flg = TRUE")); + DBUG_PRINT("info",("spider result_list->finish_flg = TRUE")); + current->finish_flg = TRUE; + result_list->finish_flg = TRUE; + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list->bgs_phase <= 1) + { +#endif + result_list->current_row_num = 0; +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + } + } else { + /* has_result() for case of result with result_tmp_tbl */ + if (current->prev && current->prev->result && + current->prev->result->has_result()) + { + current->result = current->prev->result; + current->prev->result = NULL; + result_list->limit_num -= current->prev->record_num; + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } else { + if (spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_clear_bit(spider->db_request_phase, link_idx); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + if (!(current->result = conn->db_conn->use_result(&request_key, + &error_num))) + { + if (!error_num) + { + error_num = spider_db_errorno(conn); + } else { + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + DBUG_RETURN(error_num); + } + DBUG_PRINT("info", ("spider conn[%p]->quick_target=%p", conn, spider)); + conn->quick_target = spider; + spider->quick_targets[link_idx] = spider; + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + SPIDER_DB_ROW *row; + if (!(row = current->result->fetch_row())) + { + DBUG_PRINT("info",("spider set finish_flg point 3")); + DBUG_PRINT("info",("spider current->finish_flg = TRUE")); + DBUG_PRINT("info",("spider result_list->finish_flg = TRUE")); + current->finish_flg = TRUE; + result_list->finish_flg = TRUE; + current->result->free_result(); + delete current->result; + current->result = NULL; + DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", conn)); + conn->quick_target = NULL; + spider->quick_targets[link_idx] = NULL; + if ( +#ifndef WITHOUT_SPIDER_BG_SEARCH + result_list->bgs_phase <= 1 && +#endif + result_list->quick_phase == 0 + ) { + result_list->current_row_num = 0; + table->status = STATUS_NOT_FOUND; + } else if (result_list->quick_phase > 0) + DBUG_RETURN(0); + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + SPIDER_DB_ROW *tmp_row; + uint field_count = current->result->num_fields(); + SPIDER_POSITION *position; + longlong page_size = + !result_list->quick_page_size || + result_list->limit_num < result_list->quick_page_size ? + result_list->limit_num : result_list->quick_page_size; + int roop_count = 0; + current->field_count = field_count; + if (!(position = (SPIDER_POSITION *) + spider_bulk_malloc(spider_current_trx, 7, MYF(MY_WME | MY_ZEROFILL), + &position, sizeof(SPIDER_POSITION) * page_size, + &tmp_row, sizeof(char*) * field_count, + NullS)) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + current->pos_page_size = (int) page_size; + current->first_position = position; + current->tmp_tbl_row = tmp_row; + do { + if (!(position->row = row->clone())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + position++; + roop_count++; + } while ( + page_size > roop_count && + (row = current->result->fetch_row()) + ); + if ( + result_list->quick_mode == 3 && + page_size == roop_count && + result_list->limit_num > roop_count && + (row = current->result->fetch_row()) + ) { + THD *thd = current_thd; + char buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin); + tmp_str.init_calc_mem(120); + + DBUG_PRINT("info",("spider store result to temporary table")); + DBUG_ASSERT(!current->result_tmp_tbl); + if (!(current->result_tmp_tbl = spider_mk_sys_tmp_table_for_result( + thd, table, ¤t->result_tmp_tbl_prm, "a", "b", "c", + &my_charset_bin))) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + current->result_tmp_tbl_thd = thd; + TABLE *tmp_tbl = current->result_tmp_tbl; + tmp_tbl->file->extra(HA_EXTRA_WRITE_CACHE); + tmp_tbl->file->ha_start_bulk_insert((ha_rows) 0); + do { + if ((error_num = row->store_to_tmp_table(tmp_tbl, &tmp_str))) + { + tmp_tbl->file->ha_end_bulk_insert(); + DBUG_RETURN(error_num); + } + roop_count++; + } while ( + result_list->limit_num > roop_count && + (row = current->result->fetch_row()) + ); + tmp_tbl->file->ha_end_bulk_insert(); + page_size = result_list->limit_num; + } + current->record_num = roop_count; + result_list->record_num += roop_count; + if ( + result_list->internal_limit <= result_list->record_num || + page_size > roop_count + ) { + DBUG_PRINT("info",("spider set finish_flg point 4")); + DBUG_PRINT("info",("spider current->finish_flg = TRUE")); + DBUG_PRINT("info",("spider result_list->finish_flg = TRUE")); + current->finish_flg = TRUE; + result_list->finish_flg = TRUE; + current->result->free_result(); + if (!current->result_tmp_tbl) + { + delete current->result; + current->result = NULL; + } + DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", conn)); + conn->quick_target = NULL; + spider->quick_targets[link_idx] = NULL; + } else if (result_list->limit_num == roop_count) + { + current->result->free_result(); + if (!current->result_tmp_tbl) + { + delete current->result; + current->result = NULL; + } + DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", conn)); + conn->quick_target = NULL; + spider->quick_targets[link_idx] = NULL; + } + if ( +#ifndef WITHOUT_SPIDER_BG_SEARCH + result_list->bgs_phase <= 1 && +#endif + result_list->quick_phase == 0 + ) { + result_list->current_row_num = 0; + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) + conn = spider->hs_r_conns[link_idx]; + else + conn = spider->hs_w_conns[link_idx]; + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider conn->connection_id=%llu", + conn->connection_id)); + DBUG_PRINT("info",("spider spider->connection_ids[%d]=%llu", + link_idx, spider->connection_ids[link_idx])); + if (conn->connection_id != spider->connection_ids[link_idx]) + { + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + if (spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_clear_bit(spider->db_request_phase, link_idx); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + if (!(result_list->hs_result = conn->db_conn->store_result( + &result_list->hs_result_buf, &request_key, &error_num))) + { + if (!error_num) + { + spider_db_errorno(conn); + DBUG_RETURN(ER_SPIDER_HS_NUM); + } else { + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + DBUG_RETURN(error_num); + } + result_list->hs_conn = conn->db_conn; + result_list->hs_has_result = TRUE; + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } +#endif + DBUG_RETURN(0); +} + +void spider_db_discard_result( + ha_spider *spider, + int link_idx, + SPIDER_CONN *conn +) { + int error_num; + SPIDER_DB_RESULT *result; + DBUG_ENTER("spider_db_discard_result"); + if (spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_clear_bit(spider->db_request_phase, link_idx); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { + result->free_result(); + delete result; + } + DBUG_VOID_RETURN; +} + +void spider_db_discard_multiple_result( + ha_spider *spider, + int link_idx, + SPIDER_CONN *conn +) { + int error_num; + SPIDER_DB_RESULT *result; + st_spider_db_request_key request_key; + DBUG_ENTER("spider_db_discard_multiple_result"); + if (spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_clear_bit(spider->db_request_phase, link_idx); + } + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + do + { + if (!conn->db_conn->cmp_request_key_to_snd(&request_key)) + break; + if ((result = conn->db_conn->use_result(&request_key, &error_num))) + result->free_result(); + delete result; + } while (!conn->db_conn->next_result()); + DBUG_VOID_RETURN; +} + +#ifdef HA_CAN_BULK_ACCESS +int spider_db_bulk_store_result( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx, + bool discard_result +) { + int error_num, tmp_error_num; + DBUG_ENTER("spider_db_bulk_store_result"); + DBUG_PRINT("info",("spider spider=%p", spider)); + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { + /* already stored */ + DBUG_RETURN(0); + } + error_num = spider_db_bulk_open_handler(spider, conn, link_idx); + if (!discard_result) + { + bool tmp_mta_conn_mutex_unlock_later; + tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((tmp_error_num = spider_db_store_result(spider, link_idx, + spider->get_table()))) + { + error_num = tmp_error_num; + } + conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; + } else { + if (spider->connection_ids[link_idx] == conn->connection_id) + spider_db_discard_result(spider, link_idx, conn); + } + DBUG_RETURN(error_num); +} +#endif + +int spider_db_fetch( + uchar *buf, + ha_spider *spider, + TABLE *table +) { + int error_num; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_db_fetch"); + if (spider->sql_kind[spider->result_link_idx] == SPIDER_SQL_KIND_SQL) + { + if (!spider->select_column_mode) { + if (result_list->keyread) + error_num = spider_db_fetch_key(spider, buf, table, + result_list->key_info, result_list); + else + error_num = spider_db_fetch_table(spider, buf, table, + result_list); + } else + error_num = spider_db_fetch_minimum_columns(spider, buf, table, + result_list); + } else { + error_num = spider_db_fetch_table(spider, buf, table, + result_list); + } + result_list->current_row_num++; + DBUG_PRINT("info",("spider error_num=%d", error_num)); + spider->pushed_pos = NULL; + DBUG_RETURN(error_num); +} + +int spider_db_seek_prev( + uchar *buf, + ha_spider *spider, + TABLE *table +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_db_seek_prev"); + if (result_list->current_row_num <= 1) + { + if (result_list->current == result_list->first) + { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + if (result_list->low_mem_read == 1) + { + my_message(ER_SPIDER_LOW_MEM_READ_PREV_NUM, + ER_SPIDER_LOW_MEM_READ_PREV_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_LOW_MEM_READ_PREV_NUM); + } + result_list->current = result_list->current->prev; + result_list->current_row_num = result_list->current->record_num - 1; + } else { + result_list->current_row_num -= 2; + } + if (result_list->quick_mode == 0) + result_list->current->result->move_to_pos(result_list->current_row_num); + DBUG_RETURN(spider_db_fetch(buf, spider, table)); +} + +int spider_db_seek_next( + uchar *buf, + ha_spider *spider, + int link_idx, + TABLE *table +) { + int error_num; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_db_seek_next"); + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL && +#endif + result_list->current_row_num >= result_list->current->record_num + ) { + DBUG_PRINT("info",("spider result_list->current_row_num=%lld", + result_list->current_row_num)); + DBUG_PRINT("info",("spider result_list->current->record_num=%lld", + result_list->current->record_num)); + if (result_list->low_mem_read) + spider_db_free_one_result(result_list, + (SPIDER_RESULT*) result_list->current); + + int roop_start, roop_end, roop_count, lock_mode, link_ok; + lock_mode = spider_conn_lock_mode(spider); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = spider->share->link_count; + } else { + link_ok = link_idx; + roop_start = link_idx; + roop_end = link_idx + 1; + } + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (result_list->bgs_phase > 0) + { + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if ((error_num = spider_bg_conn_search(spider, roop_count, roop_start, + FALSE, FALSE, (roop_count != link_ok)))) + { + DBUG_PRINT("info",("spider error_num 1=%d", error_num)); + DBUG_RETURN(error_num); + } + } + } else { +#endif + if (result_list->current == result_list->bgs_current) + { + if (result_list->finish_flg) + { + table->status = STATUS_NOT_FOUND; + DBUG_PRINT("info",("spider error_num 2=%d", HA_ERR_END_OF_FILE)); + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + spider_next_split_read_param(spider); + if ( + result_list->quick_mode == 0 || + !result_list->current->result + ) { + result_list->limit_num = + result_list->internal_limit - result_list->record_num >= + result_list->split_read ? + result_list->split_read : + result_list->internal_limit - result_list->record_num; + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = spider->reappend_limit_sql_part( + result_list->record_num, result_list->limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_PRINT("info",("spider error_num 3=%d", error_num)); + DBUG_RETURN(error_num); + } + if ( + !result_list->use_union && + (error_num = spider->append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) { + DBUG_PRINT("info",("spider error_num 4=%d", error_num)); + DBUG_RETURN(error_num); + } + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + spider_db_append_handler_next(spider); + if ((error_num = spider->reappend_limit_sql_part( + 0, result_list->limit_num, + SPIDER_SQL_TYPE_HANDLER))) + { + DBUG_PRINT("info",("spider error_num 5=%d", error_num)); + DBUG_RETURN(error_num); + } + } + + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + ulong sql_type; + conn = spider->conns[roop_count]; + if (spider->sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } + spider_db_handler *dbton_handler = + spider->dbton_handler[conn->dbton_id]; + if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_handler->set_sql_for_exec(sql_type, + roop_count))) + { + DBUG_PRINT("info",("spider error_num 6=%d", error_num)); + DBUG_RETURN(error_num); + } + if (!dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + conn->need_mon = &spider->need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_PRINT("info",("spider error_num 7=%d", error_num)); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count, + spider->trx->thd, share); + if (dbton_handler->execute_sql( + sql_type, + conn, + result_list->quick_mode, + &spider->need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_PRINT("info",("spider error_num 8=%d", error_num)); + DBUG_RETURN(error_num); + } + spider->connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(spider, roop_count, + table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_PRINT("info",("spider error_num 9=%d", error_num)); + DBUG_RETURN(error_num); + } + spider->result_link_idx = link_ok; + } else { + spider_db_discard_result(spider, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + } else { + spider->connection_ids[link_idx] = conn->connection_id; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_store_result(spider, link_idx, table))) + { + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_PRINT("info",("spider error_num 10=%d", error_num)); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_unlock_later = FALSE; + } + } else { + result_list->current = result_list->current->next; + result_list->current_row_num = 0; + if ( + result_list->current == result_list->bgs_current && + result_list->finish_flg + ) { + table->status = STATUS_NOT_FOUND; + DBUG_PRINT("info",("spider error_num 11=%d", HA_ERR_END_OF_FILE)); + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + DBUG_RETURN(spider_db_fetch(buf, spider, table)); + } else + DBUG_RETURN(spider_db_fetch(buf, spider, table)); +} + +int spider_db_seek_last( + uchar *buf, + ha_spider *spider, + int link_idx, + TABLE *table +) { + int error_num; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_db_seek_last"); + if (result_list->finish_flg) + { + if (result_list->low_mem_read == 1) + { + my_message(ER_SPIDER_LOW_MEM_READ_PREV_NUM, + ER_SPIDER_LOW_MEM_READ_PREV_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_LOW_MEM_READ_PREV_NUM); + } + result_list->current = result_list->last; + result_list->current_row_num = result_list->current->record_num - 1; + if (result_list->quick_mode == 0) + result_list->current->result->move_to_pos(result_list->current_row_num); + DBUG_RETURN(spider_db_fetch(buf, spider, table)); + } else if (!result_list->sorted || + result_list->internal_limit <= result_list->record_num * 2) + { + if (result_list->low_mem_read == 1) + { + my_message(ER_SPIDER_LOW_MEM_READ_PREV_NUM, + ER_SPIDER_LOW_MEM_READ_PREV_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_LOW_MEM_READ_PREV_NUM); + } + spider_next_split_read_param(spider); + result_list->limit_num = + result_list->internal_limit - result_list->record_num; + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = spider->reappend_limit_sql_part( + result_list->internal_offset + result_list->record_num, + result_list->limit_num, + SPIDER_SQL_TYPE_SELECT_SQL))) + DBUG_RETURN(error_num); + if ( + !result_list->use_union && + (error_num = spider->append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + DBUG_RETURN(error_num); + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + spider_db_append_handler_next(spider); + if ((error_num = spider->reappend_limit_sql_part( + result_list->internal_offset + result_list->record_num, + result_list->limit_num, + SPIDER_SQL_TYPE_HANDLER))) + DBUG_RETURN(error_num); + if ( + !result_list->use_union && + (error_num = spider->append_select_lock_sql_part( + SPIDER_SQL_TYPE_HANDLER)) + ) + DBUG_RETURN(error_num); + } + + int roop_start, roop_end, roop_count, lock_mode, link_ok; + lock_mode = spider_conn_lock_mode(spider); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = spider->share->link_count; + } else { + link_ok = link_idx; + roop_start = link_idx; + roop_end = link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + ulong sql_type; + if (spider->sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } + conn = spider->conns[roop_count]; + spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; + if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); + conn->need_mon = &spider->need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + share); + if (dbton_handler->execute_sql( + sql_type, + conn, + result_list->quick_mode, + &spider->need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider->connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(spider, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider->result_link_idx = link_ok; + } else { + spider_db_discard_result(spider, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + result_list->current_row_num = result_list->current->record_num - 1; + if (result_list->quick_mode == 0) + result_list->current->result->move_to_pos(result_list->current_row_num); + DBUG_RETURN(spider_db_fetch(buf, spider, table)); + } + if ((error_num = spider_db_free_result(spider, FALSE))) + DBUG_RETURN(error_num); + spider_first_split_read_param(spider); + result_list->desc_flg = !(result_list->desc_flg); + result_list->limit_num = + result_list->internal_limit >= result_list->split_read ? + result_list->split_read : result_list->internal_limit; + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + spider->set_order_to_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); + if ( + (error_num = spider->append_key_order_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL)) || + (error_num = spider->append_limit_sql_part( + result_list->internal_offset, + result_list->limit_num, SPIDER_SQL_TYPE_SELECT_SQL)) || + ( + !result_list->use_union && + (spider->sql_kinds & SPIDER_SQL_KIND_SQL) && + (error_num = spider->append_select_lock_sql_part( + SPIDER_SQL_TYPE_SELECT_SQL)) + ) + ) + DBUG_RETURN(error_num); + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + const char *alias; + uint alias_length; + if (result_list->sorted && result_list->desc_flg) + { + alias = SPIDER_SQL_LAST_STR; + alias_length = SPIDER_SQL_LAST_LEN; + } else { + alias = SPIDER_SQL_FIRST_STR; + alias_length = SPIDER_SQL_FIRST_LEN; + } + spider->set_order_to_pos_sql(SPIDER_SQL_TYPE_HANDLER); + if ( + (error_num = spider->append_key_order_with_alias_sql_part( + alias, alias_length, SPIDER_SQL_TYPE_HANDLER)) || + (error_num = spider->reappend_limit_sql_part( + result_list->internal_offset, + result_list->limit_num, SPIDER_SQL_TYPE_HANDLER)) + ) + DBUG_RETURN(error_num); + } + + int roop_start, roop_end, roop_count, lock_mode, link_ok; + lock_mode = spider_conn_lock_mode(spider); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + link_ok = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_OK); + roop_start = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_end = spider->share->link_count; + } else { + link_ok = link_idx; + roop_start = link_idx; + roop_end = link_idx + 1; + } + for (roop_count = roop_start; roop_count < roop_end; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + ulong sql_type; + if (spider->sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } + conn = spider->conns[roop_count]; + spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; + if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); + conn->need_mon = &spider->need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + share); + if (dbton_handler->execute_sql( + sql_type, + conn, + result_list->quick_mode, + &spider->need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider->connection_ids[roop_count] = conn->connection_id; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (roop_count == link_ok) + { + if ((error_num = spider_db_store_result(spider, roop_count, table))) + { + if ( + error_num != HA_ERR_END_OF_FILE && + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider->result_link_idx = link_ok; + } else { + spider_db_discard_result(spider, roop_count, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + DBUG_RETURN(spider_db_fetch(buf, spider, table)); +} + +int spider_db_seek_first( + uchar *buf, + ha_spider *spider, + TABLE *table +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_db_seek_first"); + if ( + result_list->current != result_list->first && + result_list->low_mem_read == 1 + ) { + my_message(ER_SPIDER_LOW_MEM_READ_PREV_NUM, ER_SPIDER_LOW_MEM_READ_PREV_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_LOW_MEM_READ_PREV_NUM); + } + result_list->current = result_list->first; + spider_db_set_pos_to_first_row(result_list); + DBUG_RETURN(spider_db_fetch(buf, spider, table)); +} + +void spider_db_set_pos_to_first_row( + SPIDER_RESULT_LIST *result_list +) { + DBUG_ENTER("spider_db_set_pos_to_first_row"); + result_list->current_row_num = 0; + if (result_list->quick_mode == 0) + result_list->current->result->move_to_pos(0); + DBUG_VOID_RETURN; +} + +void spider_db_create_position( + ha_spider *spider, + SPIDER_POSITION *pos +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_RESULT *current = (SPIDER_RESULT*) result_list->current; + DBUG_ENTER("spider_db_create_position"); + if (result_list->quick_mode == 0) + { + SPIDER_DB_RESULT *result = current->result; + pos->row = result->current_row(); + pos->pos_mode = 2; + pos->row->next_pos = result_list->tmp_pos_row_first; + result_list->tmp_pos_row_first = pos->row; + } else { + if (result_list->current_row_num <= result_list->quick_page_size) + { + SPIDER_POSITION *tmp_pos = + ¤t->first_position[result_list->current_row_num - 1]; + memcpy(pos, tmp_pos, sizeof(SPIDER_POSITION)); + tmp_pos->use_position = TRUE; + tmp_pos->pos_mode = 0; + pos->pos_mode = 0; + } else { + TABLE *tmp_tbl = current->result_tmp_tbl; + pos->row = NULL; + pos->pos_mode = 1; + DBUG_PRINT("info",("spider tmp_tbl=%p", tmp_tbl)); + DBUG_PRINT("info",("spider tmp_tbl->file=%p", tmp_tbl->file)); + DBUG_PRINT("info",("spider tmp_tbl->file->ref=%p", tmp_tbl->file->ref)); + tmp_tbl->file->ref = (uchar *) &pos->tmp_tbl_pos; + tmp_tbl->file->position(tmp_tbl->record[0]); + } + } + current->use_position = TRUE; + pos->use_position = TRUE; + pos->mrr_with_cnt = spider->mrr_with_cnt; + pos->sql_kind = spider->sql_kind[spider->result_link_idx]; + pos->position_bitmap = spider->position_bitmap; + pos->ft_first = spider->ft_first; + pos->ft_current = spider->ft_current; + pos->result = current; + DBUG_VOID_RETURN; +} + +int spider_db_seek_tmp( + uchar *buf, + SPIDER_POSITION *pos, + ha_spider *spider, + TABLE *table +) { + int error_num; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_db_seek_tmp"); + if (pos->pos_mode != 1) + { + if (!pos->row) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + pos->row->first(); + } + if (spider->sql_kind[spider->result_link_idx] == SPIDER_SQL_KIND_SQL) + { + if (!spider->select_column_mode) + { + if (result_list->keyread) + error_num = spider_db_seek_tmp_key(buf, pos, spider, table, + result_list->key_info); + else + error_num = spider_db_seek_tmp_table(buf, pos, spider, table); + } else + error_num = spider_db_seek_tmp_minimum_columns(buf, pos, spider, table); + } else + error_num = spider_db_seek_tmp_table(buf, pos, spider, table); + + DBUG_PRINT("info",("spider error_num=%d", error_num)); + DBUG_RETURN(error_num); +} + +int spider_db_seek_tmp_table( + uchar *buf, + SPIDER_POSITION *pos, + ha_spider *spider, + TABLE *table +) { + int error_num; + Field **field; + SPIDER_DB_ROW *row = pos->row; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]); + DBUG_ENTER("spider_db_seek_tmp_table"); + if (pos->pos_mode == 1) + { + if ((error_num = spider_db_get_row_from_tmp_tbl_pos(pos, &row))) + DBUG_RETURN(error_num); + } else if (pos->pos_mode == 2) + { +/* + SPIDER_DB_RESULT *result = pos->result->result; + result->current_row = row; +*/ + } + + /* for mrr */ + if (pos->mrr_with_cnt) + { + DBUG_PRINT("info", ("spider mrr_with_cnt")); + if (pos->sql_kind == SPIDER_SQL_KIND_SQL) + { + row->next(); + } + } + if ((error_num = spider_db_append_match_fetch(spider, + pos->ft_first, pos->ft_current, row))) + DBUG_RETURN(error_num); + + for ( + field = table->field; + *field; + field++ + ) { + if (( + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + )) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->field_name)); + if ((error_num = + spider_db_fetch_row(spider->share, *field, row, ptr_diff))) + DBUG_RETURN(error_num); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + } + row->next(); + } + DBUG_RETURN(0); +} + +int spider_db_seek_tmp_key( + uchar *buf, + SPIDER_POSITION *pos, + ha_spider *spider, + TABLE *table, + const KEY *key_info +) { + int error_num; + KEY_PART_INFO *key_part; + uint part_num; + SPIDER_DB_ROW *row = pos->row; + Field *field; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]); + DBUG_ENTER("spider_db_seek_tmp_key"); + if (pos->pos_mode == 1) + { + if ((error_num = spider_db_get_row_from_tmp_tbl_pos(pos, &row))) + DBUG_RETURN(error_num); + } else if (pos->pos_mode == 2) + { +/* + SPIDER_DB_RESULT *result = pos->result->result; + result->current_row = row; +*/ + } + + /* for mrr */ + if (pos->mrr_with_cnt) + { + DBUG_PRINT("info", ("spider mrr_with_cnt")); + row->next(); + } + if ((error_num = spider_db_append_match_fetch(spider, + pos->ft_first, pos->ft_current, row))) + DBUG_RETURN(error_num); + + for ( + key_part = key_info->key_part, + part_num = 0; + part_num < key_info->key_parts; + key_part++, + part_num++ + ) { + field = key_part->field; + if (( + bitmap_is_set(table->read_set, field->field_index) | + bitmap_is_set(table->write_set, field->field_index) + )) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + DBUG_PRINT("info", ("spider bitmap is set %s", field->field_name)); + if ((error_num = + spider_db_fetch_row(spider->share, field, row, ptr_diff))) + DBUG_RETURN(error_num); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + } + row->next(); + } + DBUG_RETURN(0); +} + +int spider_db_seek_tmp_minimum_columns( + uchar *buf, + SPIDER_POSITION *pos, + ha_spider *spider, + TABLE *table +) { + int error_num; + Field **field; + SPIDER_DB_ROW *row = pos->row; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]); + DBUG_ENTER("spider_db_seek_tmp_minimum_columns"); + if (pos->pos_mode == 1) + { + if ((error_num = spider_db_get_row_from_tmp_tbl_pos(pos, &row))) + DBUG_RETURN(error_num); + } else if (pos->pos_mode == 2) + { +/* + SPIDER_DB_RESULT *result = pos->result->result; + result->current_row = row; +*/ + } + + /* for mrr */ + if (pos->mrr_with_cnt) + { + DBUG_PRINT("info", ("spider mrr_with_cnt")); + row->next(); + } + if ((error_num = spider_db_append_match_fetch(spider, + pos->ft_first, pos->ft_current, row))) + DBUG_RETURN(error_num); + + for ( + field = table->field; + *field; + field++ + ) { + DBUG_PRINT("info", ("spider field_index %u", (*field)->field_index)); + if (spider_bit_is_set(pos->position_bitmap, (*field)->field_index)) + { +/* + if (( + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + )) { + DBUG_PRINT("info", ("spider read_set %u", + bitmap_is_set(table->read_set, (*field)->field_index))); + DBUG_PRINT("info", ("spider write_set %u", + bitmap_is_set(table->write_set, (*field)->field_index))); +*/ +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->field_name)); + if ((error_num = + spider_db_fetch_row(spider->share, *field, row, ptr_diff))) + DBUG_RETURN(error_num); + row->next(); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + } + else if (bitmap_is_set(table->read_set, (*field)->field_index)) + { + DBUG_PRINT("info", ("spider bitmap is cleared %s", + (*field)->field_name)); + bitmap_clear_bit(table->read_set, (*field)->field_index); + } + } + DBUG_RETURN(0); +} + +int spider_db_show_table_status( + ha_spider *spider, + int link_idx, + int sts_mode, + uint flag +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + DBUG_ENTER("spider_db_show_table_status"); + DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); + sts_mode = dbton_hdl->sts_mode_exchange(sts_mode); + error_num = dbton_hdl->show_table_status( + link_idx, + sts_mode, + flag + ); + DBUG_RETURN(error_num); +} + +int spider_db_show_records( + ha_spider *spider, + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + DBUG_ENTER("spider_db_show_records"); + error_num = spider->dbton_handler[conn->dbton_id]->show_records( + link_idx + ); + DBUG_RETURN(error_num); +} + +void spider_db_set_cardinarity( + ha_spider *spider, + TABLE *table +) { + int roop_count, roop_count2; + SPIDER_SHARE *share = spider->share; + KEY *key_info; + KEY_PART_INFO *key_part; + Field *field; + ha_rows rec_per_key; + DBUG_ENTER("spider_db_set_cardinarity"); + for (roop_count = 0; roop_count < (int) table->s->keys; roop_count++) + { + key_info = &table->key_info[roop_count]; + for (roop_count2 = 0; roop_count2 < (int) key_info->key_parts; + roop_count2++) + { + key_part = &key_info->key_part[roop_count2]; + field = key_part->field; + rec_per_key = (ha_rows) share->records / + share->cardinality[field->field_index]; + if (rec_per_key > ~(ulong) 0) + key_info->rec_per_key[roop_count2] = ~(ulong) 0; + else if (rec_per_key == 0) + key_info->rec_per_key[roop_count2] = 1; + else + key_info->rec_per_key[roop_count2] = (ulong) rec_per_key; + DBUG_PRINT("info", + ("spider column id=%d", field->field_index)); + DBUG_PRINT("info", + ("spider cardinality=%lld", + share->cardinality[field->field_index])); + DBUG_PRINT("info", + ("spider rec_per_key=%lu", + key_info->rec_per_key[roop_count2])); + } + } + DBUG_VOID_RETURN; +} + +int spider_db_show_index( + ha_spider *spider, + int link_idx, + TABLE *table, + int crd_mode +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + DBUG_ENTER("spider_db_show_index"); + crd_mode = dbton_hdl->crd_mode_exchange(crd_mode); + error_num = spider->dbton_handler[conn->dbton_id]->show_index( + link_idx, + crd_mode + ); + DBUG_RETURN(error_num); +} + +ha_rows spider_db_explain_select( + key_range *start_key, + key_range *end_key, + ha_spider *spider, + int link_idx +) { + SPIDER_CONN *conn = spider->conns[link_idx]; + ha_rows rows; + DBUG_ENTER("spider_db_explain_select"); + rows = spider->dbton_handler[conn->dbton_id]->explain_select( + start_key, + end_key, + link_idx + ); + DBUG_RETURN(rows); +} + +int spider_db_bulk_insert_init( + ha_spider *spider, + const TABLE *table +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_db_bulk_insert_init"); + spider->sql_kinds = 0; + spider->reset_sql_sql(SPIDER_SQL_TYPE_INSERT_SQL); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider->reset_hs_sql(SPIDER_SQL_TYPE_OTHER_HS); +#endif + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if (spider->conns[roop_count]) + spider->conns[roop_count]->ignore_dup_key = spider->ignore_dup_key; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ( + spider_conn_use_handler(spider, spider->lock_mode, roop_count) && + ( + !spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_WRITE) || +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + spider->hs_w_ret_fields_num[roop_count] < MAX_FIELDS || +#endif + spider->hs_w_conns[roop_count]->server_lost + ) + ) { + if ((error_num = spider_db_open_handler(spider, + spider->hs_w_conns[roop_count], roop_count))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider->set_handler_opened(roop_count); + } +#else + spider_conn_use_handler(spider, spider->lock_mode, roop_count); +#endif + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { +#endif + if ( + (error_num = spider->append_insert_sql_part()) || + (error_num = spider->append_into_sql_part( + SPIDER_SQL_TYPE_INSERT_SQL)) + ) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HS) + { + spider->result_list.hs_upd_rows = 0; + } +#endif + DBUG_RETURN(0); +} + +int spider_db_bulk_insert( + ha_spider *spider, + TABLE *table, + bool bulk_end +) { + int error_num, first_insert_link_idx = -1; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_RESULT_LIST *result_list = &spider->result_list; +#endif + SPIDER_SHARE *share = spider->share; + THD *thd = spider->trx->thd; + bool mta_conn_mutex_lock_already_backup; + bool mta_conn_mutex_unlock_later_backup; + DBUG_ENTER("spider_db_bulk_insert"); + + if (!bulk_end) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { +#endif + if ((error_num = spider->append_insert_values_sql_part( + SPIDER_SQL_TYPE_INSERT_SQL))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HS) + { + if ((error_num = spider->append_insert_values_hs_part( + SPIDER_SQL_TYPE_INSERT_HS))) + DBUG_RETURN(error_num); + result_list->hs_upd_rows++; + } +#endif + } + + if (spider->is_bulk_insert_exec_period(bulk_end)) + { + int roop_count2; + SPIDER_CONN *conn, *first_insert_conn = NULL; + if ((error_num = spider->append_insert_terminator_sql_part( + SPIDER_SQL_TYPE_INSERT_SQL))) + { + DBUG_RETURN(error_num); + } +#ifdef HA_CAN_BULK_ACCESS + if (!spider->is_bulk_access_clone) + { +#endif + for ( + roop_count2 = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count2 < (int) share->link_count; + roop_count2 = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count2, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + ulong sql_type; + spider_db_handler *dbton_handler; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[roop_count2] == SPIDER_CONN_KIND_MYSQL) + { +#endif + sql_type = SPIDER_SQL_TYPE_INSERT_SQL; + conn = spider->conns[roop_count2]; + dbton_handler = spider->dbton_handler[conn->dbton_id]; + mta_conn_mutex_lock_already_backup = + conn->mta_conn_mutex_lock_already; + mta_conn_mutex_unlock_later_backup = + conn->mta_conn_mutex_unlock_later; + if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + if (!mta_conn_mutex_lock_already_backup) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + } + if ((error_num = dbton_handler->set_sql_for_exec(sql_type, + roop_count2))) + { + DBUG_RETURN(error_num); + } + if (!dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) + { + if (!mta_conn_mutex_lock_already_backup) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + sql_type = SPIDER_SQL_TYPE_INSERT_HS; + conn = spider->hs_w_conns[roop_count2]; + dbton_handler = spider->dbton_handler[conn->dbton_id]; + mta_conn_mutex_lock_already_backup = + conn->mta_conn_mutex_lock_already; + mta_conn_mutex_unlock_later_backup = + conn->mta_conn_mutex_unlock_later; + if (!mta_conn_mutex_lock_already_backup) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + } +#endif + conn->need_mon = &spider->need_mons[roop_count2]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, roop_count2))) + { + conn->mta_conn_mutex_lock_already = + mta_conn_mutex_lock_already_backup; + conn->mta_conn_mutex_unlock_later = + mta_conn_mutex_unlock_later_backup; + if (!mta_conn_mutex_unlock_later_backup) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + if ( + share->monitoring_kind[roop_count2] && + spider->need_mons[roop_count2] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count2], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count2], + NULL, + 0, + share->monitoring_kind[roop_count2], + share->monitoring_limit[roop_count2], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count2, spider->trx->thd, + share); + if (dbton_handler->execute_sql( + sql_type, + conn, + -1, + &spider->need_mons[roop_count2]) + ) { + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); + error_num = spider_db_errorno(conn); + if (error_num == HA_ERR_FOUND_DUPP_KEY) + { + conn->db_conn->set_dup_key_idx(spider, roop_count2); + } + conn->mta_conn_mutex_lock_already = + mta_conn_mutex_lock_already_backup; + conn->mta_conn_mutex_unlock_later = + mta_conn_mutex_unlock_later_backup; + if (!mta_conn_mutex_unlock_later_backup) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + if ( + error_num != ER_DUP_ENTRY && + error_num != ER_DUP_KEY && + error_num != HA_ERR_FOUND_DUPP_KEY && + share->monitoring_kind[roop_count2] && + spider->need_mons[roop_count2] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count2], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count2], + NULL, + 0, + share->monitoring_kind[roop_count2], + share->monitoring_limit[roop_count2], + TRUE + ); + } + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = mta_conn_mutex_lock_already_backup; + conn->mta_conn_mutex_unlock_later = mta_conn_mutex_unlock_later_backup; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind != SPIDER_CONN_KIND_MYSQL) + { + uint roop_count; + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider result_list->hs_upd_rows=%llu", + result_list->hs_upd_rows)); + for (roop_count = 0; roop_count < result_list->hs_upd_rows; + roop_count++) + { + SPIDER_DB_RESULT *result; + if (spider_bit_is_set(spider->db_request_phase, roop_count2)) + { + spider_clear_bit(spider->db_request_phase, roop_count2); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[roop_count2]; + request_key.next = NULL; + if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { + result->free_result(); + delete result; + } else { + if (!error_num) + { + error_num = spider_db_errorno(conn); + } + DBUG_RETURN(error_num); + } + } + } +#endif + if (!mta_conn_mutex_unlock_later_backup) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + if (first_insert_link_idx == -1) + { + first_insert_link_idx = roop_count2; + first_insert_conn = conn; + } + } + + conn = first_insert_conn; + mta_conn_mutex_lock_already_backup = conn->mta_conn_mutex_lock_already; + mta_conn_mutex_unlock_later_backup = conn->mta_conn_mutex_unlock_later; + if (!mta_conn_mutex_lock_already_backup) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + conn->need_mon = &spider->need_mons[first_insert_link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); + if (table->next_number_field && + ( + !table->auto_increment_field_not_null || + ( + !table->next_number_field->val_int() && + !(thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) + ) + ) + ) { + ulonglong last_insert_id; + spider_db_handler *dbton_handler = + spider->dbton_handler[conn->dbton_id]; + if (spider->store_last_insert_id) + last_insert_id = spider->store_last_insert_id; + else if ((error_num = dbton_handler-> + show_last_insert_id(first_insert_link_idx, last_insert_id))) + { + conn->mta_conn_mutex_lock_already = + mta_conn_mutex_lock_already_backup; + conn->mta_conn_mutex_unlock_later = + mta_conn_mutex_unlock_later_backup; + if (!mta_conn_mutex_unlock_later_backup) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); + } + table->next_number_field->set_notnull(); + if ( + (error_num = spider_db_update_auto_increment(spider, + first_insert_link_idx)) || + (error_num = table->next_number_field->store( + last_insert_id, TRUE)) + ) { + conn->mta_conn_mutex_lock_already = + mta_conn_mutex_lock_already_backup; + conn->mta_conn_mutex_unlock_later = + mta_conn_mutex_unlock_later_backup; + if (!mta_conn_mutex_unlock_later_backup) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); + } + } + conn->mta_conn_mutex_lock_already = mta_conn_mutex_lock_already_backup; + conn->mta_conn_mutex_unlock_later = mta_conn_mutex_unlock_later_backup; + if (!mta_conn_mutex_unlock_later_backup) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + spider->store_last_insert_id = 0; +#ifdef HA_CAN_BULK_ACCESS + } +#endif + } + if ( + (bulk_end || !spider->bulk_insert) && + (error_num = spider_trx_check_link_idx_failed(spider)) + ) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +int spider_db_bulk_bulk_insert( + ha_spider *spider +) { + int error_num = 0, first_insert_link_idx = -1, tmp_error_num; + int roop_count2; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn, *first_insert_conn = NULL; + TABLE *table = spider->get_table(); + THD *thd = spider->trx->thd; + DBUG_ENTER("spider_db_bulk_bulk_insert"); + for ( + roop_count2 = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count2 < (int) share->link_count; + roop_count2 = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count2, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[roop_count2] == SPIDER_CONN_KIND_MYSQL) + { +#endif + conn = spider->conns[roop_count2]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + conn = spider->hs_w_conns[roop_count2]; + } +#endif + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((tmp_error_num = spider_db_bulk_open_handler(spider, conn, + roop_count2))) + { + error_num = tmp_error_num; + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind != SPIDER_CONN_KIND_MYSQL) + { + uint roop_count; + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider result_list->hs_upd_rows=%llu", + result_list->hs_upd_rows)); + for (roop_count = 0; roop_count < result_list->hs_upd_rows; + roop_count++) + { + SPIDER_DB_RESULT *result; + if (spider_bit_is_set(spider->db_request_phase, roop_count2)) + { + spider_clear_bit(spider->db_request_phase, roop_count2); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[roop_count2]; + request_key.next = NULL; + if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { + result->free_result(); + delete result; + } else { + if (!error_num) + { + error_num = spider_db_errorno(conn); + } + DBUG_RETURN(error_num); + } + } + } +#endif + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if (first_insert_link_idx == -1) + { + first_insert_link_idx = roop_count2; + first_insert_conn = conn; + } + } + + conn = first_insert_conn; + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[first_insert_link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if (table->next_number_field && + ( + !table->auto_increment_field_not_null || + ( + !table->next_number_field->val_int() && + !(thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) + ) + ) + ) { + ulonglong last_insert_id; + if (spider->store_last_insert_id) + last_insert_id = spider->store_last_insert_id; + else + last_insert_id = conn->db_conn->last_insert_id(); + table->next_number_field->set_notnull(); + if ( + (tmp_error_num = spider_db_update_auto_increment(spider, + first_insert_link_idx)) || + (tmp_error_num = table->next_number_field->store( + last_insert_id, TRUE)) + ) { + error_num = tmp_error_num; + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + spider->store_last_insert_id = 0; + DBUG_RETURN(error_num); +} +#endif + +int spider_db_update_auto_increment( + ha_spider *spider, + int link_idx +) { + int roop_count; + THD *thd = spider->trx->thd; + ulonglong last_insert_id, affected_rows; + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + int auto_increment_mode = spider_param_auto_increment_mode(thd, + share->auto_increment_mode); + DBUG_ENTER("spider_db_update_auto_increment"); + if ( + auto_increment_mode == 2 || + (auto_increment_mode == 3 && !table->auto_increment_field_not_null) + ) { + last_insert_id = spider->conns[link_idx]->db_conn->last_insert_id(); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) + { +#endif + affected_rows = spider->conns[link_idx]->db_conn->affected_rows(); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + affected_rows = spider->result_list.hs_upd_rows; + } +#endif + DBUG_PRINT("info",("spider last_insert_id=%llu", last_insert_id)); + share->auto_increment_value = + last_insert_id + affected_rows; +/* + thd->record_first_successful_insert_id_in_cur_stmt(last_insert_id); +*/ + if ( + thd->first_successful_insert_id_in_cur_stmt == 0 || + thd->first_successful_insert_id_in_cur_stmt > last_insert_id + ) { + bool first_set = (thd->first_successful_insert_id_in_cur_stmt == 0); + thd->first_successful_insert_id_in_cur_stmt = last_insert_id; + if ( + table->s->next_number_keypart == 0 && + mysql_bin_log.is_open() && +#if MYSQL_VERSION_ID < 50500 + !thd->current_stmt_binlog_row_based +#else + !thd->is_current_stmt_binlog_format_row() +#endif + ) { + if ( + spider->check_partitioned() && + thd->auto_inc_intervals_in_cur_stmt_for_binlog.nb_elements() > 0 + ) { + DBUG_PRINT("info",("spider table partitioning")); + Discrete_interval *current = + thd->auto_inc_intervals_in_cur_stmt_for_binlog.get_current(); + current->replace(last_insert_id, affected_rows, 1); + } else { + DBUG_PRINT("info",("spider table")); + thd->auto_inc_intervals_in_cur_stmt_for_binlog.append( + last_insert_id, affected_rows, 1); + } + if (affected_rows > 1 || !first_set) + { + for (roop_count = first_set ? 1 : 0; + roop_count < (int) affected_rows; + roop_count++) + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_SPIDER_AUTOINC_VAL_IS_DIFFERENT_NUM, + ER_SPIDER_AUTOINC_VAL_IS_DIFFERENT_STR); + } + } + } else { + if ( + table->s->next_number_keypart == 0 && + mysql_bin_log.is_open() && +#if MYSQL_VERSION_ID < 50500 + !thd->current_stmt_binlog_row_based +#else + !thd->is_current_stmt_binlog_format_row() +#endif + ) { + for (roop_count = 0; roop_count < (int) affected_rows; roop_count++) + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_SPIDER_AUTOINC_VAL_IS_DIFFERENT_NUM, + ER_SPIDER_AUTOINC_VAL_IS_DIFFERENT_STR); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_bulk_update_size_limit( + ha_spider *spider, + TABLE *table +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_CONN *conn; + uint dup_key_found = 0; + DBUG_ENTER("spider_db_bulk_update_size_limit"); + + if (result_list->bulk_update_mode == 1) + { + /* execute bulk updating */ + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = spider_db_query_for_bulk_update( + spider, conn, roop_count, &dup_key_found))) + DBUG_RETURN(error_num); + } + spider->reset_sql_sql(SPIDER_SQL_TYPE_BULK_UPDATE_SQL); + } else { + /* store query to temporary tables */ + if ((error_num = spider->mk_bulk_tmp_table_and_bulk_start())) + { + goto error_mk_table; + } + if ((error_num = spider->bulk_tmp_table_insert())) + { + goto error_write_row; + } + spider->reset_sql_sql(SPIDER_SQL_TYPE_BULK_UPDATE_SQL); + } + DBUG_RETURN(0); + +error_write_row: + spider->bulk_tmp_table_end_bulk_insert(); + spider->rm_bulk_tmp_table(); + spider->reset_sql_sql(SPIDER_SQL_TYPE_BULK_UPDATE_SQL); +error_mk_table: + DBUG_RETURN(error_num); +} + +int spider_db_bulk_update_end( + ha_spider *spider, + uint *dup_key_found +) { + int error_num = 0, error_num2, roop_count; + THD *thd = spider->trx->thd; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + bool is_error = thd->is_error(); + DBUG_ENTER("spider_db_bulk_update_end"); + + if (spider->bulk_tmp_table_created()) + { + if ((error_num2 = spider->bulk_tmp_table_end_bulk_insert())) + { + error_num = error_num2; + } + + if (!is_error) + { + if (error_num) + goto error_last_query; + + if ((error_num = spider->bulk_tmp_table_rnd_init())) + { + goto error_rnd_init; + } + + while (!(error_num = spider->bulk_tmp_table_rnd_next())) + { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL, roop_count))) + { + if (error_num == ER_SPIDER_COND_SKIP_NUM) + { + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + continue; + } + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = spider_db_query_for_bulk_update( + spider, conn, roop_count, dup_key_found))) + goto error_query; + } + } + if (error_num != HA_ERR_END_OF_FILE) + goto error_rnd_next; + + spider->bulk_tmp_table_rnd_end(); + } + } + + if (!is_error) + { + if (!spider->sql_is_empty(SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = spider_db_query_for_bulk_update( + spider, conn, roop_count, dup_key_found))) + goto error_last_query; + } + } + } + spider->rm_bulk_tmp_table(); + spider->reset_sql_sql(SPIDER_SQL_TYPE_BULK_UPDATE_SQL); + DBUG_RETURN(0); + +error_query: +error_rnd_next: + spider->bulk_tmp_table_rnd_end(); +error_rnd_init: +error_last_query: + spider->rm_bulk_tmp_table(); + spider->reset_sql_sql(SPIDER_SQL_TYPE_BULK_UPDATE_SQL); + DBUG_RETURN(error_num); +} + +int spider_db_bulk_update( + ha_spider *spider, + TABLE *table, + my_ptrdiff_t ptr_diff +) { + int error_num; + DBUG_ENTER("spider_db_bulk_update"); + + if ((error_num = spider->append_update_sql(table, ptr_diff, TRUE))) + DBUG_RETURN(error_num); + + if ( + spider->sql_is_filled_up(SPIDER_SQL_TYPE_BULK_UPDATE_SQL) && + (error_num = spider_db_bulk_update_size_limit(spider, table)) + ) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +} + +int spider_db_update( + ha_spider *spider, + TABLE *table, + const uchar *old_data +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(old_data, table->record[0]); + DBUG_ENTER("spider_db_update"); + if (result_list->bulk_update_mode) + DBUG_RETURN(spider_db_bulk_update(spider, table, ptr_diff)); + + if ((error_num = spider->append_update_sql(table, ptr_diff, FALSE))) + DBUG_RETURN(error_num); + + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + conn->ignore_dup_key = spider->ignore_dup_key; +#endif + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_UPDATE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec( + SPIDER_SQL_TYPE_UPDATE_SQL, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_UPDATE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + conn->need_mon = &spider->need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_UPDATE_SQL, + conn, + -1, + &spider->need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + error_num != ER_DUP_ENTRY && + error_num != ER_DUP_KEY && + error_num != HA_ERR_FOUND_DUPP_KEY && + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + + if ( + !conn->db_conn->affected_rows() && + share->link_statuses[roop_count] == SPIDER_LINK_STATUS_RECOVERY && + spider->pk_update + ) { + /* insert */ + if ((error_num = dbton_hdl->append_insert_for_recovery( + SPIDER_SQL_TYPE_INSERT_SQL, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_INSERT_SQL, + conn, + -1, + &spider->need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + error_num != ER_DUP_ENTRY && + error_num != ER_DUP_KEY && + error_num != HA_ERR_FOUND_DUPP_KEY && + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + result_list->update_sqls[roop_count].length(0); + } + spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_db_direct_update( + ha_spider *spider, + TABLE *table, + KEY_MULTI_RANGE *ranges, + uint range_count, + uint *update_rows +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + bool counted = FALSE; + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + DBUG_ENTER("spider_db_direct_update"); + + spider_set_result_list_param(spider); + result_list->finish_flg = FALSE; + DBUG_PRINT("info", ("spider do_direct_update=%s", + spider->do_direct_update ? "TRUE" : "FALSE")); + DBUG_PRINT("info", ("spider direct_update_kinds=%u", + spider->direct_update_kinds)); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ( +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + ( + spider->do_direct_update && + (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) + ) || + ( + !spider->do_direct_update && +#endif + (spider->sql_kinds & SPIDER_SQL_KIND_SQL) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + ) +#endif + ) { +#endif + if ((error_num = spider->append_update_sql_part())) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + +/* + SQL access -> SQL remote access + !spider->do_direct_update && + (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + + SQL access -> SQL remote access with dirct_update + spider->do_direct_update && + spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && + spider->direct_update_fields + + Handlersocket access -> SQL remote access with dirct_update + spider->do_direct_update && + (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) + + Handlersocket access -> Handlersocket access + spider->do_direct_update && + (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) +*/ + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider->hs_increment || spider->hs_decrement) + { + if ( + (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) && + (error_num = spider->append_increment_update_set_sql_part()) + ) { + DBUG_RETURN(error_num); + } + } else { +#endif +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if (!spider->do_direct_update) + { +#endif + if ( + (spider->sql_kinds & SPIDER_SQL_KIND_SQL) && + (error_num = spider->append_update_set_sql_part()) + ) { + DBUG_RETURN(error_num); + } +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + } else { + if ( + (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) && + (error_num = spider->append_direct_update_set_sql_part()) + ) { + DBUG_RETURN(error_num); + } + if ( + (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) && + (error_num = spider->append_direct_update_set_hs_part()) + ) { + DBUG_RETURN(error_num); + } + } +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + + result_list->desc_flg = FALSE; + result_list->sorted = TRUE; + if (spider->active_index == MAX_KEY) + result_list->key_info = NULL; + else + result_list->key_info = &table->key_info[spider->active_index]; + spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); + result_list->limit_num = + result_list->internal_limit >= select_limit ? + select_limit : result_list->internal_limit; + result_list->internal_offset += offset_limit; + if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) + { + if ( + (error_num = spider->append_key_where_sql_part( + (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, + (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, + SPIDER_SQL_TYPE_UPDATE_SQL)) || + (error_num = spider-> + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_UPDATE_SQL)) || + (error_num = spider->append_limit_sql_part( + result_list->internal_offset, result_list->limit_num, + SPIDER_SQL_TYPE_UPDATE_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) + { + if ( + (error_num = spider->append_key_where_hs_part( + (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, + (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, + SPIDER_SQL_TYPE_UPDATE_HS)) || + (error_num = spider->append_limit_hs_part( + result_list->internal_offset, result_list->limit_num, + SPIDER_SQL_TYPE_UPDATE_HS)) + ) { + DBUG_RETURN(error_num); + } + } + + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) + { +#endif + DBUG_PRINT("info", ("spider exec sql")); + conn = spider->conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_UPDATE_SQL; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + DBUG_PRINT("info", ("spider exec hs")); + conn = spider->hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_UPDATE_HS; + } +#endif + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } +#ifdef HA_CAN_BULK_ACCESS + if (spider->is_bulk_access_clone) + { + spider->connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(spider->trx, conn); + } else { +#endif + conn->need_mon = &spider->need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + share); + if ( + (error_num = dbton_hdl->execute_sql( + sql_type, + conn, + -1, + &spider->need_mons[roop_count]) + ) && + (error_num != HA_ERR_FOUND_DUPP_KEY || !spider->ignore_dup_key) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + error_num != ER_DUP_ENTRY && + error_num != ER_DUP_KEY && + error_num != HA_ERR_FOUND_DUPP_KEY && + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) + { + if (!counted) + { +#endif + *update_rows = spider->conns[roop_count]->db_conn->affected_rows(); + DBUG_PRINT("info", ("spider update_rows = %u", *update_rows)); + counted = TRUE; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + SPIDER_DB_RESULT *result; + if (spider_bit_is_set(spider->db_request_phase, roop_count)) + { + spider_clear_bit(spider->db_request_phase, roop_count); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[roop_count]; + request_key.next = NULL; + if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { + if (!counted) + { + *update_rows = conn->db_conn->affected_rows(); + DBUG_PRINT("info", ("spider update_rows = %u", *update_rows)); + counted = TRUE; + } + result->free_result(); + delete result; + } else { + if (!error_num) + { + error_num = spider_db_errorno(conn); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } +#endif +#ifdef HA_CAN_BULK_ACCESS + } +#endif + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider->reset_hs_sql(SPIDER_SQL_TYPE_UPDATE_HS); + spider->reset_hs_keys(SPIDER_SQL_TYPE_UPDATE_HS); + spider->reset_hs_upds(SPIDER_SQL_TYPE_UPDATE_HS); +#endif + DBUG_RETURN(0); +} +#endif + +#ifdef HA_CAN_BULK_ACCESS +int spider_db_bulk_direct_update( + ha_spider *spider, + uint *update_rows +) { + int error_num = 0, roop_count, tmp_error_num; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + bool counted = FALSE; + DBUG_ENTER("spider_db_bulk_direct_update"); + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) + { +#endif + DBUG_PRINT("info", ("spider exec sql")); + conn = spider->conns[roop_count]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + DBUG_PRINT("info", ("spider exec hs")); + conn = spider->hs_w_conns[roop_count]; + } +#endif + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((tmp_error_num = spider_db_bulk_open_handler(spider, conn, + roop_count))) + { + error_num = tmp_error_num; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) + { + if (!counted) + { +#endif + *update_rows = spider->conns[roop_count]->db_conn->affected_rows(); + DBUG_PRINT("info", ("spider update_rows = %u", *update_rows)); + counted = TRUE; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + SPIDER_DB_RESULT *result; + if (spider_bit_is_set(spider->db_request_phase, roop_count)) + { + spider_clear_bit(spider->db_request_phase, roop_count); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[roop_count]; + request_key.next = NULL; + if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { + if (!counted) + { + *update_rows = conn->db_conn->affected_rows(); + DBUG_PRINT("info", ("spider update_rows = %u", *update_rows)); + counted = TRUE; + } + result->free_result(); + delete result; + } else { + if (!error_num) + { + error_num = spider_db_errorno(conn); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } +#endif + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); +} +#endif + +int spider_db_bulk_delete( + ha_spider *spider, + TABLE *table, + my_ptrdiff_t ptr_diff +) { + int error_num; + DBUG_ENTER("spider_db_bulk_delete"); + + if ((error_num = spider->append_delete_sql(table, ptr_diff, TRUE))) + DBUG_RETURN(error_num); + + if ( + spider->sql_is_filled_up(SPIDER_SQL_TYPE_BULK_UPDATE_SQL) && + (error_num = spider_db_bulk_update_size_limit(spider, table)) + ) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +} + +int spider_db_delete( + ha_spider *spider, + TABLE *table, + const uchar *buf +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]); + DBUG_ENTER("spider_db_delete"); + if (result_list->bulk_update_mode) + DBUG_RETURN(spider_db_bulk_delete(spider, table, ptr_diff)); + + if ((error_num = spider->append_delete_sql(table, ptr_diff, FALSE))) + DBUG_RETURN(error_num); + + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_DELETE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec( + SPIDER_SQL_TYPE_DELETE_SQL, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_DELETE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = spider_db_query_with_set_names( + SPIDER_SQL_TYPE_DELETE_SQL, spider, conn, roop_count))) + DBUG_RETURN(error_num); + result_list->update_sqls[roop_count].length(0); + } + if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) + { + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_db_direct_delete( + ha_spider *spider, + TABLE *table, + KEY_MULTI_RANGE *ranges, + uint range_count, + uint *delete_rows +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + bool counted = FALSE; + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + DBUG_ENTER("spider_db_direct_delete"); + + spider_set_result_list_param(spider); + result_list->finish_flg = FALSE; + result_list->desc_flg = FALSE; + result_list->sorted = TRUE; + if (spider->active_index == MAX_KEY) + result_list->key_info = NULL; + else + result_list->key_info = &table->key_info[spider->active_index]; + spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); + result_list->limit_num = + result_list->internal_limit >= select_limit ? + select_limit : result_list->internal_limit; + result_list->internal_offset += offset_limit; +/* + result_list->limit_num = + result_list->internal_limit >= result_list->split_read ? + result_list->split_read : result_list->internal_limit; +*/ + if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) + { + if ( + (error_num = spider->append_delete_sql_part()) || + (error_num = spider->append_from_sql_part(SPIDER_SQL_TYPE_DELETE_SQL)) + ) { + DBUG_RETURN(error_num); + } + spider->set_where_pos_sql(SPIDER_SQL_TYPE_DELETE_SQL); + if ( + (error_num = spider->append_key_where_sql_part( + (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, + (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, + SPIDER_SQL_TYPE_DELETE_SQL)) || + (error_num = spider-> + append_key_order_for_direct_order_limit_with_alias_sql_part( + NULL, 0, SPIDER_SQL_TYPE_DELETE_SQL)) || + (error_num = spider->append_limit_sql_part( + result_list->internal_offset, result_list->limit_num, + SPIDER_SQL_TYPE_DELETE_SQL)) + ) { + DBUG_RETURN(error_num); + } + } + if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) + { + if ( + (error_num = spider->append_key_where_hs_part( + (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, + (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, + SPIDER_SQL_TYPE_DELETE_HS)) || + (error_num = spider->append_limit_hs_part( + result_list->internal_offset, result_list->limit_num, + SPIDER_SQL_TYPE_DELETE_HS)) + ) { + DBUG_RETURN(error_num); + } + } + + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + ulong sql_type; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) + { +#endif + DBUG_PRINT("info", ("spider exec sql")); + conn = spider->conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_DELETE_SQL; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + DBUG_PRINT("info", ("spider exec hs")); + conn = spider->hs_w_conns[roop_count]; + sql_type = SPIDER_SQL_TYPE_DELETE_HS; + } +#endif + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } +#ifdef HA_CAN_BULK_ACCESS + if (spider->is_bulk_access_clone) + { + spider->connection_ids[roop_count] = conn->connection_id; + spider_trx_add_bulk_access_conn(spider->trx, conn); + } else { +#endif + conn->need_mon = &spider->need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + -1, + &spider->need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) + { +#endif + if (!counted) + { + *delete_rows = spider->conns[roop_count]->db_conn->affected_rows(); + DBUG_PRINT("info", ("spider delete_rows = %u", *delete_rows)); + counted = TRUE; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + SPIDER_DB_RESULT *result; + if (spider_bit_is_set(spider->db_request_phase, roop_count)) + { + spider_clear_bit(spider->db_request_phase, roop_count); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[roop_count]; + request_key.next = NULL; + if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { + if (!counted) + { + *delete_rows = conn->db_conn->affected_rows(); + DBUG_PRINT("info", ("spider delete_rows = %u", *delete_rows)); + counted = TRUE; + } + result->free_result(); + delete result; + } else { + if (!error_num) + { + error_num = spider_db_errorno(conn); + } + DBUG_RETURN(error_num); + } + } +#endif +#ifdef HA_CAN_BULK_ACCESS + } +#endif + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + int error_num2 = 0; + if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) + error_num2 = error_num; + } + if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) + { + if ((error_num = spider->reset_hs_sql(SPIDER_SQL_TYPE_DELETE_HS))) + error_num2 = error_num; + if ((error_num = spider->reset_hs_keys(SPIDER_SQL_TYPE_DELETE_HS))) + error_num2 = error_num; + } + DBUG_RETURN(error_num2); +} +#endif + +int spider_db_delete_all_rows( + ha_spider *spider +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + DBUG_ENTER("spider_db_delete_all_rows"); + if ((error_num = spider->append_delete_all_rows_sql_part( + SPIDER_SQL_TYPE_DELETE_SQL))) + DBUG_RETURN(error_num); + + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + uint dbton_id = share->use_sql_dbton_ids[roop_count]; + spider_db_handler *dbton_hdl = spider->dbton_handler[dbton_id]; + conn = spider->conns[roop_count]; + if (dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_DELETE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + if ((error_num = dbton_hdl->set_sql_for_exec( + SPIDER_SQL_TYPE_DELETE_SQL, roop_count))) + { + DBUG_RETURN(error_num); + } + if (!dbton_hdl->need_lock_before_set_sql_for_exec( + SPIDER_SQL_TYPE_DELETE_SQL)) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + } + conn->need_mon = &spider->need_mons[roop_count]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, roop_count)) || + ( + dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_DELETE_SQL, + conn, + -1, + &spider->need_mons[roop_count]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, roop_count))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd, + share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_DELETE_SQL, + conn, + -1, + &spider->need_mons[roop_count]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +} + +int spider_db_disable_keys( + ha_spider *spider +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + spider_db_handler *dbton_hdl; + DBUG_ENTER("spider_db_disable_keys"); + if ( + spider_param_internal_optimize(spider->trx->thd, + share->internal_optimize) == 1 + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((error_num = dbton_hdl->disable_keys(conn, roop_count))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_enable_keys( + ha_spider *spider +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + spider_db_handler *dbton_hdl; + DBUG_ENTER("spider_db_enable_keys"); + if ( + spider_param_internal_optimize(spider->trx->thd, + share->internal_optimize) == 1 + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((error_num = dbton_hdl->enable_keys(conn, roop_count))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_check_table( + ha_spider *spider, + HA_CHECK_OPT* check_opt +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + spider_db_handler *dbton_hdl; + DBUG_ENTER("spider_db_check_table"); + if ( + spider_param_internal_optimize(spider->trx->thd, + share->internal_optimize) == 1 + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((error_num = dbton_hdl->check_table(conn, roop_count, check_opt))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_repair_table( + ha_spider *spider, + HA_CHECK_OPT* check_opt +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + spider_db_handler *dbton_hdl; + DBUG_ENTER("spider_db_repair_table"); + if ( + spider_param_internal_optimize(spider->trx->thd, + share->internal_optimize) == 1 + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((error_num = dbton_hdl->repair_table(conn, roop_count, check_opt))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_analyze_table( + ha_spider *spider +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + spider_db_handler *dbton_hdl; + DBUG_ENTER("spider_db_analyze_table"); + if ( + spider_param_internal_optimize(spider->trx->thd, + share->internal_optimize) == 1 + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((error_num = dbton_hdl->analyze_table(conn, roop_count))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_optimize_table( + ha_spider *spider +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + spider_db_handler *dbton_hdl; + DBUG_ENTER("spider_db_optimize_table"); + if ( + spider_param_internal_optimize(spider->trx->thd, + share->internal_optimize) == 1 + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((error_num = dbton_hdl->optimize_table(conn, roop_count))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_flush_tables( + ha_spider *spider, + bool lock +) { + int error_num, roop_count; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + spider_db_handler *dbton_hdl; + DBUG_ENTER("spider_db_flush_tables"); + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((error_num = dbton_hdl->flush_tables(conn, roop_count, lock))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int spider_db_flush_logs( + ha_spider *spider +) { + int roop_count, error_num; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + spider_db_handler *dbton_hdl; + DBUG_ENTER("spider_db_flush_logs"); + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + conn = spider->conns[roop_count]; + dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((error_num = dbton_hdl->flush_logs(conn, roop_count))) + { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int spider_db_print_item_type( + Item *item, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + DBUG_ENTER("spider_db_print_item_type"); + DBUG_PRINT("info",("spider COND type=%d", item->type())); + switch (item->type()) + { + case Item::FUNC_ITEM: + DBUG_RETURN(spider_db_open_item_func((Item_func *) item, spider, str, + alias, alias_length, dbton_id)); + case Item::COND_ITEM: + DBUG_RETURN(spider_db_open_item_cond((Item_cond *) item, spider, str, + alias, alias_length, dbton_id)); + case Item::FIELD_ITEM: + DBUG_RETURN(spider_db_open_item_field((Item_field *) item, spider, str, + alias, alias_length, dbton_id)); + case Item::REF_ITEM: + DBUG_RETURN(spider_db_open_item_ref((Item_ref *) item, spider, str, + alias, alias_length, dbton_id)); + case Item::ROW_ITEM: + DBUG_RETURN(spider_db_open_item_row((Item_row *) item, spider, str, + alias, alias_length, dbton_id)); + case Item::STRING_ITEM: + DBUG_RETURN(spider_db_open_item_string(item, spider, str, + alias, alias_length, dbton_id)); + case Item::INT_ITEM: + case Item::REAL_ITEM: + case Item::DECIMAL_ITEM: + DBUG_RETURN(spider_db_open_item_int(item, spider, str, + alias, alias_length, dbton_id)); + case Item::CACHE_ITEM: + DBUG_RETURN(spider_db_open_item_cache((Item_cache *)item, spider, str, + alias, alias_length, dbton_id)); + case Item::SUBSELECT_ITEM: + case Item::TRIGGER_FIELD_ITEM: + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + default: + THD *thd = spider->trx->thd; + SPIDER_SHARE *share = spider->share; + if (spider_param_skip_default_condition(thd, + share->skip_default_condition)) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (str) + { + if (spider->share->access_charset->cset == system_charset_info->cset) + { +#if MYSQL_VERSION_ID < 50500 + item->print(str->get_str(), QT_IS); +#else + item->print(str->get_str(), QT_TO_SYSTEM_CHARSET); +#endif + } else { + item->print(str->get_str(), QT_ORDINARY); + } + str->mem_calc(); + } + break; + } + DBUG_RETURN(0); +} + +int spider_db_open_item_cond( + Item_cond *item_cond, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + int error_num = 0; + List_iterator_fast lif(*(item_cond->argument_list())); + Item *item; + char *func_name = NULL; + int func_name_length = 0, restart_pos = 0; + DBUG_ENTER("spider_db_open_item_cond"); + if (str) + { + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + +restart_first: + if ((item = lif++)) + { + if (str) + restart_pos = str->length(); + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + { + if ( + str && + error_num == ER_SPIDER_COND_SKIP_NUM && + item_cond->functype() == Item_func::COND_AND_FUNC + ) { + DBUG_PRINT("info",("spider COND skip")); + str->length(restart_pos); + goto restart_first; + } + DBUG_RETURN(error_num); + } + } + if (error_num) + DBUG_RETURN(error_num); + while ((item = lif++)) + { + if (str) + { + restart_pos = str->length(); + if (!func_name) + { + func_name = (char*) item_cond->func_name(); + func_name_length = strlen(func_name); + } + if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + { + if ( + str && + error_num == ER_SPIDER_COND_SKIP_NUM && + item_cond->functype() == Item_func::COND_AND_FUNC + ) { + DBUG_PRINT("info",("spider COND skip")); + str->length(restart_pos); + } else + DBUG_RETURN(error_num); + } + } + if (str) + { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +} + +int spider_db_open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + DBUG_ENTER("spider_db_open_item_func"); + DBUG_RETURN(spider_dbton[dbton_id].db_util->open_item_func( + item_func, spider, str, alias, alias_length)); +} + +int spider_db_open_item_ident( + Item_ident *item_ident, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + int error_num, field_name_length; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_db_open_item_ident"); + if ( + item_ident->cached_field_index != NO_CACHED_FIELD_INDEX && + item_ident->cached_table + ) { + Field *field = item_ident->cached_table->table->field[ + item_ident->cached_field_index]; + if (!(field = spider->field_exchange(field))) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + DBUG_PRINT("info",("spider use cached_field_index")); + if (str) + { + if ((error_num = share->dbton_share[dbton_id]-> + append_column_name_with_alias(str, field->field_index, + alias, alias_length))) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); + } + if (str) + { + if (item_ident->field_name) + field_name_length = strlen(item_ident->field_name); + else + field_name_length = 0; + if (share->access_charset->cset == system_charset_info->cset) + { + if (str->reserve(alias_length + + field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(alias, alias_length); + if ((error_num = spider_dbton[dbton_id].db_util-> + append_name(str, item_ident->field_name, field_name_length))) + { + DBUG_RETURN(error_num); + } + } else { + if (str->reserve(alias_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + if ((error_num = spider_dbton[dbton_id].db_util-> + append_name_with_charset(str, item_ident->field_name, + field_name_length, system_charset_info))) + { + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_open_item_field( + Item_field *item_field, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + int error_num; + Field *field = item_field->field; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_db_open_item_field"); + if (field) + { + DBUG_PRINT("info",("spider field=%p", field)); + if (!(field = spider->field_exchange(field))) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (field->table->const_table) + { + if (str) + { + if ((error_num = share->dbton_share[dbton_id]-> + append_column_name_with_alias(str, field->field_index, + alias, alias_length))) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); + } + } + DBUG_RETURN(spider_db_open_item_ident( + (Item_ident *) item_field, spider, str, alias, alias_length, dbton_id)); +} + +int spider_db_open_item_ref( + Item_ref *item_ref, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + int error_num; + DBUG_ENTER("spider_db_open_item_ref"); + if (item_ref->ref) + { + if ( + (*(item_ref->ref))->type() != Item::CACHE_ITEM && + item_ref->ref_type() != Item_ref::VIEW_REF && + !item_ref->table_name && + item_ref->name && + item_ref->alias_name_used + ) { + if (str) + { + uint length = strlen(item_ref->name); + if (str->reserve(length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if ((error_num = spider_dbton[dbton_id].db_util-> + append_name(str, item_ref->name, length))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); + } + DBUG_RETURN(spider_db_print_item_type(*(item_ref->ref), spider, str, + alias, alias_length, dbton_id)); + } + DBUG_RETURN(spider_db_open_item_ident((Item_ident *) item_ref, spider, str, + alias, alias_length, dbton_id)); +} + +int spider_db_open_item_row( + Item_row *item_row, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + int error_num; + uint roop_count, cols = item_row->cols() - 1; + Item *item; + DBUG_ENTER("spider_db_open_item_row"); + if (str) + { + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + for (roop_count = 0; roop_count < cols; roop_count++) + { + item = item_row->element_index(roop_count); + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + item = item_row->element_index(roop_count); + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +} + +int spider_db_open_item_string( + Item *item, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + DBUG_ENTER("spider_db_open_item_string"); + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + String *tmp_str2; + tmp_str.init_calc_mem(126); + if ( + !(tmp_str2 = item->val_str(tmp_str.get_str())) || + str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + tmp_str2->length() * 2) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_str.mem_calc(); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if ( + append_escaped(str->get_str(), tmp_str2) || + str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->mem_calc(); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } + DBUG_RETURN(0); +} + +int spider_db_open_item_int( + Item *item, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + DBUG_ENTER("spider_db_open_item_int"); + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(127); + if (str->append(*item->val_str(tmp_str.get_str()))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_str.mem_calc(); + } + DBUG_RETURN(0); +} + +int spider_db_open_item_cache( + Item_cache *item_cache, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + DBUG_ENTER("spider_db_open_item_cache"); + if (!item_cache->const_item()) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + switch (item_cache->result_type()) + { + case STRING_RESULT: + DBUG_RETURN(spider_db_open_item_string(item_cache, spider, str, + alias, alias_length, dbton_id)); + case ROW_RESULT: + { + int error_num; + Item_cache_row *item_cache_row = (Item_cache_row *) item_cache; + uint item_count = item_cache_row->cols() - 1, roop_count; + if (str) + { + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + for (roop_count = 0; roop_count < item_count; ++roop_count) + { + if ((error_num = spider_db_open_item_cache( + (Item_cache *) item_cache_row->element_index(roop_count), + spider, str, alias, alias_length, dbton_id + ))) { + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if ((error_num = spider_db_open_item_cache( + (Item_cache *) item_cache_row->element_index(roop_count), + spider, str, alias, alias_length, dbton_id + ))) { + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + } + DBUG_RETURN(0); + case REAL_RESULT: + case INT_RESULT: + case DECIMAL_RESULT: + default: + break; + } + DBUG_RETURN(spider_db_open_item_int(item_cache, spider, str, + alias, alias_length, dbton_id)); +} + +int spider_db_append_condition( + ha_spider *spider, + const char *alias, + uint alias_length, + bool test_flg +) { + int error_num; + DBUG_ENTER("spider_db_append_condition"); + if (!test_flg) + { + if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) + { + if ((error_num = spider->append_condition_sql_part( + alias, alias_length, SPIDER_SQL_TYPE_SELECT_SQL, FALSE))) + DBUG_RETURN(error_num); + } + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + if ((error_num = spider->append_condition_sql_part( + alias, alias_length, SPIDER_SQL_TYPE_HANDLER, FALSE))) + DBUG_RETURN(error_num); + } + } else { + if (spider->cond_check) + DBUG_RETURN(spider->cond_check_error); + spider->cond_check = TRUE; + if ((spider->cond_check_error = spider->append_condition_sql_part( + NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL, TRUE))) + DBUG_RETURN(spider->cond_check_error); + } + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_db_append_update_columns( + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +) { + int error_num; + List_iterator_fast fi(*spider->direct_update_fields), + vi(*spider->direct_update_values); + Item *field, *value; + DBUG_ENTER("spider_db_append_update_columns"); + while ((field = fi++)) + { + value = vi++; + if ((error_num = spider_db_print_item_type( + (Item *) field, spider, str, alias, alias_length, dbton_id))) + { + if ( + error_num == ER_SPIDER_COND_SKIP_NUM && + field->type() == Item::FIELD_ITEM && + ((Item_field *) field)->field + ) + continue; + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + } + if ((error_num = spider_db_print_item_type( + (Item *) value, spider, str, alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if (str) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} +#endif + +uint spider_db_check_ft_idx( + Item_func *item_func, + ha_spider *spider +) { + uint roop_count, roop_count2, part_num; + uint item_count = item_func->argument_count(); + Item **item_list = item_func->arguments(); + Item_field *item_field; + Field *field; + TABLE *table = spider->get_table(); + TABLE_SHARE *table_share = table->s; + KEY *key_info; + KEY_PART_INFO *key_part; + bool match1, match2; + DBUG_ENTER("spider_db_check_ft_idx"); + + for (roop_count = 0; roop_count < table_share->keys; roop_count++) + { + key_info = &table->key_info[roop_count]; + if ( + key_info->algorithm == HA_KEY_ALG_FULLTEXT && + item_count - 1 == key_info->key_parts + ) { + match1 = TRUE; + for (roop_count2 = 1; roop_count2 < item_count; roop_count2++) + { + item_field = (Item_field *) item_list[roop_count2]; + field = item_field->field; + if (!(field = spider->field_exchange(field))) + DBUG_RETURN(MAX_KEY); + match2 = FALSE; + for (key_part = key_info->key_part, part_num = 0; + part_num < key_info->key_parts; key_part++, part_num++) + { + if (key_part->field == field) + { + match2 = TRUE; + break; + } + } + if (!match2) + { + match1 = FALSE; + break; + } + } + if (match1) + DBUG_RETURN(roop_count); + } + } + DBUG_RETURN(MAX_KEY); +} + +int spider_db_udf_fetch_row( + SPIDER_TRX *trx, + Field *field, + SPIDER_DB_ROW *row +) { + DBUG_ENTER("spider_db_udf_fetch_row"); + DBUG_RETURN(row->store_to_field(field, trx->udf_access_charset)); + DBUG_RETURN(0); +} + +int spider_db_udf_fetch_table( + SPIDER_TRX *trx, + SPIDER_CONN *conn, + TABLE *table, + SPIDER_DB_RESULT *result, + uint set_on, + uint set_off +) { + int error_num; + SPIDER_DB_ROW *row = NULL; + Field **field; + uint roop_count; + DBUG_ENTER("spider_db_udf_fetch_table"); + if (!(row = result->fetch_row())) + DBUG_RETURN(HA_ERR_END_OF_FILE); + +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->write_set); +#endif + for ( + roop_count = 0, + field = table->field; + roop_count < set_on; + roop_count++, + field++ + ) { + if ((error_num = + spider_db_udf_fetch_row(trx, *field, row))) + { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + DBUG_RETURN(error_num); + } + row->next(); + } + + for (; roop_count < set_off; roop_count++, field++) + (*field)->set_default(); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->write_set, tmp_map); +#endif + table->status = 0; + DBUG_RETURN(0); +} + +int spider_db_udf_direct_sql_connect( + const SPIDER_DIRECT_SQL *direct_sql, + SPIDER_CONN *conn +) { + int error_num, connect_retry_count; + THD* thd = current_thd; + longlong connect_retry_interval; + DBUG_ENTER("spider_db_udf_direct_sql_connect"); + + if (thd) + { + conn->connect_timeout = spider_param_connect_timeout(thd, + direct_sql->connect_timeout); + conn->net_read_timeout = spider_param_net_read_timeout(thd, + direct_sql->net_read_timeout); + conn->net_write_timeout = spider_param_net_write_timeout(thd, + direct_sql->net_write_timeout); + connect_retry_interval = spider_param_connect_retry_interval(thd); + connect_retry_count = spider_param_connect_retry_count(thd); + } else { + conn->connect_timeout = spider_param_connect_timeout(NULL, + direct_sql->connect_timeout); + conn->net_read_timeout = spider_param_net_read_timeout(NULL, + direct_sql->net_read_timeout); + conn->net_write_timeout = spider_param_net_write_timeout(NULL, + direct_sql->net_write_timeout); + connect_retry_interval = spider_param_connect_retry_interval(NULL); + connect_retry_count = spider_param_connect_retry_count(NULL); + } + DBUG_PRINT("info",("spider connect_timeout=%u", conn->connect_timeout)); + DBUG_PRINT("info",("spider net_read_timeout=%u", conn->net_read_timeout)); + DBUG_PRINT("info",("spider net_write_timeout=%u", conn->net_write_timeout)); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + if ((error_num = spider_reset_conn_setted_parameter(conn, thd))) + DBUG_RETURN(error_num); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + + if (conn->dbton_id == SPIDER_DBTON_SIZE) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + my_printf_error( + ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, + ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, + MYF(0), conn->tgt_wrapper); + DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + my_printf_error( + ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, + ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, + MYF(0), conn->tgt_wrapper); + DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM); + } +#endif + } + +/* + if (!(conn->db_conn = spider_dbton[conn->dbton_id].create_db_conn(conn))) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +*/ + + if ((error_num = conn->db_conn->connect( + direct_sql->tgt_host, + direct_sql->tgt_username, + direct_sql->tgt_password, + direct_sql->tgt_port, + direct_sql->tgt_socket, + direct_sql->server_name, + connect_retry_count, connect_retry_interval))) + { + DBUG_RETURN(error_num); + } + ++conn->connection_id; + DBUG_RETURN(0); +} + +int spider_db_udf_direct_sql_ping( + SPIDER_DIRECT_SQL *direct_sql +) { + int error_num; + SPIDER_CONN *conn = direct_sql->conn; + DBUG_ENTER("spider_db_udf_direct_sql_ping"); + if (conn->server_lost) + { + if ((error_num = spider_db_udf_direct_sql_connect(direct_sql, conn))) + DBUG_RETURN(error_num); + conn->server_lost = FALSE; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + if ((error_num = conn->db_conn->ping())) + { + spider_db_disconnect(conn); + if ((error_num = spider_db_udf_direct_sql_connect(direct_sql, conn))) + { + DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); + conn->server_lost = TRUE; + DBUG_RETURN(error_num); + } + if((error_num = conn->db_conn->ping())) + { + spider_db_disconnect(conn); + DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); + conn->server_lost = TRUE; + DBUG_RETURN(error_num); + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + conn->ping_time = (time_t) time((time_t*) 0); + DBUG_RETURN(0); +} + +int spider_db_udf_direct_sql( + SPIDER_DIRECT_SQL *direct_sql +) { + int error_num = 0, status = 0, roop_count = 0, need_mon = 0; + uint udf_table_mutex_index, field_num, set_on, set_off; + long long roop_count2; + bool end_of_file; + SPIDER_TRX *trx = direct_sql->trx; + THD *thd = trx->thd, *c_thd = current_thd; + SPIDER_CONN *conn = direct_sql->conn; + SPIDER_DB_RESULT *result = NULL; + TABLE *table; + int bulk_insert_rows = (int) spider_param_udf_ds_bulk_insert_rows(thd, + direct_sql->bulk_insert_rows); + int table_loop_mode = spider_param_udf_ds_table_loop_mode(thd, + direct_sql->table_loop_mode); + double ping_interval_at_trx_start = + spider_param_ping_interval_at_trx_start(thd); + time_t tmp_time = (time_t) time((time_t*) 0); + bool need_trx_end, need_all_commit, insert_start = FALSE; +#if MYSQL_VERSION_ID < 50500 +#else + enum_sql_command sql_command_backup; +#endif + DBUG_ENTER("spider_db_udf_direct_sql"); +#if MYSQL_VERSION_ID < 50500 +#else + if (direct_sql->real_table_used) + { + if (spider_sys_open_tables(c_thd, &direct_sql->table_list_first, + &direct_sql->open_tables_backup)) + { + direct_sql->real_table_used = FALSE; + DBUG_RETURN(my_errno); + } + for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) + { + if (!spider_bit_is_set(direct_sql->real_table_bitmap, roop_count)) + continue; + direct_sql->tables[roop_count] = + direct_sql->table_list[roop_count].table; + } + direct_sql->open_tables_thd = c_thd; + roop_count = 0; + } +#endif + + if (c_thd != thd) + { + need_all_commit = TRUE; + need_trx_end = TRUE; + } else { + need_all_commit = FALSE; +#if MYSQL_VERSION_ID < 50500 +#else + if (direct_sql->real_table_used) + { + need_trx_end = TRUE; + } else { +#endif + if (c_thd->transaction.stmt.ha_list) + need_trx_end = FALSE; + else + need_trx_end = TRUE; +#if MYSQL_VERSION_ID < 50500 +#else + } +#endif + } + + if (!conn->disable_reconnect) + { + if ( + ( + conn->server_lost || + difftime(tmp_time, conn->ping_time) >= ping_interval_at_trx_start + ) && + (error_num = spider_db_udf_direct_sql_ping(direct_sql)) + ) + DBUG_RETURN(error_num); + } else if (conn->server_lost) + { + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + +#if MYSQL_VERSION_ID < 50500 +#else + sql_command_backup = c_thd->lex->sql_command; + c_thd->lex->sql_command = SQLCOM_INSERT; +#endif + + conn->need_mon = &need_mon; + if ( + !(error_num = spider_db_udf_direct_sql_set_names(direct_sql, trx, conn)) && + !(error_num = spider_db_udf_direct_sql_select_db(direct_sql, conn)) + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode != 0) + { + st_spider_db_request_key request_key; + request_key.spider_thread_id = direct_sql->trx->spider_thread_id; + request_key.query_id = direct_sql->trx->thd->query_id; + request_key.handler = direct_sql; + request_key.request_id = 1; + request_key.next = NULL; + if ((error_num = conn->db_conn->append_sql( + direct_sql->sql, direct_sql->sql_length, &request_key))) + { +#if MYSQL_VERSION_ID < 50500 +#else + c_thd->lex->sql_command = sql_command_backup; +#endif + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); + } +#endif + spider_conn_set_timeout_from_direct_sql(conn, thd, direct_sql); + if (spider_db_query( + conn, + direct_sql->sql, + direct_sql->sql_length, + -1, + &need_mon) + ) { + error_num = spider_db_errorno(conn); + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + } else { + DBUG_PRINT("info",("spider conn=%p", conn)); + if (!direct_sql->table_count) + roop_count = -1; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + do { + if (roop_count == direct_sql->table_count) + { + if (table_loop_mode == 1) + roop_count--; + else if (table_loop_mode == 2) + roop_count = 0; + else + roop_count = -1; + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = direct_sql->trx->spider_thread_id; + request_key.query_id = direct_sql->trx->thd->query_id; + request_key.handler = direct_sql; + request_key.request_id = 1; + request_key.next = NULL; + if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { + end_of_file = FALSE; + if (roop_count >= 0) + { + while (!error_num && !end_of_file) + { + udf_table_mutex_index = spider_udf_calc_hash( + direct_sql->db_names[roop_count], + spider_param_udf_table_lock_mutex_count()); + udf_table_mutex_index += spider_udf_calc_hash( + direct_sql->table_names[roop_count], + spider_param_udf_table_lock_mutex_count()); + udf_table_mutex_index %= + spider_param_udf_table_lock_mutex_count(); + pthread_mutex_lock( + &trx->udf_table_mutexes[udf_table_mutex_index]); + table = direct_sql->tables[roop_count]; + table->in_use = c_thd; + memset((uchar *) table->null_flags, ~(uchar) 0, + sizeof(uchar) * table->s->null_bytes); + insert_start = TRUE; + + field_num = result->num_fields(); + if (field_num > table->s->fields) + { + set_on = table->s->fields; + set_off = table->s->fields; + } else { + set_on = field_num; + set_off = table->s->fields; + } + for (roop_count2 = 0; roop_count2 < set_on; roop_count2++) + bitmap_set_bit(table->write_set, (uint) roop_count2); + for (; roop_count2 < set_off; roop_count2++) + bitmap_clear_bit(table->write_set, (uint) roop_count2); + +#if MYSQL_VERSION_ID < 50500 + if (table->file->has_transactions()) +#endif + { + THR_LOCK_DATA *to[2]; + table->file->store_lock(table->in_use, to, + TL_WRITE_CONCURRENT_INSERT); + if ((error_num = table->file->ha_external_lock(table->in_use, + F_WRLCK))) + { + table->file->print_error(error_num, MYF(0)); + break; + } +#if MYSQL_VERSION_ID < 50500 +#else + if (table->pos_in_table_list) + { + TABLE_LIST *next_tables = + table->pos_in_table_list->next_global; + while (next_tables && next_tables->parent_l) + { + DBUG_PRINT("info",("spider call child lock")); + TABLE *child_table = next_tables->table; + child_table->file->store_lock(child_table->in_use, to, + TL_WRITE_CONCURRENT_INSERT); + if ((error_num = child_table->file->ha_external_lock( + child_table->in_use, F_WRLCK))) + { + table->file->print_error(error_num, MYF(0)); + break; + } + next_tables = next_tables->next_global; + } + } +#endif + } + + if (direct_sql->iop) + { + if (direct_sql->iop[roop_count] == 1) + table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); + else if (direct_sql->iop[roop_count] == 2) + table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE); + } + table->file->ha_start_bulk_insert( + (ha_rows) bulk_insert_rows); + + for (roop_count2 = 0; + roop_count2 < bulk_insert_rows; + roop_count2++) + { + if ((error_num = spider_db_udf_fetch_table( + trx, conn, table, result, set_on, set_off))) + { + if (error_num == HA_ERR_END_OF_FILE) + { + end_of_file = TRUE; + error_num = 0; + } + break; + } + if (direct_sql->iop && direct_sql->iop[roop_count] == 2) + { + if ((error_num = spider_sys_replace(table, + &direct_sql->modified_non_trans_table))) + { + table->file->print_error(error_num, MYF(0)); + break; + } + } else if ((error_num = + table->file->ha_write_row(table->record[0]))) + { + /* insert */ + if ( + !direct_sql->iop || direct_sql->iop[roop_count] != 1 || + table->file->is_fatal_error(error_num, HA_CHECK_DUP) + ) { + DBUG_PRINT("info",("spider error_num=%d", error_num)); + table->file->print_error(error_num, MYF(0)); + break; + } else + error_num = 0; + } + } + + if (error_num) + table->file->ha_end_bulk_insert(); + else + error_num = table->file->ha_end_bulk_insert(); + if (direct_sql->iop) + { + if (direct_sql->iop[roop_count] == 1) + table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + else if (direct_sql->iop[roop_count] == 2) + table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); + } +#if MYSQL_VERSION_ID < 50500 + if (table->file->has_transactions()) +#endif + { + table->file->ha_external_lock(table->in_use, F_UNLCK); +#if MYSQL_VERSION_ID < 50500 +#else + if (table->pos_in_table_list) + { + TABLE_LIST *next_tables = + table->pos_in_table_list->next_global; + while (next_tables && next_tables->parent_l) + { + DBUG_PRINT("info",("spider call child lock")); + TABLE *child_table = next_tables->table; + child_table->file->ha_external_lock(child_table->in_use, + F_UNLCK); + next_tables = next_tables->next_global; + } + } +#endif + } + table->file->ha_reset(); + table->in_use = thd; + pthread_mutex_unlock( + &trx->udf_table_mutexes[udf_table_mutex_index]); + } + if (error_num) + roop_count = -1; + } + result->free_result(); + delete result; + } else { + if (!error_num) + { + error_num = spider_db_errorno(conn); + } + if (error_num) + { + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + else if (error_num == HA_ERR_FOUND_DUPP_KEY) + { + my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), + conn->db_conn->get_errno(), conn->db_conn->get_error()); + } + break; + } + } + if ((status = conn->db_conn->next_result()) > 0) + { + error_num = status; + break; + } + if (roop_count >= 0) + roop_count++; + } while (status == 0); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + if (need_trx_end && insert_start) + { + if (error_num) + { + (void) ha_rollback_trans(c_thd, FALSE); + if (need_all_commit) + (void) ha_rollback_trans(c_thd, TRUE); + } else { + if ((error_num = ha_commit_trans(c_thd, FALSE))) + my_error(error_num, MYF(0)); + if (need_all_commit) + { + if ((error_num = ha_commit_trans(c_thd, TRUE))) + my_error(error_num, MYF(0)); + } + } + } +#if MYSQL_VERSION_ID < 50500 +#else + c_thd->lex->sql_command = sql_command_backup; +#endif + DBUG_RETURN(error_num); +} + +int spider_db_udf_direct_sql_select_db( + SPIDER_DIRECT_SQL *direct_sql, + SPIDER_CONN *conn +) { + int error_num, need_mon = 0; + bool tmp_mta_conn_mutex_lock_already; + SPIDER_DB_CONN *db_conn = conn->db_conn; + DBUG_ENTER("spider_db_udf_direct_sql_select_db"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + if (!conn->mta_conn_mutex_lock_already) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &need_mon; + } + DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); + if ( + !conn->default_database.length() || + conn->default_database.length() != + direct_sql->tgt_default_db_name_length || + memcmp(direct_sql->tgt_default_db_name, conn->default_database.ptr(), + direct_sql->tgt_default_db_name_length) + ) { + tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already; + conn->mta_conn_mutex_lock_already = TRUE; + if ( + ( + spider_db_before_query(conn, &need_mon) || + db_conn->select_db(direct_sql->tgt_default_db_name) + ) && + (error_num = spider_db_errorno(conn)) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + DBUG_RETURN(error_num); + } + conn->default_database.length(0); + if (conn->default_database.reserve( + direct_sql->tgt_default_db_name_length + 1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + conn->default_database.q_append(direct_sql->tgt_default_db_name, + direct_sql->tgt_default_db_name_length + 1); + conn->default_database.length(direct_sql->tgt_default_db_name_length); + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + } + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + DBUG_RETURN(0); +} + +int spider_db_udf_direct_sql_set_names( + SPIDER_DIRECT_SQL *direct_sql, + SPIDER_TRX *trx, + SPIDER_CONN *conn +) { + int error_num, need_mon = 0; + bool tmp_mta_conn_mutex_lock_already; + DBUG_ENTER("spider_db_udf_direct_sql_set_names"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + if (!conn->mta_conn_mutex_lock_already) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &need_mon; + } + DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); + if ( + !conn->access_charset || + trx->udf_access_charset->cset != conn->access_charset->cset + ) { + tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already; + conn->mta_conn_mutex_lock_already = TRUE; + if ( + ( + spider_db_before_query(conn, &need_mon) || + conn->db_conn->set_character_set(trx->udf_access_charset->csname) + ) && + (error_num = spider_db_errorno(conn)) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + } + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + conn->access_charset = trx->udf_access_charset; + } + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + DBUG_RETURN(0); +} + +int spider_db_udf_check_and_set_set_names( + SPIDER_TRX *trx +) { + int error_num; + DBUG_ENTER("spider_db_udf_check_and_set_set_names"); + if ( + !trx->udf_access_charset || + trx->udf_access_charset->cset != + trx->thd->variables.character_set_client->cset) + { + trx->udf_access_charset = trx->thd->variables.character_set_client; + if ((error_num = spider_db_udf_append_set_names(trx))) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_db_udf_append_set_names( + SPIDER_TRX *trx +) { + DBUG_ENTER("spider_db_udf_append_set_names"); + DBUG_RETURN(0); +} + +void spider_db_udf_free_set_names( + SPIDER_TRX *trx +) { + DBUG_ENTER("spider_db_udf_free_set_names"); + DBUG_VOID_RETURN; +} + +int spider_db_udf_ping_table( + SPIDER_TABLE_MON_LIST *table_mon_list, + SPIDER_SHARE *share, + SPIDER_TRX *trx, + SPIDER_CONN *conn, + char *where_clause, + uint where_clause_length, + bool ping_only, + bool use_where, + longlong limit +) { + int error_num, need_mon = 0; + uint tmp_conn_link_idx = 0; + ha_spider spider; + DBUG_ENTER("spider_db_udf_ping_table"); + if (!pthread_mutex_trylock(&table_mon_list->monitor_mutex)) + { + spider.share = share; + spider.trx = trx; + spider.need_mons = &need_mon; + spider.conn_link_idx = &tmp_conn_link_idx; + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &need_mon; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_ping(&spider, conn, 0))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + table_mon_list->last_mon_result = error_num; + pthread_mutex_unlock(&table_mon_list->monitor_mutex); + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), + share->server_names[0]); + DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if (!ping_only) + { + int init_sql_alloc_size = + spider_param_init_sql_alloc_size(trx->thd, share->init_sql_alloc_size); +#ifdef _MSC_VER + spider_string sql_str(init_sql_alloc_size); + sql_str.set_charset(system_charset_info); + spider_string where_str(init_sql_alloc_size); + where_str.set_charset(system_charset_info); +#else + char sql_buf[init_sql_alloc_size], where_buf[init_sql_alloc_size]; + spider_string sql_str(sql_buf, sizeof(sql_buf), + system_charset_info); + spider_string where_str(where_buf, sizeof(where_buf), + system_charset_info); +#endif + sql_str.init_calc_mem(128); + where_str.init_calc_mem(129); + sql_str.length(0); + where_str.length(0); + if ( + use_where && + where_str.append(where_clause, where_clause_length, + trx->thd->variables.character_set_client) + ) { + table_mon_list->last_mon_result = HA_ERR_OUT_OF_MEM; + pthread_mutex_unlock(&table_mon_list->monitor_mutex); + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + share->access_charset = system_charset_info; + if ((error_num = spider_db_udf_ping_table_append_select(&sql_str, + share, trx, &where_str, use_where, limit, conn->dbton_id))) + { + table_mon_list->last_mon_result = error_num; + pthread_mutex_unlock(&table_mon_list->monitor_mutex); + my_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &need_mon; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(&spider, conn, 0))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + table_mon_list->last_mon_result = error_num; + pthread_mutex_unlock(&table_mon_list->monitor_mutex); + DBUG_PRINT("info",("spider error_num=%d", error_num)); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, 0, trx->thd, share); + if (spider_db_query( + conn, + sql_str.ptr(), + sql_str.length(), + -1, + &need_mon) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + table_mon_list->last_mon_result = error_num; + pthread_mutex_unlock(&table_mon_list->monitor_mutex); + DBUG_PRINT("info",("spider error_num=%d", error_num)); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + spider_db_discard_result(&spider, 0, conn); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + table_mon_list->last_mon_result = 0; + pthread_mutex_unlock(&table_mon_list->monitor_mutex); + } else { + pthread_mutex_lock(&table_mon_list->monitor_mutex); + error_num = table_mon_list->last_mon_result; + pthread_mutex_unlock(&table_mon_list->monitor_mutex); + DBUG_RETURN(error_num); + } + + DBUG_RETURN(0); +} + +int spider_db_udf_ping_table_append_mon_next( + spider_string *str, + char *child_table_name, + uint child_table_name_length, + int link_id, + char *where_clause, + uint where_clause_length, + longlong first_sid, + int full_mon_count, + int current_mon_count, + int success_count, + int fault_count, + int flags, + longlong limit +) { + char limit_str[SPIDER_SQL_INT_LEN], sid_str[SPIDER_SQL_INT_LEN]; + int limit_str_length, sid_str_length; + spider_string child_table_name_str(child_table_name, + child_table_name_length + 1, str->charset()); + spider_string where_clause_str(where_clause ? where_clause : "", + where_clause_length + 1, str->charset()); + DBUG_ENTER("spider_db_udf_ping_table_append_mon_next"); + child_table_name_str.init_calc_mem(130); + where_clause_str.init_calc_mem(131); + child_table_name_str.length(child_table_name_length); + where_clause_str.length(where_clause_length); + limit_str_length = my_sprintf(limit_str, (limit_str, "%lld", limit)); + sid_str_length = my_sprintf(sid_str, (sid_str, "%lld", first_sid)); + if (str->reserve( + SPIDER_SQL_SELECT_LEN + + SPIDER_SQL_PING_TABLE_LEN + + (child_table_name_length * 2) + + (SPIDER_SQL_INT_LEN * 6) + + sid_str_length + + limit_str_length + + (where_clause_length * 2) + + (SPIDER_SQL_VALUE_QUOTE_LEN * 4) + + (SPIDER_SQL_COMMA_LEN * 9) + + SPIDER_SQL_CLOSE_PAREN_LEN + )) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN); + str->q_append(SPIDER_SQL_PING_TABLE_STR, SPIDER_SQL_PING_TABLE_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + append_escaped(str->get_str(), child_table_name_str.get_str()); + str->mem_calc(); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->qs_append(link_id); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->qs_append(flags); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->q_append(limit_str, limit_str_length); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + append_escaped(str->get_str(), where_clause_str.get_str()); + str->mem_calc(); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->q_append(sid_str, sid_str_length); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->qs_append(full_mon_count); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->qs_append(current_mon_count); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->qs_append(success_count); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->qs_append(fault_count); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_db_udf_ping_table_append_select( + spider_string *str, + SPIDER_SHARE *share, + SPIDER_TRX *trx, + spider_string *where_str, + bool use_where, + longlong limit, + uint dbton_id +) { + int error_num; + char limit_str[SPIDER_SQL_INT_LEN]; + int limit_str_length; + DBUG_ENTER("spider_db_udf_ping_table_append_select"); + if (str->reserve(SPIDER_SQL_SELECT_LEN + SPIDER_SQL_ONE_LEN + + SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN); + str->q_append(SPIDER_SQL_ONE_STR, SPIDER_SQL_ONE_LEN); + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + if ((error_num = spider_db_append_name_with_quote_str(str, + share->tgt_dbs[0], dbton_id))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_DOT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + if ((error_num = spider_db_append_name_with_quote_str(str, + share->tgt_table_names[0], share->sql_dbton_ids[0]))) + DBUG_RETURN(error_num); + + limit_str_length = my_sprintf(limit_str, (limit_str, "%lld", limit)); + if (str->reserve( + (use_where ? (where_str->length() * 2) : 0) + + SPIDER_SQL_LIMIT_LEN + limit_str_length + )) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (use_where) + append_escaped(str->get_str(), where_str->get_str()); + str->mem_calc(); + str->q_append(SPIDER_SQL_LIMIT_STR, SPIDER_SQL_LIMIT_LEN); + str->q_append(limit_str, limit_str_length); + DBUG_RETURN(0); +} + +int spider_db_udf_ping_table_mon_next( + THD *thd, + SPIDER_TABLE_MON *table_mon, + SPIDER_CONN *conn, + SPIDER_MON_TABLE_RESULT *mon_table_result, + char *child_table_name, + uint child_table_name_length, + int link_id, + char *where_clause, + uint where_clause_length, + longlong first_sid, + int full_mon_count, + int current_mon_count, + int success_count, + int fault_count, + int flags, + longlong limit +) { + int error_num, need_mon = 0; + uint tmp_conn_link_idx = 0; + SPIDER_DB_RESULT *res; + SPIDER_SHARE *share = table_mon->share; + int init_sql_alloc_size = + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); +#ifdef _MSC_VER + spider_string sql_str(init_sql_alloc_size); + sql_str.set_charset(thd->variables.character_set_client); +#else + char sql_buf[init_sql_alloc_size]; + spider_string sql_str(sql_buf, sizeof(sql_buf), + thd->variables.character_set_client); +#endif + ha_spider spider; + SPIDER_TRX trx; + DBUG_ENTER("spider_db_udf_ping_table_mon_next"); + sql_str.init_calc_mem(132); + sql_str.length(0); + trx.thd = thd; + spider.share = share; + spider.trx = &trx; + spider.need_mons = &need_mon; + spider.conn_link_idx = &tmp_conn_link_idx; + + share->access_charset = thd->variables.character_set_client; + if ((error_num = spider_db_udf_ping_table_append_mon_next(&sql_str, + child_table_name, child_table_name_length, link_id, where_clause, + where_clause_length, first_sid, full_mon_count, current_mon_count, + success_count, fault_count, flags, limit))) + { + my_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &need_mon; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_ping(&spider, conn, 0))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), + share->server_names[0]); + DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + } + if ((error_num = spider_db_set_names(&spider, conn, 0))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, 0, thd, share); + if (spider_db_query( + conn, + sql_str.ptr(), + sql_str.length(), + -1, + &need_mon) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = trx.spider_thread_id; + request_key.query_id = trx.thd->query_id; + request_key.handler = table_mon; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (error_num || (error_num = spider_db_errorno(conn))) + DBUG_RETURN(error_num); + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_mon_status(mon_table_result->result_status); + res->free_result(); + delete res; + DBUG_RETURN(error_num); +} + +int spider_db_udf_copy_key_row( + spider_string *str, + spider_string *source_str, + Field *field, + ulong *row_pos, + ulong *length, + const char *joint_str, + const int joint_length, + uint dbton_id +) { + int error_num; + DBUG_ENTER("spider_db_udf_copy_key_row"); + if ((error_num = spider_db_append_name_with_quote_str(str, + (char *) field->field_name, dbton_id))) + DBUG_RETURN(error_num); + if (str->reserve(joint_length + *length + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(joint_str, joint_length); + str->q_append(source_str->ptr() + *row_pos, *length); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + DBUG_RETURN(0); +} + +int spider_db_udf_copy_tables( + SPIDER_COPY_TABLES *copy_tables, + ha_spider *spider, + TABLE *table, + longlong bulk_insert_rows +) { + int error_num = 0, roop_count; + bool end_of_file = FALSE; + ulong *last_lengths, *last_row_pos = NULL; + ha_spider *tmp_spider; + SPIDER_CONN *tmp_conn; + int all_link_cnt = + copy_tables->link_idx_count[0] + copy_tables->link_idx_count[1]; + SPIDER_COPY_TABLE_CONN *src_tbl_conn = copy_tables->table_conn[0]; + SPIDER_COPY_TABLE_CONN *dst_tbl_conn; + spider_db_copy_table *select_ct = src_tbl_conn->copy_table; + spider_db_copy_table *insert_ct = NULL; + KEY *key_info = &table->key_info[table->s->primary_key]; + int bulk_insert_interval; + DBUG_ENTER("spider_db_udf_copy_tables"); + if (!(last_row_pos = (ulong *) + spider_bulk_malloc(spider_current_trx, 30, MYF(MY_WME), + &last_row_pos, sizeof(ulong) * table->s->fields, + &last_lengths, sizeof(ulong) * table->s->fields, + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + while (!end_of_file) + { + if (copy_tables->trx->thd->killed) + { + my_error(ER_QUERY_INTERRUPTED, MYF(0)); + error_num = ER_QUERY_INTERRUPTED; + goto error_killed; + } + if (copy_tables->use_transaction) + { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + tmp_conn = tmp_spider->conns[0]; + if (!tmp_conn->trx_start) + { + if (spider_db_ping(tmp_spider, tmp_conn, 0)) + { + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), + tmp_spider->share->server_names[0]); + error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; + goto error_db_ping; + } + if ( + (error_num = spider_db_set_names(tmp_spider, tmp_conn, 0)) || + (error_num = spider_db_start_transaction(tmp_conn, + tmp_spider->need_mons)) + ) + goto error_start_transaction; + } + } + } else { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + tmp_conn = tmp_spider->conns[0]; + spider_db_handler *tmp_dbton_hdl = + tmp_spider->dbton_handler[tmp_conn->dbton_id]; + if ((error_num = tmp_dbton_hdl->insert_lock_tables_list(tmp_conn, 0))) + goto error_lock_table_hash; + tmp_conn->table_lock = 2; + } + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + tmp_conn = tmp_spider->conns[0]; + if (spider_db_ping(tmp_spider, tmp_conn, 0)) + { + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), + tmp_spider->share->server_names[0]); + error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; + goto error_db_ping; + } + if ( + tmp_conn->db_conn->have_lock_table_list() && + ( + (error_num = spider_db_set_names(tmp_spider, tmp_conn, 0)) || + (error_num = spider_db_lock_tables(tmp_spider, 0)) + ) + ) { + tmp_conn->table_lock = 0; + if (error_num == HA_ERR_OUT_OF_MEM) + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error_lock_tables; + } + tmp_conn->table_lock = 1; + } + } + + tmp_conn = src_tbl_conn->conn; + spider_conn_set_timeout_from_share(tmp_conn, 0, + copy_tables->trx->thd, src_tbl_conn->share); + if (select_ct->exec_query( + tmp_conn, + -1, + &src_tbl_conn->need_mon) + ) { + error_num = spider_db_errorno(tmp_conn); + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + goto error_db_query; + } else { + SPIDER_DB_RESULT *result; + st_spider_db_request_key request_key; + request_key.spider_thread_id = copy_tables->trx->spider_thread_id; + request_key.query_id = copy_tables->trx->thd->query_id; + request_key.handler = copy_tables; + request_key.request_id = 1; + request_key.next = NULL; + if ((result = tmp_conn->db_conn->use_result(&request_key, &error_num))) + { + SPIDER_DB_ROW *row; + roop_count = 0; + while ((row = result->fetch_row())) + { + dst_tbl_conn = copy_tables->table_conn[1]; + insert_ct = dst_tbl_conn->copy_table; + if ((error_num = insert_ct->copy_rows(table, row, + &last_row_pos, &last_lengths))) + { + if (error_num == HA_ERR_OUT_OF_MEM) + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + result->free_result(); + delete result; + SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + goto error_db_query; + } + for (dst_tbl_conn = dst_tbl_conn->next; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + row->first(); + insert_ct = dst_tbl_conn->copy_table; + if ((error_num = insert_ct->copy_rows(table, row))) + { + if (error_num == HA_ERR_OUT_OF_MEM) + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + result->free_result(); + delete result; + SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + goto error_db_query; + } + } + ++roop_count; + } + error_num = result->get_errno(); + if (error_num == HA_ERR_END_OF_FILE) + { + if (roop_count < copy_tables->bulk_insert_rows) + { + end_of_file = TRUE; + if (roop_count) + error_num = 0; + } else { + /* add next where clause */ + select_ct->set_sql_to_pos(); + error_num = select_ct->append_copy_where(insert_ct, key_info, + last_row_pos, last_lengths); + if (error_num) + { + if (error_num == HA_ERR_OUT_OF_MEM) + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + result->free_result(); + delete result; + SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + goto error_db_query; + } + bulk_insert_rows = spider_param_udf_ct_bulk_insert_rows( + copy_tables->bulk_insert_rows); + if ( + select_ct->append_key_order_str(key_info, 0, FALSE) || + select_ct->append_limit(0, bulk_insert_rows) || + ( + copy_tables->use_transaction && + select_ct->append_select_lock_str(SPIDER_LOCK_MODE_SHARED) + ) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + result->free_result(); + delete result; + SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + error_num = ER_OUT_OF_RESOURCES; + goto error_db_query; + } + error_num = 0; + } + } else { + if (error_num == HA_ERR_OUT_OF_MEM) + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + result->free_result(); + delete result; + SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + goto error_db_query; + } + result->free_result(); + delete result; + SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + insert_ct = dst_tbl_conn->copy_table; + if ((error_num = insert_ct->append_insert_terminator())) + { + if (error_num == HA_ERR_OUT_OF_MEM) + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error_db_query; + } + } + } else { + if (!error_num) + { + error_num = spider_db_errorno(tmp_conn); + } + if (error_num) + { + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + goto error_db_query; + } + error_num = HA_ERR_END_OF_FILE; + end_of_file = TRUE; + SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + } + } + + if (!error_num) + { +/* + dst_tbl_conn = copy_tables->table_conn[1]; + spider_db_copy_table *source_ct = dst_tbl_conn->copy_table; + for (dst_tbl_conn = dst_tbl_conn->next; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + insert_ct = dst_tbl_conn->copy_table; + if (insert_ct->copy_insert_values(source_ct)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + error_num = ER_OUT_OF_RESOURCES; + goto error_db_query; + } + } +*/ +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (copy_tables->bg_mode) + { + for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + if (spider_udf_bg_copy_exec_sql(dst_tbl_conn)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + error_num = ER_OUT_OF_RESOURCES; + goto error_db_query; + } + } + } else { +#endif + for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + tmp_conn = dst_tbl_conn->conn; + insert_ct = dst_tbl_conn->copy_table; + pthread_mutex_lock(&tmp_conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + tmp_conn->need_mon = &dst_tbl_conn->need_mon; + tmp_conn->mta_conn_mutex_lock_already = TRUE; + tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_set_timeout_from_share(tmp_conn, 0, + copy_tables->trx->thd, dst_tbl_conn->share); + if (insert_ct->exec_query( + tmp_conn, + -1, + &dst_tbl_conn->need_mon) + ) { + tmp_conn->mta_conn_mutex_lock_already = FALSE; + tmp_conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(tmp_conn); + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + goto error_db_query; + } else { + tmp_conn->mta_conn_mutex_lock_already = FALSE; + tmp_conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + } + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (copy_tables->bg_mode) + { + for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + tmp_conn = dst_tbl_conn->conn; + if (tmp_conn->bg_exec_sql) + { + /* wait */ + pthread_mutex_lock(&tmp_conn->bg_conn_mutex); + pthread_mutex_unlock(&tmp_conn->bg_conn_mutex); + } + + if (dst_tbl_conn->bg_error_num) + { + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + goto error_db_query; + } + } + } +#endif + } + + if (copy_tables->use_transaction) + { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + tmp_conn = tmp_spider->conns[0]; + if (tmp_conn->trx_start) + { + if ((error_num = spider_db_commit(tmp_conn))) + goto error_commit; + } + } + } else { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + tmp_conn = tmp_spider->conns[0]; + if (tmp_conn->table_lock == 1) + { + tmp_conn->table_lock = 0; + if ((error_num = spider_db_unlock_tables(tmp_spider, 0))) + goto error_unlock_tables; + } + } + } + if (!end_of_file) + { + for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + insert_ct = dst_tbl_conn->copy_table; + insert_ct->set_sql_to_pos(); + } + DBUG_PRINT("info",("spider sleep")); + bulk_insert_interval = spider_param_udf_ct_bulk_insert_interval( + copy_tables->bulk_insert_interval); + my_sleep(bulk_insert_interval); + } + } + spider_free(spider_current_trx, last_row_pos, MYF(0)); + DBUG_RETURN(0); + +error_db_query: +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (copy_tables->bg_mode) + { + for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; + dst_tbl_conn = dst_tbl_conn->next) + { + tmp_conn = dst_tbl_conn->conn; + if (tmp_conn->bg_exec_sql) + { + /* wait */ + pthread_mutex_lock(&tmp_conn->bg_conn_mutex); + pthread_mutex_unlock(&tmp_conn->bg_conn_mutex); + } + } + } +#endif +error_unlock_tables: +error_commit: +error_lock_tables: +error_lock_table_hash: +error_start_transaction: +error_db_ping: +error_killed: + if (copy_tables->use_transaction) + { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + tmp_conn = tmp_spider->conns[0]; + if (tmp_conn->trx_start) + spider_db_rollback(tmp_conn); + } + } else { + if (copy_tables->trx->locked_connections) + { + for (roop_count = 0; roop_count < all_link_cnt; roop_count++) + { + tmp_spider = &spider[roop_count]; + tmp_conn = tmp_spider->conns[0]; + if (tmp_conn->table_lock == 1) + { + tmp_conn->table_lock = 0; + spider_db_unlock_tables(tmp_spider, 0); + } + } + } + } +error: + if (last_row_pos) + { + spider_free(spider_current_trx, last_row_pos, MYF(0)); + } + DBUG_RETURN(error_num); +} + +int spider_db_open_handler( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + bool tmp_mta_conn_mutex_lock_already; + bool tmp_mta_conn_mutex_unlock_later; + SPIDER_SHARE *share = spider->share; + uint *handler_id_ptr = +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + conn->conn_kind == SPIDER_CONN_KIND_MYSQL ? +#endif + &spider->m_handler_id[link_idx] +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + : conn->conn_kind == SPIDER_CONN_KIND_HS_READ ? + &spider->r_handler_id[link_idx] : + &spider->w_handler_id[link_idx] +#endif + ; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + DBUG_ENTER("spider_db_open_handler"); + if (!conn->mta_conn_mutex_lock_already) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + } + DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); + tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already; + conn->mta_conn_mutex_lock_already = TRUE; + tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later; + conn->mta_conn_mutex_unlock_later = TRUE; + if (!spider->handler_opened(link_idx, conn->conn_kind)) + *handler_id_ptr = conn->opened_handlers; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + if (!spider->handler_opened(link_idx, conn->conn_kind)) + my_sprintf(spider->m_handler_cid[link_idx], + (spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_FORMAT, + *handler_id_ptr)); + + if ((error_num = dbton_hdl->append_open_handler_part( + SPIDER_SQL_TYPE_HANDLER, *handler_id_ptr, conn, link_idx))) + { + goto error; + } + + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_HANDLER, + conn, + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + goto error; + } + dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + uint reconnect = 0; + if (conn->hs_pre_age != conn->hs_age && conn->server_lost) + { + spider_conn_queue_connect(share, conn, link_idx); + reconnect |= 1; + } + if ((error_num = spider_db_conn_queue_action(conn))) + { + goto error; + } + if (conn->hs_pre_age != conn->hs_age) + { + if (conn->db_conn->ping()) + { + my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), + conn->db_conn->get_errno(), conn->db_conn->get_error()); + if (!conn->mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + spider->need_mons[link_idx] = ER_SPIDER_HS_NUM; + error_num = ER_SPIDER_HS_NUM; + goto error; + } + conn->opened_handlers = 0; + conn->db_conn->reset_opened_handler(); + conn->hs_age = conn->hs_pre_age; + reconnect |= 2; + } + if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) + { + if (spider->hs_r_conn_ages[link_idx] != conn->hs_age) + { + spider->clear_handler_opened(link_idx, SPIDER_CONN_KIND_HS_READ); + *handler_id_ptr = conn->opened_handlers; + } + } else { + if (spider->hs_w_conn_ages[link_idx] != conn->hs_age) + { + spider->clear_handler_opened(link_idx, SPIDER_CONN_KIND_HS_WRITE); + *handler_id_ptr = conn->opened_handlers; + } + } + +#ifdef HA_CAN_BULK_ACCESS + if (!spider->is_bulk_access_clone) + { +#endif + conn->db_conn->reset_request_queue(); +#ifdef HA_CAN_BULK_ACCESS + } else if (!spider->bulk_access_executing) + { + if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) + { + spider_set_bit(spider->result_list.hs_r_bulk_open_index, link_idx); + } else { + spider_set_bit(spider->result_list.hs_w_bulk_open_index, link_idx); + } + } +#endif + if ((error_num = dbton_hdl->append_open_handler_part( + SPIDER_SQL_TYPE_OTHER_HS, *handler_id_ptr, conn, link_idx))) + { + goto error; + } +#ifdef HA_CAN_BULK_ACCESS + if (spider->is_bulk_access_clone && !spider->bulk_access_executing) + { + spider->connection_ids[link_idx] = conn->connection_id; + spider_trx_add_bulk_access_conn(spider->trx, conn); + } else { +#endif + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_SELECT_HS, + conn, + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + goto error; + } + + SPIDER_DB_RESULT *result; + if (spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_clear_bit(spider->db_request_phase, link_idx); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + if (!(result = conn->db_conn->use_result(&request_key, &error_num))) + { + if (!error_num) + { + spider_db_errorno(conn); + error_num = ER_SPIDER_HS_NUM; + } + goto error; + } else { + conn->ping_time = (time_t) time((time_t*) 0); + } + result->free_result(); + delete result; +#ifdef HA_CAN_BULK_ACCESS + } +#endif + if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) + { + spider->r_handler_index[link_idx] = spider->active_index; + spider->hs_r_conn_ages[link_idx] = conn->hs_age; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if ( + spider->sql_command != SQLCOM_HS_INSERT && + spider->hs_pushed_ret_fields_num < MAX_FIELDS + ) { + spider->hs_r_ret_fields_num[link_idx] = + spider->hs_pushed_ret_fields_num; + memcpy(spider->hs_r_ret_fields[link_idx], spider->hs_pushed_ret_fields, + sizeof(uint32) * spider->hs_pushed_ret_fields_num); + } else { + spider->hs_r_ret_fields_num[link_idx] = MAX_FIELDS; + } +#endif + } else { + spider->w_handler_index[link_idx] = spider->active_index; + spider->hs_w_conn_ages[link_idx] = conn->hs_age; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if ( + spider->sql_command != SQLCOM_HS_INSERT && + spider->hs_pushed_ret_fields_num < MAX_FIELDS + ) { + spider->hs_w_ret_fields_num[link_idx] = + spider->hs_pushed_ret_fields_num; + memcpy(spider->hs_w_ret_fields[link_idx], spider->hs_pushed_ret_fields, + sizeof(uint32) * spider->hs_pushed_ret_fields_num); + } else { + spider->hs_w_ret_fields_num[link_idx] = MAX_FIELDS; + } +#endif + } + } +#endif + if (!spider->handler_opened(link_idx, conn->conn_kind)) + { + if ((error_num = dbton_hdl->insert_opened_handler(conn, link_idx))) + goto error; + conn->opened_handlers++; + } + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider opened_handlers=%u", conn->opened_handlers)); + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; + if (!tmp_mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(0); + +error: + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; + if (!tmp_mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); +} + +#ifdef HA_CAN_BULK_ACCESS +int spider_db_bulk_open_handler( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +) { + int error_num = 0; + bool opening_index = FALSE; + DBUG_ENTER("spider_db_bulk_open_handler"); + DBUG_PRINT("info",("spider spider=%p", spider)); + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + DBUG_ASSERT(conn->conn_kind != SPIDER_CONN_KIND_MYSQL); + if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) + { + if (spider_bit_is_set(spider->result_list.hs_r_bulk_open_index, link_idx)) + { + DBUG_PRINT("info",("spider SPIDER_CONN_KIND_HS_READ")); + spider_clear_bit(spider->result_list.hs_r_bulk_open_index, link_idx); + opening_index = TRUE; + } + } else { + if (spider_bit_is_set(spider->result_list.hs_w_bulk_open_index, link_idx)) + { + DBUG_PRINT("info",("spider SPIDER_CONN_KIND_HS_WRITE")); + spider_clear_bit(spider->result_list.hs_w_bulk_open_index, link_idx); + opening_index = TRUE; + } + } + if (opening_index) + { + DBUG_PRINT("info",("spider conn->connection_id=%llu", + conn->connection_id)); + DBUG_PRINT("info",("spider spider->connection_ids[%d]=%llu", + link_idx, spider->connection_ids[link_idx])); + if (conn->connection_id != spider->connection_ids[link_idx]) + { + my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, + ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + + bool tmp_mta_conn_mutex_unlock_later; + tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later; + conn->mta_conn_mutex_unlock_later = TRUE; + SPIDER_DB_RESULT *result; + if (spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_clear_bit(spider->db_request_phase, link_idx); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + if (!(result = conn->db_conn->use_result(&request_key, &error_num))) + { + if (!error_num) + { + spider_db_errorno(conn); + error_num = ER_SPIDER_HS_NUM; + } + } else { + result->free_result(); + delete result; + } + conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; + } +#endif + DBUG_RETURN(error_num); +} +#endif + +int spider_db_close_handler( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx, + uint tgt_conn_kind +) { + int error_num; + bool tmp_mta_conn_mutex_lock_already; + bool tmp_mta_conn_mutex_unlock_later; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + DBUG_ENTER("spider_db_close_handler"); + DBUG_PRINT("info",("spider conn=%p", conn)); + if (spider->handler_opened(link_idx, tgt_conn_kind)) + { + if (!conn->mta_conn_mutex_lock_already) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + } + DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); + tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already; + conn->mta_conn_mutex_lock_already = TRUE; + tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later; + conn->mta_conn_mutex_unlock_later = TRUE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) + { +#endif + dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); + if ((error_num = dbton_hdl->append_close_handler_part( + SPIDER_SQL_TYPE_HANDLER, link_idx))) + DBUG_RETURN(error_num); + + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider->share); + if (dbton_hdl->execute_sql( + SPIDER_SQL_TYPE_HANDLER, + conn, + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + goto error; + } + dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { +/* + conn->hs_conn->close(); + conn->server_lost = TRUE; +*/ + } +#endif + if ((error_num = dbton_hdl->delete_opened_handler(conn, link_idx))) + goto error; + conn->opened_handlers--; + DBUG_PRINT("info",("spider opened_handlers=%u", conn->opened_handlers)); + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; + if (!tmp_mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + DBUG_RETURN(0); + +error: + conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already; + conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; + if (!tmp_mta_conn_mutex_unlock_later) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(error_num); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +void spider_db_hs_request_buf_reset( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_db_hs_request_buf_reset"); + if (conn->bulk_access_requests) + { + if (conn->db_conn->is_connected()) + { + conn->db_conn->reset_request_queue(); + } + conn->bulk_access_requests = 0; + } + DBUG_VOID_RETURN; +} +#endif diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h new file mode 100644 index 00000000000..d819255394d --- /dev/null +++ b/storage/spider/spd_db_conn.h @@ -0,0 +1,1022 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define SPIDER_DB_WRAPPER_STR "mysql" +#define SPIDER_DB_WRAPPER_LEN (sizeof(SPIDER_DB_WRAPPER_STR) - 1) +#define SPIDER_DB_PK_NAME_STR "PRIMARY" +#define SPIDER_DB_PK_NAME_LEN (sizeof(SPIDER_DB_PK_NAME_STR) - 1) +#define SPIDER_DB_UNIQUE_NAME_STR "UNIQUE" +#define SPIDER_DB_UNIQUE_NAME_LEN (sizeof(SPIDER_DB_UNIQUE_NAME_STR) - 1) +#define SPIDER_DB_KEY_NAME_STR "KEY" +#define SPIDER_DB_KEY_NAME_LEN (sizeof(SPIDER_DB_KEY_NAME_STR) - 1) +#define SPIDER_DB_SEQUENCE_NAME_STR "" +#define SPIDER_DB_SEQUENCE_NAME_LEN (sizeof(SPIDER_DB_SEQUENCE_NAME_STR) - 1) + +#define SPIDER_DB_TABLE_LOCK_READ_LOCAL 0 +#define SPIDER_DB_TABLE_LOCK_READ 1 +#define SPIDER_DB_TABLE_LOCK_LOW_PRIORITY_WRITE 2 +#define SPIDER_DB_TABLE_LOCK_WRITE 3 + +#define SPIDER_DB_INSERT_REPLACE (1 << 0) +#define SPIDER_DB_INSERT_IGNORE (1 << 1) +#define SPIDER_DB_INSERT_LOW_PRIORITY (1 << 2) +#define SPIDER_DB_INSERT_HIGH_PRIORITY (1 << 3) +#define SPIDER_DB_INSERT_DELAYED (1 << 4) + +#define SPIDER_SQL_OPEN_PAREN_STR "(" +#define SPIDER_SQL_OPEN_PAREN_LEN (sizeof(SPIDER_SQL_OPEN_PAREN_STR) - 1) +#define SPIDER_SQL_CLOSE_PAREN_STR ")" +#define SPIDER_SQL_CLOSE_PAREN_LEN (sizeof(SPIDER_SQL_CLOSE_PAREN_STR) - 1) +#define SPIDER_SQL_COMMA_STR "," +#define SPIDER_SQL_COMMA_LEN (sizeof(SPIDER_SQL_COMMA_STR) - 1) +#define SPIDER_SQL_UNION_ALL_STR ")union all(" +#define SPIDER_SQL_UNION_ALL_LEN (sizeof(SPIDER_SQL_UNION_ALL_STR) - 1) +#define SPIDER_SQL_NULL_STR "null" +#define SPIDER_SQL_NULL_LEN (sizeof(SPIDER_SQL_NULL_STR) - 1) +#define SPIDER_SQL_GT_STR " > " +#define SPIDER_SQL_GT_LEN (sizeof(SPIDER_SQL_GT_STR) - 1) +#define SPIDER_SQL_GTEQUAL_STR " >= " +#define SPIDER_SQL_GTEQUAL_LEN (sizeof(SPIDER_SQL_GTEQUAL_STR) - 1) +#define SPIDER_SQL_LT_STR " < " +#define SPIDER_SQL_LT_LEN (sizeof(SPIDER_SQL_LT_STR) - 1) +#define SPIDER_SQL_LTEQUAL_STR " <= " +#define SPIDER_SQL_LTEQUAL_LEN (sizeof(SPIDER_SQL_LTEQUAL_STR) - 1) + +#define SPIDER_SQL_ID_STR "id" +#define SPIDER_SQL_ID_LEN (sizeof(SPIDER_SQL_ID_STR) - 1) +#define SPIDER_SQL_TMP_BKA_ENGINE_STR "memory" +#define SPIDER_SQL_TMP_BKA_ENGINE_LEN (sizeof(SPIDER_SQL_TMP_BKA_ENGINE_STR) - 1) + +#define SPIDER_SQL_INSERT_STR "insert " +#define SPIDER_SQL_INSERT_LEN (sizeof(SPIDER_SQL_INSERT_STR) - 1) +#define SPIDER_SQL_REPLACE_STR "replace " +#define SPIDER_SQL_REPLACE_LEN (sizeof(SPIDER_SQL_REPLACE_STR) - 1) +#define SPIDER_SQL_SELECT_STR "select " +#define SPIDER_SQL_SELECT_LEN (sizeof(SPIDER_SQL_SELECT_STR) - 1) +#define SPIDER_SQL_UPDATE_STR "update " +#define SPIDER_SQL_UPDATE_LEN (sizeof(SPIDER_SQL_UPDATE_STR) - 1) +#define SPIDER_SQL_DELETE_STR "delete " +#define SPIDER_SQL_DELETE_LEN (sizeof(SPIDER_SQL_DELETE_STR) - 1) +#define SPIDER_SQL_HIGH_PRIORITY_STR "high_priority " +#define SPIDER_SQL_HIGH_PRIORITY_LEN (sizeof(SPIDER_SQL_HIGH_PRIORITY_STR) - 1) +#define SPIDER_SQL_LOW_PRIORITY_STR "low_priority " +#define SPIDER_SQL_LOW_PRIORITY_LEN (sizeof(SPIDER_SQL_LOW_PRIORITY_STR) - 1) +#define SPIDER_SQL_SQL_DELAYED_STR "delayed " +#define SPIDER_SQL_SQL_DELAYED_LEN (sizeof(SPIDER_SQL_SQL_DELAYED_STR) - 1) +#define SPIDER_SQL_SQL_IGNORE_STR "ignore " +#define SPIDER_SQL_SQL_IGNORE_LEN (sizeof(SPIDER_SQL_SQL_IGNORE_STR) - 1) +#define SPIDER_SQL_FROM_STR " from " +#define SPIDER_SQL_FROM_LEN (sizeof(SPIDER_SQL_FROM_STR) - 1) +#define SPIDER_SQL_WHERE_STR " where " +#define SPIDER_SQL_WHERE_LEN (sizeof(SPIDER_SQL_WHERE_STR) - 1) +#define SPIDER_SQL_OR_STR " or " +#define SPIDER_SQL_OR_LEN (sizeof(SPIDER_SQL_OR_STR) - 1) +#define SPIDER_SQL_ORDER_STR " order by " +#define SPIDER_SQL_ORDER_LEN (sizeof(SPIDER_SQL_ORDER_STR) - 1) +#define SPIDER_SQL_DESC_STR " desc" +#define SPIDER_SQL_DESC_LEN (sizeof(SPIDER_SQL_DESC_STR) - 1) +#define SPIDER_SQL_LIMIT_STR " limit " +#define SPIDER_SQL_LIMIT_LEN (sizeof(SPIDER_SQL_LIMIT_STR) - 1) +#define SPIDER_SQL_INTO_STR "into " +#define SPIDER_SQL_INTO_LEN (sizeof(SPIDER_SQL_INTO_STR) - 1) +#define SPIDER_SQL_VALUES_STR ")values" +#define SPIDER_SQL_VALUES_LEN (sizeof(SPIDER_SQL_VALUES_STR) - 1) +#define SPIDER_SQL_SHARED_LOCK_STR " lock in share mode" +#define SPIDER_SQL_SHARED_LOCK_LEN (sizeof(SPIDER_SQL_SHARED_LOCK_STR) - 1) +#define SPIDER_SQL_FOR_UPDATE_STR " for update" +#define SPIDER_SQL_FOR_UPDATE_LEN (sizeof(SPIDER_SQL_FOR_UPDATE_STR) - 1) + +#define SPIDER_SQL_SQL_ALTER_TABLE_STR "alter table " +#define SPIDER_SQL_SQL_ALTER_TABLE_LEN (sizeof(SPIDER_SQL_SQL_ALTER_TABLE_STR) - 1) +#define SPIDER_SQL_SQL_DISABLE_KEYS_STR " disable keys" +#define SPIDER_SQL_SQL_DISABLE_KEYS_LEN (sizeof(SPIDER_SQL_SQL_DISABLE_KEYS_STR) - 1) +#define SPIDER_SQL_SQL_ENABLE_KEYS_STR " enable keys" +#define SPIDER_SQL_SQL_ENABLE_KEYS_LEN (sizeof(SPIDER_SQL_SQL_ENABLE_KEYS_STR) - 1) +#define SPIDER_SQL_SQL_CHECK_TABLE_STR "check table " +#define SPIDER_SQL_SQL_CHECK_TABLE_LEN (sizeof(SPIDER_SQL_SQL_CHECK_TABLE_STR) - 1) +#define SPIDER_SQL_SQL_ANALYZE_STR "analyze " +#define SPIDER_SQL_SQL_ANALYZE_LEN (sizeof(SPIDER_SQL_SQL_ANALYZE_STR) - 1) +#define SPIDER_SQL_SQL_OPTIMIZE_STR "optimize " +#define SPIDER_SQL_SQL_OPTIMIZE_LEN (sizeof(SPIDER_SQL_SQL_OPTIMIZE_STR) - 1) +#define SPIDER_SQL_SQL_REPAIR_STR "repair " +#define SPIDER_SQL_SQL_REPAIR_LEN (sizeof(SPIDER_SQL_SQL_REPAIR_STR) - 1) +#define SPIDER_SQL_SQL_TABLE_STR "table " +#define SPIDER_SQL_SQL_TABLE_LEN (sizeof(SPIDER_SQL_SQL_TABLE_STR) - 1) +#define SPIDER_SQL_SQL_QUICK_STR " quick" +#define SPIDER_SQL_SQL_QUICK_LEN (sizeof(SPIDER_SQL_SQL_QUICK_STR) - 1) +#define SPIDER_SQL_SQL_FAST_STR " fast" +#define SPIDER_SQL_SQL_FAST_LEN (sizeof(SPIDER_SQL_SQL_FAST_STR) - 1) +#define SPIDER_SQL_SQL_MEDIUM_STR " medium" +#define SPIDER_SQL_SQL_MEDIUM_LEN (sizeof(SPIDER_SQL_SQL_MEDIUM_STR) - 1) +#define SPIDER_SQL_SQL_EXTENDED_STR " extended" +#define SPIDER_SQL_SQL_EXTENDED_LEN (sizeof(SPIDER_SQL_SQL_EXTENDED_STR) - 1) +#define SPIDER_SQL_SQL_LOCAL_STR "local " +#define SPIDER_SQL_SQL_LOCAL_LEN (sizeof(SPIDER_SQL_SQL_LOCAL_STR) - 1) +#define SPIDER_SQL_SQL_USE_FRM_STR " use_frm" +#define SPIDER_SQL_SQL_USE_FRM_LEN (sizeof(SPIDER_SQL_SQL_USE_FRM_STR) - 1) +#define SPIDER_SQL_TRUNCATE_TABLE_STR "truncate table " +#define SPIDER_SQL_TRUNCATE_TABLE_LEN (sizeof(SPIDER_SQL_TRUNCATE_TABLE_STR) - 1) +#define SPIDER_SQL_EXPLAIN_SELECT_STR "explain select 1 " +#define SPIDER_SQL_EXPLAIN_SELECT_LEN sizeof(SPIDER_SQL_EXPLAIN_SELECT_STR) - 1 +#define SPIDER_SQL_FLUSH_LOGS_STR "flush logs" +#define SPIDER_SQL_FLUSH_LOGS_LEN sizeof(SPIDER_SQL_FLUSH_LOGS_STR) - 1 +#define SPIDER_SQL_FLUSH_TABLES_STR "flush tables" +#define SPIDER_SQL_FLUSH_TABLES_LEN sizeof(SPIDER_SQL_FLUSH_TABLES_STR) - 1 +#define SPIDER_SQL_WITH_READ_LOCK_STR " with read lock" +#define SPIDER_SQL_WITH_READ_LOCK_LEN sizeof(SPIDER_SQL_WITH_READ_LOCK_STR) - 1 +#define SPIDER_SQL_DUPLICATE_KEY_UPDATE_STR " on duplicate key update " +#define SPIDER_SQL_DUPLICATE_KEY_UPDATE_LEN (sizeof(SPIDER_SQL_DUPLICATE_KEY_UPDATE_STR) - 1) +#define SPIDER_SQL_HANDLER_STR "handler " +#define SPIDER_SQL_HANDLER_LEN (sizeof(SPIDER_SQL_HANDLER_STR) - 1) +#define SPIDER_SQL_OPEN_STR " open " +#define SPIDER_SQL_OPEN_LEN (sizeof(SPIDER_SQL_OPEN_STR) - 1) +#define SPIDER_SQL_CLOSE_STR " close " +#define SPIDER_SQL_CLOSE_LEN (sizeof(SPIDER_SQL_CLOSE_STR) - 1) +#define SPIDER_SQL_READ_STR " read " +#define SPIDER_SQL_READ_LEN (sizeof(SPIDER_SQL_READ_STR) - 1) +#define SPIDER_SQL_FIRST_STR " first " +#define SPIDER_SQL_FIRST_LEN (sizeof(SPIDER_SQL_FIRST_STR) - 1) +#define SPIDER_SQL_NEXT_STR " next " +#define SPIDER_SQL_NEXT_LEN (sizeof(SPIDER_SQL_NEXT_STR) - 1) +#define SPIDER_SQL_PREV_STR " prev " +#define SPIDER_SQL_PREV_LEN (sizeof(SPIDER_SQL_PREV_STR) - 1) +#define SPIDER_SQL_LAST_STR " last " +#define SPIDER_SQL_LAST_LEN (sizeof(SPIDER_SQL_LAST_STR) - 1) +#define SPIDER_SQL_AS_STR "as " +#define SPIDER_SQL_AS_LEN (sizeof(SPIDER_SQL_AS_STR) - 1) +#define SPIDER_SQL_WITH_QUERY_EXPANSION_STR " with query expansion" +#define SPIDER_SQL_WITH_QUERY_EXPANSION_LEN (sizeof(SPIDER_SQL_WITH_QUERY_EXPANSION_STR) - 1) +#define SPIDER_SQL_IN_BOOLEAN_MODE_STR " in boolean mode" +#define SPIDER_SQL_IN_BOOLEAN_MODE_LEN (sizeof(SPIDER_SQL_IN_BOOLEAN_MODE_STR) - 1) +#define SPIDER_SQL_MATCH_STR "match(" +#define SPIDER_SQL_MATCH_LEN (sizeof(SPIDER_SQL_MATCH_STR) - 1) +#define SPIDER_SQL_AGAINST_STR ")against(" +#define SPIDER_SQL_AGAINST_LEN (sizeof(SPIDER_SQL_AGAINST_STR) - 1) +#define SPIDER_SQL_IS_NULL_STR " is null" +#define SPIDER_SQL_IS_NULL_LEN (sizeof(SPIDER_SQL_IS_NULL_STR) - 1) +#define SPIDER_SQL_IS_NOT_NULL_STR " is not null" +#define SPIDER_SQL_IS_NOT_NULL_LEN (sizeof(SPIDER_SQL_IS_NOT_NULL_STR) - 1) +#define SPIDER_SQL_NOT_NULL_STR " not null" +#define SPIDER_SQL_NOT_NULL_LEN (sizeof(SPIDER_SQL_NOT_NULL_STR) - 1) +#define SPIDER_SQL_DEFAULT_STR " default " +#define SPIDER_SQL_DEFAULT_LEN (sizeof(SPIDER_SQL_DEFAULT_STR) - 1) +#define SPIDER_SQL_SPACE_STR " " +#define SPIDER_SQL_SPACE_LEN (sizeof(SPIDER_SQL_SPACE_STR) - 1) +#define SPIDER_SQL_ONE_STR "1" +#define SPIDER_SQL_ONE_LEN sizeof(SPIDER_SQL_ONE_STR) - 1 +#define SPIDER_SQL_SQL_CACHE_STR "sql_cache " +#define SPIDER_SQL_SQL_CACHE_LEN (sizeof(SPIDER_SQL_SQL_CACHE_STR) - 1) +#define SPIDER_SQL_SQL_NO_CACHE_STR "sql_no_cache " +#define SPIDER_SQL_SQL_NO_CACHE_LEN (sizeof(SPIDER_SQL_SQL_NO_CACHE_STR) - 1) +#define SPIDER_SQL_SQL_QUICK_MODE_STR "quick " +#define SPIDER_SQL_SQL_QUICK_MODE_LEN (sizeof(SPIDER_SQL_SQL_QUICK_MODE_STR) - 1) +#define SPIDER_SQL_SET_STR " set " +#define SPIDER_SQL_SET_LEN (sizeof(SPIDER_SQL_SET_STR) - 1) +#define SPIDER_SQL_UNDERSCORE_STR "_" +#define SPIDER_SQL_UNDERSCORE_LEN sizeof(SPIDER_SQL_UNDERSCORE_STR) - 1 +#define SPIDER_SQL_PF_EQUAL_STR " <=> " +#define SPIDER_SQL_PF_EQUAL_LEN (sizeof(SPIDER_SQL_PF_EQUAL_STR) - 1) +#define SPIDER_SQL_GROUP_STR " group by " +#define SPIDER_SQL_GROUP_LEN (sizeof(SPIDER_SQL_GROUP_STR) - 1) +#define SPIDER_SQL_PLUS_STR " + " +#define SPIDER_SQL_PLUS_LEN (sizeof(SPIDER_SQL_PLUS_STR) - 1) +#define SPIDER_SQL_MINUS_STR " - " +#define SPIDER_SQL_MINUS_LEN (sizeof(SPIDER_SQL_MINUS_STR) - 1) + +#define SPIDER_SQL_SHOW_RECORDS_STR "select count(*) from " +#define SPIDER_SQL_SHOW_RECORDS_LEN sizeof(SPIDER_SQL_SHOW_RECORDS_STR) - 1 +#define SPIDER_SQL_SHOW_INDEX_STR "show index from " +#define SPIDER_SQL_SHOW_INDEX_LEN sizeof(SPIDER_SQL_SHOW_INDEX_STR) - 1 +#define SPIDER_SQL_SELECT_STATISTICS_STR "select `column_name`,`cardinality` from `information_schema`.`statistics` where `table_schema` = " +#define SPIDER_SQL_SELECT_STATISTICS_LEN sizeof(SPIDER_SQL_SELECT_STATISTICS_STR) - 1 +#define SPIDER_SQL_MAX_STR "max" +#define SPIDER_SQL_MAX_LEN sizeof(SPIDER_SQL_MAX_STR) - 1 + +#define SPIDER_SQL_DROP_TMP_STR "drop temporary table if exists " +#define SPIDER_SQL_DROP_TMP_LEN (sizeof(SPIDER_SQL_DROP_TMP_STR) - 1) +#define SPIDER_SQL_CREATE_TMP_STR "create temporary table " +#define SPIDER_SQL_CREATE_TMP_LEN (sizeof(SPIDER_SQL_CREATE_TMP_STR) - 1) +#define SPIDER_SQL_TMP_BKA_STR "tmp_spider_bka_" +#define SPIDER_SQL_TMP_BKA_LEN (sizeof(SPIDER_SQL_TMP_BKA_STR) - 1) +#define SPIDER_SQL_ENGINE_STR ")engine=" +#define SPIDER_SQL_ENGINE_LEN (sizeof(SPIDER_SQL_ENGINE_STR) - 1) +#define SPIDER_SQL_DEF_CHARSET_STR " default charset=" +#define SPIDER_SQL_DEF_CHARSET_LEN (sizeof(SPIDER_SQL_DEF_CHARSET_STR) - 1) +#define SPIDER_SQL_ID_TYPE_STR " bigint" +#define SPIDER_SQL_ID_TYPE_LEN (sizeof(SPIDER_SQL_ID_TYPE_STR) - 1) + +#define SPIDER_SQL_COLUMN_NAME_STR "`column_name`" +#define SPIDER_SQL_COLUMN_NAME_LEN sizeof(SPIDER_SQL_COLUMN_NAME_STR) - 1 + +#define SPIDER_SQL_A_DOT_STR "a." +#define SPIDER_SQL_A_DOT_LEN (sizeof(SPIDER_SQL_A_DOT_STR) - 1) +#define SPIDER_SQL_B_DOT_STR "b." +#define SPIDER_SQL_B_DOT_LEN (sizeof(SPIDER_SQL_B_DOT_STR) - 1) +#define SPIDER_SQL_A_STR "a" +#define SPIDER_SQL_A_LEN (sizeof(SPIDER_SQL_A_STR) - 1) +#define SPIDER_SQL_B_STR "b" +#define SPIDER_SQL_B_LEN (sizeof(SPIDER_SQL_B_STR) - 1) + +#define SPIDER_SQL_INT_LEN 20 +#define SPIDER_SQL_HANDLER_CID_LEN 6 +#define SPIDER_SQL_HANDLER_CID_FORMAT "t%05u" +#define SPIDER_UDF_PING_TABLE_PING_ONLY (1 << 0) +#define SPIDER_UDF_PING_TABLE_USE_WHERE (1 << 1) + +int spider_db_connect( + const SPIDER_SHARE *share, + SPIDER_CONN *conn, + int link_idx +); + +int spider_db_ping( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +); + +void spider_db_disconnect( + SPIDER_CONN *conn +); + +int spider_db_conn_queue_action( + SPIDER_CONN *conn +); + +int spider_db_before_query( + SPIDER_CONN *conn, + int *need_mon +); + +int spider_db_query( + SPIDER_CONN *conn, + const char *query, + uint length, + int quick_mode, + int *need_mon +); + +int spider_db_errorno( + SPIDER_CONN *conn +); + +int spider_db_set_trx_isolation( + SPIDER_CONN *conn, + int trx_isolation, + int *need_mon +); + +int spider_db_set_names_internal( + SPIDER_TRX *trx, + SPIDER_SHARE *share, + SPIDER_CONN *conn, + int all_link_idx, + int *need_mon +); + +int spider_db_set_names( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +); + +int spider_db_query_with_set_names( + ulong sql_type, + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +); + +int spider_db_query_for_bulk_update( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx, + uint *dup_key_found +); + +size_t spider_db_real_escape_string( + SPIDER_CONN *conn, + char *to, + const char *from, + size_t from_length +); + +int spider_db_consistent_snapshot( + SPIDER_CONN *conn, + int *need_mon +); + +int spider_db_start_transaction( + SPIDER_CONN *conn, + int *need_mon +); + +int spider_db_commit( + SPIDER_CONN *conn +); + +int spider_db_rollback( + SPIDER_CONN *conn +); + +int spider_db_append_hex_string( + spider_string *str, + uchar *hex_ptr, + int hex_ptr_length +); + +void spider_db_append_xid_str( + spider_string *tmp_str, + XID *xid +); + +int spider_db_xa_end( + SPIDER_CONN *conn, + XID *xid +); + +int spider_db_xa_prepare( + SPIDER_CONN *conn, + XID *xid +); + +int spider_db_xa_commit( + SPIDER_CONN *conn, + XID *xid +); + +int spider_db_xa_rollback( + SPIDER_CONN *conn, + XID *xid +); + +int spider_db_lock_tables( + ha_spider *spider, + int link_idx +); + +int spider_db_unlock_tables( + ha_spider *spider, + int link_idx +); + +int spider_db_append_name_with_quote_str( + spider_string *str, + char *name, + uint dbton_id +); + +int spider_db_append_select( + ha_spider *spider +); + +int spider_db_append_select_columns( + ha_spider *spider +); + +int spider_db_append_null_value( + spider_string *str, + KEY_PART_INFO *key_part, + const uchar **ptr +); + +int spider_db_append_key_columns( + const key_range *start_key, + ha_spider *spider, + spider_string *str +); + +int spider_db_append_key_hint( + spider_string *str, + char *hint_str +); + +int spider_db_append_key_where_internal( + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + const key_range *start_key, + const key_range *end_key, + ha_spider *spider, + bool set_order, + ulong sql_type, + uint dbton_id +); + +int spider_db_append_key_where( + const key_range *start_key, + const key_range *end_key, + ha_spider *spider +); + +int spider_db_append_match_fetch( + ha_spider *spider, + st_spider_ft_info *ft_first, + st_spider_ft_info *ft_current, + SPIDER_DB_ROW *row +); + +int spider_db_append_match_where( + ha_spider *spider +); + +int spider_db_append_hint_after_table( + ha_spider *spider, + spider_string *str, + spider_string *hint +); + +int spider_db_append_show_records( + SPIDER_SHARE *share +); + +void spider_db_free_show_records( + SPIDER_SHARE *share +); + +int spider_db_append_show_index( + SPIDER_SHARE *share +); + +void spider_db_free_show_index( + SPIDER_SHARE *share +); + +void spider_db_append_handler_next( + ha_spider *spider +); + +void spider_db_get_row_from_tmp_tbl_rec( + SPIDER_RESULT *current, + SPIDER_DB_ROW **row +); + +int spider_db_get_row_from_tmp_tbl( + SPIDER_RESULT *current, + SPIDER_DB_ROW **row +); + +int spider_db_get_row_from_tmp_tbl_pos( + SPIDER_POSITION *pos, + SPIDER_DB_ROW **row +); + +int spider_db_fetch_row( + SPIDER_SHARE *share, + Field *field, + SPIDER_DB_ROW *row, + my_ptrdiff_t ptr_diff +); + +int spider_db_fetch_table( + ha_spider *spider, + uchar *buf, + TABLE *table, + SPIDER_RESULT_LIST *result_list +); + +int spider_db_fetch_key( + ha_spider *spider, + uchar *buf, + TABLE *table, + const KEY *key_info, + SPIDER_RESULT_LIST *result_list +); + +int spider_db_fetch_minimum_columns( + ha_spider *spider, + uchar *buf, + TABLE *table, + SPIDER_RESULT_LIST *result_list +); + +void spider_db_free_one_result_for_start_next( + ha_spider *spider +); + +void spider_db_free_one_result( + SPIDER_RESULT_LIST *result_list, + SPIDER_RESULT *result +); + +int spider_db_free_result( + ha_spider *spider, + bool final +); + +int spider_db_store_result( + ha_spider *spider, + int link_idx, + TABLE *table +); + +void spider_db_discard_result( + ha_spider *spider, + int link_idx, + SPIDER_CONN *conn +); + +void spider_db_discard_multiple_result( + ha_spider *spider, + int link_idx, + SPIDER_CONN *conn +); + +#ifdef HA_CAN_BULK_ACCESS +int spider_db_bulk_store_result( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx, + bool discard_result +); +#endif + +int spider_db_fetch( + uchar *buf, + ha_spider *spider, + TABLE *table +); + +int spider_db_seek_prev( + uchar *buf, + ha_spider *spider, + TABLE *table +); + +int spider_db_seek_next( + uchar *buf, + ha_spider *spider, + int link_idx, + TABLE *table +); + +int spider_db_seek_last( + uchar *buf, + ha_spider *spider, + int link_idx, + TABLE *table +); + +int spider_db_seek_first( + uchar *buf, + ha_spider *spider, + TABLE *table +); + +void spider_db_set_pos_to_first_row( + SPIDER_RESULT_LIST *result_list +); + +void spider_db_create_position( + ha_spider *spider, + SPIDER_POSITION *pos +); + +int spider_db_seek_tmp( + uchar *buf, + SPIDER_POSITION *pos, + ha_spider *spider, + TABLE *table +); + +int spider_db_seek_tmp_table( + uchar *buf, + SPIDER_POSITION *pos, + ha_spider *spider, + TABLE *table +); + +int spider_db_seek_tmp_key( + uchar *buf, + SPIDER_POSITION *pos, + ha_spider *spider, + TABLE *table, + const KEY *key_info +); + +int spider_db_seek_tmp_minimum_columns( + uchar *buf, + SPIDER_POSITION *pos, + ha_spider *spider, + TABLE *table +); + +int spider_db_show_table_status( + ha_spider *spider, + int link_idx, + int sts_mode, + uint flag +); + +int spider_db_show_records( + ha_spider *spider, + int link_idx +); + +void spider_db_set_cardinarity( + ha_spider *spider, + TABLE *table +); + +int spider_db_show_index( + ha_spider *spider, + int link_idx, + TABLE *table, + int crd_mode +); + +ha_rows spider_db_explain_select( + key_range *start_key, + key_range *end_key, + ha_spider *spider, + int link_idx +); + +int spider_db_bulk_insert_init( + ha_spider *spider, + const TABLE *table +); + +int spider_db_bulk_insert( + ha_spider *spider, + TABLE *table, + bool bulk_end +); + +#ifdef HA_CAN_BULK_ACCESS +int spider_db_bulk_bulk_insert( + ha_spider *spider +); +#endif + +int spider_db_update_auto_increment( + ha_spider *spider, + int link_idx +); + +int spider_db_bulk_update_size_limit( + ha_spider *spider, + TABLE *table +); + +int spider_db_bulk_update_end( + ha_spider *spider, + uint *dup_key_found +); + +int spider_db_bulk_update( + ha_spider *spider, + TABLE *table, + my_ptrdiff_t ptr_diff +); + +int spider_db_update( + ha_spider *spider, + TABLE *table, + const uchar *old_data +); + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_db_direct_update( + ha_spider *spider, + TABLE *table, + KEY_MULTI_RANGE *ranges, + uint range_count, + uint *update_rows +); +#endif + +#ifdef HA_CAN_BULK_ACCESS +int spider_db_bulk_direct_update( + ha_spider *spider, + uint *update_rows +); +#endif + +int spider_db_bulk_delete( + ha_spider *spider, + TABLE *table, + my_ptrdiff_t ptr_diff +); + +int spider_db_delete( + ha_spider *spider, + TABLE *table, + const uchar *buf +); + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_db_direct_delete( + ha_spider *spider, + TABLE *table, + KEY_MULTI_RANGE *ranges, + uint range_count, + uint *delete_rows +); +#endif + +int spider_db_delete_all_rows( + ha_spider *spider +); + +int spider_db_disable_keys( + ha_spider *spider +); + +int spider_db_enable_keys( + ha_spider *spider +); + +int spider_db_check_table( + ha_spider *spider, + HA_CHECK_OPT* check_opt +); + +int spider_db_repair_table( + ha_spider *spider, + HA_CHECK_OPT* check_opt +); + +int spider_db_analyze_table( + ha_spider *spider +); + +int spider_db_optimize_table( + ha_spider *spider +); + +int spider_db_flush_tables( + ha_spider *spider, + bool lock +); + +int spider_db_flush_logs( + ha_spider *spider +); + +int spider_db_print_item_type( + Item *item, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_cond( + Item_cond *item_cond, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_ident( + Item_ident *item_ident, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_field( + Item_field *item_field, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_ref( + Item_ref *item_ref, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_row( + Item_row *item_row, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_string( + Item *item, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_int( + Item *item, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_open_item_cache( + Item_cache *item_cache, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); + +int spider_db_append_condition( + ha_spider *spider, + const char *alias, + uint alias_length, + bool test_flg +); + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_db_append_update_columns( + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id +); +#endif + +uint spider_db_check_ft_idx( + Item_func *item_func, + ha_spider *spider +); + +int spider_db_udf_fetch_row( + SPIDER_TRX *trx, + Field *field, + SPIDER_DB_ROW *row, + ulong *length +); + +int spider_db_udf_fetch_table( + SPIDER_TRX *trx, + SPIDER_CONN *conn, + TABLE *table, + SPIDER_DB_RESULT *result, + uint set_on, + uint set_off +); + +int spider_db_udf_direct_sql_connect( + const SPIDER_DIRECT_SQL *direct_sql, + SPIDER_CONN *conn +); + +int spider_db_udf_direct_sql_ping( + SPIDER_DIRECT_SQL *direct_sql +); + +int spider_db_udf_direct_sql( + SPIDER_DIRECT_SQL *direct_sql +); + +int spider_db_udf_direct_sql_select_db( + SPIDER_DIRECT_SQL *direct_sql, + SPIDER_CONN *conn +); + +int spider_db_udf_direct_sql_set_names( + SPIDER_DIRECT_SQL *direct_sql, + SPIDER_TRX *trx, + SPIDER_CONN *conn +); + +int spider_db_udf_check_and_set_set_names( + SPIDER_TRX *trx +); + +int spider_db_udf_append_set_names( + SPIDER_TRX *trx +); + +void spider_db_udf_free_set_names( + SPIDER_TRX *trx +); + +int spider_db_udf_ping_table( + SPIDER_TABLE_MON_LIST *table_mon_list, + SPIDER_SHARE *share, + SPIDER_TRX *trx, + SPIDER_CONN *conn, + char *where_clause, + uint where_clause_length, + bool ping_only, + bool use_where, + longlong limit +); + +int spider_db_udf_ping_table_append_mon_next( + spider_string *str, + char *child_table_name, + uint child_table_name_length, + int link_id, + char *where_clause, + uint where_clause_length, + longlong first_sid, + int full_mon_count, + int current_mon_count, + int success_count, + int fault_count, + int flags, + longlong limit +); + +int spider_db_udf_ping_table_append_select( + spider_string *str, + SPIDER_SHARE *share, + SPIDER_TRX *trx, + spider_string *where_str, + bool use_where, + longlong limit, + uint dbton_id +); + +int spider_db_udf_ping_table_mon_next( + THD *thd, + SPIDER_TABLE_MON *table_mon, + SPIDER_CONN *conn, + SPIDER_MON_TABLE_RESULT *mon_table_result, + char *child_table_name, + uint child_table_name_length, + int link_id, + char *where_clause, + uint where_clause_length, + longlong first_sid, + int full_mon_count, + int current_mon_count, + int success_count, + int fault_count, + int flags, + longlong limit +); + +int spider_db_udf_copy_tables( + SPIDER_COPY_TABLES *copy_tables, + ha_spider *spider, + TABLE *table, + longlong bulk_insert_rows +); + +int spider_db_open_handler( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +); + +#ifdef HA_CAN_BULK_ACCESS +int spider_db_bulk_open_handler( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +); +#endif + +int spider_db_close_handler( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx, + uint tgt_conn_kind +); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +void spider_db_hs_request_buf_reset( + SPIDER_CONN *conn +); +#endif diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc new file mode 100644 index 00000000000..0c1dce876dc --- /dev/null +++ b/storage/spider/spd_db_handlersocket.cc @@ -0,0 +1,5308 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_analyse.h" +#endif + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_db_handlersocket.h" +#include "ha_spider.h" +#include "spd_db_conn.h" +#include "spd_trx.h" +#include "spd_conn.h" +#include "spd_malloc.h" + +extern handlerton *spider_hton_ptr; +extern HASH spider_open_connections; +extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; +extern const char spider_dig_upper[]; + +#define SPIDER_SQL_INTERVAL_STR " + interval " +#define SPIDER_SQL_INTERVAL_LEN (sizeof(SPIDER_SQL_INTERVAL_STR) - 1) +#define SPIDER_SQL_NEGINTERVAL_STR " - interval " +#define SPIDER_SQL_NEGINTERVAL_LEN (sizeof(SPIDER_SQL_NEGINTERVAL_STR) - 1) + +#define SPIDER_SQL_NAME_QUOTE_STR "" +#define SPIDER_SQL_NAME_QUOTE_LEN (sizeof(SPIDER_SQL_NAME_QUOTE_STR) - 1) +static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; + +#define SPIDER_SQL_TYPE_FULL_HS (SPIDER_SQL_TYPE_SELECT_HS | \ + SPIDER_SQL_TYPE_INSERT_HS | SPIDER_SQL_TYPE_UPDATE_HS | \ + SPIDER_SQL_TYPE_DELETE_HS | SPIDER_SQL_TYPE_OTHER_HS) + +static uchar SPIDER_SQL_LINESTRING_HEAD_STR[] = + {0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00}; +#define SPIDER_SQL_LINESTRING_HEAD_LEN sizeof(SPIDER_SQL_LINESTRING_HEAD_STR) + +static const char *spider_db_timefunc_interval_str[] = +{ + " year", " quarter", " month", " week", " day", + " hour", " minute", " second", " microsecond", + " year_month", " day_hour", " day_minute", + " day_second", " hour_minute", " hour_second", + " minute_second", " day_microsecond", " hour_microsecond", + " minute_microsecond", " second_microsecond" +}; + +static SPIDER_HS_STRING_REF spider_null_string_ref = SPIDER_HS_STRING_REF(); + +int spider_handlersocket_init() +{ + DBUG_ENTER("spider_handlersocket_init"); + DBUG_RETURN(0); +} + +int spider_handlersocket_deinit() +{ + DBUG_ENTER("spider_handlersocket_deinit"); + DBUG_RETURN(0); +} + +spider_db_share *spider_handlersocket_create_share( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_handlersocket_create_share"); + DBUG_RETURN(new spider_handlersocket_share(share)); +} + +spider_db_handler *spider_handlersocket_create_handler( + ha_spider *spider, + spider_db_share *db_share +) { + DBUG_ENTER("spider_handlersocket_create_handler"); + DBUG_RETURN(new spider_handlersocket_handler(spider, + (spider_handlersocket_share *) db_share)); +} + +SPIDER_DB_CONN *spider_handlersocket_create_conn( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_handlersocket_create_conn"); + DBUG_RETURN(new spider_db_handlersocket(conn)); +} + +spider_db_handlersocket_util spider_db_handlersocket_utility; + +SPIDER_DBTON spider_dbton_handlersocket = { + 0, + SPIDER_DB_WRAPPER_MYSQL, + SPIDER_DB_ACCESS_TYPE_NOSQL, + spider_handlersocket_init, + spider_handlersocket_deinit, + spider_handlersocket_create_share, + spider_handlersocket_create_handler, + NULL, + spider_handlersocket_create_conn, + &spider_db_handlersocket_utility +}; + +#ifndef HANDLERSOCKET_MYSQL_UTIL +spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_hs_string_ref_buffer::init() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::init"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +void spider_db_hs_string_ref_buffer::clear() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::clear"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_conds.clear(); + DBUG_VOID_RETURN; +} + +int spider_db_hs_string_ref_buffer::push_back( + SPIDER_HS_STRING_REF &cond +) { + DBUG_ENTER("spider_db_hs_string_ref_buffer::push_back"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_conds.push_back(cond); + DBUG_RETURN(0); +} + +SPIDER_HS_STRING_REF *spider_db_hs_string_ref_buffer::ptr() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::ptr"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(&hs_conds[0]); +} + +uint spider_db_hs_string_ref_buffer::size() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::size"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((uint) hs_conds.size()); +} +#else +spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer() : hs_da_init(FALSE) +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + if (hs_da_init) + { + spider_free_mem_calc(spider_current_trx, + hs_conds_id, hs_conds.max_element * hs_conds.size_of_element); + delete_dynamic(&hs_conds); + } + DBUG_VOID_RETURN; +} + +int spider_db_hs_string_ref_buffer::init() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!hs_da_init) + { + SPD_INIT_DYNAMIC_ARRAY2(&hs_conds, sizeof(SPIDER_HS_STRING_REF), + NULL, 16, 16, MYF(MY_WME)); + spider_alloc_calc_mem_init(hs_conds, 159); + spider_alloc_calc_mem(spider_current_trx, + hs_conds, hs_conds.max_element * hs_conds.size_of_element); + hs_da_init = TRUE; + } + DBUG_RETURN(0); +} + +void spider_db_hs_string_ref_buffer::clear() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::clear"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_conds.elements = 0; + DBUG_VOID_RETURN; +} + +int spider_db_hs_string_ref_buffer::push_back( + SPIDER_HS_STRING_REF &cond +) { + uint old_elements = hs_conds.max_element; + DBUG_ENTER("spider_db_hs_string_ref_buffer::push_back"); + DBUG_PRINT("info",("spider this=%p", this)); + if (insert_dynamic(&hs_conds, (uchar *) &cond)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (hs_conds.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + hs_conds, + (hs_conds.max_element - old_elements) * hs_conds.size_of_element); + } + DBUG_RETURN(0); +} + +SPIDER_HS_STRING_REF *spider_db_hs_string_ref_buffer::ptr() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::ptr"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((SPIDER_HS_STRING_REF *) hs_conds.buffer); +} + +uint spider_db_hs_string_ref_buffer::size() +{ + DBUG_ENTER("spider_db_hs_string_ref_buffer::size"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(hs_conds.elements); +} +#endif + +spider_db_hs_str_buffer::spider_db_hs_str_buffer() : hs_da_init(FALSE) +{ + DBUG_ENTER("spider_db_hs_str_buffer::spider_db_hs_str_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_hs_str_buffer::~spider_db_hs_str_buffer() +{ + DBUG_ENTER("spider_db_hs_str_buffer::~spider_db_hs_str_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + if (hs_da_init) + { + spider_free_mem_calc(spider_current_trx, + hs_conds_id, hs_conds.max_element * hs_conds.size_of_element); + delete_dynamic(&hs_conds); + } + DBUG_VOID_RETURN; +} + +int spider_db_hs_str_buffer::init() +{ + DBUG_ENTER("spider_db_hs_str_buffer::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!hs_da_init) + { + SPD_INIT_DYNAMIC_ARRAY2(&hs_conds, sizeof(spider_string *), + NULL, 16, 16, MYF(MY_WME)); + spider_alloc_calc_mem_init(hs_conds, 160); + spider_alloc_calc_mem(spider_current_trx, + hs_conds, hs_conds.max_element * hs_conds.size_of_element); + hs_da_init = TRUE; + } + DBUG_RETURN(0); +} + +void spider_db_hs_str_buffer::clear() +{ + uint i; + spider_string *element; + DBUG_ENTER("spider_db_hs_str_buffer::clear"); + DBUG_PRINT("info",("spider this=%p", this)); + for (i = 0; i < hs_conds.elements; i++) + { + get_dynamic(&hs_conds, (uchar *) &element, i); + element->free(); + spider_free(spider_current_trx, element, MYF(0)); + } + hs_conds.elements = 0; + DBUG_VOID_RETURN; +} + +spider_string *spider_db_hs_str_buffer::add( + uint *strs_pos, + const char *str, + uint str_len +) { + spider_string *element; + DBUG_ENTER("spider_db_hs_str_buffer::add"); + DBUG_PRINT("info",("spider this=%p", this)); + if (hs_conds.elements <= *strs_pos + 1) + { + if (!(element = (spider_string *) spider_malloc(spider_current_trx, 8, + sizeof(spider_string), MYF(MY_WME | MY_ZEROFILL)))) + DBUG_RETURN(NULL); + element->init_calc_mem(98); + element->set_charset(&my_charset_bin); + if ((element->reserve(str_len + 1))) + { + spider_free(spider_current_trx, element, MYF(0)); + DBUG_RETURN(NULL); + } + element->q_append(str, str_len); + uint old_elements = hs_conds.max_element; + if (insert_dynamic(&hs_conds, (uchar *) &element)) + { + element->free(); + spider_free(spider_current_trx, element, MYF(0)); + DBUG_RETURN(NULL); + } + if (hs_conds.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + hs_conds, + (hs_conds.max_element - old_elements) * + hs_conds.size_of_element); + } + } else { + element = ((spider_string **) hs_conds.buffer)[*strs_pos]; + element->length(0); + if ((element->reserve(str_len + 1))) + DBUG_RETURN(NULL); + element->q_append(str, str_len); + } + (*strs_pos)++; + DBUG_RETURN(element); +} + +spider_db_handlersocket_row::spider_db_handlersocket_row() : spider_db_row(), + hs_row(NULL), field_count(0), cloned(FALSE) +{ + DBUG_ENTER("spider_db_handlersocket_row::spider_db_handlersocket_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_handlersocket_row::~spider_db_handlersocket_row() +{ + DBUG_ENTER("spider_db_handlersocket_row::~spider_db_handlersocket_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (cloned) + { + spider_free(spider_current_trx, hs_row_first, MYF(0)); + } + DBUG_VOID_RETURN; +} + +int spider_db_handlersocket_row::store_to_field( + Field *field, + CHARSET_INFO *access_charset +) { + DBUG_ENTER("spider_db_handlersocket_row::store_to_field"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!hs_row->begin()) + { + DBUG_PRINT("info", ("spider field is null")); + field->set_null(); + field->reset(); + } else { +#ifndef DBUG_OFF + char buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, field->charset()); + tmp_str.init_calc_mem(119); + tmp_str.length(0); + tmp_str.append(hs_row->begin(), hs_row->size(), &my_charset_bin); + DBUG_PRINT("info", ("spider val=%s", tmp_str.c_ptr_safe())); +#endif + field->set_notnull(); + if (field->flags & BLOB_FLAG) + { + DBUG_PRINT("info", ("spider blob field")); + ((Field_blob *)field)->set_ptr( + hs_row->size(), (uchar *) hs_row->begin()); + } else + field->store(hs_row->begin(), hs_row->size(), &my_charset_bin); + } + DBUG_RETURN(0); +} + +int spider_db_handlersocket_row::append_to_str( + spider_string *str +) { + DBUG_ENTER("spider_db_handlersocket_row::append_to_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(hs_row->size())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(hs_row->begin(), hs_row->size()); + DBUG_RETURN(0); +} + +int spider_db_handlersocket_row::append_escaped_to_str( + spider_string *str, + uint dbton_id +) { + DBUG_ENTER("spider_db_handlersocket_row::append_escaped_to_str"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_string tmp_str(hs_row->begin(), hs_row->size() + 1, &my_charset_bin); + tmp_str.init_calc_mem(172); + tmp_str.length(hs_row->size()); + if (str->reserve(hs_row->size() * 2 + 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + spider_dbton[dbton_id].db_util->append_escaped_util(str, tmp_str.get_str()); + str->mem_calc(); + DBUG_RETURN(0); +} + +void spider_db_handlersocket_row::first() +{ + DBUG_ENTER("spider_db_handlersocket_row::first"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_row = hs_row_first; + DBUG_VOID_RETURN; +} + +void spider_db_handlersocket_row::next() +{ + DBUG_ENTER("spider_db_handlersocket_row::next"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_row++; + DBUG_VOID_RETURN; +} + +bool spider_db_handlersocket_row::is_null() +{ + DBUG_ENTER("spider_db_handlersocket_row::is_null"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(!hs_row->begin()); +} + +int spider_db_handlersocket_row::val_int() +{ + DBUG_ENTER("spider_db_handlersocket_row::val_int"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(atoi(hs_row->begin())); +} + +double spider_db_handlersocket_row::val_real() +{ + DBUG_ENTER("spider_db_handlersocket_row::val_real"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(hs_row->begin() ? my_atof(hs_row->begin()) : 0.0); +} + +SPIDER_DB_ROW *spider_db_handlersocket_row::clone() +{ + spider_db_handlersocket_row *clone_row; + char *tmp_char; + uint row_size, i; + DBUG_ENTER("spider_db_handlersocket_row::clone"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(clone_row = new spider_db_handlersocket_row())) + { + DBUG_RETURN(NULL); + } + row_size = 0; + for (i = 0; i < field_count; i++) + { + row_size += hs_row_first[i].size(); + } + if (!spider_bulk_malloc(spider_current_trx, 169, MYF(MY_WME), + &clone_row->hs_row, sizeof(SPIDER_HS_STRING_REF) * field_count, + &tmp_char, row_size, + NullS) + ) { + delete clone_row; + DBUG_RETURN(NULL); + } + for (i = 0; i < field_count; i++) + { + memcpy(tmp_char, hs_row_first[i].begin(), hs_row_first[i].size()); + clone_row->hs_row[i].set(tmp_char, hs_row_first[i].size()); + tmp_char += hs_row_first[i].size(); + } + clone_row->hs_row_first = clone_row->hs_row; + clone_row->cloned = TRUE;; + DBUG_RETURN(NULL); +} + +int spider_db_handlersocket_row::store_to_tmp_table( + TABLE *tmp_table, + spider_string *str +) { + uint i; + SPIDER_HS_STRING_REF *tmp_hs_row = hs_row; + DBUG_ENTER("spider_db_handlersocket_row::store_to_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + for (i = 0; i < field_count; i++) + { + if (tmp_hs_row->begin()) + { + if (str->reserve(tmp_hs_row->size())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(tmp_hs_row->begin(), tmp_hs_row->size()); + } + tmp_hs_row++; + } + tmp_table->field[0]->set_notnull(); + tmp_table->field[0]->store( + (const char *) hs_row, + sizeof(SPIDER_HS_STRING_REF) * field_count, &my_charset_bin); + tmp_table->field[1]->set_notnull(); + tmp_table->field[1]->store( + str->ptr(), str->length(), &my_charset_bin); + tmp_table->field[2]->set_null(); + DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); +} + + +spider_db_handlersocket_result_buffer::spider_db_handlersocket_result_buffer( +) : spider_db_result_buffer() +{ + DBUG_ENTER("spider_db_handlersocket_result_buffer::spider_db_handlersocket_result_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_handlersocket_result_buffer::~spider_db_handlersocket_result_buffer() +{ + DBUG_ENTER( + "spider_db_handlersocket_result_buffer::~spider_db_handlersocket_result_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +void spider_db_handlersocket_result_buffer::clear() +{ + DBUG_ENTER("spider_db_handlersocket_result_buffer::clear"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_result.readbuf.clear(); + DBUG_VOID_RETURN; +} + +bool spider_db_handlersocket_result_buffer::check_size( + longlong size +) { + DBUG_ENTER("spider_db_handlersocket_result_buffer::check_size"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((uint) hs_result.readbuf.real_size() > size) + { + hs_result.readbuf.real_free(); + DBUG_RETURN(TRUE); + } + DBUG_RETURN(FALSE); +} + +spider_db_handlersocket_result::spider_db_handlersocket_result( +) : spider_db_result() +{ + DBUG_ENTER("spider_db_handlersocket_result::spider_db_handlersocket_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_handlersocket_result::~spider_db_handlersocket_result() +{ + DBUG_ENTER( + "spider_db_handlersocket_result::~spider_db_handlersocket_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +bool spider_db_handlersocket_result::has_result() +{ + DBUG_ENTER("spider_db_handlersocket_result::has_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(((*hs_conn_p)->get_response_end_offset() > 0)); +} + +void spider_db_handlersocket_result::free_result() +{ + DBUG_ENTER("spider_db_handlersocket_result::free_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if ((*hs_conn_p)->get_response_end_offset() > 0) + { + (*hs_conn_p)->response_buf_remove(); + if ((*hs_conn_p)->get_error_code()) + { + DBUG_PRINT("info",("spider hs %d %s", + (*hs_conn_p)->get_error_code(), + (*hs_conn_p)->get_error().ptr())); + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + } + DBUG_VOID_RETURN; +} + +SPIDER_DB_ROW *spider_db_handlersocket_result::current_row() +{ + DBUG_ENTER("spider_db_handlersocket_result::current_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((SPIDER_DB_ROW *) row.clone()); +} + +SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row() +{ + DBUG_ENTER("spider_db_handlersocket_result::fetch_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(row.hs_row = (SPIDER_HS_STRING_REF *) + (*hs_conn_p)->get_next_row())) + { + store_error_num = HA_ERR_END_OF_FILE; + DBUG_RETURN(NULL); + } + row.field_count = field_count; + row.hs_row_first = row.hs_row; + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row_from_result_buffer( + spider_db_result_buffer *spider_res_buf +) { + spider_db_handlersocket_result_buffer *hs_res_buf; + DBUG_ENTER("spider_db_handlersocket_result::fetch_row_from_result_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_res_buf = (spider_db_handlersocket_result_buffer *) spider_res_buf; + if (!(row.hs_row = (SPIDER_HS_STRING_REF *) + (*hs_conn_p)->get_next_row_from_result(hs_res_buf->hs_result))) + { + store_error_num = HA_ERR_END_OF_FILE; + DBUG_RETURN(NULL); + } + row.field_count = field_count; + row.hs_row_first = row.hs_row; + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row_from_tmp_table( + TABLE *tmp_table +) { + uint i; + spider_string tmp_str1, tmp_str2; + const char *row_ptr; + SPIDER_HS_STRING_REF *tmp_hs_row; + uint field_count; + DBUG_ENTER("spider_db_handlersocket_result::fetch_row_from_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_str1.init_calc_mem(171); + tmp_str2.init_calc_mem(173); + tmp_table->field[0]->val_str(tmp_str1.get_str()); + tmp_table->field[1]->val_str(tmp_str2.get_str()); + tmp_str1.mem_calc(); + tmp_str2.mem_calc(); + row_ptr = tmp_str2.ptr(); + tmp_hs_row = (SPIDER_HS_STRING_REF *) tmp_str1.ptr(); + field_count = tmp_str1.length() / sizeof(SPIDER_HS_STRING_REF); + row.hs_row = tmp_hs_row; + row.field_count = field_count; + row.hs_row_first = row.hs_row; + for (i = 0; i < field_count; i++) + { + if (tmp_hs_row->begin()) + { + uint length = tmp_hs_row->size(); + tmp_hs_row->set(row_ptr, length); + row_ptr += length; + } + tmp_hs_row++; + } + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +int spider_db_handlersocket_result::fetch_table_status( + int mode, + ha_rows &records, + ulong &mean_rec_length, + ulonglong &data_file_length, + ulonglong &max_data_file_length, + ulonglong &index_file_length, + ulonglong &auto_increment_value, + time_t &create_time, + time_t &update_time, + time_t &check_time +) { + DBUG_ENTER("spider_db_handlersocket_result::fetch_table_status"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_handlersocket_result::fetch_table_records( + int mode, + ha_rows &records +) { + DBUG_ENTER("spider_db_handlersocket_result::fetch_table_records"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_handlersocket_result::fetch_table_cardinality( + int mode, + TABLE *table, + longlong *cardinality, + uchar *cardinality_upd, + int bitmap_size +) { + DBUG_ENTER("spider_db_handlersocket_result::fetch_table_cardinality"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_handlersocket_result::fetch_table_mon_status( + int &status +) { + DBUG_ENTER("spider_db_handlersocket_result::fetch_table_mon_status"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +longlong spider_db_handlersocket_result::num_rows() +{ + DBUG_ENTER("spider_db_handlersocket_result::num_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((longlong) 0); +} + +uint spider_db_handlersocket_result::num_fields() +{ + DBUG_ENTER("spider_db_handlersocket_result::num_fields"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(field_count); +} + +void spider_db_handlersocket_result::move_to_pos( + longlong pos +) { + DBUG_ENTER("spider_db_handlersocket_result::move_to_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +int spider_db_handlersocket_result::get_errno() +{ + DBUG_ENTER("spider_db_handlersocket_result::get_errno"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider store_error_num=%d", store_error_num)); + DBUG_RETURN(store_error_num); +} + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +int spider_db_handlersocket_result::fetch_columns_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset +) { + DBUG_ENTER("spider_db_handlersocket_result::fetch_columns_for_discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +} + +int spider_db_handlersocket_result::fetch_index_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset +) { + DBUG_ENTER("spider_db_handlersocket_result::fetch_index_for_discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +} +#endif + +spider_db_handlersocket::spider_db_handlersocket( + SPIDER_CONN *conn +) : spider_db_conn(conn), + handler_open_array_inited(FALSE), + request_key_req_first(NULL), + request_key_req_last(NULL), + request_key_snd_first(NULL), + request_key_snd_last(NULL), + request_key_reuse_first(NULL), + request_key_reuse_last(NULL) +{ + DBUG_ENTER("spider_db_handlersocket::spider_db_handlersocket"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifndef HANDLERSOCKET_MYSQL_UTIL +#else + hs_conn = NULL; +#endif + DBUG_VOID_RETURN; +} + +spider_db_handlersocket::~spider_db_handlersocket() +{ + st_spider_db_request_key *tmp_request_key; + DBUG_ENTER("spider_db_handlersocket::~spider_db_handlersocket"); + DBUG_PRINT("info",("spider this=%p", this)); + if (handler_open_array_inited) + { + reset_opened_handler(); + spider_free_mem_calc(spider_current_trx, + handler_open_array_id, + handler_open_array.max_element * + handler_open_array.size_of_element); + delete_dynamic(&handler_open_array); + } + while (request_key_req_first) + { + tmp_request_key = request_key_req_first->next; + spider_free(spider_current_trx, request_key_req_first, MYF(0)); + request_key_req_first = tmp_request_key; + } + while (request_key_snd_first) + { + tmp_request_key = request_key_snd_first->next; + spider_free(spider_current_trx, request_key_snd_first, MYF(0)); + request_key_snd_first = tmp_request_key; + } + while (request_key_reuse_first) + { + tmp_request_key = request_key_reuse_first->next; + spider_free(spider_current_trx, request_key_reuse_first, MYF(0)); + request_key_reuse_first = tmp_request_key; + } + DBUG_VOID_RETURN; +} + +int spider_db_handlersocket::init() +{ + DBUG_ENTER("spider_db_handlersocket::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + SPD_INIT_DYNAMIC_ARRAY2(&handler_open_array, + sizeof(SPIDER_LINK_FOR_HASH *), NULL, 16, 16, MYF(MY_WME)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider_alloc_calc_mem_init(handler_open_array, 79); + spider_alloc_calc_mem(spider_current_trx, + handler_open_array, + handler_open_array.max_element * + handler_open_array.size_of_element); + handler_open_array_inited = TRUE; + DBUG_RETURN(0); +} + +bool spider_db_handlersocket::is_connected() +{ + DBUG_ENTER("spider_db_handlersocket::is_connected"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifndef HANDLERSOCKET_MYSQL_UTIL + DBUG_RETURN(hs_conn.operator->()); +#else + DBUG_RETURN(hs_conn); +#endif +} + +void spider_db_handlersocket::bg_connect() +{ + DBUG_ENTER("spider_db_handlersocket::bg_connect"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_handlersocket::connect( + char *tgt_host, + char *tgt_username, + char *tgt_password, + long tgt_port, + char *tgt_socket, + char *server_name, + int connect_retry_count, + longlong connect_retry_interval +) { + DBUG_ENTER("spider_db_handlersocket::connect"); + DBUG_PRINT("info",("spider this=%p", this)); + SPIDER_HS_SOCKARGS sockargs; + sockargs.timeout = conn->connect_timeout; + sockargs.recv_timeout = conn->net_read_timeout; + sockargs.send_timeout = conn->net_write_timeout; + if (conn->hs_sock) + { + sockargs.family = AF_UNIX; + sockargs.set_unix_domain(conn->hs_sock); + } else { + char port_str[6]; + my_sprintf(port_str, (port_str, "%05ld", conn->hs_port)); + if (sockargs.resolve(conn->tgt_host, port_str) != 0) + { + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), + conn->tgt_host); + DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + } + } +#ifndef HANDLERSOCKET_MYSQL_UTIL + if (!(hs_conn.operator->())) +#else + if (!(hs_conn)) +#endif + { + hs_conn = SPIDER_HS_CONN_CREATE(sockargs); + } else { + hs_conn->reconnect(); + spider_db_hs_request_buf_reset(conn); + } +#ifndef HANDLERSOCKET_MYSQL_UTIL + if (!(hs_conn.operator->())) +#else + if (!(hs_conn)) +#endif + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + while (hs_conn->get_error_code()) + { + if (!connect_retry_count) + { + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), + conn->tgt_host); + DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + } + connect_retry_count--; + my_sleep((ulong) connect_retry_interval); + hs_conn->reconnect(); + } + reset_request_key_req(); + reset_request_key_snd(); + DBUG_RETURN(0); +} + +int spider_db_handlersocket::ping() +{ + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::ping"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if ((*hs_conn_p)->reconnect()) + { + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + DBUG_RETURN(ER_SPIDER_HS_NUM); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + + reset_request_key_req(); + reset_request_key_snd(); + conn->opened_handlers = 0; + conn->db_conn->reset_opened_handler(); + ++conn->connection_id; + DBUG_RETURN(0); +} + +void spider_db_handlersocket::bg_disconnect() +{ + DBUG_ENTER("spider_db_handlersocket::bg_disconnect"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +void spider_db_handlersocket::disconnect() +{ + DBUG_ENTER("spider_db_handlersocket::disconnect"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifndef HANDLERSOCKET_MYSQL_UTIL + if (hs_conn.operator->()) +#else + DBUG_PRINT("info",("spider hs_conn=%p", hs_conn)); + if (hs_conn) +#endif + { + hs_conn->close(); +#ifndef HANDLERSOCKET_MYSQL_UTIL + SPIDER_HS_CONN tmp_hs_conn; + tmp_hs_conn = hs_conn; +#else + delete hs_conn; + hs_conn = NULL; +#endif + } + DBUG_VOID_RETURN; +} + +int spider_db_handlersocket::set_net_timeout() +{ + DBUG_ENTER("spider_db_handlersocket::set_net_timeout"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(hs_conn->set_timeout( + conn->net_write_timeout, + conn->net_read_timeout + )); +} + +int spider_db_handlersocket::exec_query( + const char *query, + uint length, + int quick_mode +) { + DBUG_ENTER("spider_db_handlersocket::query"); + DBUG_PRINT("info",("spider this=%p", this)); + SPIDER_HS_CONN *hs_conn_p = &hs_conn; +#ifndef HANDLERSOCKET_MYSQL_UTIL + DBUG_PRINT("info", ("spider hs_conn %p", hs_conn.operator->())); +#else + DBUG_PRINT("info", ("spider hs_conn %p", hs_conn)); +#endif + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if ((*hs_conn_p)->request_send() < 0) + { + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + DBUG_RETURN(ER_SPIDER_HS_NUM); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + move_request_key_to_snd(); + DBUG_RETURN(0); +} + +int spider_db_handlersocket::get_errno() +{ + DBUG_ENTER("spider_db_handlersocket::get_errno"); + DBUG_PRINT("info",("spider this=%p", this)); + stored_error = hs_conn->get_error_code(); + DBUG_PRINT("info",("spider stored_error=%d", stored_error)); + DBUG_RETURN(stored_error); +} + +const char *spider_db_handlersocket::get_error() +{ + const char *error_ptr; + DBUG_ENTER("spider_db_handlersocket::get_error"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifndef HANDLERSOCKET_MYSQL_UTIL + error_ptr = hs_conn->get_error().c_str(); +#else + error_ptr = hs_conn->get_error().c_ptr(); +#endif + DBUG_PRINT("info",("spider error=%s", error_ptr)); + DBUG_RETURN(error_ptr); +} + +bool spider_db_handlersocket::is_server_gone_error( + int error_num +) { + bool server_gone; + DBUG_ENTER("spider_db_handlersocket::is_server_gone_error"); + DBUG_PRINT("info",("spider this=%p", this)); + server_gone = (hs_conn->get_error_code() < 0); + DBUG_PRINT("info",("spider server_gone=%s", server_gone ? "TRUE" : "FALSE")); + DBUG_RETURN(server_gone); +} + +bool spider_db_handlersocket::is_dup_entry_error( + int error_num +) { + bool dup_entry; + DBUG_ENTER("spider_db_handlersocket::is_dup_entry_error"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifndef HANDLERSOCKET_MYSQL_UTIL + const char *c_str = hs_conn->get_error().c_str(); +#else + const char *c_str = hs_conn->get_error().c_ptr_safe(); +#endif + dup_entry = + ( + c_str[0] == '1' && + c_str[1] == '2' && + c_str[2] == '1' && + c_str[3] == '\0' + ); + DBUG_PRINT("info",("spider dup_entry=%s", dup_entry ? "TRUE" : "FALSE")); + DBUG_RETURN(dup_entry); +} + +bool spider_db_handlersocket::is_xa_nota_error( + int error_num +) { + bool xa_nota; + DBUG_ENTER("spider_db_handlersocket::is_xa_nota_error"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + xa_nota = (stored_error == ER_XAER_NOTA); + DBUG_PRINT("info",("spider xa_nota=%s", xa_nota ? "TRUE" : "FALSE")); + DBUG_RETURN(xa_nota); +} + +spider_db_result *spider_db_handlersocket::store_result( + spider_db_result_buffer **spider_res_buf, + st_spider_db_request_key *request_key, + int *error_num +) { + int internal_error; + spider_db_handlersocket_result *result; + spider_db_handlersocket_result_buffer *hs_res_buf; + DBUG_ENTER("spider_db_handlersocket::store_result"); + DBUG_PRINT("info",("spider this=%p", this)); + if (*spider_res_buf) + { + hs_res_buf = (spider_db_handlersocket_result_buffer *) *spider_res_buf; + } else { + if (!(hs_res_buf = new spider_db_handlersocket_result_buffer())) + { + *error_num = HA_ERR_OUT_OF_MEM; + DBUG_RETURN(NULL); + } + *spider_res_buf = (spider_db_result_buffer *) hs_res_buf; + } + hs_res_buf->clear(); + if (!(result = new spider_db_handlersocket_result())) + { + *error_num = HA_ERR_OUT_OF_MEM; + DBUG_RETURN(NULL); + } + *error_num = 0; + result->hs_conn_p = &hs_conn; + size_t num_fields; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + if (request_key) + { + int tmp_res, tmp_err = (*hs_conn_p)->get_error_code(); + while ((tmp_res = check_request_key(request_key)) == 1) + { + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if ((internal_error = (*hs_conn_p)->response_recv(num_fields))) + { + if (!tmp_err && internal_error > 0) + { + (*hs_conn_p)->clear_error(); + } else { + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); +#ifndef DBUG_OFF + if ((*hs_conn_p)->get_response_end_offset() > 0 && + (*hs_conn_p)->get_readbuf_begin()) + { + char tmp_buf[MAX_FIELD_WIDTH]; + String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); + tmp_str.length(0); + tmp_str.append((*hs_conn_p)->get_readbuf_begin(), + (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); + DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", + (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); + } +#endif + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if (internal_error > 0) + { + (*hs_conn_p)->response_buf_remove(); + if ((*hs_conn_p)->get_error_code()) + { + DBUG_PRINT("info",("spider hs %d %s", + (*hs_conn_p)->get_error_code(), + (*hs_conn_p)->get_error().ptr())); + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->clear_error(); + } + delete result; + DBUG_RETURN(NULL); + } + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->response_buf_remove(); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + } + if (tmp_res == -1) + { + DBUG_PRINT("info",("spider ER_SPIDER_REQUEST_KEY_NUM")); + *error_num = ER_SPIDER_REQUEST_KEY_NUM; + DBUG_RETURN(NULL); + } + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if ( + (internal_error = (*hs_conn_p)->response_recv(num_fields)) || + (*error_num = (*hs_conn_p)->get_result(hs_res_buf->hs_result)) + ) { + if (*error_num) + { + *error_num = HA_ERR_OUT_OF_MEM; + } + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); +#ifndef DBUG_OFF + if ((*hs_conn_p)->get_response_end_offset() > 0 && + (*hs_conn_p)->get_readbuf_begin()) + { + char tmp_buf[MAX_FIELD_WIDTH]; + String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); + tmp_str.length(0); + tmp_str.append((*hs_conn_p)->get_readbuf_begin(), + (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); + DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", + (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); + } +#endif + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if (internal_error > 0) + { + (*hs_conn_p)->response_buf_remove(); + if ((*hs_conn_p)->get_error_code()) + { + DBUG_PRINT("info",("spider hs %d %s", + (*hs_conn_p)->get_error_code(), + (*hs_conn_p)->get_error().ptr())); + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + } + delete result; + DBUG_RETURN(NULL); + } +#ifndef DBUG_OFF + if ((*hs_conn_p)->get_response_end_offset() > 0 && + (*hs_conn_p)->get_readbuf_begin()) + { + char tmp_buf[MAX_FIELD_WIDTH]; + String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); + tmp_str.length(0); + tmp_str.append((*hs_conn_p)->get_readbuf_begin(), + (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); + DBUG_PRINT("info",("spider hs readbuf02 size=%zu str=%s", + (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); + } +#endif + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->response_buf_remove(); + if ((*hs_conn_p)->get_error_code()) + { + DBUG_PRINT("info",("spider hs %d %s", + (*hs_conn_p)->get_error_code(), + (*hs_conn_p)->get_error().ptr())); + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + field_count = (uint) num_fields; + result->field_count = field_count; + DBUG_RETURN(result); +} + +spider_db_result *spider_db_handlersocket::use_result( + st_spider_db_request_key *request_key, + int *error_num +) { + int internal_error; + spider_db_handlersocket_result *result; + DBUG_ENTER("spider_db_handlersocket::use_result"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(result = new spider_db_handlersocket_result())) + { + *error_num = HA_ERR_OUT_OF_MEM; + DBUG_RETURN(NULL); + } + *error_num = 0; + result->hs_conn_p = &hs_conn; + size_t num_fields; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + if (request_key) + { + int tmp_res, tmp_err = (*hs_conn_p)->get_error_code(); + while ((tmp_res = check_request_key(request_key)) == 1) + { + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if ((internal_error = (*hs_conn_p)->response_recv(num_fields))) + { + if (!tmp_err && internal_error > 0) + { + (*hs_conn_p)->clear_error(); + } else { + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); +#ifndef DBUG_OFF + if ((*hs_conn_p)->get_response_end_offset() > 0 && + (*hs_conn_p)->get_readbuf_begin()) + { + char tmp_buf[MAX_FIELD_WIDTH]; + String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); + tmp_str.length(0); + tmp_str.append((*hs_conn_p)->get_readbuf_begin(), + (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); + DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", + (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); + } +#endif + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if (internal_error > 0) + { + (*hs_conn_p)->response_buf_remove(); + if ((*hs_conn_p)->get_error_code()) + { + DBUG_PRINT("info",("spider hs %d %s", + (*hs_conn_p)->get_error_code(), + (*hs_conn_p)->get_error().ptr())); + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->clear_error(); + } + delete result; + DBUG_RETURN(NULL); + } + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->response_buf_remove(); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + } + if (tmp_res == -1) + { + DBUG_PRINT("info",("spider ER_SPIDER_REQUEST_KEY_NUM")); + *error_num = ER_SPIDER_REQUEST_KEY_NUM; + DBUG_RETURN(NULL); + } + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if ( + (internal_error = (*hs_conn_p)->response_recv(num_fields)) + ) { + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); +#ifndef DBUG_OFF + if ((*hs_conn_p)->get_response_end_offset() > 0 && + (*hs_conn_p)->get_readbuf_begin()) + { + char tmp_buf[MAX_FIELD_WIDTH]; + String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); + tmp_str.length(0); + tmp_str.append((*hs_conn_p)->get_readbuf_begin(), + (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); + DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", + (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); + } +#endif + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if (internal_error > 0) + { + (*hs_conn_p)->response_buf_remove(); + if ((*hs_conn_p)->get_error_code()) + { + DBUG_PRINT("info",("spider hs %d %s", + (*hs_conn_p)->get_error_code(), + (*hs_conn_p)->get_error().ptr())); + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + } + delete result; + DBUG_RETURN(NULL); + } +#ifndef DBUG_OFF + if ((*hs_conn_p)->get_response_end_offset() > 0 && + (*hs_conn_p)->get_readbuf_begin()) + { + char tmp_buf[MAX_FIELD_WIDTH]; + String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); + tmp_str.length(0); + tmp_str.append((*hs_conn_p)->get_readbuf_begin(), + (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); + DBUG_PRINT("info",("spider hs readbuf02 size=%zu str=%s", + (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); + } +#endif + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + field_count = (uint) num_fields; + result->field_count = field_count; + DBUG_RETURN(result); +} + +int spider_db_handlersocket::next_result() +{ + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::next_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + if ((*hs_conn_p)->stable_point()) + DBUG_RETURN(-1); + DBUG_RETURN(0); +} + +uint spider_db_handlersocket::affected_rows() +{ + int error_num; + const SPIDER_HS_STRING_REF *hs_row; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::affected_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + if ( + field_count != 1 || + !(hs_row = (*hs_conn_p)->get_next_row()) || + !hs_row->begin() + ) { + DBUG_RETURN(0); + } + DBUG_RETURN((uint) my_strtoll10(hs_row->begin(), (char**) NULL, &error_num)); +} + +ulonglong spider_db_handlersocket::last_insert_id() +{ + DBUG_ENTER("spider_db_handlersocket::last_insert_id"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_db_handlersocket::set_character_set( + const char *csname +) { + DBUG_ENTER("spider_db_handlersocket::set_character_set"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::select_db( + const char *dbname +) { + DBUG_ENTER("spider_db_handlersocket::select_db"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::consistent_snapshot( + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::consistent_snapshot"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +bool spider_db_handlersocket::trx_start_in_bulk_sql() +{ + DBUG_ENTER("spider_db_handlersocket::trx_start_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_handlersocket::start_transaction( + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::start_transaction"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::commit( + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::commit"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::rollback( + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::rollback"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +bool spider_db_handlersocket::xa_start_in_bulk_sql() +{ + DBUG_ENTER("spider_db_handlersocket::xa_start_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_handlersocket::xa_start( + XID *xid, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::xa_start"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::xa_end( + XID *xid, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::xa_end"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::xa_prepare( + XID *xid, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::xa_prepare"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::xa_commit( + XID *xid, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::xa_commit"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::xa_rollback( + XID *xid, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::xa_rollback"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +bool spider_db_handlersocket::set_trx_isolation_in_bulk_sql() +{ + DBUG_ENTER("spider_db_handlersocket::set_trx_isolation_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_handlersocket::set_trx_isolation( + int trx_isolation, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::set_trx_isolation"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +bool spider_db_handlersocket::set_autocommit_in_bulk_sql() +{ + DBUG_ENTER("spider_db_handlersocket::set_autocommit_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_handlersocket::set_autocommit( + bool autocommit, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::set_autocommit"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +bool spider_db_handlersocket::set_sql_log_off_in_bulk_sql() +{ + DBUG_ENTER("spider_db_handlersocket::set_sql_log_off_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_handlersocket::set_sql_log_off( + bool sql_log_off, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::set_sql_log_off"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +bool spider_db_handlersocket::set_time_zone_in_bulk_sql() +{ + DBUG_ENTER("spider_db_handlersocket::set_time_zone_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_handlersocket::set_time_zone( + Time_zone *time_zone, + int *need_mon +) { + DBUG_ENTER("spider_db_handlersocket::set_time_zone"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket::append_sql( + char *sql, + ulong sql_length, + st_spider_db_request_key *request_key +) { + int error_num; + size_t req_num; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::append_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = append_request_key(request_key))) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + if (!(req_num = (*hs_conn_p)->request_buf_append(sql, sql + sql_length))) + { + DBUG_PRINT("info",("spider hs %d %s", + (*hs_conn_p)->get_error_code(), + (*hs_conn_p)->get_error().ptr())); + (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); + DBUG_RETURN((*hs_conn_p)->get_error_code()); + } + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + while (req_num > 1) + { + if ((error_num = append_request_key(request_key))) + DBUG_RETURN(error_num); + --req_num; + } + DBUG_RETURN(0); +} + +int spider_db_handlersocket::append_open_handler( + uint handler_id, + const char *db_name, + const char *table_name, + const char *index_name, + const char *sql, + st_spider_db_request_key *request_key +) { + int error_num; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::append_open_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = append_request_key(request_key))) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->request_buf_open_index( + handler_id, + db_name, + table_name, + index_name, + sql + ); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + DBUG_RETURN(0); +} + +int spider_db_handlersocket::append_select( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key +) { + int error_num; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::append_select"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = append_request_key(request_key))) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->request_buf_exec_generic( + handler_id, + SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), + keys->ptr(), (size_t) keys->size(), + limit, skip, + SPIDER_HS_STRING_REF(), + NULL, 0); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + DBUG_RETURN(0); +} + +int spider_db_handlersocket::append_insert( + uint handler_id, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + st_spider_db_request_key *request_key +) { + int error_num; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::append_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = append_request_key(request_key))) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->request_buf_exec_generic( + handler_id, + SPIDER_HS_STRING_REF(SPIDER_SQL_HS_INSERT_STR, SPIDER_SQL_HS_INSERT_LEN), + upds->ptr(), (size_t) upds->size(), + 0, 0, + SPIDER_HS_STRING_REF(), NULL, 0); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + DBUG_RETURN(0); +} + +int spider_db_handlersocket::append_update( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + int limit, + int skip, + bool increment, + bool decrement, + st_spider_db_request_key *request_key +) { + int error_num; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = append_request_key(request_key))) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->request_buf_exec_generic( + handler_id, + SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), + keys->ptr(), (size_t) keys->size(), + limit, skip, + increment ? + SPIDER_HS_STRING_REF(SPIDER_SQL_HS_INCREMENT_STR, + SPIDER_SQL_HS_INCREMENT_LEN) : + decrement ? + SPIDER_HS_STRING_REF(SPIDER_SQL_HS_DECREMENT_STR, + SPIDER_SQL_HS_DECREMENT_LEN) : + SPIDER_HS_STRING_REF(SPIDER_SQL_HS_UPDATE_STR, + SPIDER_SQL_HS_UPDATE_LEN), + upds->ptr(), (size_t) upds->size() + ); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + DBUG_RETURN(0); +} + +int spider_db_handlersocket::append_delete( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key +) { + int error_num; + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = append_request_key(request_key))) + DBUG_RETURN(error_num); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->request_buf_exec_generic( + handler_id, + SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), + keys->ptr(), (size_t) keys->size(), + limit, skip, + SPIDER_HS_STRING_REF(SPIDER_SQL_HS_DELETE_STR, SPIDER_SQL_HS_DELETE_LEN), + NULL, 0); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + DBUG_RETURN(0); +} + +void spider_db_handlersocket::reset_request_queue() +{ + SPIDER_HS_CONN *hs_conn_p = &hs_conn; + DBUG_ENTER("spider_db_handlersocket::reset_request_queue"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + (*hs_conn_p)->request_reset(); + DBUG_PRINT("info",("spider hs num_req_bufd=%zu", + (*hs_conn_p)->get_num_req_bufd())); + DBUG_PRINT("info",("spider hs num_req_sent=%zu", + (*hs_conn_p)->get_num_req_sent())); + DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", + (*hs_conn_p)->get_num_req_rcvd())); + DBUG_PRINT("info",("spider hs response_end_offset=%zu", + (*hs_conn_p)->get_response_end_offset())); + reset_request_key_req(); + DBUG_VOID_RETURN; +} + +size_t spider_db_handlersocket::escape_string( + char *to, + const char *from, + size_t from_length +) { + DBUG_ENTER("spider_db_handlersocket::escape_string"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + memcpy(to, from, from_length); + DBUG_RETURN(from_length); +} + +bool spider_db_handlersocket::have_lock_table_list() +{ + DBUG_ENTER("spider_db_handlersocket::have_lock_table_list"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_handlersocket::append_lock_tables( + spider_string *str +) { + DBUG_ENTER("spider_db_handlersocket::lock_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_db_handlersocket::append_unlock_tables( + spider_string *str +) { + DBUG_ENTER("spider_db_handlersocket::append_unlock_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +uint spider_db_handlersocket::get_lock_table_hash_count() +{ + DBUG_ENTER("spider_db_handlersocket::get_lock_table_hash_count"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +void spider_db_handlersocket::reset_lock_table_hash() +{ + DBUG_ENTER("spider_db_handlersocket::reset_lock_table_hash"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +uint spider_db_handlersocket::get_opened_handler_count() +{ + DBUG_ENTER("spider_db_handlersocket::get_opened_handler_count"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(handler_open_array.elements); +} + +void spider_db_handlersocket::reset_opened_handler() +{ + ha_spider *tmp_spider; + int tmp_link_idx; + SPIDER_LINK_FOR_HASH **tmp_link_for_hash; + DBUG_ENTER("spider_db_handlersocket::reset_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + while ((tmp_link_for_hash = + (SPIDER_LINK_FOR_HASH **) pop_dynamic(&handler_open_array))) + { + tmp_spider = (*tmp_link_for_hash)->spider; + tmp_link_idx = (*tmp_link_for_hash)->link_idx; + tmp_spider->clear_handler_opened(tmp_link_idx, conn->conn_kind); + } + DBUG_VOID_RETURN; +} + +void spider_db_handlersocket::set_dup_key_idx( + ha_spider *spider, + int link_idx +) { + DBUG_ENTER("spider_db_handlersocket::set_dup_key_idx"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +int spider_db_handlersocket::append_request_key( + st_spider_db_request_key *request_key +) { + st_spider_db_request_key *tmp_request_key; + DBUG_ENTER("spider_db_handlersocket::append_request_key"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider request_key=%p", request_key)); + if (request_key) + { + DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", + request_key->spider_thread_id)); + DBUG_PRINT("info",("spider request_key->query_id=%llu", + request_key->query_id)); + DBUG_PRINT("info",("spider request_key->handler=%p", + request_key->handler)); + DBUG_PRINT("info",("spider request_key->request_id=%llu", + request_key->request_id)); + if (request_key_reuse_first) + { + tmp_request_key = request_key_reuse_first; + request_key_reuse_first = request_key_reuse_first->next; + if (!request_key_reuse_first) + request_key_reuse_last = NULL; + } else { + if (!(tmp_request_key = (st_spider_db_request_key *) + spider_malloc(spider_current_trx, 1, sizeof(st_spider_db_request_key), + MYF(MY_WME))) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + *tmp_request_key = *request_key; + tmp_request_key->next = NULL; + if (request_key_req_last) + request_key_req_last->next = tmp_request_key; + else + request_key_req_first = tmp_request_key; + request_key_req_last = tmp_request_key; + } + DBUG_RETURN(0); +} + +void spider_db_handlersocket::reset_request_key_req() +{ + DBUG_ENTER("spider_db_handlersocket::reset_request_key_req"); + DBUG_PRINT("info",("spider this=%p", this)); + if (request_key_req_first) + { + if (request_key_reuse_last) + request_key_reuse_last->next = request_key_req_first; + else + request_key_reuse_first = request_key_req_first; + request_key_reuse_last = request_key_req_last; + request_key_req_first = NULL; + request_key_req_last = NULL; + } + DBUG_VOID_RETURN; +} + +void spider_db_handlersocket::reset_request_key_snd() +{ + DBUG_ENTER("spider_db_handlersocket::reset_request_key_snd"); + DBUG_PRINT("info",("spider this=%p", this)); + if (request_key_snd_first) + { + if (request_key_reuse_last) + request_key_reuse_last->next = request_key_snd_first; + else + request_key_reuse_first = request_key_snd_first; + request_key_reuse_last = request_key_snd_last; + request_key_snd_first = NULL; + request_key_snd_last = NULL; + } + DBUG_VOID_RETURN; +} + +void spider_db_handlersocket::move_request_key_to_snd() +{ + DBUG_ENTER("spider_db_handlersocket::move_request_key_to_snd"); + DBUG_PRINT("info",("spider this=%p", this)); + if (request_key_req_first) + { + if (request_key_snd_last) + request_key_snd_last->next = request_key_req_first; + else + request_key_snd_first = request_key_req_first; + request_key_snd_last = request_key_req_last; + request_key_req_first = NULL; + request_key_req_last = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_db_handlersocket::check_request_key( + st_spider_db_request_key *request_key +) { + st_spider_db_request_key *tmp_request_key; + DBUG_ENTER("spider_db_handlersocket::check_request_key"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider request_key=%p", request_key)); + DBUG_PRINT("info",("spider request_key_snd_first=%p", + request_key_snd_first)); + if (!request_key_snd_first) + { + DBUG_PRINT("info",("spider -1")); + DBUG_RETURN(-1); + } + tmp_request_key = request_key_snd_first; + request_key_snd_first = request_key_snd_first->next; + if (!request_key_snd_first) + request_key_snd_last = NULL; + tmp_request_key->next = NULL; + if (request_key_reuse_last) + request_key_reuse_last->next = tmp_request_key; + else + request_key_reuse_first = tmp_request_key; + request_key_reuse_last = tmp_request_key; + + DBUG_PRINT("info",("spider tmp_request_key->spider_thread_id=%llu", + tmp_request_key->spider_thread_id)); + DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", + request_key->spider_thread_id)); + DBUG_PRINT("info",("spider tmp_request_key->query_id=%llu", + tmp_request_key->query_id)); + DBUG_PRINT("info",("spider request_key->query_id=%llu", + request_key->query_id)); + DBUG_PRINT("info",("spider tmp_request_key->handler=%p", + tmp_request_key->handler)); + DBUG_PRINT("info",("spider request_key->handler=%p", + request_key->handler)); + DBUG_PRINT("info",("spider tmp_request_key->request_id=%llu", + tmp_request_key->request_id)); + DBUG_PRINT("info",("spider request_key->request_id=%llu", + request_key->request_id)); + if ( + tmp_request_key->spider_thread_id != request_key->spider_thread_id || + tmp_request_key->query_id != request_key->query_id || + tmp_request_key->handler != request_key->handler || + tmp_request_key->request_id != request_key->request_id + ) { + DBUG_PRINT("info",("spider 1")); + DBUG_RETURN(1); + } + DBUG_PRINT("info",("spider 0")); + DBUG_RETURN(0); +} + +bool spider_db_handlersocket::cmp_request_key_to_snd( + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_handlersocket::cmp_request_key_to_snd"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider request_key=%p", request_key)); + if ( + !request_key + ) { + DBUG_PRINT("info",("spider TRUE")); + DBUG_RETURN(TRUE); + } + DBUG_PRINT("info",("spider request_key_snd_first=%p", + request_key_snd_first)); + if ( + !request_key_snd_first + ) { + DBUG_PRINT("info",("spider FALSE")); + DBUG_RETURN(FALSE); + } + DBUG_PRINT("info",("spider request_key_snd_first->spider_thread_id=%llu", + request_key_snd_first->spider_thread_id)); + DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", + request_key->spider_thread_id)); + DBUG_PRINT("info",("spider request_key_snd_first->query_id=%llu", + request_key_snd_first->query_id)); + DBUG_PRINT("info",("spider request_key->query_id=%llu", + request_key->query_id)); + DBUG_PRINT("info",("spider request_key_snd_first->handler=%p", + request_key_snd_first->handler)); + DBUG_PRINT("info",("spider request_key->handler=%p", + request_key->handler)); + DBUG_PRINT("info",("spider request_key_snd_first->request_id=%llu", + request_key_snd_first->request_id)); + DBUG_PRINT("info",("spider request_key->request_id=%llu", + request_key->request_id)); + if ( + request_key_snd_first->spider_thread_id != request_key->spider_thread_id || + request_key_snd_first->query_id != request_key->query_id || + request_key_snd_first->handler != request_key->handler || + request_key_snd_first->request_id != request_key->request_id + ) { + DBUG_PRINT("info",("spider FALSE")); + DBUG_RETURN(FALSE); + } + DBUG_PRINT("info",("spider TRUE")); + DBUG_RETURN(TRUE); +} + +spider_db_handlersocket_util::spider_db_handlersocket_util() : spider_db_util() +{ + DBUG_ENTER("spider_db_handlersocket_util::spider_db_handlersocket_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_handlersocket_util::~spider_db_handlersocket_util() +{ + DBUG_ENTER("spider_db_handlersocket_util::~spider_db_handlersocket_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_handlersocket_util::append_name( + spider_string *str, + const char *name, + uint name_length +) { + DBUG_ENTER("spider_db_handlersocket_util::append_name"); + str->q_append(name, name_length); + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_name_with_charset( + spider_string *str, + const char *name, + uint name_length, + CHARSET_INFO *name_charset +) { + DBUG_ENTER("spider_db_handlersocket_util::append_name_with_charset"); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->append(name, name_length, name_charset); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + DBUG_RETURN(0); +} + +bool spider_db_handlersocket_util::is_name_quote( + const char head_code +) { + DBUG_ENTER("spider_db_handlersocket_util::is_name_quote"); + DBUG_RETURN(head_code == *name_quote_str); +} + +int spider_db_handlersocket_util::append_escaped_name_quote( + spider_string *str +) { + DBUG_ENTER("spider_db_handlersocket_util::append_escaped_name_quote"); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_column_value( + ha_spider *spider, + spider_string *str, + Field *field, + const uchar *new_ptr, + CHARSET_INFO *access_charset +) { + char buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin); + String *ptr; + uint length; + DBUG_ENTER("spider_db_handlersocket_util::append_column_value"); + tmp_str.init_calc_mem(180); + + if (new_ptr) + { + if ( + field->type() == MYSQL_TYPE_BLOB || + field->real_type() == MYSQL_TYPE_VARCHAR + ) { + length = uint2korr(new_ptr); + tmp_str.set_quick((char *) new_ptr + HA_KEY_BLOB_LENGTH, length, + &my_charset_bin); + ptr = tmp_str.get_str(); + } else if (field->type() == MYSQL_TYPE_GEOMETRY) + { +/* + uint mlength = SIZEOF_STORED_DOUBLE, lcnt; + uchar *dest = (uchar *) buf; + const uchar *source; + for (lcnt = 0; lcnt < 4; lcnt++) + { + mlength = SIZEOF_STORED_DOUBLE; + source = new_ptr + mlength + SIZEOF_STORED_DOUBLE * lcnt; + while (mlength--) + *dest++ = *--source; + } + tmp_str.length(SIZEOF_STORED_DOUBLE * lcnt); +*/ + double xmin, xmax, ymin, ymax; +/* + float8store(buf,xmin); + float8store(buf+8,xmax); + float8store(buf+16,ymin); + float8store(buf+24,ymax); + memcpy(&xmin,new_ptr,sizeof(xmin)); + memcpy(&xmax,new_ptr + 8,sizeof(xmax)); + memcpy(&ymin,new_ptr + 16,sizeof(ymin)); + memcpy(&ymax,new_ptr + 24,sizeof(ymax)); + float8get(xmin, buf); + float8get(xmax, buf + 8); + float8get(ymin, buf + 16); + float8get(ymax, buf + 24); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + DBUG_PRINT("info", ("spider geo is %.14g %.14g %.14g %.14g", + xmin, xmax, ymin, ymax)); +*/ + float8get(xmin, new_ptr); + float8get(xmax, new_ptr + 8); + float8get(ymin, new_ptr + 16); + float8get(ymax, new_ptr + 24); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); +/* + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 4); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 5); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 6); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 7); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 8); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 9); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 10); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 11); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 12); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 13); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 14); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 15); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); +*/ +/* + tmp_str.set_quick((char *) new_ptr, SIZEOF_STORED_DOUBLE * 4, + &my_charset_bin); +*/ + tmp_str.length(0); + tmp_str.q_append((char *) SPIDER_SQL_LINESTRING_HEAD_STR, + SPIDER_SQL_LINESTRING_HEAD_LEN); + tmp_str.q_append((char *) new_ptr, SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 2, + SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE, + SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 3, + SIZEOF_STORED_DOUBLE); + ptr = tmp_str.get_str(); + } else { + ptr = field->val_str(tmp_str.get_str(), new_ptr); + tmp_str.mem_calc(); + } + } else { + ptr = field->val_str(tmp_str.get_str()); + tmp_str.mem_calc(); + } + DBUG_PRINT("info", ("spider field->type() is %d", field->type())); + DBUG_PRINT("info", ("spider ptr->length() is %d", ptr->length())); +/* + if ( + field->type() == MYSQL_TYPE_BIT || + (field->type() >= MYSQL_TYPE_TINY_BLOB && + field->type() <= MYSQL_TYPE_BLOB) + ) { + uchar *hex_ptr = (uchar *) ptr->ptr(), *end_ptr; + char *str_ptr; + DBUG_PRINT("info", ("spider HEX")); + if (str->reserve(SPIDER_SQL_HEX_LEN + ptr->length() * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HEX_STR, SPIDER_SQL_HEX_LEN); + str_ptr = (char *) str->ptr() + str->length(); + for (end_ptr = hex_ptr + ptr->length(); hex_ptr < end_ptr; hex_ptr++) + { + *str_ptr++ = spider_dig_upper[(*hex_ptr) >> 4]; + *str_ptr++ = spider_dig_upper[(*hex_ptr) & 0x0F]; + } + str->length(str->length() + ptr->length() * 2); + } else +*/ + spider_handlersocket_handler *hs_handler = (spider_handlersocket_handler *) + spider->dbton_handler[spider_dbton_handlersocket.dbton_id]; + spider_string *hs_str; + if (!(hs_str = hs_handler->hs_strs.add( + &hs_handler->hs_strs_pos, ptr->ptr(), ptr->length()))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + SPIDER_HS_STRING_REF ref = + SPIDER_HS_STRING_REF(hs_str->ptr(), hs_str->length()); + if (hs_handler->hs_adding_keys) + { + DBUG_PRINT("info", ("spider add to key:%s", hs_str->c_ptr_safe())); + hs_handler->hs_keys.push_back(ref); + } else { + DBUG_PRINT("info", ("spider add to upd:%s", hs_str->c_ptr_safe())); + hs_handler->hs_upds.push_back(ref); + } + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_trx_isolation( + spider_string *str, + int trx_isolation +) { + DBUG_ENTER("spider_db_handlersocket_util::append_trx_isolation"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_autocommit( + spider_string *str, + bool autocommit +) { + DBUG_ENTER("spider_db_handlersocket_util::append_autocommit"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_sql_log_off( + spider_string *str, + bool sql_log_off +) { + DBUG_ENTER("spider_db_handlersocket_util::append_sql_log_off"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_time_zone( + spider_string *str, + Time_zone *time_zone +) { + DBUG_ENTER("spider_db_handlersocket_util::append_time_zone"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_start_transaction( + spider_string *str +) { + DBUG_ENTER("spider_db_handlersocket_util::append_start_transaction"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_xa_start( + spider_string *str, + XID *xid +) { + DBUG_ENTER("spider_db_handlersocket_util::append_xa_start"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_lock_table_head( + spider_string *str +) { + DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_head"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_lock_table_body( + spider_string *str, + const char *db_name, + uint db_name_length, + CHARSET_INFO *db_name_charset, + const char *table_name, + uint table_name_length, + CHARSET_INFO *table_name_charset, + int lock_type +) { + DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_body"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_lock_table_tail( + spider_string *str +) { + DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_tail"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_unlock_table( + spider_string *str +) { + DBUG_ENTER("spider_db_handlersocket_util::append_unlock_table"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length +) { + uint dbton_id = spider_dbton_handlersocket.dbton_id; + int error_num; + Item *item, **item_list = item_func->arguments(); + uint roop_count, item_count = item_func->argument_count(), start_item = 0; + const char *func_name = SPIDER_SQL_NULL_CHAR_STR, + *separete_str = SPIDER_SQL_NULL_CHAR_STR, + *last_str = SPIDER_SQL_NULL_CHAR_STR; + int func_name_length = SPIDER_SQL_NULL_CHAR_LEN, + separete_str_length = SPIDER_SQL_NULL_CHAR_LEN, + last_str_length = SPIDER_SQL_NULL_CHAR_LEN; + int use_pushdown_udf; + DBUG_ENTER("spider_db_handlersocket_util::open_item_func"); + if (str) + { + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + DBUG_PRINT("info",("spider functype = %d", item_func->functype())); + switch (item_func->functype()) + { + case Item_func::ISNULL_FUNC: + last_str = SPIDER_SQL_IS_NULL_STR; + last_str_length = SPIDER_SQL_IS_NULL_LEN; + break; + case Item_func::ISNOTNULL_FUNC: + last_str = SPIDER_SQL_IS_NOT_NULL_STR; + last_str_length = SPIDER_SQL_IS_NOT_NULL_LEN; + break; + case Item_func::UNKNOWN_FUNC: + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (func_name_length == 1 && + ( + !strncasecmp("+", func_name, func_name_length) || + !strncasecmp("-", func_name, func_name_length) || + !strncasecmp("*", func_name, func_name_length) || + !strncasecmp("/", func_name, func_name_length) || + !strncasecmp("%", func_name, func_name_length) || + !strncasecmp("&", func_name, func_name_length) || + !strncasecmp("|", func_name, func_name_length) || + !strncasecmp("^", func_name, func_name_length) + ) + ) { + /* no action */ + break; + } else if (func_name_length == 2 && + ( + !strncasecmp("<<", func_name, func_name_length) || + !strncasecmp(">>", func_name, func_name_length) + ) + ) { + /* no action */ + break; + } else if (func_name_length == 3 && + !strncasecmp("div", func_name, func_name_length) + ) { + /* no action */ + break; + } else if (func_name_length == 4) + { + if ( + !strncasecmp("rand", func_name, func_name_length) && + !item_func->arg_count + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if ( + !strncasecmp("case", func_name, func_name_length) + ) { +#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC + Item_func_case *item_func_case = (Item_func_case *) item_func; + if (str) + { + if (str->reserve(SPIDER_SQL_CASE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN); + } + if (item_func_case->first_expr_num != -1) + { + if ((error_num = spider_db_print_item_type( + item_list[item_func_case->first_expr_num], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + for (roop_count = 0; roop_count < item_func_case->ncases; + roop_count += 2) + { + if (str) + { + if (str->reserve(SPIDER_SQL_WHEN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[roop_count], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_THEN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[roop_count + 1], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (item_func_case->else_expr_num != -1) + { + if (str) + { + if (str->reserve(SPIDER_SQL_ELSE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[item_func_case->else_expr_num], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +#else + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); +#endif + } + } else if (func_name_length == 6 && + !strncasecmp("istrue", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_TRUE_STR; + last_str_length = SPIDER_SQL_IS_TRUE_LEN; + break; + } else if (func_name_length == 7) + { + if (!strncasecmp("isfalse", func_name, func_name_length)) + { + last_str = SPIDER_SQL_IS_FALSE_STR; + last_str_length = SPIDER_SQL_IS_FALSE_LEN; + break; + } else if ( + !strncasecmp("sysdate", func_name, func_name_length) || + !strncasecmp("curdate", func_name, func_name_length) || + !strncasecmp("curtime", func_name, func_name_length) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if ( + !strncasecmp("convert", func_name, func_name_length) + ) { + if (str) + { + if (str->reserve(func_name_length * 2 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, + SPIDER_SQL_OPEN_PAREN_LEN); + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } + } else if (func_name_length == 8 && + ( + !strncasecmp("utc_date", func_name, func_name_length) || + !strncasecmp("utc_time", func_name, func_name_length) + ) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if (func_name_length == 9 && + !strncasecmp("isnottrue", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_NOT_TRUE_STR; + last_str_length = SPIDER_SQL_IS_NOT_TRUE_LEN; + break; + } else if (func_name_length == 10 && + !strncasecmp("isnotfalse", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_NOT_FALSE_STR; + last_str_length = SPIDER_SQL_IS_NOT_FALSE_LEN; + break; + } else if (func_name_length == 12) + { + if (!strncasecmp("cast_as_date", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_DATE_STR; + last_str_length = SPIDER_SQL_AS_DATE_LEN; + break; + } else if (!strncasecmp("cast_as_time", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_TIME_STR; + last_str_length = SPIDER_SQL_AS_TIME_LEN; + break; + } + } else if (func_name_length == 13 && + !strncasecmp("utc_timestamp", func_name, func_name_length) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if (func_name_length == 14) + { + if (!strncasecmp("cast_as_binary", func_name, func_name_length)) + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(123); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_BINARY_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } else if (!strncasecmp("cast_as_signed", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_SIGNED_STR; + last_str_length = SPIDER_SQL_AS_SIGNED_LEN; + break; + } + } else if (func_name_length == 16) + { + if (!strncasecmp("cast_as_unsigned", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_UNSIGNED_STR; + last_str_length = SPIDER_SQL_AS_UNSIGNED_LEN; + break; + } else if (!strncasecmp("decimal_typecast", func_name, + func_name_length)) + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(124); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_DECIMAL_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } else if (!strncasecmp("cast_as_datetime", func_name, + func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_DATETIME_STR; + last_str_length = SPIDER_SQL_AS_DATETIME_LEN; + break; + } + } else if (func_name_length == 17) + { + if (!strncasecmp("date_add_interval", func_name, func_name_length)) + { + Item_date_add_interval *item_date_add_interval = + (Item_date_add_interval *) item_func; + func_name = spider_db_timefunc_interval_str[ + item_date_add_interval->int_type]; + func_name_length = strlen(func_name); + if ((error_num = spider_db_print_item_type(item_list[0], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (item_date_add_interval->date_sub_interval) + { + if (str->reserve(SPIDER_SQL_NEGINTERVAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NEGINTERVAL_STR, + SPIDER_SQL_NEGINTERVAL_LEN); + } else { + if (str->reserve(SPIDER_SQL_INTERVAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_INTERVAL_STR, SPIDER_SQL_INTERVAL_LEN); + } + } + if ((error_num = spider_db_print_item_type(item_list[1], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(func_name_length + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); + } + } + if (str) + { + if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::NOW_FUNC: + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::CHAR_TYPECAST_FUNC: + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(125); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_CHAR_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + } + break; + case Item_func::NOT_FUNC: + case Item_func::NEG_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + break; + case Item_func::IN_FUNC: + if (((Item_func_opt_neg *) item_func)->negated) + { + func_name = SPIDER_SQL_NOT_IN_STR; + func_name_length = SPIDER_SQL_NOT_IN_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } else { + func_name = SPIDER_SQL_IN_STR; + func_name_length = SPIDER_SQL_IN_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + case Item_func::BETWEEN: + if (((Item_func_opt_neg *) item_func)->negated) + { + func_name = SPIDER_SQL_NOT_BETWEEN_STR; + func_name_length = SPIDER_SQL_NOT_BETWEEN_LEN; + separete_str = SPIDER_SQL_AND_STR; + separete_str_length = SPIDER_SQL_AND_LEN; + } else { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + separete_str = SPIDER_SQL_AND_STR; + separete_str_length = SPIDER_SQL_AND_LEN; + } + break; + case Item_func::UDF_FUNC: + use_pushdown_udf = spider_param_use_pushdown_udf(spider->trx->thd, + spider->share->use_pushdown_udf); + if (!use_pushdown_udf) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; +#ifdef MARIADB_BASE_VERSION + case Item_func::XOR_FUNC: +#else + case Item_func::COND_XOR_FUNC: +#endif + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN( + spider_db_open_item_cond((Item_cond *) item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::TRIG_COND_FUNC: + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + case Item_func::GUSERVAR_FUNC: + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (item_func->result_type() == STRING_RESULT) + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + else + DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::FT_FUNC: + if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + start_item = 1; + if (str) + { + if (str->reserve(SPIDER_SQL_MATCH_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); + } + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::SP_EQUALS_FUNC: + if (str) + { + func_name = SPIDER_SQL_MBR_EQUAL_STR; + func_name_length = SPIDER_SQL_MBR_EQUAL_LEN; + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(func_name_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::SP_DISJOINT_FUNC: + case Item_func::SP_INTERSECTS_FUNC: + case Item_func::SP_TOUCHES_FUNC: + case Item_func::SP_CROSSES_FUNC: + case Item_func::SP_WITHIN_FUNC: + case Item_func::SP_CONTAINS_FUNC: + case Item_func::SP_OVERLAPS_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(SPIDER_SQL_MBR_LEN + func_name_length + + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::EQ_FUNC: + case Item_func::EQUAL_FUNC: + case Item_func::NE_FUNC: + case Item_func::LT_FUNC: + case Item_func::LE_FUNC: + case Item_func::GE_FUNC: + case Item_func::GT_FUNC: + case Item_func::LIKE_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + } + break; + default: + THD *thd = spider->trx->thd; + SPIDER_SHARE *share = spider->share; + if (spider_param_skip_default_condition(thd, + share->skip_default_condition)) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + } + break; + } + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + DBUG_PRINT("info",("spider separete_str = %s", separete_str)); + DBUG_PRINT("info",("spider separete_str_length = %d", separete_str_length)); + DBUG_PRINT("info",("spider last_str = %s", last_str)); + DBUG_PRINT("info",("spider last_str_length = %d", last_str_length)); + if (item_count) + { + item_count--; + for (roop_count = start_item; roop_count < item_count; roop_count++) + { + item = item_list[roop_count]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (roop_count == 1) + { + func_name = separete_str; + func_name_length = separete_str_length; + } + if (str) + { + if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + } + item = item_list[roop_count]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (item_func->functype() == Item_func::FT_FUNC) + { + Item_func_match *item_func_match = (Item_func_match *)item_func; + if (str) + { + if (str->reserve(SPIDER_SQL_AGAINST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); + } + item = item_list[0]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve( + ((item_func_match->flags & FT_BOOL) ? + SPIDER_SQL_IN_BOOLEAN_MODE_LEN : 0) + + ((item_func_match->flags & FT_EXPAND) ? + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN : 0) + )) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (item_func_match->flags & FT_BOOL) + str->q_append(SPIDER_SQL_IN_BOOLEAN_MODE_STR, + SPIDER_SQL_IN_BOOLEAN_MODE_LEN); + if (item_func_match->flags & FT_EXPAND) + str->q_append(SPIDER_SQL_WITH_QUERY_EXPANSION_STR, + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN); + } + } else if (item_func->functype() == Item_func::UNKNOWN_FUNC) + { + if ( + func_name_length == 7 && + !strncasecmp("convert", func_name, func_name_length) + ) { + if (str) + { + Item_func_conv_charset *item_func_conv_charset = + (Item_func_conv_charset *)item_func; + CHARSET_INFO *conv_charset = item_func_conv_charset->conv_charset; + uint cset_length = strlen(conv_charset->csname); + if (str->reserve(SPIDER_SQL_USING_LEN + cset_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_USING_STR, SPIDER_SQL_USING_LEN); + str->q_append(conv_charset->csname, cset_length); + } + } + } + if (str) + { + if (str->reserve(last_str_length + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(last_str, last_str_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +} + +int spider_db_handlersocket_util::append_escaped_util( + spider_string *to, + String *from +) { + DBUG_ENTER("spider_db_handlersocket_util::append_escaped_util"); + DBUG_PRINT("info",("spider this=%p", this)); + append_escaped(to->get_str(), from); + to->mem_calc(); + DBUG_RETURN(0); +} + +spider_handlersocket_share::spider_handlersocket_share( + st_spider_share *share +) : spider_db_share( + share +), + table_names_str(NULL), + db_names_str(NULL), + db_table_str(NULL), +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + db_table_str_hash_value(NULL), +#endif + table_nm_max_length(0), + db_nm_max_length(0), + column_name_str(NULL), + same_db_table_name(TRUE), + first_all_link_idx(-1) +{ + DBUG_ENTER("spider_handlersocket_share::spider_handlersocket_share"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_alloc_calc_mem_init(mem_calc, 186); + spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); + DBUG_VOID_RETURN; +} + +spider_handlersocket_share::~spider_handlersocket_share() +{ + DBUG_ENTER("spider_handlersocket_share::~spider_handlersocket_share"); + DBUG_PRINT("info",("spider this=%p", this)); + free_column_name_str(); + free_table_names_str(); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (db_table_str_hash_value) + { + spider_free(spider_current_trx, db_table_str_hash_value, MYF(0)); + } +#endif + spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); + DBUG_VOID_RETURN; +} + +int spider_handlersocket_share::init() +{ + int error_num; + DBUG_ENTER("spider_handlersocket_share::init"); + DBUG_PRINT("info",("spider this=%p", this)); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(db_table_str_hash_value = (my_hash_value_type *) + spider_bulk_alloc_mem(spider_current_trx, 203, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &db_table_str_hash_value, + sizeof(my_hash_value_type) * spider_share->all_link_count, + NullS)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#endif + + if ( + (error_num = create_table_names_str()) || + (error_num = create_column_name_str()) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + DBUG_RETURN(0); +} + +int spider_handlersocket_share::append_table_name( + spider_string *str, + int all_link_idx +) { + const char *db_nm = db_names_str[all_link_idx].ptr(); + uint db_nm_len = db_names_str[all_link_idx].length(); + const char *table_nm = table_names_str[all_link_idx].ptr(); + uint table_nm_len = table_names_str[all_link_idx].length(); + DBUG_ENTER("spider_handlersocket_share::append_table_name"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(db_nm_len + SPIDER_SQL_DOT_LEN + table_nm_len + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider_db_handlersocket_utility.append_name(str, db_nm, db_nm_len); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + spider_db_handlersocket_utility.append_name(str, table_nm, table_nm_len); + DBUG_RETURN(0); +} + +int spider_handlersocket_share::create_table_names_str() +{ + int error_num, roop_count; + uint table_nm_len, db_nm_len; + spider_string *str, *first_tbl_nm_str, *first_db_nm_str, *first_db_tbl_str; + char *first_tbl_nm, *first_db_nm; + uint dbton_id = spider_dbton_handlersocket.dbton_id; + DBUG_ENTER("spider_handlersocket_share::create_table_names_str"); + table_names_str = NULL; + db_names_str = NULL; + db_table_str = NULL; + if ( + !(table_names_str = new spider_string[spider_share->all_link_count]) || + !(db_names_str = new spider_string[spider_share->all_link_count]) || + !(db_table_str = new spider_string[spider_share->all_link_count]) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + + same_db_table_name = TRUE; + first_tbl_nm = spider_share->tgt_table_names[0]; + first_db_nm = spider_share->tgt_dbs[0]; + table_nm_len = spider_share->tgt_table_names_lengths[0]; + db_nm_len = spider_share->tgt_dbs_lengths[0]; + first_tbl_nm_str = &table_names_str[0]; + first_db_nm_str = &db_names_str[0]; + first_db_tbl_str = &db_table_str[0]; + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + table_names_str[roop_count].init_calc_mem(86); + db_names_str[roop_count].init_calc_mem(87); + db_table_str[roop_count].init_calc_mem(88); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + if (first_all_link_idx == -1) + first_all_link_idx = roop_count; + + str = &table_names_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name && + spider_share->tgt_table_names_lengths[roop_count] == table_nm_len && + !memcmp(first_tbl_nm, spider_share->tgt_table_names[roop_count], + table_nm_len) + ) { + if (str->copy(*first_tbl_nm_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + spider_share->tgt_table_names[roop_count], dbton_id))) + goto error; + if (roop_count) + { + same_db_table_name = FALSE; + DBUG_PRINT("info", ("spider found different table name %s", + spider_share->tgt_table_names[roop_count])); + if (str->length() > table_nm_max_length) + table_nm_max_length = str->length(); + } else + table_nm_max_length = str->length(); + } + + str = &db_names_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name && + spider_share->tgt_dbs_lengths[roop_count] == db_nm_len && + !memcmp(first_db_nm, spider_share->tgt_dbs[roop_count], + db_nm_len) + ) { + if (str->copy(*first_db_nm_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + spider_share->tgt_dbs[roop_count], dbton_id))) + goto error; + if (roop_count) + { + same_db_table_name = FALSE; + DBUG_PRINT("info", ("spider found different db name %s", + spider_share->tgt_dbs[roop_count])); + if (str->length() > db_nm_max_length) + db_nm_max_length = str->length(); + } else + db_nm_max_length = str->length(); + } + + str = &db_table_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name + ) { + if (str->copy(*first_db_tbl_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = append_table_name(str, roop_count))) + goto error; + } +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + db_table_str_hash_value[roop_count] = my_calc_hash( + &spider_open_connections, (uchar*) str->ptr(), str->length()); +#endif + } + DBUG_RETURN(0); + +error: + if (db_table_str) + { + delete [] db_table_str; + db_table_str = NULL; + } + if (db_names_str) + { + delete [] db_names_str; + db_names_str = NULL; + } + if (table_names_str) + { + delete [] table_names_str; + table_names_str = NULL; + } + DBUG_RETURN(error_num); +} + +void spider_handlersocket_share::free_table_names_str() +{ + DBUG_ENTER("spider_handlersocket_share::free_table_names_str"); + if (db_table_str) + { + delete [] db_table_str; + db_table_str = NULL; + } + if (db_names_str) + { + delete [] db_names_str; + db_names_str = NULL; + } + if (table_names_str) + { + delete [] table_names_str; + table_names_str = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_handlersocket_share::create_column_name_str() +{ + spider_string *str; + int error_num; + Field **field; + TABLE_SHARE *table_share = spider_share->table_share; + uint dbton_id = spider_dbton_handlersocket.dbton_id; + DBUG_ENTER("spider_handlersocket_share::create_column_name_str"); + if ( + table_share->fields && + !(column_name_str = new spider_string[table_share->fields]) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + for (field = table_share->field, str = column_name_str; + *field; field++, str++) + { + str->init_calc_mem(202); + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + (char *) (*field)->field_name, dbton_id))) + goto error; + } + DBUG_RETURN(0); + +error: + if (column_name_str) + { + delete [] column_name_str; + column_name_str = NULL; + } + DBUG_RETURN(error_num); +} + +void spider_handlersocket_share::free_column_name_str() +{ + DBUG_ENTER("spider_handlersocket_share::free_column_name_str"); + if (column_name_str) + { + delete [] column_name_str; + column_name_str = NULL; + } + DBUG_VOID_RETURN; +} + +uint spider_handlersocket_share::get_column_name_length( + uint field_index +) { + DBUG_ENTER("spider_handlersocket_share::get_column_name_length"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(column_name_str[field_index].length()); +} + +int spider_handlersocket_share::append_column_name( + spider_string *str, + uint field_index +) { + int error_num; + DBUG_ENTER("spider_handlersocket_share::append_column_name"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = spider_db_handlersocket_utility.append_name(str, + column_name_str[field_index].ptr(), column_name_str[field_index].length()); + DBUG_RETURN(error_num); +} + +int spider_handlersocket_share::append_column_name_with_alias( + spider_string *str, + uint field_index, + const char *alias, + uint alias_length +) { + DBUG_ENTER("spider_handlersocket_share::append_column_name_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve( + alias_length + + column_name_str[field_index].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + append_column_name(str, field_index); + DBUG_RETURN(0); +} + +bool spider_handlersocket_share::need_change_db_table_name() +{ + DBUG_ENTER("spider_handlersocket_share::need_change_db_table_name"); + DBUG_RETURN(!same_db_table_name); +} + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +int spider_handlersocket_share::discover_table_structure( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str +) { + DBUG_ENTER("spider_handlersocket_share::discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +} +#endif + +spider_handlersocket_handler::spider_handlersocket_handler( + ha_spider *spider, + spider_handlersocket_share *db_share +) : spider_db_handler( + spider, + db_share +), + handlersocket_share(db_share), + link_for_hash(NULL) +{ + DBUG_ENTER("spider_handlersocket_handler::spider_handlersocket_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_alloc_calc_mem_init(mem_calc, 187); + spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); + DBUG_VOID_RETURN; +} + +spider_handlersocket_handler::~spider_handlersocket_handler() +{ + DBUG_ENTER("spider_handlersocket_handler::~spider_handlersocket_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if (link_for_hash) + { + spider_free(spider_current_trx, link_for_hash, MYF(0)); + } + spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); + DBUG_VOID_RETURN; +} + +int spider_handlersocket_handler::init() +{ + st_spider_share *share = spider->share; + DBUG_ENTER("spider_handlersocket_handler::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *) + spider_bulk_alloc_mem(spider_current_trx, 204, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &link_for_hash, + sizeof(SPIDER_LINK_FOR_HASH) * share->link_count, + NullS)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + uint roop_count; + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + link_for_hash[roop_count].spider = spider; + link_for_hash[roop_count].link_idx = roop_count; + link_for_hash[roop_count].db_table_str = + &handlersocket_share->db_table_str[roop_count]; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + link_for_hash[roop_count].db_table_str_hash_value = + handlersocket_share->db_table_str_hash_value[roop_count]; +#endif + } + hs_sql.init_calc_mem(63); + hs_sql.set_charset(share->access_charset); + hs_keys.init(); + hs_upds.init(); + hs_strs.init(); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_table_name_with_adjusting( + spider_string *str, + int link_idx, + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_table_name_with_adjusting"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_tmp_table_and_sql_for_bka( + const key_range *start_key +) { + DBUG_ENTER("spider_handlersocket_handler::append_tmp_table_and_sql_for_bka"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::reuse_tmp_table_and_sql_for_bka() +{ + DBUG_ENTER("spider_handlersocket_handler::reuse_tmp_table_and_sql_for_bka"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_insert_for_recovery( + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::append_insert_for_recovery"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff +) { + DBUG_ENTER("spider_handlersocket_handler::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff +) { + DBUG_ENTER("spider_handlersocket_handler::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_insert_part() +{ + DBUG_ENTER("spider_handlersocket_handler::append_insert_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_update_part() +{ + DBUG_ENTER("spider_handlersocket_handler::append_update_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_delete_part() +{ + DBUG_ENTER("spider_handlersocket_handler::append_delete_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_handlersocket_handler::append_increment_update_set_part() +{ + DBUG_ENTER("spider_handlersocket_handler::append_increment_update_set_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} +#endif + +int spider_handlersocket_handler::append_update_set_part() +{ + DBUG_ENTER("spider_handlersocket_handler::append_update_set_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_handlersocket_handler::append_direct_update_set_part() +{ + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_handlersocket_handler::append_direct_update_set_part"); + if ( + spider->do_direct_update && + (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) + ) { + DBUG_PRINT("info",("spider add set for DU SPIDER_SQL_KIND_HS")); + size_t roop_count; + Field *field; + hs_adding_keys = FALSE; + for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; + roop_count++) + { + Field *top_table_field = + spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); + if (!(field = spider->field_exchange(top_table_field))) + continue; + if (top_table_field->is_null()) + { + hs_upds.push_back(spider_null_string_ref); + } else { + if (spider_db_handlersocket_utility. + append_column_value(spider, NULL, top_table_field, NULL, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + } + DBUG_RETURN(0); +} +#endif + +int spider_handlersocket_handler::append_minimum_select_without_quote( + spider_string *str +) { + TABLE *table = spider->get_table(); + Field **field; + int field_length; + bool appended = FALSE; + DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_without_quote"); + for (field = table->field; *field; field++) + { + if ( + spider_bit_is_set(spider->searched_bitmap, (*field)->field_index) | + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + ) { + field_length = + handlersocket_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append( + handlersocket_share->column_name_str[(*field)->field_index].ptr(), + handlersocket_share->column_name_str[(*field)->field_index].length()); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + appended = TRUE; + } + } + if (appended) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_handlersocket_handler::append_minimum_select_by_field_idx_list( + spider_string *str, + uint32 *field_idxs, + size_t field_idxs_num +) { + Field *field; + int roop_count, field_length; + bool appended = FALSE; + DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_by_field_idx_list"); + for (roop_count = 0; roop_count < (int) field_idxs_num; roop_count++) + { + field = spider->get_top_table_field(field_idxs[roop_count]); + if ((field = spider->field_exchange(field))) + { + field_length = + handlersocket_share->column_name_str[field->field_index].length(); + if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append( + handlersocket_share->column_name_str[field->field_index].ptr(), + handlersocket_share->column_name_str[field->field_index].length()); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + appended = TRUE; + } + } + if (appended) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_dup_update_pushdown_part( + const char *alias, + uint alias_length +) { + DBUG_ENTER("spider_handlersocket_handler::append_dup_update_pushdown_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_update_columns_part( + const char *alias, + uint alias_length +) { + DBUG_ENTER("spider_handlersocket_handler::append_update_columns_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::check_update_columns_part() +{ + DBUG_ENTER("spider_handlersocket_handler::check_update_columns_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} +#endif + +int spider_handlersocket_handler::append_select_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_table_select_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_table_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_key_select_part( + ulong sql_type, + uint idx +) { + DBUG_ENTER("spider_handlersocket_handler::append_key_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_minimum_select_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_hint_after_table_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_hint_after_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +void spider_handlersocket_handler::set_where_pos( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::set_where_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +void spider_handlersocket_handler::set_where_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::set_where_to_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +int spider_handlersocket_handler::check_item_type( + Item *item +) { + DBUG_ENTER("spider_handlersocket_handler::check_item_type"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_values_connector_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_values_connector_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_values_terminator_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_values_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_key_column_values_part( + const key_range *start_key, + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_key_column_values_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_key_where_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type +) { + int error_num; + spider_string *str; + bool set_order; + DBUG_ENTER("spider_handlersocket_handler::append_key_where_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_HS: + case SPIDER_SQL_TYPE_INSERT_HS: + case SPIDER_SQL_TYPE_UPDATE_HS: + case SPIDER_SQL_TYPE_DELETE_HS: + str = &hs_sql; + str->length(0); + hs_adding_keys = TRUE; + set_order = FALSE; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_where(str, NULL, NULL, start_key, end_key, + sql_type, set_order); + DBUG_RETURN(error_num); +} + +int spider_handlersocket_handler::append_key_where( + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + const key_range *start_key, + const key_range *end_key, + ulong sql_type, + bool set_order +) { + int error_num; + DBUG_ENTER("spider_handlersocket_handler::append_key_where"); + error_num = spider_db_append_key_where_internal(str, str_part, str_part2, + start_key, end_key, spider, set_order, sql_type, + spider_dbton_handlersocket.dbton_id); + DBUG_RETURN(error_num); +} + +int spider_handlersocket_handler::append_is_null_part( + ulong sql_type, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_handlersocket_handler::append_is_null_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_HS: + case SPIDER_SQL_TYPE_INSERT_HS: + case SPIDER_SQL_TYPE_UPDATE_HS: + case SPIDER_SQL_TYPE_DELETE_HS: + str = &hs_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_is_null(sql_type, str, NULL, NULL, key_part, key, ptr, + key_eq); + DBUG_RETURN(error_num); +} + +int spider_handlersocket_handler::append_is_null( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq +) { + DBUG_ENTER("spider_handlersocket_handler::append_is_null"); + DBUG_PRINT("info",("spider this=%p", this)); + if (key_part->null_bit) + { + if (*(*ptr)++) + { + hs_keys.push_back(spider_null_string_ref); + DBUG_RETURN(-1); + } + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_where_terminator_part( + ulong sql_type, + bool set_order, + int key_count +) { + DBUG_ENTER("spider_handlersocket_handler::append_where_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_match_where_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_match_where_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_condition_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg +) { + DBUG_ENTER("spider_handlersocket_handler::append_condition_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_match_select_part( + ulong sql_type, + const char *alias, + uint alias_length +) { + DBUG_ENTER("spider_handlersocket_handler::append_match_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +void spider_handlersocket_handler::set_order_pos( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::set_order_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +void spider_handlersocket_handler::set_order_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::set_order_to_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +int spider_handlersocket_handler::append_key_order_for_merge_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_key_order_for_merge_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_key_order_for_direct_order_limit_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_key_order_for_direct_order_limit_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_key_order_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_key_order_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_limit_part( + longlong offset, + longlong limit, + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_limit_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info", ("spider offset=%lld", offset)); + DBUG_PRINT("info", ("spider limit=%lld", limit)); + hs_skip = (int) offset; + hs_limit = (int) limit; + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::reappend_limit_part( + longlong offset, + longlong limit, + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::reappend_limit_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_select_lock_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_select_lock_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_union_all_start_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_union_all_start_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_union_all_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_union_all_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_union_all_end_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_union_all_end_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_multi_range_cnt_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma +) { + DBUG_ENTER("spider_handlersocket_handler::append_multi_range_cnt_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_open_handler_part( + ulong sql_type, + uint handler_id, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_handlersocket_handler::append_open_handler_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_HS: + str = &hs_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_open_handler(str, handler_id, conn, link_idx); + DBUG_RETURN(error_num); +} + +int spider_handlersocket_handler::append_open_handler( + spider_string *str, + uint handler_id, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + DBUG_ENTER("spider_handlersocket_handler::append_open_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + str->length() == 0 && +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + ( + ( + ( + spider->sql_command == SQLCOM_HS_INSERT || + spider->hs_pushed_ret_fields_num == MAX_FIELDS + ) && +#endif + (error_num = append_minimum_select_without_quote(str)) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + ) || + ( + ( + spider->sql_command != SQLCOM_HS_INSERT && + spider->hs_pushed_ret_fields_num < MAX_FIELDS + ) && + (error_num = append_minimum_select_by_field_idx_list(str, + spider->hs_pushed_ret_fields, spider->hs_pushed_ret_fields_num)) + ) + ) +#endif + ) { + DBUG_RETURN(error_num); + } + + TABLE *table = spider->get_table(); + SPIDER_SHARE *share = spider->share; + DBUG_PRINT("info",("spider field list=%s", str->c_ptr_safe())); + if (!spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_set_bit(spider->db_request_phase, link_idx); + ++spider->db_request_id[link_idx]; + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + conn->db_conn->append_open_handler( + handler_id, + share->tgt_dbs[spider->conn_link_idx[link_idx]], + share->tgt_table_names[spider->conn_link_idx[link_idx]], + spider->active_index < MAX_KEY ? + table->s->key_info[spider->active_index].name : + "0", + str->c_ptr_safe(), + &request_key + ); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_close_handler_part( + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::append_close_handler_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_insert_terminator_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_insert_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_insert_values_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_insert_values_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_HS: + str = &hs_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_insert_values(str); + DBUG_RETURN(error_num); +} + +int spider_handlersocket_handler::append_insert_values( + spider_string *str +) { + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + Field **field; + DBUG_ENTER("spider_mysql_handler::append_insert_values"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_adding_keys = FALSE; + for (field = table->field; *field; field++) + { + DBUG_PRINT("info",("spider field_index=%u", (*field)->field_index)); + if ( + bitmap_is_set(table->write_set, (*field)->field_index) || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->read_set); +#endif + DBUG_PRINT("info",("spider is_null()=%s", + (*field)->is_null() ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider table->next_number_field=%p", + table->next_number_field)); + DBUG_PRINT("info",("spider *field=%p", *field)); + DBUG_PRINT("info",("spider force_auto_increment=%s", + (table->next_number_field && spider->force_auto_increment) ? + "TRUE" : "FALSE")); + if ( + (*field)->is_null() || + ( + table->next_number_field == *field && + !table->auto_increment_field_not_null && + !spider->force_auto_increment + ) + ) { + hs_upds.push_back(spider_null_string_ref); + } else { + spider_db_handlersocket_utility. + append_column_value(spider, NULL, *field, NULL, + share->access_charset); + } +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + } + } + int error_num; + int roop_count2; + for ( + roop_count2 = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count2 < (int) share->link_count; + roop_count2 = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count2, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if (spider->sql_kind[roop_count2] == SPIDER_SQL_KIND_HS) + { + SPIDER_CONN *conn = spider->hs_w_conns[roop_count2]; + if (conn->dbton_id == spider_dbton_handlersocket.dbton_id) + { + if ((error_num = request_buf_insert(roop_count2))) + DBUG_RETURN(error_num); +#ifdef HA_CAN_BULK_ACCESS + if (spider->is_bulk_access_clone) + { + spider->connection_ids[roop_count2] = conn->connection_id; + spider_trx_add_bulk_access_conn(spider->trx, conn); + } +#endif + } + } + } + hs_upds.clear(); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_into_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_into_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +void spider_handlersocket_handler::set_insert_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::set_insert_to_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +int spider_handlersocket_handler::append_from_part( + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::append_from_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_delete_all_rows_part( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::append_delete_all_rows_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_explain_select_part( + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::append_explain_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +bool spider_handlersocket_handler::is_bulk_insert_exec_period( + bool bulk_end +) { + DBUG_ENTER("spider_handlersocket_handler::is_bulk_insert_exec_period"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!spider->bulk_insert || bulk_end) + DBUG_RETURN(TRUE); + DBUG_RETURN(FALSE); +} + +bool spider_handlersocket_handler::sql_is_filled_up( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::sql_is_filled_up"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(FALSE); +} + +bool spider_handlersocket_handler::sql_is_empty( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::sql_is_empty"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(FALSE); +} + +bool spider_handlersocket_handler::support_multi_split_read() +{ + DBUG_ENTER("spider_handlersocket_handler::support_multi_split_read"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(FALSE); +} + +bool spider_handlersocket_handler::support_bulk_update() +{ + DBUG_ENTER("spider_handlersocket_handler::support_bulk_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(FALSE); +} + +int spider_handlersocket_handler::bulk_tmp_table_insert() +{ + DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::bulk_tmp_table_insert( + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::bulk_tmp_table_end_bulk_insert() +{ + DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_end_bulk_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::bulk_tmp_table_rnd_init() +{ + DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_init"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::bulk_tmp_table_rnd_next() +{ + DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_next"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::bulk_tmp_table_rnd_end() +{ + DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_end"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +bool spider_handlersocket_handler::need_copy_for_update( + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::need_copy_for_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(TRUE); +} + +bool spider_handlersocket_handler::bulk_tmp_table_created() +{ + DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_created"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(FALSE); +} + +int spider_handlersocket_handler::mk_bulk_tmp_table_and_bulk_start() +{ + DBUG_ENTER("spider_handlersocket_handler::mk_bulk_tmp_table_and_bulk_start"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +void spider_handlersocket_handler::rm_bulk_tmp_table() +{ + DBUG_ENTER("spider_handlersocket_handler::rm_bulk_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + +int spider_handlersocket_handler::insert_lock_tables_list( + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::insert_lock_tables_list"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::append_lock_tables_list( + SPIDER_CONN *conn, + int link_idx, + int *appended +) { + DBUG_ENTER("spider_handlersocket_handler::append_lock_tables_list"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::realloc_sql( + ulong *realloced +) { + THD *thd = spider->trx->thd; + st_spider_share *share = spider->share; + int init_sql_alloc_size = + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); + DBUG_ENTER("spider_handlersocket_handler::realloc_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((int) hs_sql.alloced_length() > init_sql_alloc_size * 2) + { + hs_sql.free(); + if (hs_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_FULL_HS; + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::reset_sql( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::reset_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & SPIDER_SQL_TYPE_FULL_HS) + { + hs_sql.length(0); + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::reset_keys( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::reset_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & SPIDER_SQL_TYPE_FULL_HS) + { + hs_keys.clear(); + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::reset_upds( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::reset_upds"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & SPIDER_SQL_TYPE_FULL_HS) + { + hs_upds.clear(); + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::reset_strs( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::reset_strs"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & SPIDER_SQL_TYPE_FULL_HS) + { + hs_strs.clear(); + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::reset_strs_pos( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::reset_strs_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & SPIDER_SQL_TYPE_FULL_HS) + { + hs_strs_pos = 0; + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::push_back_upds( + SPIDER_HS_STRING_REF &info +) { + int error_num; + DBUG_ENTER("spider_handlersocket_handler::push_back_upds"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = hs_upds.push_back(info); + DBUG_RETURN(error_num); +} + +int spider_handlersocket_handler::request_buf_find( + int link_idx +) { + int error_num; + spider_string *hs_str; + SPIDER_CONN *conn; + uint handler_id; + DBUG_ENTER("spider_handlersocket_handler::request_buf_find"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) + { + conn = spider->hs_r_conns[link_idx]; + handler_id = spider->r_handler_id[link_idx]; + } else { + conn = spider->hs_w_conns[link_idx]; + handler_id = spider->w_handler_id[link_idx]; + } + if ((error_num = spider_db_conn_queue_action(conn))) + DBUG_RETURN(error_num); + if (!spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_set_bit(spider->db_request_phase, link_idx); + ++spider->db_request_id[link_idx]; + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + conn->db_conn->append_select( + handler_id, hs_str, &hs_keys, + hs_limit, hs_skip, &request_key); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::request_buf_insert( + int link_idx +) { + int error_num; + DBUG_ENTER("spider_handlersocket_handler::request_buf_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) + DBUG_RETURN(error_num); + if (!spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_set_bit(spider->db_request_phase, link_idx); + ++spider->db_request_id[link_idx]; + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + spider->hs_w_conns[link_idx]->db_conn->append_insert( + spider->w_handler_id[link_idx], &hs_upds, &request_key); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::request_buf_update( + int link_idx +) { + int error_num; + spider_string *hs_str; + DBUG_ENTER("spider_handlersocket_handler::request_buf_update"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) + DBUG_RETURN(error_num); + if (!spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_set_bit(spider->db_request_phase, link_idx); + ++spider->db_request_id[link_idx]; + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + spider->hs_w_conns[link_idx]->db_conn->append_update( + spider->w_handler_id[link_idx], hs_str, &hs_keys, &hs_upds, + hs_limit, hs_skip, + spider->hs_increment, spider->hs_decrement, &request_key + ); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::request_buf_delete( + int link_idx +) { + int error_num; + spider_string *hs_str; + DBUG_ENTER("spider_handlersocket_handler::request_buf_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) + DBUG_RETURN(error_num); + if (!spider_bit_is_set(spider->db_request_phase, link_idx)) + { + spider_set_bit(spider->db_request_phase, link_idx); + ++spider->db_request_id[link_idx]; + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = spider->db_request_id[link_idx]; + request_key.next = NULL; + spider->hs_w_conns[link_idx]->db_conn->append_delete( + spider->w_handler_id[link_idx], hs_str, &hs_keys, + hs_limit, hs_skip, &request_key); + DBUG_RETURN(0); +} + +bool spider_handlersocket_handler::need_lock_before_set_sql_for_exec( + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::need_lock_before_set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_handlersocket_handler::set_sql_for_exec( + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & SPIDER_SQL_TYPE_SELECT_HS) + { + DBUG_RETURN(request_buf_find(link_idx)); + } + if (sql_type & SPIDER_SQL_TYPE_INSERT_HS) + { + DBUG_RETURN(request_buf_insert(link_idx)); + } + if (sql_type & SPIDER_SQL_TYPE_UPDATE_HS) + { + DBUG_RETURN(request_buf_update(link_idx)); + } + if (sql_type & SPIDER_SQL_TYPE_DELETE_HS) + { + DBUG_RETURN(request_buf_delete(link_idx)); + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::set_sql_for_exec( + spider_db_copy_table *tgt_ct, + ulong sql_type +) { + DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::execute_sql( + ulong sql_type, + SPIDER_CONN *conn, + int quick_mode, + int *need_mon +) { + DBUG_ENTER("spider_handlersocket_handler::execute_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(sql_type & SPIDER_SQL_TYPE_FULL_HS)) + { + /* nothing to do */ + DBUG_RETURN(0); + } + DBUG_RETURN(spider_db_query( + conn, + NULL, + 0, + quick_mode, + need_mon + )); +} + +int spider_handlersocket_handler::reset() +{ + DBUG_ENTER("spider_handlersocket_handler::reset"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::sts_mode_exchange( + int sts_mode +) { + DBUG_ENTER("spider_handlersocket_handler::sts_mode_exchange"); + DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); + DBUG_RETURN(sts_mode); +} + +int spider_handlersocket_handler::show_table_status( + int link_idx, + int sts_mode, + uint flag +) { + spider_db_handlersocket_result res; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_handlersocket_show_table_status"); + res.fetch_table_status( + sts_mode, + share->records, + share->mean_rec_length, + share->data_file_length, + share->max_data_file_length, + share->index_file_length, + share->auto_increment_value, + share->create_time, + share->update_time, + share->check_time + ); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::crd_mode_exchange( + int crd_mode +) { + DBUG_ENTER("spider_handlersocket_handler::crd_mode_exchange"); + DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); + DBUG_RETURN(crd_mode); +} + +int spider_handlersocket_handler::show_index( + int link_idx, + int crd_mode +) { + DBUG_ENTER("spider_handlersocket_handler::show_index"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::show_records( + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::show_records"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::show_last_insert_id( + int link_idx, + ulonglong &last_insert_id +) { + DBUG_ENTER("spider_handlersocket_handler::show_last_insert_id"); + last_insert_id = 0; + DBUG_RETURN(0); +} + +ha_rows spider_handlersocket_handler::explain_select( + key_range *start_key, + key_range *end_key, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::explain_select"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::lock_tables( + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::lock_tables"); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::unlock_tables( + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::unlock_tables"); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::disable_keys( + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::disable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::enable_keys( + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::enable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::check_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt +) { + DBUG_ENTER("spider_handlersocket_handler::check_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::repair_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt +) { + DBUG_ENTER("spider_handlersocket_handler::repair_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::analyze_table( + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::analyze_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::optimize_table( + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::optimize_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::flush_tables( + SPIDER_CONN *conn, + int link_idx, + bool lock +) { + DBUG_ENTER("spider_handlersocket_handler::flush_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::flush_logs( + SPIDER_CONN *conn, + int link_idx +) { + DBUG_ENTER("spider_handlersocket_handler::flush_logs"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::insert_opened_handler( + SPIDER_CONN *conn, + int link_idx +) { + spider_db_handlersocket *db_conn = (spider_db_handlersocket *) conn->db_conn; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash = &link_for_hash[link_idx]; + DBUG_ASSERT(tmp_link_for_hash->spider == spider); + DBUG_ASSERT(tmp_link_for_hash->link_idx == link_idx); + uint old_elements = db_conn->handler_open_array.max_element; + DBUG_ENTER("spider_handlersocket_handler::insert_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if (insert_dynamic(&db_conn->handler_open_array, + (uchar*) &tmp_link_for_hash)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (db_conn->handler_open_array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + db_conn->handler_open_array, + (db_conn->handler_open_array.max_element - old_elements) * + db_conn->handler_open_array.size_of_element); + } + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::delete_opened_handler( + SPIDER_CONN *conn, + int link_idx +) { + spider_db_handlersocket *db_conn = (spider_db_handlersocket *) conn->db_conn; + uint roop_count, elements = db_conn->handler_open_array.elements; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash; + DBUG_ENTER("spider_handlersocket_handler::delete_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + for (roop_count = 0; roop_count < elements; roop_count++) + { + get_dynamic(&db_conn->handler_open_array, (uchar *) &tmp_link_for_hash, + roop_count); + if (tmp_link_for_hash == &link_for_hash[link_idx]) + { + delete_dynamic_element(&db_conn->handler_open_array, roop_count); + break; + } + } + DBUG_ASSERT(roop_count < elements); + DBUG_RETURN(0); +} + +int spider_handlersocket_handler::sync_from_clone_source( + spider_db_handler *dbton_hdl +) { + spider_handlersocket_handler *hs_hdl = + (spider_handlersocket_handler *) dbton_hdl; + DBUG_ENTER("spider_handlersocket_handler::sync_from_clone_source"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_strs_pos = hs_hdl->hs_strs_pos; + DBUG_RETURN(0); +} + +bool spider_handlersocket_handler::support_use_handler( + int use_handler +) { + DBUG_ENTER("spider_handlersocket_handler::support_use_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} +#endif diff --git a/storage/spider/spd_db_handlersocket.h b/storage/spider/spd_db_handlersocket.h new file mode 100644 index 00000000000..f516e1ef101 --- /dev/null +++ b/storage/spider/spd_db_handlersocket.h @@ -0,0 +1,893 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define SPIDER_HS_CONN dena::hstcpcli_ptr +#define SPIDER_HS_CONN_CREATE dena::hstcpcli_i::create +#define SPIDER_HS_RESULT dena::hstresult +#define SPIDER_HS_SOCKARGS dena::socket_args + +class spider_db_handlersocket_util: public spider_db_util +{ +public: + spider_db_handlersocket_util(); + ~spider_db_handlersocket_util(); + int append_name( + spider_string *str, + const char *name, + uint name_length + ); + int append_name_with_charset( + spider_string *str, + const char *name, + uint name_length, + CHARSET_INFO *name_charset + ); + bool is_name_quote( + const char head_code + ); + int append_escaped_name_quote( + spider_string *str + ); + int append_column_value( + ha_spider *spider, + spider_string *str, + Field *field, + const uchar *new_ptr, + CHARSET_INFO *access_charset + ); + int append_trx_isolation( + spider_string *str, + int trx_isolation + ); + int append_autocommit( + spider_string *str, + bool autocommit + ); + int append_sql_log_off( + spider_string *str, + bool sql_log_off + ); + int append_time_zone( + spider_string *str, + Time_zone *time_zone + ); + int append_start_transaction( + spider_string *str + ); + int append_xa_start( + spider_string *str, + XID *xid + ); + int append_lock_table_head( + spider_string *str + ); + int append_lock_table_body( + spider_string *str, + const char *db_name, + uint db_name_length, + CHARSET_INFO *db_name_charset, + const char *table_name, + uint table_name_length, + CHARSET_INFO *table_name_charset, + int lock_type + ); + int append_lock_table_tail( + spider_string *str + ); + int append_unlock_table( + spider_string *str + ); + int open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length + ); + int append_escaped_util( + spider_string *to, + String *from + ); +}; + +class spider_db_handlersocket_row: public spider_db_row +{ +public: + SPIDER_HS_STRING_REF *hs_row; + SPIDER_HS_STRING_REF *hs_row_first; + uint field_count; + bool cloned; + spider_db_handlersocket_row(); + ~spider_db_handlersocket_row(); + int store_to_field( + Field *field, + CHARSET_INFO *access_charset + ); + int append_to_str( + spider_string *str + ); + int append_escaped_to_str( + spider_string *str, + uint dbton_id + ); + void first(); + void next(); + bool is_null(); + int val_int(); + double val_real(); + SPIDER_DB_ROW *clone(); + int store_to_tmp_table( + TABLE *tmp_table, + spider_string *str + ); +}; + +class spider_db_handlersocket_result_buffer: public spider_db_result_buffer +{ +public: + SPIDER_HS_RESULT hs_result; + spider_db_handlersocket_result_buffer(); + ~spider_db_handlersocket_result_buffer(); + void clear(); + bool check_size( + longlong size + ); +}; + +class spider_db_handlersocket_result: public spider_db_result +{ +public: + SPIDER_HS_CONN *hs_conn_p; + spider_db_handlersocket_row row; + SPIDER_HS_STRING_REF hs_row; + uint field_count; + int store_error_num; + spider_db_handlersocket_result(); + ~spider_db_handlersocket_result(); + bool has_result(); + void free_result(); + SPIDER_DB_ROW *current_row(); + SPIDER_DB_ROW *fetch_row(); + SPIDER_DB_ROW *fetch_row_from_result_buffer( + spider_db_result_buffer *spider_res_buf + ); + SPIDER_DB_ROW *fetch_row_from_tmp_table( + TABLE *tmp_table + ); + int fetch_table_status( + int mode, + ha_rows &records, + ulong &mean_rec_length, + ulonglong &data_file_length, + ulonglong &max_data_file_length, + ulonglong &index_file_length, + ulonglong &auto_increment_value, + time_t &create_time, + time_t &update_time, + time_t &check_time + ); + int fetch_table_records( + int mode, + ha_rows &records + ); + int fetch_table_cardinality( + int mode, + TABLE *table, + longlong *cardinality, + uchar *cardinality_upd, + int bitmap_size + ); + int fetch_table_mon_status( + int &status + ); + longlong num_rows(); + uint num_fields(); + void move_to_pos( + longlong pos + ); + int get_errno(); +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + int fetch_columns_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset + ); + int fetch_index_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset + ); +#endif +}; + +class spider_db_handlersocket: public spider_db_conn +{ + SPIDER_HS_CONN hs_conn; + int stored_error; + uint field_count; +public: + DYNAMIC_ARRAY handler_open_array; + bool handler_open_array_inited; + uint handler_open_array_id; + const char *handler_open_array_func_name; + const char *handler_open_array_file_name; + ulong handler_open_array_line_no; + st_spider_db_request_key *request_key_req_first; + st_spider_db_request_key *request_key_req_last; + st_spider_db_request_key *request_key_snd_first; + st_spider_db_request_key *request_key_snd_last; + st_spider_db_request_key *request_key_reuse_first; + st_spider_db_request_key *request_key_reuse_last; + spider_db_handlersocket( + SPIDER_CONN *conn + ); + ~spider_db_handlersocket(); + int init(); + bool is_connected(); + void bg_connect(); + int connect( + char *tgt_host, + char *tgt_username, + char *tgt_password, + long tgt_port, + char *tgt_socket, + char *server_name, + int connect_retry_count, + longlong connect_retry_interval + ); + int ping(); + void bg_disconnect(); + void disconnect(); + int set_net_timeout(); + int exec_query( + const char *query, + uint length, + int quick_mode + ); + int get_errno(); + const char *get_error(); + bool is_server_gone_error( + int error_num + ); + bool is_dup_entry_error( + int error_num + ); + bool is_xa_nota_error( + int error_num + ); + spider_db_result *store_result( + spider_db_result_buffer **spider_res_buf, + st_spider_db_request_key *request_key, + int *error_num + ); + spider_db_result *use_result( + st_spider_db_request_key *request_key, + int *error_num + ); + int next_result(); + uint affected_rows(); + ulonglong last_insert_id(); + int set_character_set( + const char *csname + ); + int select_db( + const char *dbname + ); + int consistent_snapshot( + int *need_mon + ); + bool trx_start_in_bulk_sql(); + int start_transaction( + int *need_mon + ); + int commit( + int *need_mon + ); + int rollback( + int *need_mon + ); + bool xa_start_in_bulk_sql(); + int xa_start( + XID *xid, + int *need_mon + ); + int xa_end( + XID *xid, + int *need_mon + ); + int xa_prepare( + XID *xid, + int *need_mon + ); + int xa_commit( + XID *xid, + int *need_mon + ); + int xa_rollback( + XID *xid, + int *need_mon + ); + bool set_trx_isolation_in_bulk_sql(); + int set_trx_isolation( + int trx_isolation, + int *need_mon + ); + bool set_autocommit_in_bulk_sql(); + int set_autocommit( + bool autocommit, + int *need_mon + ); + bool set_sql_log_off_in_bulk_sql(); + int set_sql_log_off( + bool sql_log_off, + int *need_mon + ); + bool set_time_zone_in_bulk_sql(); + int set_time_zone( + Time_zone *time_zone, + int *need_mon + ); + int append_sql( + char *sql, + ulong sql_length, + st_spider_db_request_key *request_key + ); + int append_open_handler( + uint handler_id, + const char *db_name, + const char *table_name, + const char *index_name, + const char *sql, + st_spider_db_request_key *request_key + ); + int append_select( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key + ); + int append_insert( + uint handler_id, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + st_spider_db_request_key *request_key + ); + int append_update( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + int limit, + int skip, + bool increment, + bool decrement, + st_spider_db_request_key *request_key + ); + int append_delete( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key + ); + void reset_request_queue(); + size_t escape_string( + char *to, + const char *from, + size_t from_length + ); + bool have_lock_table_list(); + int append_lock_tables( + spider_string *str + ); + int append_unlock_tables( + spider_string *str + ); + uint get_lock_table_hash_count(); + void reset_lock_table_hash(); + uint get_opened_handler_count(); + void reset_opened_handler(); + void set_dup_key_idx( + ha_spider *spider, + int link_idx + ); + int append_request_key( + st_spider_db_request_key *request_key + ); + void reset_request_key_req(); + void reset_request_key_snd(); + void move_request_key_to_snd(); + int check_request_key( + st_spider_db_request_key *request_key + ); + bool cmp_request_key_to_snd( + st_spider_db_request_key *request_key + ); +}; + +class spider_handlersocket_share: public spider_db_share +{ +public: + spider_string *table_names_str; + spider_string *db_names_str; + spider_string *db_table_str; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type *db_table_str_hash_value; +#endif + uint table_nm_max_length; + uint db_nm_max_length; + spider_string *column_name_str; + bool same_db_table_name; + int first_all_link_idx; + spider_handlersocket_share( + st_spider_share *share + ); + ~spider_handlersocket_share(); + int init(); + int append_table_name( + spider_string *str, + int all_link_idx + ); + int create_table_names_str(); + void free_table_names_str(); + int create_column_name_str(); + void free_column_name_str(); + uint get_column_name_length( + uint field_index + ); + int append_column_name( + spider_string *str, + uint field_index + ); + int append_column_name_with_alias( + spider_string *str, + uint field_index, + const char *alias, + uint alias_length + ); + bool need_change_db_table_name(); +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + int discover_table_structure( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str + ); +#endif +}; + +class spider_handlersocket_handler: public spider_db_handler +{ + spider_string hs_sql; +public: + bool hs_adding_keys; + SPIDER_DB_HS_STRING_REF_BUFFER hs_keys; + SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; + SPIDER_DB_HS_STR_BUFFER hs_strs; + uint hs_strs_pos; + int hs_limit; + int hs_skip; + spider_handlersocket_share *handlersocket_share; + SPIDER_LINK_FOR_HASH *link_for_hash; + spider_handlersocket_handler( + ha_spider *spider, + spider_handlersocket_share *db_share + ); + ~spider_handlersocket_handler(); + int init(); + int append_table_name_with_adjusting( + spider_string *str, + int link_idx, + ulong sql_type + ); + int append_tmp_table_and_sql_for_bka( + const key_range *start_key + ); + int reuse_tmp_table_and_sql_for_bka(); + int append_insert_for_recovery( + ulong sql_type, + int link_idx + ); + int append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff + ); + int append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx + ); + int append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff + ); + int append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx + ); + int append_insert_part(); + int append_update_part(); + int append_delete_part(); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_increment_update_set_part(); +#endif + int append_update_set_part(); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_direct_update_set_part(); +#endif + int append_minimum_select_without_quote( + spider_string *str + ); +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_minimum_select_by_field_idx_list( + spider_string *str, + uint32 *field_idxs, + size_t field_idxs_num + ); + int append_dup_update_pushdown_part( + const char *alias, + uint alias_length + ); + int append_update_columns_part( + const char *alias, + uint alias_length + ); + int check_update_columns_part(); + int append_select_part( + ulong sql_type + ); +#endif + int append_table_select_part( + ulong sql_type + ); + int append_key_select_part( + ulong sql_type, + uint idx + ); + int append_minimum_select_part( + ulong sql_type + ); + int append_hint_after_table_part( + ulong sql_type + ); + void set_where_pos( + ulong sql_type + ); + void set_where_to_pos( + ulong sql_type + ); + int check_item_type( + Item *item + ); + int append_values_connector_part( + ulong sql_type + ); + int append_values_terminator_part( + ulong sql_type + ); + int append_key_column_values_part( + const key_range *start_key, + ulong sql_type + ); + int append_key_where_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type + ); + int append_key_where( + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + const key_range *start_key, + const key_range *end_key, + ulong sql_type, + bool set_order + ); + int append_is_null_part( + ulong sql_type, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq + ); + int append_is_null( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq + ); + int append_where_terminator_part( + ulong sql_type, + bool set_order, + int key_count + ); + int append_match_where_part( + ulong sql_type + ); + int append_condition_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg + ); + int append_match_select_part( + ulong sql_type, + const char *alias, + uint alias_length + ); + void set_order_pos( + ulong sql_type + ); + void set_order_to_pos( + ulong sql_type + ); + int append_key_order_for_merge_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_for_direct_order_limit_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_limit_part( + longlong offset, + longlong limit, + ulong sql_type + ); + int reappend_limit_part( + longlong offset, + longlong limit, + ulong sql_type + ); + int append_select_lock_part( + ulong sql_type + ); + int append_union_all_start_part( + ulong sql_type + ); + int append_union_all_part( + ulong sql_type + ); + int append_union_all_end_part( + ulong sql_type + ); + int append_multi_range_cnt_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma + ); + int append_open_handler_part( + ulong sql_type, + uint handler_id, + SPIDER_CONN *conn, + int link_idx + ); + int append_open_handler( + spider_string *str, + uint handler_id, + SPIDER_CONN *conn, + int link_idx + ); + int append_close_handler_part( + ulong sql_type, + int link_idx + ); + int append_insert_terminator_part( + ulong sql_type + ); + int append_insert_values_part( + ulong sql_type + ); + int append_insert_values( + spider_string *str + ); + int append_into_part( + ulong sql_type + ); + void set_insert_to_pos( + ulong sql_type + ); + int append_from_part( + ulong sql_type, + int link_idx + ); + int append_delete_all_rows_part( + ulong sql_type + ); + int append_explain_select_part( + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx + ); + bool is_bulk_insert_exec_period( + bool bulk_end + ); + bool sql_is_filled_up( + ulong sql_type + ); + bool sql_is_empty( + ulong sql_type + ); + bool support_multi_split_read(); + bool support_bulk_update(); + int bulk_tmp_table_insert(); + int bulk_tmp_table_insert( + int link_idx + ); + int bulk_tmp_table_end_bulk_insert(); + int bulk_tmp_table_rnd_init(); + int bulk_tmp_table_rnd_next(); + int bulk_tmp_table_rnd_end(); + bool need_copy_for_update( + int link_idx + ); + bool bulk_tmp_table_created(); + int mk_bulk_tmp_table_and_bulk_start(); + void rm_bulk_tmp_table(); + int insert_lock_tables_list( + SPIDER_CONN *conn, + int link_idx + ); + int append_lock_tables_list( + SPIDER_CONN *conn, + int link_idx, + int *appended + ); + int realloc_sql( + ulong *realloced + ); + int reset_sql( + ulong sql_type + ); + int reset_keys( + ulong sql_type + ); + int reset_upds( + ulong sql_type + ); + int reset_strs( + ulong sql_type + ); + int reset_strs_pos( + ulong sql_type + ); + int push_back_upds( + SPIDER_HS_STRING_REF &info + ); + int request_buf_find( + int link_idx + ); + int request_buf_insert( + int link_idx + ); + int request_buf_update( + int link_idx + ); + int request_buf_delete( + int link_idx + ); + bool need_lock_before_set_sql_for_exec( + ulong sql_type + ); + int set_sql_for_exec( + ulong sql_type, + int link_idx + ); + int set_sql_for_exec( + spider_db_copy_table *tgt_ct, + ulong sql_type + ); + int execute_sql( + ulong sql_type, + SPIDER_CONN *conn, + int quick_mode, + int *need_mon + ); + int reset(); + int sts_mode_exchange( + int sts_mode + ); + int show_table_status( + int link_idx, + int sts_mode, + uint flag + ); + int crd_mode_exchange( + int crd_mode + ); + int show_index( + int link_idx, + int crd_mode + ); + int show_records( + int link_idx + ); + int show_last_insert_id( + int link_idx, + ulonglong &last_insert_id + ); + ha_rows explain_select( + key_range *start_key, + key_range *end_key, + int link_idx + ); + int lock_tables( + int link_idx + ); + int unlock_tables( + int link_idx + ); + int disable_keys( + SPIDER_CONN *conn, + int link_idx + ); + int enable_keys( + SPIDER_CONN *conn, + int link_idx + ); + int check_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int repair_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int analyze_table( + SPIDER_CONN *conn, + int link_idx + ); + int optimize_table( + SPIDER_CONN *conn, + int link_idx + ); + int flush_tables( + SPIDER_CONN *conn, + int link_idx, + bool lock + ); + int flush_logs( + SPIDER_CONN *conn, + int link_idx + ); + int insert_opened_handler( + SPIDER_CONN *conn, + int link_idx + ); + int delete_opened_handler( + SPIDER_CONN *conn, + int link_idx + ); + int sync_from_clone_source( + spider_db_handler *dbton_hdl + ); + bool support_use_handler( + int use_handler + ); +}; diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h new file mode 100644 index 00000000000..e2b3a2c95fe --- /dev/null +++ b/storage/spider/spd_db_include.h @@ -0,0 +1,1579 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "hs_compat.h" +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#include "hstcpcli.hpp" +#endif + +#define SPIDER_DB_WRAPPER_MYSQL "mysql" + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 +#define SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +#define SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE +#define SPIDER_HAS_SHOW_SIMPLE_FUNC +#endif +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100003 +#define SPIDER_GENERATE_PARTITION_SYNTAX_HAS_CURRENT_COMMENT_START +#endif + +class spider_db_conn; +typedef spider_db_conn SPIDER_DB_CONN; +class spider_db_result; +typedef spider_db_result SPIDER_DB_RESULT; +class spider_db_row; +typedef spider_db_row SPIDER_DB_ROW; +class spider_db_result_buffer; +typedef spider_db_result_buffer SPIDER_DB_RESULT_BUFFER; +struct st_spider_conn; +typedef st_spider_conn SPIDER_CONN; +struct st_spider_result; +typedef st_spider_result SPIDER_RESULT; + +#define SPIDER_SQL_SEMICOLON_STR ";" +#define SPIDER_SQL_SEMICOLON_LEN sizeof(SPIDER_SQL_SEMICOLON_STR) - 1 +#define SPIDER_SQL_VALUE_QUOTE_STR "'" +#define SPIDER_SQL_VALUE_QUOTE_LEN (sizeof(SPIDER_SQL_VALUE_QUOTE_STR) - 1) + +#define SPIDER_SQL_DOT_STR "." +#define SPIDER_SQL_DOT_LEN (sizeof(SPIDER_SQL_DOT_STR) - 1) + +#define SPIDER_SQL_EQUAL_STR " = " +#define SPIDER_SQL_EQUAL_LEN (sizeof(SPIDER_SQL_EQUAL_STR) - 1) +#define SPIDER_SQL_AND_STR " and " +#define SPIDER_SQL_AND_LEN (sizeof(SPIDER_SQL_AND_STR) - 1) +#define SPIDER_SQL_BETWEEN_STR " between " +#define SPIDER_SQL_BETWEEN_LEN (sizeof(SPIDER_SQL_BETWEEN_STR) - 1) + +#define SPIDER_SQL_TABLE_NAME_STR "`table_name`" +#define SPIDER_SQL_TABLE_NAME_LEN sizeof(SPIDER_SQL_TABLE_NAME_STR) - 1 + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#define SPIDER_SQL_HS_EQUAL_STR "=" +#define SPIDER_SQL_HS_EQUAL_LEN (sizeof(SPIDER_SQL_HS_EQUAL_STR) - 1) +#define SPIDER_SQL_HS_GT_STR ">" +#define SPIDER_SQL_HS_GT_LEN (sizeof(SPIDER_SQL_HS_GT_STR) - 1) +#define SPIDER_SQL_HS_GTEQUAL_STR ">=" +#define SPIDER_SQL_HS_GTEQUAL_LEN (sizeof(SPIDER_SQL_HS_GTEQUAL_STR) - 1) +#define SPIDER_SQL_HS_LT_STR "<" +#define SPIDER_SQL_HS_LT_LEN (sizeof(SPIDER_SQL_HS_LT_STR) - 1) +#define SPIDER_SQL_HS_INSERT_STR "+" +#define SPIDER_SQL_HS_INSERT_LEN (sizeof(SPIDER_SQL_HS_INSERT_STR) - 1) +#define SPIDER_SQL_HS_UPDATE_STR "U" +#define SPIDER_SQL_HS_UPDATE_LEN (sizeof(SPIDER_SQL_HS_UPDATE_STR) - 1) +#define SPIDER_SQL_HS_DELETE_STR "D" +#define SPIDER_SQL_HS_DELETE_LEN (sizeof(SPIDER_SQL_HS_DELETE_STR) - 1) +#define SPIDER_SQL_HS_INCREMENT_STR "+" +#define SPIDER_SQL_HS_INCREMENT_LEN (sizeof(SPIDER_SQL_HS_INCREMENT_STR) - 1) +#define SPIDER_SQL_HS_DECREMENT_STR "-" +#define SPIDER_SQL_HS_DECREMENT_LEN (sizeof(SPIDER_SQL_HS_DECREMENT_STR) - 1) +#endif +#define SPIDER_SQL_HS_LTEQUAL_STR "<=" +#define SPIDER_SQL_HS_LTEQUAL_LEN (sizeof(SPIDER_SQL_HS_LTEQUAL_STR) - 1) + +#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC +#define SPIDER_SQL_CASE_STR "case " +#define SPIDER_SQL_CASE_LEN (sizeof(SPIDER_SQL_CASE_STR) - 1) +#define SPIDER_SQL_WHEN_STR " when " +#define SPIDER_SQL_WHEN_LEN (sizeof(SPIDER_SQL_WHEN_STR) - 1) +#define SPIDER_SQL_THEN_STR " then " +#define SPIDER_SQL_THEN_LEN (sizeof(SPIDER_SQL_THEN_STR) - 1) +#define SPIDER_SQL_ELSE_STR " else " +#define SPIDER_SQL_ELSE_LEN (sizeof(SPIDER_SQL_ELSE_STR) - 1) +#define SPIDER_SQL_END_STR " end" +#define SPIDER_SQL_END_LEN (sizeof(SPIDER_SQL_END_STR) - 1) +#endif + +#define SPIDER_SQL_USING_STR " using " +#define SPIDER_SQL_USING_LEN (sizeof(SPIDER_SQL_USING_STR) - 1) +#define SPIDER_SQL_MBR_STR "mbr" +#define SPIDER_SQL_MBR_LEN (sizeof(SPIDER_SQL_MBR_STR) - 1) +#define SPIDER_SQL_MBR_EQUAL_STR "mbrequal(" +#define SPIDER_SQL_MBR_EQUAL_LEN (sizeof(SPIDER_SQL_MBR_EQUAL_STR) - 1) +#define SPIDER_SQL_MBR_CONTAIN_STR "mbrcontains(" +#define SPIDER_SQL_MBR_CONTAIN_LEN (sizeof(SPIDER_SQL_MBR_CONTAIN_STR) - 1) +#define SPIDER_SQL_MBR_INTERSECT_STR "mbrintersects(" +#define SPIDER_SQL_MBR_INTERSECT_LEN (sizeof(SPIDER_SQL_MBR_INTERSECT_STR) - 1) +#define SPIDER_SQL_MBR_WITHIN_STR "mbrwithin(" +#define SPIDER_SQL_MBR_WITHIN_LEN (sizeof(SPIDER_SQL_MBR_WITHIN_STR) - 1) +#define SPIDER_SQL_MBR_DISJOINT_STR "mbrdisjoint(" +#define SPIDER_SQL_MBR_DISJOINT_LEN (sizeof(SPIDER_SQL_MBR_DISJOINT_STR) - 1) +#define SPIDER_SQL_NOT_BETWEEN_STR "not between" +#define SPIDER_SQL_NOT_BETWEEN_LEN (sizeof(SPIDER_SQL_NOT_BETWEEN_STR) - 1) +#define SPIDER_SQL_IN_STR "in(" +#define SPIDER_SQL_IN_LEN (sizeof(SPIDER_SQL_IN_STR) - 1) +#define SPIDER_SQL_NOT_IN_STR "not in(" +#define SPIDER_SQL_NOT_IN_LEN (sizeof(SPIDER_SQL_NOT_IN_STR) - 1) +#define SPIDER_SQL_AS_CHAR_STR " as char" +#define SPIDER_SQL_AS_CHAR_LEN (sizeof(SPIDER_SQL_AS_CHAR_STR) - 1) +#define SPIDER_SQL_CAST_STR "cast(" +#define SPIDER_SQL_CAST_LEN (sizeof(SPIDER_SQL_CAST_STR) - 1) +#define SPIDER_SQL_AS_DATETIME_STR " as datetime" +#define SPIDER_SQL_AS_DATETIME_LEN (sizeof(SPIDER_SQL_AS_DATETIME_STR) - 1) +#define SPIDER_SQL_AS_DECIMAL_STR " as decimal" +#define SPIDER_SQL_AS_DECIMAL_LEN (sizeof(SPIDER_SQL_AS_DECIMAL_STR) - 1) +#define SPIDER_SQL_AS_SIGNED_STR " as signed" +#define SPIDER_SQL_AS_SIGNED_LEN (sizeof(SPIDER_SQL_AS_SIGNED_STR) - 1) +#define SPIDER_SQL_AS_UNSIGNED_STR " as unsigned" +#define SPIDER_SQL_AS_UNSIGNED_LEN (sizeof(SPIDER_SQL_AS_UNSIGNED_STR) - 1) +#define SPIDER_SQL_AS_DATE_STR " as date" +#define SPIDER_SQL_AS_DATE_LEN (sizeof(SPIDER_SQL_AS_DATE_STR) - 1) +#define SPIDER_SQL_AS_TIME_STR " as time" +#define SPIDER_SQL_AS_TIME_LEN (sizeof(SPIDER_SQL_AS_TIME_STR) - 1) +#define SPIDER_SQL_AS_BINARY_STR " as binary" +#define SPIDER_SQL_AS_BINARY_LEN (sizeof(SPIDER_SQL_AS_BINARY_STR) - 1) +#define SPIDER_SQL_IS_TRUE_STR " is true" +#define SPIDER_SQL_IS_TRUE_LEN (sizeof(SPIDER_SQL_IS_TRUE_STR) - 1) +#define SPIDER_SQL_IS_NOT_TRUE_STR " is not true" +#define SPIDER_SQL_IS_NOT_TRUE_LEN (sizeof(SPIDER_SQL_IS_NOT_TRUE_STR) - 1) +#define SPIDER_SQL_IS_FALSE_STR " is false" +#define SPIDER_SQL_IS_FALSE_LEN (sizeof(SPIDER_SQL_IS_FALSE_STR) - 1) +#define SPIDER_SQL_IS_NOT_FALSE_STR " is not false" +#define SPIDER_SQL_IS_NOT_FALSE_LEN (sizeof(SPIDER_SQL_IS_NOT_FALSE_STR) - 1) +#define SPIDER_SQL_NULL_CHAR_STR "" +#define SPIDER_SQL_NULL_CHAR_LEN (sizeof(SPIDER_SQL_NULL_CHAR_STR) - 1) +#define SPIDER_SQL_CREATE_TABLE_STR "create table " +#define SPIDER_SQL_CREATE_TABLE_LEN (sizeof(SPIDER_SQL_CREATE_TABLE_STR) - 1) +#define SPIDER_SQL_DEFAULT_CHARSET_STR " default charset " +#define SPIDER_SQL_DEFAULT_CHARSET_LEN (sizeof(SPIDER_SQL_DEFAULT_CHARSET_STR) - 1) +#define SPIDER_SQL_COLLATE_STR " collate " +#define SPIDER_SQL_COLLATE_LEN (sizeof(SPIDER_SQL_COLLATE_STR) - 1) +#define SPIDER_SQL_COMMENT_STR " comment " +#define SPIDER_SQL_COMMENT_LEN (sizeof(SPIDER_SQL_COMMENT_STR) - 1) +#define SPIDER_SQL_CONNECTION_STR " connection " +#define SPIDER_SQL_CONNECTION_LEN (sizeof(SPIDER_SQL_CONNECTION_STR) - 1) +#define SPIDER_SQL_LCL_NAME_QUOTE_STR "`" +#define SPIDER_SQL_LCL_NAME_QUOTE_LEN (sizeof(SPIDER_SQL_LCL_NAME_QUOTE_STR) - 1) + +#define SPIDER_CONN_KIND_MYSQL (1 << 0) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#define SPIDER_CONN_KIND_HS_READ (1 << 2) +#define SPIDER_CONN_KIND_HS_WRITE (1 << 3) +#endif + +#define SPIDER_SQL_KIND_SQL (1 << 0) +#define SPIDER_SQL_KIND_HANDLER (1 << 1) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#define SPIDER_SQL_KIND_HS (1 << 2) +#endif + +#define SPIDER_SQL_TYPE_SELECT_SQL (1 << 0) +#define SPIDER_SQL_TYPE_INSERT_SQL (1 << 1) +#define SPIDER_SQL_TYPE_UPDATE_SQL (1 << 2) +#define SPIDER_SQL_TYPE_DELETE_SQL (1 << 3) +#define SPIDER_SQL_TYPE_BULK_UPDATE_SQL (1 << 4) +#define SPIDER_SQL_TYPE_TMP_SQL (1 << 5) +#define SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL (1 << 6) +#define SPIDER_SQL_TYPE_OTHER_SQL (1 << 7) +#define SPIDER_SQL_TYPE_HANDLER (1 << 8) +#define SPIDER_SQL_TYPE_SELECT_HS (1 << 9) +#define SPIDER_SQL_TYPE_INSERT_HS (1 << 10) +#define SPIDER_SQL_TYPE_UPDATE_HS (1 << 11) +#define SPIDER_SQL_TYPE_DELETE_HS (1 << 12) +#define SPIDER_SQL_TYPE_OTHER_HS (1 << 13) + +enum spider_bulk_upd_start { + SPD_BU_NOT_START, + SPD_BU_START_BY_INDEX_OR_RND_INIT, + SPD_BU_START_BY_BULK_INIT +}; + +struct st_spider_ft_info; +struct st_spider_result; +typedef struct st_spider_transaction SPIDER_TRX; +typedef struct st_spider_share SPIDER_SHARE; +class ha_spider; +class spider_db_copy_table; + +class spider_string +{ +public: + bool mem_calc_inited; + String str; + uint id; + const char *func_name; + const char *file_name; + ulong line_no; + uint32 current_alloc_mem; + spider_string *next; + + spider_string(); + spider_string( + uint32 length_arg + ); + spider_string( + const char *str, + CHARSET_INFO *cs + ); + spider_string( + const char *str, + uint32 len, + CHARSET_INFO *cs + ); + spider_string( + char *str, + uint32 len, + CHARSET_INFO *cs + ); + spider_string( + const String &str + ); + ~spider_string(); + void init_mem_calc( + uint id, + const char *func_name, + const char *file_name, + ulong line_no + ); + void mem_calc(); + String *get_str(); + void set_charset( + CHARSET_INFO *charset_arg + ); + CHARSET_INFO *charset() const; + uint32 length() const; + uint32 alloced_length() const; + char &operator [] ( + uint32 i + ) const; + void length( + uint32 len + ); + bool is_empty() const; + const char *ptr() const; + char *c_ptr(); + char *c_ptr_quick(); + char *c_ptr_safe(); + LEX_STRING lex_string() const; + void set( + String &str, + uint32 offset, + uint32 arg_length + ); + void set( + char *str, + uint32 arg_length, + CHARSET_INFO *cs + ); + void set( + const char *str, + uint32 arg_length, + CHARSET_INFO *cs + ); + bool set_ascii( + const char *str, + uint32 arg_length + ); + void set_quick( + char *str, + uint32 arg_length, + CHARSET_INFO *cs + ); + bool set_int( + longlong num, + bool unsigned_flag, + CHARSET_INFO *cs + ); + bool set( + longlong num, + CHARSET_INFO *cs + ); + bool set( + ulonglong num, + CHARSET_INFO *cs + ); + bool set_real( + double num, + uint decimals, + CHARSET_INFO *cs + ); + void chop(); + void free(); + bool alloc( + uint32 arg_length + ); + bool real_alloc( + uint32 arg_length + ); + bool realloc( + uint32 arg_length + ); + void shrink( + uint32 arg_length + ); + bool is_alloced(); + spider_string& operator = ( + const String &s + ); + bool copy(); + bool copy( + const spider_string &s + ); + bool copy( + const String &s + ); + bool copy( + const char *s, + uint32 arg_length, + CHARSET_INFO *cs + ); + bool needs_conversion( + uint32 arg_length, + CHARSET_INFO *cs_from, + CHARSET_INFO *cs_to, + uint32 *offset + ); + bool copy_aligned( + const char *s, + uint32 arg_length, + uint32 offset, + CHARSET_INFO *cs + ); + bool set_or_copy_aligned( + const char *s, + uint32 arg_length, + CHARSET_INFO *cs + ); + bool copy( + const char *s, + uint32 arg_length, + CHARSET_INFO *csfrom, + CHARSET_INFO *csto, + uint *errors + ); + bool append( + const spider_string &s + ); + bool append( + const String &s + ); + bool append( + const char *s + ); + bool append( + LEX_STRING *ls + ); + bool append( + const char *s, + uint32 arg_length + ); + bool append( + const char *s, + uint32 arg_length, + CHARSET_INFO *cs + ); + bool append_ulonglong( + ulonglong val + ); + bool append( + IO_CACHE *file, + uint32 arg_length + ); + bool append_with_prefill( + const char *s, + uint32 arg_length, + uint32 full_length, + char fill_char + ); + int strstr( + const String &search, + uint32 offset = 0 + ); + int strrstr( + const String &search, + uint32 offset = 0 + ); + bool replace( + uint32 offset, + uint32 arg_length, + const char *to, + uint32 length + ); + bool replace( + uint32 offset, + uint32 arg_length, + const String &to + ); + inline bool append( + char chr + ); + bool fill( + uint32 max_length, + char fill + ); + void strip_sp(); + uint32 numchars(); + int charpos( + int i, + uint32 offset=0 + ); + int reserve( + uint32 space_needed + ); + int reserve( + uint32 space_needed, + uint32 grow_by + ); + void q_append( + const char c + ); + void q_append( + const uint32 n + ); + void q_append( + double d + ); + void q_append( + double *d + ); + void q_append( + const char *data, + uint32 data_len + ); + void write_at_position( + int position, + uint32 value + ); + void qs_append( + const char *str, + uint32 len + ); + void qs_append( + double d + ); + void qs_append( + double *d + ); + void qs_append( + const char c + ); + void qs_append( + int i + ); + void qs_append( + uint i + ); + char *prep_append( + uint32 arg_length, + uint32 step_alloc + ); + bool append( + const char *s, + uint32 arg_length, + uint32 step_alloc + ); +#ifdef SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE + bool append_for_single_quote( + const char *st, + uint len + ); +#endif + void print( + String *print + ); + void swap( + spider_string &s + ); + bool uses_buffer_owned_by( + const String *s + ) const; + bool is_ascii() const; +}; + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#define SPIDER_HS_UINT32_INFO dena::uint32_info +#define SPIDER_HS_STRING_REF dena::string_ref +#ifndef HANDLERSOCKET_MYSQL_UTIL +#define SPIDER_HS_VECTOR std::vector +class spider_db_hs_string_ref_buffer +{ + SPIDER_HS_VECTOR hs_conds; +public: + spider_db_hs_string_ref_buffer(); + ~spider_db_hs_string_ref_buffer(); + int init(); + void clear(); + int push_back( + SPIDER_HS_STRING_REF &cond + ); + SPIDER_HS_STRING_REF *ptr(); + uint size(); +}; +#else +class spider_db_hs_string_ref_buffer +{ + bool hs_da_init; + DYNAMIC_ARRAY hs_conds; + uint hs_conds_id; + const char *hs_conds_func_name; + const char *hs_conds_file_name; + ulong hs_conds_line_no; +public: + spider_db_hs_string_ref_buffer(); + ~spider_db_hs_string_ref_buffer(); + int init(); + void clear(); + int push_back( + SPIDER_HS_STRING_REF &cond + ); + SPIDER_HS_STRING_REF *ptr(); + uint size(); +}; +#endif + +class spider_db_hs_str_buffer +{ + bool hs_da_init; + DYNAMIC_ARRAY hs_conds; + uint hs_conds_id; + const char *hs_conds_func_name; + const char *hs_conds_file_name; + ulong hs_conds_line_no; +public: + spider_db_hs_str_buffer(); + ~spider_db_hs_str_buffer(); + int init(); + void clear(); + spider_string *add( + uint *strs_pos, + const char *str, + uint str_len + ); +}; + +#define SPIDER_DB_HS_STRING_REF_BUFFER spider_db_hs_string_ref_buffer +#define SPIDER_DB_HS_STR_BUFFER spider_db_hs_str_buffer +#endif + +struct st_spider_db_request_key +{ + ulonglong spider_thread_id; + query_id_t query_id; + void *handler; + ulonglong request_id; + st_spider_db_request_key *next; +}; + +class spider_db_util +{ +public: + spider_db_util() {} + virtual ~spider_db_util() {} + virtual int append_name( + spider_string *str, + const char *name, + uint name_length + ) = 0; + virtual int append_name_with_charset( + spider_string *str, + const char *name, + uint name_length, + CHARSET_INFO *name_charset + ) = 0; + virtual bool is_name_quote( + const char head_code + ) = 0; + virtual int append_escaped_name_quote( + spider_string *str + ) = 0; + virtual int append_column_value( + ha_spider *spider, + spider_string *str, + Field *field, + const uchar *new_ptr, + CHARSET_INFO *access_charset + ) = 0; + virtual int append_trx_isolation( + spider_string *str, + int trx_isolation + ) = 0; + virtual int append_autocommit( + spider_string *str, + bool autocommit + ) = 0; + virtual int append_sql_log_off( + spider_string *str, + bool sql_log_off + ) = 0; + virtual int append_time_zone( + spider_string *str, + Time_zone *time_zone + ) = 0; + virtual int append_start_transaction( + spider_string *str + ) = 0; + virtual int append_xa_start( + spider_string *str, + XID *xid + ) = 0; + virtual int append_lock_table_head( + spider_string *str + ) = 0; + virtual int append_lock_table_body( + spider_string *str, + const char *db_name, + uint db_name_length, + CHARSET_INFO *db_name_charset, + const char *table_name, + uint table_name_length, + CHARSET_INFO *table_name_charset, + int lock_type + ) = 0; + virtual int append_lock_table_tail( + spider_string *str + ) = 0; + virtual int append_unlock_table( + spider_string *str + ) = 0; + virtual int open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length + ) = 0; + virtual int append_escaped_util( + spider_string *to, + String *from + ) = 0; +}; + +class spider_db_row +{ +public: + SPIDER_DB_ROW *next_pos; + spider_db_row() : next_pos(NULL) {} + virtual ~spider_db_row() {} + virtual int store_to_field( + Field *field, + CHARSET_INFO *access_charset + ) = 0; + virtual int append_to_str( + spider_string *str + ) = 0; + virtual int append_escaped_to_str( + spider_string *str, + uint dbton_id + ) = 0; + virtual void first() = 0; + virtual void next() = 0; + virtual bool is_null() = 0; + virtual int val_int() = 0; + virtual double val_real() = 0; + virtual SPIDER_DB_ROW *clone() = 0; + virtual int store_to_tmp_table( + TABLE *tmp_table, + spider_string *str + ) = 0; +}; + +class spider_db_result_buffer +{ +public: + spider_db_result_buffer() {} + virtual ~spider_db_result_buffer() {} + virtual void clear() = 0; + virtual bool check_size( + longlong size + ) = 0; +}; + +class spider_db_result +{ +public: + spider_db_result() {} + virtual ~spider_db_result() {} + virtual bool has_result() = 0; + virtual void free_result() = 0; + virtual SPIDER_DB_ROW *current_row() = 0; + virtual SPIDER_DB_ROW *fetch_row() = 0; + virtual SPIDER_DB_ROW *fetch_row_from_result_buffer( + spider_db_result_buffer *spider_res_buf + ) = 0; + virtual SPIDER_DB_ROW *fetch_row_from_tmp_table( + TABLE *tmp_table + ) = 0; + virtual int fetch_table_status( + int mode, + ha_rows &records, + ulong &mean_rec_length, + ulonglong &data_file_length, + ulonglong &max_data_file_length, + ulonglong &index_file_length, + ulonglong &auto_increment_value, + time_t &create_time, + time_t &update_time, + time_t &check_time + ) = 0; + virtual int fetch_table_records( + int mode, + ha_rows &records + ) = 0; + virtual int fetch_table_cardinality( + int mode, + TABLE *table, + longlong *cardinality, + uchar *cardinality_upd, + int bitmap_size + ) = 0; + virtual int fetch_table_mon_status( + int &status + ) = 0; + virtual longlong num_rows() = 0; + virtual uint num_fields() = 0; + virtual void move_to_pos( + longlong pos + ) = 0; + virtual int get_errno() = 0; +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + virtual int fetch_columns_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset + ) = 0; + virtual int fetch_index_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset + ) = 0; +#endif +}; + +class spider_db_conn +{ +protected: + SPIDER_CONN *conn; +public: + spider_db_conn( + SPIDER_CONN *conn + ) : conn(conn) {} + virtual ~spider_db_conn() {} + virtual int init() = 0; + virtual bool is_connected() = 0; + virtual void bg_connect() = 0; + virtual int connect( + char *tgt_host, + char *tgt_username, + char *tgt_password, + long tgt_port, + char *tgt_socket, + char *server_name, + int connect_retry_count, + longlong connect_retry_interval + ) = 0; + virtual int ping() = 0; + virtual void bg_disconnect() = 0; + virtual void disconnect() = 0; + virtual int set_net_timeout() = 0; + virtual int exec_query( + const char *query, + uint length, + int quick_mode + ) = 0; + virtual int get_errno() = 0; + virtual const char *get_error() = 0; + virtual bool is_server_gone_error( + int error_num + ) = 0; + virtual bool is_dup_entry_error( + int error_num + ) = 0; + virtual bool is_xa_nota_error( + int error_num + ) = 0; + virtual spider_db_result *store_result( + spider_db_result_buffer **spider_res_buf, + st_spider_db_request_key *request_key, + int *error_num + ) = 0; + virtual spider_db_result *use_result( + st_spider_db_request_key *request_key, + int *error_num + ) = 0; + virtual int next_result() = 0; + virtual uint affected_rows() = 0; + virtual ulonglong last_insert_id() = 0; + virtual int set_character_set( + const char *csname + ) = 0; + virtual int select_db( + const char *dbname + ) = 0; + virtual int consistent_snapshot( + int *need_mon + ) = 0; + virtual bool trx_start_in_bulk_sql() = 0; + virtual int start_transaction( + int *need_mon + ) = 0; + virtual int commit( + int *need_mon + ) = 0; + virtual int rollback( + int *need_mon + ) = 0; + virtual bool xa_start_in_bulk_sql() = 0; + virtual int xa_start( + XID *xid, + int *need_mon + ) = 0; + virtual int xa_end( + XID *xid, + int *need_mon + ) = 0; + virtual int xa_prepare( + XID *xid, + int *need_mon + ) = 0; + virtual int xa_commit( + XID *xid, + int *need_mon + ) = 0; + virtual int xa_rollback( + XID *xid, + int *need_mon + ) = 0; + virtual bool set_trx_isolation_in_bulk_sql() = 0; + virtual int set_trx_isolation( + int trx_isolation, + int *need_mon + ) = 0; + virtual bool set_autocommit_in_bulk_sql() = 0; + virtual int set_autocommit( + bool autocommit, + int *need_mon + ) = 0; + virtual bool set_sql_log_off_in_bulk_sql() = 0; + virtual int set_sql_log_off( + bool sql_log_off, + int *need_mon + ) = 0; + virtual bool set_time_zone_in_bulk_sql() = 0; + virtual int set_time_zone( + Time_zone *time_zone, + int *need_mon + ) = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + virtual int append_sql( + char *sql, + ulong sql_length, + st_spider_db_request_key *request_key + ) = 0; + virtual int append_open_handler( + uint handler_id, + const char *db_name, + const char *table_name, + const char *index_name, + const char *sql, + st_spider_db_request_key *request_key + ) = 0; + virtual int append_select( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key + ) = 0; + virtual int append_insert( + uint handler_id, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + st_spider_db_request_key *request_key + ) = 0; + virtual int append_update( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + int limit, + int skip, + bool increment, + bool decrement, + st_spider_db_request_key *request_key + ) = 0; + virtual int append_delete( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key + ) = 0; + virtual void reset_request_queue() = 0; +#endif + virtual size_t escape_string( + char *to, + const char *from, + size_t from_length + ) = 0; + virtual bool have_lock_table_list() = 0; + virtual int append_lock_tables( + spider_string *str + ) = 0; + virtual int append_unlock_tables( + spider_string *str + ) = 0; + virtual uint get_lock_table_hash_count() = 0; + virtual void reset_lock_table_hash() = 0; + virtual uint get_opened_handler_count() = 0; + virtual void reset_opened_handler() = 0; + virtual void set_dup_key_idx( + ha_spider *spider, + int link_idx + ) = 0; + virtual bool cmp_request_key_to_snd( + st_spider_db_request_key *request_key + ) = 0; +}; + +class spider_db_share +{ +protected: + uint mem_calc_id; + const char *mem_calc_func_name; + const char *mem_calc_file_name; + ulong mem_calc_line_no; +public: + st_spider_share *spider_share; + spider_db_share(st_spider_share *share) : spider_share(share) {} + virtual ~spider_db_share() {} + virtual int init() = 0; + virtual uint get_column_name_length( + uint field_index + ) = 0; + virtual int append_column_name( + spider_string *str, + uint field_index + ) = 0; + virtual int append_column_name_with_alias( + spider_string *str, + uint field_index, + const char *alias, + uint alias_length + ) = 0; + virtual bool need_change_db_table_name() = 0; +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + virtual int discover_table_structure( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str + ) = 0; +#endif +}; + +class spider_db_handler +{ +protected: + uint mem_calc_id; + const char *mem_calc_func_name; + const char *mem_calc_file_name; + ulong mem_calc_line_no; +public: + ha_spider *spider; + spider_db_share *db_share; + int first_link_idx; + spider_db_handler(ha_spider *spider, spider_db_share *db_share) : + spider(spider), db_share(db_share), first_link_idx(-1) {} + virtual ~spider_db_handler() {} + virtual int init() = 0; + virtual int append_table_name_with_adjusting( + spider_string *str, + int link_idx, + ulong sql_type + ) = 0; + virtual int append_tmp_table_and_sql_for_bka( + const key_range *start_key + ) = 0; + virtual int reuse_tmp_table_and_sql_for_bka() = 0; + virtual int append_insert_for_recovery( + ulong sql_type, + int link_idx + ) = 0; + virtual int append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff + ) = 0; + virtual int append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx + ) = 0; + virtual int append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff + ) = 0; + virtual int append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx + ) = 0; + virtual int append_insert_part() = 0; + virtual int append_update_part() = 0; + virtual int append_delete_part() = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + virtual int append_increment_update_set_part() = 0; +#endif +#endif + virtual int append_update_set_part() = 0; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + virtual int append_direct_update_set_part() = 0; + virtual int append_dup_update_pushdown_part( + const char *alias, + uint alias_length + ) = 0; + virtual int append_update_columns_part( + const char *alias, + uint alias_length + ) = 0; + virtual int check_update_columns_part() = 0; +#endif + virtual int append_select_part( + ulong sql_type + ) = 0; + virtual int append_table_select_part( + ulong sql_type + ) = 0; + virtual int append_key_select_part( + ulong sql_type, + uint idx + ) = 0; + virtual int append_minimum_select_part( + ulong sql_type + ) = 0; + virtual int append_hint_after_table_part( + ulong sql_type + ) = 0; + virtual void set_where_pos( + ulong sql_type + ) = 0; + virtual void set_where_to_pos( + ulong sql_type + ) = 0; + virtual int check_item_type( + Item *item + ) = 0; + virtual int append_values_connector_part( + ulong sql_type + ) = 0; + virtual int append_values_terminator_part( + ulong sql_type + ) = 0; + virtual int append_key_column_values_part( + const key_range *start_key, + ulong sql_type + ) = 0; + virtual int append_key_where_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type + ) = 0; + virtual int append_is_null_part( + ulong sql_type, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq + ) = 0; + virtual int append_where_terminator_part( + ulong sql_type, + bool set_order, + int key_count + ) = 0; + virtual int append_match_where_part( + ulong sql_type + ) = 0; + virtual int append_condition_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg + ) = 0; + virtual int append_match_select_part( + ulong sql_type, + const char *alias, + uint alias_length + ) = 0; + virtual void set_order_pos( + ulong sql_type + ) = 0; + virtual void set_order_to_pos( + ulong sql_type + ) = 0; + virtual int append_key_order_for_merge_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ) = 0; + virtual int append_key_order_for_direct_order_limit_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ) = 0; + virtual int append_key_order_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ) = 0; + virtual int append_limit_part( + longlong offset, + longlong limit, + ulong sql_type + ) = 0; + virtual int reappend_limit_part( + longlong offset, + longlong limit, + ulong sql_type + ) = 0; + virtual int append_select_lock_part( + ulong sql_type + ) = 0; + virtual int append_union_all_start_part( + ulong sql_type + ) = 0; + virtual int append_union_all_part( + ulong sql_type + ) = 0; + virtual int append_union_all_end_part( + ulong sql_type + ) = 0; + virtual int append_multi_range_cnt_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma + ) = 0; + virtual int append_open_handler_part( + ulong sql_type, + uint handler_id, + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int append_close_handler_part( + ulong sql_type, + int link_idx + ) = 0; + virtual int append_insert_terminator_part( + ulong sql_type + ) = 0; + virtual int append_insert_values_part( + ulong sql_type + ) = 0; + virtual int append_into_part( + ulong sql_type + ) = 0; + virtual void set_insert_to_pos( + ulong sql_type + ) = 0; + virtual int append_from_part( + ulong sql_type, + int link_idx + ) = 0; + virtual int append_delete_all_rows_part( + ulong sql_type + ) = 0; + virtual int append_explain_select_part( + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx + ) = 0; + virtual bool is_bulk_insert_exec_period( + bool bulk_end + ) = 0; + virtual bool sql_is_filled_up( + ulong sql_type + ) = 0; + virtual bool sql_is_empty( + ulong sql_type + ) = 0; + virtual bool support_multi_split_read() = 0; + virtual bool support_bulk_update() = 0; + virtual int bulk_tmp_table_insert() = 0; + virtual int bulk_tmp_table_insert( + int link_idx + ) = 0; + virtual int bulk_tmp_table_end_bulk_insert() = 0; + virtual int bulk_tmp_table_rnd_init() = 0; + virtual int bulk_tmp_table_rnd_next() = 0; + virtual int bulk_tmp_table_rnd_end() = 0; + virtual bool need_copy_for_update( + int link_idx + ) = 0; + virtual bool bulk_tmp_table_created() = 0; + virtual int mk_bulk_tmp_table_and_bulk_start() = 0; + virtual void rm_bulk_tmp_table() = 0; + virtual int insert_lock_tables_list( + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int append_lock_tables_list( + SPIDER_CONN *conn, + int link_idx, + int *appended + ) = 0; + virtual int realloc_sql( + ulong *realloced + ) = 0; + virtual int reset_sql( + ulong sql_type + ) = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + virtual int reset_keys( + ulong sql_type + ) = 0; + virtual int reset_upds( + ulong sql_type + ) = 0; + virtual int reset_strs( + ulong sql_type + ) = 0; + virtual int reset_strs_pos( + ulong sql_type + ) = 0; + virtual int push_back_upds( + SPIDER_HS_STRING_REF &info + ) = 0; +#endif + virtual bool need_lock_before_set_sql_for_exec( + ulong sql_type + ) = 0; + virtual int set_sql_for_exec( + ulong sql_type, + int link_idx + ) = 0; + virtual int set_sql_for_exec( + spider_db_copy_table *tgt_ct, + ulong sql_type + ) = 0; + virtual int execute_sql( + ulong sql_type, + SPIDER_CONN *conn, + int quick_mode, + int *need_mon + ) = 0; + virtual int reset() = 0; + virtual int sts_mode_exchange( + int sts_mode + ) = 0; + virtual int show_table_status( + int link_idx, + int sts_mode, + uint flag + ) = 0; + virtual int crd_mode_exchange( + int crd_mode + ) = 0; + virtual int show_index( + int link_idx, + int crd_mode + ) = 0; + virtual int show_records( + int link_idx + ) = 0; + virtual int show_last_insert_id( + int link_idx, + ulonglong &last_insert_id + ) = 0; + virtual ha_rows explain_select( + key_range *start_key, + key_range *end_key, + int link_idx + ) = 0; + virtual int lock_tables( + int link_idx + ) = 0; + virtual int unlock_tables( + int link_idx + ) = 0; + virtual int disable_keys( + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int enable_keys( + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int check_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt + ) = 0; + virtual int repair_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt + ) = 0; + virtual int analyze_table( + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int optimize_table( + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int flush_tables( + SPIDER_CONN *conn, + int link_idx, + bool lock + ) = 0; + virtual int flush_logs( + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int insert_opened_handler( + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int delete_opened_handler( + SPIDER_CONN *conn, + int link_idx + ) = 0; + virtual int sync_from_clone_source( + spider_db_handler *dbton_hdl + ) = 0; + virtual bool support_use_handler( + int use_handler + ) = 0; +}; + +class spider_db_copy_table +{ +public: + spider_db_share *db_share; + spider_db_copy_table(spider_db_share *db_share) : + db_share(db_share) {} + virtual ~spider_db_copy_table() {} + virtual int init() = 0; + virtual void set_sql_charset( + CHARSET_INFO *cs + ) = 0; + virtual int append_select_str() = 0; + virtual int append_insert_str( + int insert_flg + ) = 0; + virtual int append_table_columns( + TABLE_SHARE *table_share + ) = 0; + virtual int append_from_str() = 0; + virtual int append_table_name( + int link_idx + ) = 0; + virtual void set_sql_pos() = 0; + virtual void set_sql_to_pos() = 0; + virtual int append_copy_where( + spider_db_copy_table *source_ct, + KEY *key_info, + ulong *last_row_pos, + ulong *last_lengths + ) = 0; + virtual int append_key_order_str( + KEY *key_info, + int start_pos, + bool desc_flg + ) = 0; + virtual int append_limit( + longlong offset, + longlong limit + ) = 0; + virtual int append_into_str() = 0; + virtual int append_open_paren_str() = 0; + virtual int append_values_str() = 0; + virtual int append_select_lock_str( + int lock_mode + ) = 0; + virtual int exec_query( + SPIDER_CONN *conn, + int quick_mode, + int *need_mon + ) = 0; + virtual int copy_rows( + TABLE *table, + SPIDER_DB_ROW *row, + ulong **last_row_pos, + ulong **last_lengths + ) = 0; + virtual int copy_rows( + TABLE *table, + SPIDER_DB_ROW *row + ) = 0; + virtual int append_insert_terminator() = 0; + virtual int copy_insert_values( + spider_db_copy_table *source_ct + ) = 0; +}; + +enum spider_db_access_type +{ + SPIDER_DB_ACCESS_TYPE_SQL, + SPIDER_DB_ACCESS_TYPE_NOSQL +}; + +typedef struct st_spider_dbton +{ + uint dbton_id; + const char *wrapper; + enum spider_db_access_type db_access_type; + int (*init)(); + int (*deinit)(); + spider_db_share *(*create_db_share)(st_spider_share *share); + spider_db_handler *(*create_db_handler)(ha_spider *spider, + spider_db_share *db_share); + spider_db_copy_table *(*create_db_copy_table)( + spider_db_share *db_share); + SPIDER_DB_CONN *(*create_db_conn)(SPIDER_CONN *conn); + spider_db_util *db_util; +} SPIDER_DBTON; +#define SPIDER_DBTON_SIZE 15 + +typedef struct st_spider_position +{ + SPIDER_DB_ROW *row; + uint pos_mode; + bool use_position; + bool mrr_with_cnt; + uint sql_kind; + uchar *position_bitmap; + st_spider_ft_info *ft_first; + st_spider_ft_info *ft_current; + my_off_t tmp_tbl_pos; + SPIDER_RESULT *result; +} SPIDER_POSITION; + +typedef struct st_spider_condition +{ + COND *cond; + st_spider_condition *next; +} SPIDER_CONDITION; + +typedef struct st_spider_result +{ + SPIDER_DB_RESULT *result; +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile +#endif + st_spider_result *prev; +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile +#endif + st_spider_result *next; + SPIDER_POSITION *first_position; /* for quick mode */ + int pos_page_size; /* for quick mode */ + longlong record_num; + bool finish_flg; + bool use_position; + uint field_count; /* for quick mode */ + TABLE *result_tmp_tbl; + TMP_TABLE_PARAM result_tmp_tbl_prm; + THD *result_tmp_tbl_thd; + uint result_tmp_tbl_inited; + SPIDER_DB_ROW *tmp_tbl_row; +} SPIDER_RESULT; + +typedef struct st_spider_result_list +{ +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile +#endif + SPIDER_RESULT *first; +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile +#endif + SPIDER_RESULT *last; +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile +#endif + SPIDER_RESULT *current; + KEY *key_info; + int key_order; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ulonglong hs_upd_rows; + SPIDER_DB_RESULT *hs_result; + SPIDER_DB_RESULT_BUFFER *hs_result_buf; + bool hs_has_result; + SPIDER_DB_CONN *hs_conn; +#endif +#ifdef HA_CAN_BULK_ACCESS +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uchar *hs_r_bulk_open_index; + uchar *hs_w_bulk_open_index; +#endif +#endif + spider_string *sqls; + int ha_read_kind; + bool have_sql_kind_backup; + uint *sql_kind_backup; + uint sql_kinds_backup; + bool use_union; + spider_string *insert_sqls; + spider_string *update_sqls; + TABLE **upd_tmp_tbls; + TMP_TABLE_PARAM *upd_tmp_tbl_prms; + bool tmp_table_join; + uchar *tmp_table_join_first; + bool tmp_tables_created; + uchar *tmp_table_created; + bool tmp_table_join_break_after_get_next; + key_part_map tmp_table_join_key_part_map; + spider_string *tmp_sqls; + bool tmp_reuse_sql; + bool sorted; + bool desc_flg; + longlong current_row_num; + longlong record_num; + bool finish_flg; + longlong limit_num; + longlong internal_offset; + longlong internal_limit; + longlong split_read; + int multi_split_read; + int max_order; + int quick_mode; + longlong quick_page_size; + int low_mem_read; + int bulk_update_mode; + int bulk_update_size; + spider_bulk_upd_start bulk_update_start; + bool check_direct_order_limit; + bool direct_order_limit; + bool set_split_read; + bool insert_dup_update_pushdown; + longlong split_read_base; + double semi_split_read; + longlong semi_split_read_limit; + longlong semi_split_read_base; + longlong first_read; + longlong second_read; + int set_split_read_count; +#ifndef WITHOUT_SPIDER_BG_SEARCH + /* 0:nomal 1:store 2:store end */ + volatile +#endif + int quick_phase; + bool keyread; + int lock_type; + TABLE *table; +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile int bgs_error; + bool bgs_error_with_message; + char bgs_error_msg[MYSQL_ERRMSG_SIZE]; + volatile bool bgs_working; + /* 0:not use bg 1:first read 2:second read 3:after second read */ + volatile int bgs_phase; + volatile longlong bgs_first_read; + volatile longlong bgs_second_read; + volatile longlong bgs_split_read; + volatile +#endif + SPIDER_RESULT *bgs_current; + SPIDER_DB_ROW *tmp_pos_row_first; +} SPIDER_RESULT_LIST; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc new file mode 100644 index 00000000000..d17de6cd32e --- /dev/null +++ b/storage/spider/spd_db_mysql.cc @@ -0,0 +1,10839 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#include "sql_analyse.h" +#include "sql_base.h" +#include "tztime.h" +#endif +#include "sql_common.h" +#include +#include +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_db_mysql.h" +#include "ha_spider.h" +#include "spd_conn.h" +#include "spd_db_conn.h" +#include "spd_malloc.h" +#include "spd_sys_table.h" +#include "spd_table.h" + +extern struct charset_info_st *spd_charset_utf8_bin; + +extern handlerton *spider_hton_ptr; +extern pthread_mutex_t spider_open_conn_mutex; +extern HASH spider_open_connections; +extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; +extern const char spider_dig_upper[]; + +#define SPIDER_SQL_NAME_QUOTE_STR "`" +#define SPIDER_SQL_NAME_QUOTE_LEN (sizeof(SPIDER_SQL_NAME_QUOTE_STR) - 1) +static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; + +#define SPIDER_SQL_ISO_READ_UNCOMMITTED_STR "set session transaction isolation level read uncommitted" +#define SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN sizeof(SPIDER_SQL_ISO_READ_UNCOMMITTED_STR) - 1 +#define SPIDER_SQL_ISO_READ_COMMITTED_STR "set session transaction isolation level read committed" +#define SPIDER_SQL_ISO_READ_COMMITTED_LEN sizeof(SPIDER_SQL_ISO_READ_COMMITTED_STR) - 1 +#define SPIDER_SQL_ISO_REPEATABLE_READ_STR "set session transaction isolation level repeatable read" +#define SPIDER_SQL_ISO_REPEATABLE_READ_LEN sizeof(SPIDER_SQL_ISO_REPEATABLE_READ_STR) - 1 +#define SPIDER_SQL_ISO_SERIALIZABLE_STR "set session transaction isolation level serializable" +#define SPIDER_SQL_ISO_SERIALIZABLE_LEN sizeof(SPIDER_SQL_ISO_SERIALIZABLE_STR) - 1 + +#define SPIDER_SQL_START_CONSISTENT_SNAPSHOT_STR "start transaction with consistent snapshot" +#define SPIDER_SQL_START_CONSISTENT_SNAPSHOT_LEN sizeof(SPIDER_SQL_START_CONSISTENT_SNAPSHOT_STR) - 1 +#define SPIDER_SQL_START_TRANSACTION_STR "start transaction" +#define SPIDER_SQL_START_TRANSACTION_LEN sizeof(SPIDER_SQL_START_TRANSACTION_STR) - 1 + +#define SPIDER_SQL_AUTOCOMMIT_OFF_STR "set session autocommit = 0" +#define SPIDER_SQL_AUTOCOMMIT_OFF_LEN sizeof(SPIDER_SQL_AUTOCOMMIT_OFF_STR) - 1 +#define SPIDER_SQL_AUTOCOMMIT_ON_STR "set session autocommit = 1" +#define SPIDER_SQL_AUTOCOMMIT_ON_LEN sizeof(SPIDER_SQL_AUTOCOMMIT_ON_STR) - 1 + +#define SPIDER_SQL_SQL_LOG_OFF_STR "set session sql_log_off = 0" +#define SPIDER_SQL_SQL_LOG_OFF_LEN sizeof(SPIDER_SQL_SQL_LOG_OFF_STR) - 1 +#define SPIDER_SQL_SQL_LOG_ON_STR "set session sql_log_off = 1" +#define SPIDER_SQL_SQL_LOG_ON_LEN sizeof(SPIDER_SQL_SQL_LOG_ON_STR) - 1 + +#define SPIDER_SQL_TIME_ZONE_STR "set session time_zone = '" +#define SPIDER_SQL_TIME_ZONE_LEN sizeof(SPIDER_SQL_TIME_ZONE_STR) - 1 + +#define SPIDER_SQL_COMMIT_STR "commit" +#define SPIDER_SQL_COMMIT_LEN sizeof(SPIDER_SQL_COMMIT_STR) - 1 +#define SPIDER_SQL_ROLLBACK_STR "rollback" +#define SPIDER_SQL_ROLLBACK_LEN sizeof(SPIDER_SQL_ROLLBACK_STR) - 1 + +#define SPIDER_SQL_XA_START_STR "xa start " +#define SPIDER_SQL_XA_START_LEN sizeof(SPIDER_SQL_XA_START_STR) - 1 +#define SPIDER_SQL_XA_END_STR "xa end " +#define SPIDER_SQL_XA_END_LEN sizeof(SPIDER_SQL_XA_END_STR) - 1 +#define SPIDER_SQL_XA_PREPARE_STR "xa prepare " +#define SPIDER_SQL_XA_PREPARE_LEN sizeof(SPIDER_SQL_XA_PREPARE_STR) - 1 +#define SPIDER_SQL_XA_COMMIT_STR "xa commit " +#define SPIDER_SQL_XA_COMMIT_LEN sizeof(SPIDER_SQL_XA_COMMIT_STR) - 1 +#define SPIDER_SQL_XA_ROLLBACK_STR "xa rollback " +#define SPIDER_SQL_XA_ROLLBACK_LEN sizeof(SPIDER_SQL_XA_ROLLBACK_STR) - 1 + +#define SPIDER_SQL_LOCK_TABLE_STR "lock tables " +#define SPIDER_SQL_LOCK_TABLE_LEN (sizeof(SPIDER_SQL_LOCK_TABLE_STR) - 1) +#define SPIDER_SQL_UNLOCK_TABLE_STR "unlock tables" +#define SPIDER_SQL_UNLOCK_TABLE_LEN (sizeof(SPIDER_SQL_UNLOCK_TABLE_STR) - 1) + +#define SPIDER_SQL_SHOW_TABLE_STATUS_STR "show table status from " +#define SPIDER_SQL_SHOW_TABLE_STATUS_LEN sizeof(SPIDER_SQL_SHOW_TABLE_STATUS_STR) - 1 +#define SPIDER_SQL_SELECT_TABLES_STATUS_STR "select `table_rows`,`avg_row_length`,`data_length`,`max_data_length`,`index_length`,`auto_increment`,`create_time`,`update_time`,`check_time` from `information_schema`.`tables` where `table_schema` = " +#define SPIDER_SQL_SELECT_TABLES_STATUS_LEN sizeof(SPIDER_SQL_SELECT_TABLES_STATUS_STR) - 1 + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +#define SPIDER_SQL_SHOW_COLUMNS_STR "show columns from " +#define SPIDER_SQL_SHOW_COLUMNS_LEN sizeof(SPIDER_SQL_SHOW_COLUMNS_STR) - 1 +#endif + +#define SPIDER_SQL_LIKE_STR " like " +#define SPIDER_SQL_LIKE_LEN (sizeof(SPIDER_SQL_LIKE_STR) - 1) +#define SPIDER_SQL_LIMIT1_STR " limit 1" +#define SPIDER_SQL_LIMIT1_LEN (sizeof(SPIDER_SQL_LIMIT1_STR) - 1) +#define SPIDER_SQL_COLLATE_STR " collate " +#define SPIDER_SQL_COLLATE_LEN (sizeof(SPIDER_SQL_COLLATE_STR) - 1) + +#define SPIDER_SQL_INTERVAL_STR " + interval " +#define SPIDER_SQL_INTERVAL_LEN (sizeof(SPIDER_SQL_INTERVAL_STR) - 1) +#define SPIDER_SQL_NEGINTERVAL_STR " - interval " +#define SPIDER_SQL_NEGINTERVAL_LEN (sizeof(SPIDER_SQL_NEGINTERVAL_STR) - 1) + +static uchar SPIDER_SQL_LINESTRING_HEAD_STR[] = + {0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00}; +#define SPIDER_SQL_LINESTRING_HEAD_LEN sizeof(SPIDER_SQL_LINESTRING_HEAD_STR) + +static const char *spider_db_table_lock_str[] = +{ + " read local,", + " read,", + " low_priority write,", + " write," +}; +static const int spider_db_table_lock_len[] = +{ + sizeof(" read local,") - 1, + sizeof(" read,") - 1, + sizeof(" low_priority write,") - 1, + sizeof(" write,") - 1 +}; +static const char *spider_db_timefunc_interval_str[] = +{ + " year", " quarter", " month", " week", " day", + " hour", " minute", " second", " microsecond", + " year_month", " day_hour", " day_minute", + " day_second", " hour_minute", " hour_second", + " minute_second", " day_microsecond", " hour_microsecond", + " minute_microsecond", " second_microsecond" +}; + +int spider_mysql_init() +{ + DBUG_ENTER("spider_mysql_init"); + DBUG_RETURN(0); +} + +int spider_mysql_deinit() +{ + DBUG_ENTER("spider_mysql_deinit"); + DBUG_RETURN(0); +} + +spider_db_share *spider_mysql_create_share( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_mysql_create_share"); + DBUG_RETURN(new spider_mysql_share(share)); +} + +spider_db_handler *spider_mysql_create_handler( + ha_spider *spider, + spider_db_share *db_share +) { + DBUG_ENTER("spider_mysql_create_handler"); + DBUG_RETURN(new spider_mysql_handler(spider, + (spider_mysql_share *) db_share)); +} + +spider_db_copy_table *spider_mysql_create_copy_table( + spider_db_share *db_share +) { + DBUG_ENTER("spider_mysql_create_copy_table"); + DBUG_RETURN(new spider_mysql_copy_table( + (spider_mysql_share *) db_share)); +} + +SPIDER_DB_CONN *spider_mysql_create_conn( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_mysql_create_conn"); + DBUG_RETURN(new spider_db_mysql(conn)); +} + +spider_db_mysql_util spider_db_mysql_utility; + +SPIDER_DBTON spider_dbton_mysql = { + 0, + SPIDER_DB_WRAPPER_MYSQL, + SPIDER_DB_ACCESS_TYPE_SQL, + spider_mysql_init, + spider_mysql_deinit, + spider_mysql_create_share, + spider_mysql_create_handler, + spider_mysql_create_copy_table, + spider_mysql_create_conn, + &spider_db_mysql_utility +}; + +spider_db_mysql_row::spider_db_mysql_row() : spider_db_row(), + row(NULL), lengths(NULL), cloned(FALSE) +{ + DBUG_ENTER("spider_db_mysql_row::spider_db_mysql_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mysql_row::~spider_db_mysql_row() +{ + DBUG_ENTER("spider_db_mysql_row::~spider_db_mysql_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (cloned) + { + spider_free(spider_current_trx, row_first, MYF(0)); + } + DBUG_VOID_RETURN; +} + +int spider_db_mysql_row::store_to_field( + Field *field, + CHARSET_INFO *access_charset +) { + DBUG_ENTER("spider_db_mysql_row::store_to_field"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!*row) + { + DBUG_PRINT("info", ("spider field is null")); + field->set_null(); + field->reset(); + } else { + field->set_notnull(); + if (field->flags & BLOB_FLAG) + { + DBUG_PRINT("info", ("spider blob field")); + if ( + field->charset() == &my_charset_bin || + field->charset()->cset == access_charset->cset + ) + ((Field_blob *)field)->set_ptr(*lengths, (uchar *) *row); + else { + DBUG_PRINT("info", ("spider blob convert")); + if (field->table->file->ht == spider_hton_ptr) + { + ha_spider *spider = (ha_spider *) field->table->file; + spider_string *str = &spider->blob_buff[field->field_index]; + str->length(0); + if (str->append(*row, *lengths, access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + ((Field_blob *)field)->set_ptr(str->length(), (uchar *) str->ptr()); + } else { + field->store(*row, *lengths, access_charset); + } + } + } else + field->store(*row, *lengths, access_charset); + } + DBUG_RETURN(0); +} + +int spider_db_mysql_row::append_to_str( + spider_string *str +) { + DBUG_ENTER("spider_db_mysql_row::append_to_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(*lengths)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(*row, *lengths); + DBUG_RETURN(0); +} + +int spider_db_mysql_row::append_escaped_to_str( + spider_string *str, + uint dbton_id +) { + DBUG_ENTER("spider_db_mysql_row::append_escaped_to_str"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_string tmp_str(*row, *lengths + 1, str->charset()); + tmp_str.init_calc_mem(133); + tmp_str.length(*lengths); + if (str->reserve(*lengths * 2 + 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + spider_dbton[dbton_id].db_util->append_escaped_util(str, tmp_str.get_str()); + DBUG_RETURN(0); +} + +void spider_db_mysql_row::first() +{ + DBUG_ENTER("spider_db_mysql_row::first"); + DBUG_PRINT("info",("spider this=%p", this)); + row = row_first; + lengths = lengths_first; + DBUG_VOID_RETURN; +} + +void spider_db_mysql_row::next() +{ + DBUG_ENTER("spider_db_mysql_row::next"); + DBUG_PRINT("info",("spider this=%p", this)); + row++; + lengths++; + DBUG_VOID_RETURN; +} + +bool spider_db_mysql_row::is_null() +{ + DBUG_ENTER("spider_db_mysql_row::is_null"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(!(*row)); +} + +int spider_db_mysql_row::val_int() +{ + DBUG_ENTER("spider_db_mysql_row::val_int"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(*row ? atoi(*row) : 0); +} + +double spider_db_mysql_row::val_real() +{ + DBUG_ENTER("spider_db_mysql_row::val_real"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(*row ? my_atof(*row) : 0.0); +} + +SPIDER_DB_ROW *spider_db_mysql_row::clone() +{ + spider_db_mysql_row *clone_row; + char *tmp_char; + MYSQL_ROW tmp_row = row_first, ctmp_row; + ulong *tmp_lengths = lengths_first; + uint row_size, i; + DBUG_ENTER("spider_db_mysql_row::clone"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(clone_row = new spider_db_mysql_row())) + { + DBUG_RETURN(NULL); + } + row_size = field_count; + for (i = 0; i < field_count; i++) + { + row_size += *tmp_lengths; + tmp_lengths++; + } + if (!spider_bulk_malloc(spider_current_trx, 29, MYF(MY_WME), + &clone_row->row, sizeof(char*) * field_count, + &tmp_char, row_size, + &clone_row->lengths, sizeof(ulong) * field_count, + NullS) + ) { + delete clone_row; + DBUG_RETURN(NULL); + } + memcpy(clone_row->lengths, lengths_first, sizeof(ulong) * field_count); + tmp_lengths = lengths_first; + ctmp_row = clone_row->row; + for (i = 0; i < field_count; i++) + { + DBUG_PRINT("info",("spider *lengths=%lu", *tmp_lengths)); + if (*tmp_row == NULL) + { + *ctmp_row = NULL; + *tmp_char = 0; + tmp_char++; + } else { + *ctmp_row = tmp_char; + memcpy(tmp_char, *tmp_row, *tmp_lengths + 1); + tmp_char += *tmp_lengths + 1; + } + ctmp_row++; + tmp_lengths++; + tmp_row++; + } + clone_row->field_count = field_count; + clone_row->row_first = clone_row->row; + clone_row->lengths_first = clone_row->lengths; + clone_row->cloned = TRUE; + DBUG_RETURN((SPIDER_DB_ROW *) clone_row); +} + +int spider_db_mysql_row::store_to_tmp_table( + TABLE *tmp_table, + spider_string *str +) { + uint i; + MYSQL_ROW tmp_row = row; + ulong *tmp_lengths = lengths; + DBUG_ENTER("spider_db_mysql_row::store_to_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + for (i = 0; i < field_count; i++) + { + if (*tmp_row) + { + if (str->reserve(*tmp_lengths + 1)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(*tmp_row, *tmp_lengths + 1); + } + tmp_lengths++; + tmp_row++; + } + tmp_table->field[0]->set_notnull(); + tmp_table->field[0]->store( + (const char *) lengths, + sizeof(ulong) * field_count, &my_charset_bin); + tmp_table->field[1]->set_notnull(); + tmp_table->field[1]->store( + str->ptr(), str->length(), &my_charset_bin); + tmp_table->field[2]->set_notnull(); + tmp_table->field[2]->store( + (char *) row, (uint) (sizeof(char *) * field_count), &my_charset_bin); + DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); +} + +spider_db_mysql_result::spider_db_mysql_result() : spider_db_result(), + db_result(NULL) +{ + DBUG_ENTER("spider_db_mysql_result::spider_db_mysql_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mysql_result::~spider_db_mysql_result() +{ + DBUG_ENTER("spider_db_mysql_result::~spider_db_mysql_result"); + DBUG_PRINT("info",("spider this=%p", this)); + if (db_result) + { + free_result(); + } + DBUG_VOID_RETURN; +} + +bool spider_db_mysql_result::has_result() +{ + DBUG_ENTER("spider_db_mysql_result::has_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(db_result); +} + +void spider_db_mysql_result::free_result() +{ + DBUG_ENTER("spider_db_mysql_result::free_result"); + DBUG_PRINT("info",("spider this=%p", this)); + /* need 2 times execution design */ + if (db_result) + { + mysql_free_result(db_result); + db_result = NULL; + } + DBUG_VOID_RETURN; +} + +SPIDER_DB_ROW *spider_db_mysql_result::current_row() +{ + DBUG_ENTER("spider_db_mysql_result::current_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((SPIDER_DB_ROW *) row.clone()); +} + +SPIDER_DB_ROW *spider_db_mysql_result::fetch_row() +{ + DBUG_ENTER("spider_db_mysql_result::fetch_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(row.row = mysql_fetch_row(db_result))) + { + store_error_num = HA_ERR_END_OF_FILE; + DBUG_RETURN(NULL); + } + row.lengths = mysql_fetch_lengths(db_result); + row.field_count = mysql_num_fields(db_result); + row.row_first = row.row; + row.lengths_first = row.lengths; + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_result_buffer( + spider_db_result_buffer *spider_res_buf +) { + DBUG_ENTER("spider_db_mysql_result::fetch_row_from_result_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(row.row = mysql_fetch_row(db_result))) + { + store_error_num = HA_ERR_END_OF_FILE; + DBUG_RETURN(NULL); + } + row.lengths = mysql_fetch_lengths(db_result); + row.field_count = mysql_num_fields(db_result); + row.row_first = row.row; + row.lengths_first = row.lengths; + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_tmp_table( + TABLE *tmp_table +) { + uint i; + spider_string tmp_str1, tmp_str2, tmp_str3; + const char *row_ptr; + MYSQL_ROW tmp_row; + ulong *tmp_lengths; + uint field_count; + DBUG_ENTER("spider_db_mysql_result::fetch_row_from_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_str1.init_calc_mem(117); + tmp_str2.init_calc_mem(118); + tmp_str3.init_calc_mem(170); + tmp_table->field[0]->val_str(tmp_str1.get_str()); + tmp_table->field[1]->val_str(tmp_str2.get_str()); + tmp_table->field[2]->val_str(tmp_str3.get_str()); + tmp_str1.mem_calc(); + tmp_str2.mem_calc(); + tmp_str3.mem_calc(); + row_ptr = tmp_str2.ptr(); + tmp_lengths = (ulong *) tmp_str1.ptr(); + tmp_row = (MYSQL_ROW) tmp_str3.ptr(); + field_count = tmp_str1.length() / sizeof(ulong); + row.row = tmp_row; + row.lengths = tmp_lengths; + row.field_count = field_count; + row.row_first = row.row; + row.lengths_first = row.lengths; + for (i = 0; i < field_count; i++) + { + if (*tmp_row) + { + *tmp_row = (char *) row_ptr; + row_ptr += *tmp_lengths + 1; + } + tmp_row++; + tmp_lengths++; + } + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +int spider_db_mysql_result::fetch_table_status( + int mode, + ha_rows &records, + ulong &mean_rec_length, + ulonglong &data_file_length, + ulonglong &max_data_file_length, + ulonglong &index_file_length, + ulonglong &auto_increment_value, + time_t &create_time, + time_t &update_time, + time_t &check_time +) { + int error_num; + MYSQL_ROW mysql_row; + MYSQL_TIME mysql_time; +#ifdef MARIADB_BASE_VERSION + uint not_used_uint; +#else + my_bool not_used_my_bool; +#endif + int not_used_int; + long not_used_long; + DBUG_ENTER("spider_db_mysql_result::fetch_table_status"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(mysql_row = mysql_fetch_row(db_result))) + { + DBUG_PRINT("info",("spider fetch row is null")); + DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM); + } + if (mode == 1) + { + if (num_fields() != 18) + { + DBUG_PRINT("info",("spider field_count != 18")); + DBUG_RETURN(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM); + } + + if (mysql_row[4]) + records = + (ha_rows) my_strtoll10(mysql_row[4], (char**) NULL, &error_num); + else + records = (ha_rows) 0; + DBUG_PRINT("info", + ("spider records=%lld", records)); + if (mysql_row[5]) + mean_rec_length = + (ulong) my_strtoll10(mysql_row[5], (char**) NULL, &error_num); + else + mean_rec_length = 0; + DBUG_PRINT("info", + ("spider mean_rec_length=%lu", mean_rec_length)); + if (mysql_row[6]) + data_file_length = + (ulonglong) my_strtoll10(mysql_row[6], (char**) NULL, &error_num); + else + data_file_length = 0; + DBUG_PRINT("info", + ("spider data_file_length=%lld", data_file_length)); + if (mysql_row[7]) + max_data_file_length = + (ulonglong) my_strtoll10(mysql_row[7], (char**) NULL, &error_num); + else + max_data_file_length = 0; + DBUG_PRINT("info", + ("spider max_data_file_length=%lld", max_data_file_length)); + if (mysql_row[8]) + index_file_length = + (ulonglong) my_strtoll10(mysql_row[8], (char**) NULL, &error_num); + else + index_file_length = 0; + DBUG_PRINT("info", + ("spider index_file_length=%lld", index_file_length)); + if (mysql_row[10]) + auto_increment_value = + (ulonglong) my_strtoll10(mysql_row[10], (char**) NULL, &error_num); + else + auto_increment_value = 1; + DBUG_PRINT("info", + ("spider auto_increment_value=%lld", auto_increment_value)); + if (mysql_row[11]) + { + str_to_datetime(mysql_row[11], strlen(mysql_row[11]), &mysql_time, 0, + ¬_used_int); +#ifdef MARIADB_BASE_VERSION + create_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_uint); +#else + create_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_my_bool); +#endif + } else + create_time = (time_t) 0; +#ifndef DBUG_OFF + { + struct tm *ts, tmp_ts; + char buf[80]; + ts = localtime_r(&create_time, &tmp_ts); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts); + DBUG_PRINT("info",("spider create_time=%s", buf)); + } +#endif + if (mysql_row[12]) + { + str_to_datetime(mysql_row[12], strlen(mysql_row[12]), &mysql_time, 0, + ¬_used_int); +#ifdef MARIADB_BASE_VERSION + update_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_uint); +#else + update_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_my_bool); +#endif + } else + update_time = (time_t) 0; +#ifndef DBUG_OFF + { + struct tm *ts, tmp_ts; + char buf[80]; + ts = localtime_r(&update_time, &tmp_ts); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts); + DBUG_PRINT("info",("spider update_time=%s", buf)); + } +#endif + if (mysql_row[13]) + { + str_to_datetime(mysql_row[13], strlen(mysql_row[13]), &mysql_time, 0, + ¬_used_int); +#ifdef MARIADB_BASE_VERSION + check_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_uint); +#else + check_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_my_bool); +#endif + } else + check_time = (time_t) 0; +#ifndef DBUG_OFF + { + struct tm *ts, tmp_ts; + char buf[80]; + ts = localtime_r(&check_time, &tmp_ts); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts); + DBUG_PRINT("info",("spider check_time=%s", buf)); + } +#endif + } else { + if (mysql_row[0]) + records = + (ha_rows) my_strtoll10(mysql_row[0], (char**) NULL, &error_num); + else + records = (ha_rows) 0; + DBUG_PRINT("info", + ("spider records=%lld", records)); + if (mysql_row[1]) + mean_rec_length = + (ulong) my_strtoll10(mysql_row[1], (char**) NULL, &error_num); + else + mean_rec_length = 0; + DBUG_PRINT("info", + ("spider mean_rec_length=%lu", mean_rec_length)); + if (mysql_row[2]) + data_file_length = + (ulonglong) my_strtoll10(mysql_row[2], (char**) NULL, &error_num); + else + data_file_length = 0; + DBUG_PRINT("info", + ("spider data_file_length=%lld", data_file_length)); + if (mysql_row[3]) + max_data_file_length = + (ulonglong) my_strtoll10(mysql_row[3], (char**) NULL, &error_num); + else + max_data_file_length = 0; + DBUG_PRINT("info", + ("spider max_data_file_length=%lld", max_data_file_length)); + if (mysql_row[4]) + index_file_length = + (ulonglong) my_strtoll10(mysql_row[4], (char**) NULL, &error_num); + else + index_file_length = 0; + DBUG_PRINT("info", + ("spider index_file_length=%lld", index_file_length)); + if (mysql_row[5]) + auto_increment_value = + (ulonglong) my_strtoll10(mysql_row[5], (char**) NULL, &error_num); + else + auto_increment_value = 1; + DBUG_PRINT("info", + ("spider auto_increment_value=%lld", auto_increment_value)); + if (mysql_row[6]) + { + str_to_datetime(mysql_row[6], strlen(mysql_row[6]), &mysql_time, 0, + ¬_used_int); +#ifdef MARIADB_BASE_VERSION + create_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_uint); +#else + create_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_my_bool); +#endif + } else + create_time = (time_t) 0; +#ifndef DBUG_OFF + { + struct tm *ts, tmp_ts; + char buf[80]; + ts = localtime_r(&create_time, &tmp_ts); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts); + DBUG_PRINT("info",("spider create_time=%s", buf)); + } +#endif + if (mysql_row[7]) + { + str_to_datetime(mysql_row[7], strlen(mysql_row[7]), &mysql_time, 0, + ¬_used_int); +#ifdef MARIADB_BASE_VERSION + update_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_uint); +#else + update_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_my_bool); +#endif + } else + update_time = (time_t) 0; +#ifndef DBUG_OFF + { + struct tm *ts, tmp_ts; + char buf[80]; + ts = localtime_r(&update_time, &tmp_ts); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts); + DBUG_PRINT("info",("spider update_time=%s", buf)); + } +#endif + if (mysql_row[8]) + { + str_to_datetime(mysql_row[8], strlen(mysql_row[8]), &mysql_time, 0, + ¬_used_int); +#ifdef MARIADB_BASE_VERSION + check_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_uint); +#else + check_time = (time_t) my_system_gmt_sec(&mysql_time, + ¬_used_long, ¬_used_my_bool); +#endif + } else + check_time = (time_t) 0; +#ifndef DBUG_OFF + { + struct tm *ts, tmp_ts; + char buf[80]; + ts = localtime_r(&check_time, &tmp_ts); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts); + DBUG_PRINT("info",("spider check_time=%s", buf)); + } +#endif + } + DBUG_RETURN(0); +} + +int spider_db_mysql_result::fetch_table_records( + int mode, + ha_rows &records +) { + int error_num; + MYSQL_ROW mysql_row; + DBUG_ENTER("spider_db_mysql_result::fetch_table_records"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(mysql_row = mysql_fetch_row(db_result))) + { + DBUG_PRINT("info",("spider fetch row is null")); + DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + } + if (mode == 1) + { + if (mysql_row[0]) + { + records = + (ha_rows) my_strtoll10(mysql_row[0], (char**) NULL, &error_num); + } else + records = (ha_rows) 0; + DBUG_PRINT("info", + ("spider records=%lld", records)); + } else { + if (num_fields() != 10) + { + DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + } + + if (mysql_row[8]) + { + records = + (ha_rows) my_strtoll10(mysql_row[8], (char**) NULL, &error_num); + } else + records = 0; + } + DBUG_RETURN(0); +} + +int spider_db_mysql_result::fetch_table_cardinality( + int mode, + TABLE *table, + longlong *cardinality, + uchar *cardinality_upd, + int bitmap_size +) { + int error_num; + MYSQL_ROW mysql_row; + Field *field; + DBUG_ENTER("spider_db_mysql_result::fetch_table_cardinality"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(mysql_row = mysql_fetch_row(db_result))) + { + DBUG_PRINT("info",("spider fetch row is null")); + /* no index */ + DBUG_RETURN(0); + } + memset((uchar *) cardinality_upd, 0, sizeof(uchar) * bitmap_size); + if (mode == 1) + { + uint num_fields = this->num_fields(); + if (num_fields < 12 || num_fields > 13) + { + DBUG_PRINT("info",("spider num_fields < 12 || num_fields > 13")); + DBUG_RETURN(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM); + } + + while (mysql_row) + { + if ( + mysql_row[4] && + mysql_row[6] && + (field = find_field_in_table_sef(table, mysql_row[4])) + ) { + if ((cardinality[field->field_index] = + (longlong) my_strtoll10(mysql_row[6], (char**) NULL, &error_num)) + <= 0) + cardinality[field->field_index] = 1; + spider_set_bit(cardinality_upd, field->field_index); + DBUG_PRINT("info", + ("spider col_name=%s", mysql_row[4])); + DBUG_PRINT("info", + ("spider cardinality=%lld", + cardinality[field->field_index])); + } else if (mysql_row[4]) + { + DBUG_PRINT("info", + ("spider skip col_name=%s", mysql_row[4])); + } else { + DBUG_RETURN(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM); + } + mysql_row = mysql_fetch_row(db_result); + } + } else { + while (mysql_row) + { + if ( + mysql_row[0] && + mysql_row[1] && + (field = find_field_in_table_sef(table, mysql_row[0])) + ) { + if ((cardinality[field->field_index] = + (longlong) my_strtoll10(mysql_row[1], (char**) NULL, &error_num)) + <= 0) + cardinality[field->field_index] = 1; + spider_set_bit(cardinality_upd, field->field_index); + DBUG_PRINT("info", + ("spider col_name=%s", mysql_row[0])); + DBUG_PRINT("info", + ("spider cardinality=%lld", + cardinality[field->field_index])); + } else if (mysql_row[0]) + { + DBUG_PRINT("info", + ("spider skip col_name=%s", mysql_row[0])); + } else { + DBUG_RETURN(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM); + } + mysql_row = mysql_fetch_row(db_result); + } + } + DBUG_RETURN(0); +} + +int spider_db_mysql_result::fetch_table_mon_status( + int &status +) { + MYSQL_ROW mysql_row; + DBUG_ENTER("spider_db_mysql_result::fetch_table_mon_status"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(mysql_row = mysql_fetch_row(db_result))) + { + DBUG_PRINT("info",("spider fetch row is null")); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (num_fields() != 1) + { + DBUG_PRINT("info",("spider num_fields != 1")); + my_printf_error(ER_SPIDER_UNKNOWN_NUM, ER_SPIDER_UNKNOWN_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + } + if (mysql_row[0]) + status = atoi(mysql_row[0]); + else + status = SPIDER_LINK_MON_OK; + DBUG_PRINT("info", ("spider status=%d", status)); + DBUG_RETURN(0); +} + +longlong spider_db_mysql_result::num_rows() +{ + DBUG_ENTER("spider_db_mysql_result::num_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((longlong) mysql_num_rows(db_result)); +} + +uint spider_db_mysql_result::num_fields() +{ + DBUG_ENTER("spider_db_mysql_result::num_fields"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(mysql_num_fields(db_result)); +} + +void spider_db_mysql_result::move_to_pos( + longlong pos +) { + DBUG_ENTER("spider_db_mysql_result::move_to_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider pos=%lld", pos)); +/* + DBUG_ASSERT(first_row); +*/ + db_result->data_cursor = first_row + pos; + DBUG_VOID_RETURN; +} + +int spider_db_mysql_result::get_errno() +{ + DBUG_ENTER("spider_db_mysql_result::get_errno"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider store_error_num=%d", store_error_num)); + DBUG_RETURN(store_error_num); +} + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +int spider_db_mysql_result::fetch_columns_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset +) { + MYSQL_ROW mysql_row; + DBUG_ENTER("spider_db_mysql_result::fetch_columns_for_discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(mysql_row = mysql_fetch_row(db_result))) + { + DBUG_PRINT("info",("spider fetch row is null")); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (num_fields() != 6) + { + DBUG_PRINT("info",("spider num_fields != 6")); + my_printf_error(ER_SPIDER_UNKNOWN_NUM, ER_SPIDER_UNKNOWN_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + } + do { + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if (str->append(mysql_row[0], strlen(mysql_row[0]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_SPACE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + if (str->append(mysql_row[1], strlen(mysql_row[1]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (!strcmp(mysql_row[2], "NO")) + { + if (str->reserve(SPIDER_SQL_NOT_NULL_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NOT_NULL_STR, SPIDER_SQL_NOT_NULL_LEN); + if (mysql_row[4]) + { + if (str->reserve(SPIDER_SQL_DEFAULT_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_DEFAULT_STR, SPIDER_SQL_DEFAULT_LEN); + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if (str->append(mysql_row[4], strlen(mysql_row[4]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } + } else { + if (str->reserve(SPIDER_SQL_DEFAULT_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_DEFAULT_STR, SPIDER_SQL_DEFAULT_LEN); + if (mysql_row[4]) + { + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if (str->append(mysql_row[4], strlen(mysql_row[4]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } else { + if (str->reserve(SPIDER_SQL_NULL_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } + } + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } while ((mysql_row = mysql_fetch_row(db_result))); + DBUG_RETURN(0); +} + +int spider_db_mysql_result::fetch_index_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset +) { + MYSQL_ROW mysql_row; + DBUG_ENTER("spider_db_mysql_result::fetch_index_for_discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(mysql_row = mysql_fetch_row(db_result))) + { + DBUG_PRINT("info",("spider fetch row is null")); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (num_fields() != 13) + { + DBUG_PRINT("info",("spider num_fields != 13")); + my_printf_error(ER_SPIDER_UNKNOWN_NUM, ER_SPIDER_UNKNOWN_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + } + bool first = TRUE; + do { + if (!strcmp(mysql_row[3], "1")) + { + if (first) + { + first = FALSE; + } else { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_COMMA_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + /* new index */ + if (!strcmp(mysql_row[2], SPIDER_DB_PK_NAME_STR)) + { + /* primary key */ + if (str->reserve(SPIDER_DB_PK_NAME_LEN + SPIDER_SQL_SPACE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_DB_PK_NAME_STR, SPIDER_DB_PK_NAME_LEN); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } else if (!strcmp(mysql_row[1], "0")) + { + /* unique key */ + if (str->reserve(SPIDER_DB_UNIQUE_NAME_LEN + SPIDER_SQL_SPACE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_DB_UNIQUE_NAME_STR, SPIDER_DB_UNIQUE_NAME_LEN); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + if (str->reserve(SPIDER_DB_KEY_NAME_LEN + SPIDER_SQL_SPACE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_DB_KEY_NAME_STR, SPIDER_DB_KEY_NAME_LEN); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + if (strcmp(mysql_row[2], SPIDER_DB_PK_NAME_STR)) + { + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if (str->append(mysql_row[2], strlen(mysql_row[2]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + } + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if (str->append(mysql_row[4], strlen(mysql_row[4]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if (mysql_row[7]) + { + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + if (str->append(mysql_row[7], strlen(mysql_row[7]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } + } else { + if (str->reserve(SPIDER_SQL_COMMA_LEN + SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if (str->append(mysql_row[4], strlen(mysql_row[4]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if (mysql_row[7]) + { + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + if (str->append(mysql_row[7], strlen(mysql_row[7]), access_charset)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } + } + } while ((mysql_row = mysql_fetch_row(db_result))); + if (!first) + { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_COMMA_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + DBUG_RETURN(0); +} +#endif + +spider_db_mysql::spider_db_mysql( + SPIDER_CONN *conn +) : spider_db_conn(conn), lock_table_hash_inited(FALSE), + handler_open_array_inited(FALSE) +{ + DBUG_ENTER("spider_db_mysql::spider_db_mysql"); + DBUG_PRINT("info",("spider this=%p", this)); + db_conn = NULL; + DBUG_VOID_RETURN; +} + +spider_db_mysql::~spider_db_mysql() +{ + DBUG_ENTER("spider_db_mysql::~spider_db_mysql"); + DBUG_PRINT("info",("spider this=%p", this)); + if (handler_open_array_inited) + { + reset_opened_handler(); + spider_free_mem_calc(spider_current_trx, + handler_open_array_id, + handler_open_array.max_element * + handler_open_array.size_of_element); + delete_dynamic(&handler_open_array); + } + if (lock_table_hash_inited) + { + spider_free_mem_calc(spider_current_trx, + lock_table_hash_id, + lock_table_hash.array.max_element * + lock_table_hash.array.size_of_element); + my_hash_free(&lock_table_hash); + } + DBUG_VOID_RETURN; +} + +int spider_db_mysql::init() +{ + DBUG_ENTER("spider_db_mysql::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + my_hash_init(&lock_table_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_link_get_key, 0, 0) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider_alloc_calc_mem_init(lock_table_hash, 140); + spider_alloc_calc_mem(spider_current_trx, + lock_table_hash, + lock_table_hash.array.max_element * + lock_table_hash.array.size_of_element); + lock_table_hash_inited = TRUE; + + if ( + SPD_INIT_DYNAMIC_ARRAY2(&handler_open_array, + sizeof(SPIDER_LINK_FOR_HASH *), NULL, 16, 16, MYF(MY_WME)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider_alloc_calc_mem_init(handler_open_array, 162); + spider_alloc_calc_mem(spider_current_trx, + handler_open_array, + handler_open_array.max_element * + handler_open_array.size_of_element); + handler_open_array_inited = TRUE; + DBUG_RETURN(0); +} + +bool spider_db_mysql::is_connected() +{ + DBUG_ENTER("spider_db_mysql::is_connected"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(db_conn); +} + +void spider_db_mysql::bg_connect() +{ + DBUG_ENTER("spider_db_mysql::bg_connect"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_mysql::connect( + char *tgt_host, + char *tgt_username, + char *tgt_password, + long tgt_port, + char *tgt_socket, + char *server_name, + int connect_retry_count, + longlong connect_retry_interval +) { + int error_num; + my_bool connect_mutex = spider_param_connect_mutex(); + DBUG_ENTER("spider_db_mysql::connect"); + DBUG_PRINT("info",("spider this=%p", this)); + while (TRUE) + { + if (!db_conn) + { + if (!(db_conn = mysql_init(NULL))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + mysql_options(db_conn, MYSQL_OPT_READ_TIMEOUT, + &conn->net_read_timeout); + mysql_options(db_conn, MYSQL_OPT_WRITE_TIMEOUT, + &conn->net_write_timeout); + mysql_options(db_conn, MYSQL_OPT_CONNECT_TIMEOUT, + &conn->connect_timeout); + mysql_options(db_conn, MYSQL_OPT_USE_REMOTE_CONNECTION, + NULL); + + if ( + conn->tgt_ssl_ca_length | + conn->tgt_ssl_capath_length | + conn->tgt_ssl_cert_length | + conn->tgt_ssl_key_length + ) { + mysql_ssl_set(db_conn, conn->tgt_ssl_key, conn->tgt_ssl_cert, + conn->tgt_ssl_ca, conn->tgt_ssl_capath, conn->tgt_ssl_cipher); + if (conn->tgt_ssl_vsc) + { + my_bool verify_flg = TRUE; + mysql_options(db_conn, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + &verify_flg); + } + } + + if (conn->tgt_default_file) + { + DBUG_PRINT("info",("spider tgt_default_file=%s", + conn->tgt_default_file)); + mysql_options(db_conn, MYSQL_READ_DEFAULT_FILE, + conn->tgt_default_file); + } + if (conn->tgt_default_group) + { + DBUG_PRINT("info",("spider tgt_default_group=%s", + conn->tgt_default_group)); + mysql_options(db_conn, MYSQL_READ_DEFAULT_GROUP, + conn->tgt_default_group); + } + + if (connect_mutex) + pthread_mutex_lock(&spider_open_conn_mutex); + /* tgt_db not use */ + if (!mysql_real_connect( + db_conn, + tgt_host, + tgt_username, + tgt_password, + NULL, + tgt_port, + tgt_socket, + CLIENT_MULTI_STATEMENTS + )) { + if (connect_mutex) + pthread_mutex_unlock(&spider_open_conn_mutex); + error_num = mysql_errno(db_conn); + disconnect(); + if ( + ( + error_num != CR_CONN_HOST_ERROR && + error_num != CR_CONNECTION_ERROR + ) || + !connect_retry_count + ) { + *conn->need_mon = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), + server_name ? server_name : tgt_host); + DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + } + connect_retry_count--; + my_sleep((ulong) connect_retry_interval); + } else { + if (connect_mutex) + pthread_mutex_unlock(&spider_open_conn_mutex); + break; + } + } + DBUG_RETURN(0); +} + +int spider_db_mysql::ping( +) { + DBUG_ENTER("spider_db_mysql::ping"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(simple_command(db_conn, COM_PING, 0, 0, 0)); +} + +void spider_db_mysql::bg_disconnect() +{ + DBUG_ENTER("spider_db_mysql::bg_disconnect"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +void spider_db_mysql::disconnect() +{ + DBUG_ENTER("spider_db_mysql::disconnect"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider db_conn=%p", db_conn)); + if (db_conn) + { + mysql_close(db_conn); + db_conn = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_db_mysql::set_net_timeout() +{ + DBUG_ENTER("spider_db_mysql::set_net_timeout"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider conn=%p", conn)); + my_net_set_read_timeout(&db_conn->net, conn->net_read_timeout); + my_net_set_write_timeout(&db_conn->net, conn->net_write_timeout); + DBUG_RETURN(0); +} + +int spider_db_mysql::exec_query( + const char *query, + uint length, + int quick_mode +) { + DBUG_ENTER("spider_db_mysql::exec_query"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(mysql_real_query(db_conn, query, length)); +} + +int spider_db_mysql::get_errno() +{ + DBUG_ENTER("spider_db_mysql::get_errno"); + DBUG_PRINT("info",("spider this=%p", this)); + stored_error = mysql_errno(db_conn); + DBUG_PRINT("info",("spider stored_error=%d", stored_error)); + DBUG_RETURN(stored_error); +} + +const char *spider_db_mysql::get_error() +{ + const char *error_ptr; + DBUG_ENTER("spider_db_mysql::get_error"); + DBUG_PRINT("info",("spider this=%p", this)); + error_ptr = mysql_error(db_conn); + DBUG_PRINT("info",("spider error=%s", error_ptr)); + DBUG_RETURN(error_ptr); +} + +bool spider_db_mysql::is_server_gone_error( + int error_num +) { + bool server_gone; + DBUG_ENTER("spider_db_mysql::is_server_gone_error"); + DBUG_PRINT("info",("spider this=%p", this)); + server_gone = + (error_num == CR_SERVER_GONE_ERROR || error_num == CR_SERVER_LOST); + DBUG_PRINT("info",("spider server_gone=%s", server_gone ? "TRUE" : "FALSE")); + DBUG_RETURN(server_gone); +} + +bool spider_db_mysql::is_dup_entry_error( + int error_num +) { + bool dup_entry; + DBUG_ENTER("spider_db_mysql::is_dup_entry_error"); + DBUG_PRINT("info",("spider this=%p", this)); + dup_entry = + ( + error_num == ER_DUP_ENTRY || + error_num == ER_DUP_KEY || + error_num == HA_ERR_FOUND_DUPP_KEY + ); + DBUG_PRINT("info",("spider dup_entry=%s", dup_entry ? "TRUE" : "FALSE")); + DBUG_RETURN(dup_entry); +} + +bool spider_db_mysql::is_xa_nota_error( + int error_num +) { + bool xa_nota; + DBUG_ENTER("spider_db_mysql::is_xa_nota_error"); + DBUG_PRINT("info",("spider this=%p", this)); + xa_nota = + ( + error_num == ER_XAER_NOTA || + error_num == ER_XA_RBTIMEOUT || + error_num == ER_XA_RBDEADLOCK + ); + DBUG_PRINT("info",("spider xa_nota=%s", xa_nota ? "TRUE" : "FALSE")); + DBUG_RETURN(xa_nota); +} + +spider_db_result *spider_db_mysql::store_result( + spider_db_result_buffer **spider_res_buf, + st_spider_db_request_key *request_key, + int *error_num +) { + spider_db_mysql_result *result; + DBUG_ENTER("spider_db_mysql::store_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(!spider_res_buf); + if ((result = new spider_db_mysql_result())) + { + *error_num = 0; + if (!(result->db_result = mysql_store_result(db_conn))) + { + delete result; + result = NULL; + } else { + result->first_row = result->db_result->data_cursor; + DBUG_PRINT("info",("spider result->first_row=%p", result->first_row)); + } + } else { + *error_num = HA_ERR_OUT_OF_MEM; + } + DBUG_RETURN(result); +} + +spider_db_result *spider_db_mysql::use_result( + st_spider_db_request_key *request_key, + int *error_num +) { + spider_db_mysql_result *result; + DBUG_ENTER("spider_db_mysql::use_result"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((result = new spider_db_mysql_result())) + { + *error_num = 0; + if (!(result->db_result = db_conn->methods->use_result(db_conn))) + { + delete result; + result = NULL; + } else { + result->first_row = NULL; + } + } else { + *error_num = HA_ERR_OUT_OF_MEM; + } + DBUG_RETURN(result); +} + +int spider_db_mysql::next_result() +{ + int status; + DBUG_ENTER("spider_db_mysql::next_result"); + DBUG_PRINT("info",("spider this=%p", this)); + if (db_conn->status != MYSQL_STATUS_READY) + { + my_message(ER_SPIDER_UNKNOWN_NUM, ER_SPIDER_UNKNOWN_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + } + + db_conn->net.last_errno = 0; + db_conn->net.last_error[0] = '\0'; + strmov(db_conn->net.sqlstate, "00000"); + db_conn->affected_rows = ~(my_ulonglong) 0; + +#if MYSQL_VERSION_ID < 50500 + if (db_conn->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) +#else + if (db_conn->server_status & SERVER_MORE_RESULTS_EXISTS) +#endif + { + if ((status = db_conn->methods->read_query_result(db_conn)) > 0) + DBUG_RETURN(spider_db_errorno(conn)); + DBUG_RETURN(status); + } + DBUG_RETURN(-1); +} + +uint spider_db_mysql::affected_rows() +{ + MYSQL *last_used_con; + DBUG_ENTER("spider_db_mysql::affected_rows"); + DBUG_PRINT("info",("spider this=%p", this)); +#if MYSQL_VERSION_ID < 50500 + last_used_con = db_conn->last_used_con; +#else + last_used_con = db_conn; +#endif + DBUG_RETURN((uint) last_used_con->affected_rows); +} + +ulonglong spider_db_mysql::last_insert_id() +{ + MYSQL *last_used_con; + DBUG_ENTER("spider_db_mysql::last_insert_id"); + DBUG_PRINT("info",("spider this=%p", this)); +#if MYSQL_VERSION_ID < 50500 + last_used_con = db_conn->last_used_con; +#else + last_used_con = db_conn; +#endif + DBUG_RETURN((uint) last_used_con->insert_id); +} + +int spider_db_mysql::set_character_set( + const char *csname +) { + DBUG_ENTER("spider_db_mysql::set_character_set"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(mysql_set_character_set(db_conn, csname)); +} + +int spider_db_mysql::select_db( + const char *dbname +) { + DBUG_ENTER("spider_db_mysql::select_db"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(mysql_select_db(db_conn, dbname)); +} + +int spider_db_mysql::consistent_snapshot( + int *need_mon +) { + DBUG_ENTER("spider_db_mysql::consistent_snapshot"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_db_query( + conn, + SPIDER_SQL_START_CONSISTENT_SNAPSHOT_STR, + SPIDER_SQL_START_CONSISTENT_SNAPSHOT_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +bool spider_db_mysql::trx_start_in_bulk_sql() +{ + DBUG_ENTER("spider_db_mysql::trx_start_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_db_mysql::start_transaction( + int *need_mon +) { + DBUG_ENTER("spider_db_mysql::start_transaction"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_db_query( + conn, + SPIDER_SQL_START_TRANSACTION_STR, + SPIDER_SQL_START_TRANSACTION_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_db_mysql::commit( + int *need_mon +) { + DBUG_ENTER("spider_db_mysql::commit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_db_query( + conn, + SPIDER_SQL_COMMIT_STR, + SPIDER_SQL_COMMIT_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_db_mysql::rollback( + int *need_mon +) { + bool is_error; + int error_num; + DBUG_ENTER("spider_db_mysql::rollback"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider_db_query( + conn, + SPIDER_SQL_ROLLBACK_STR, + SPIDER_SQL_ROLLBACK_LEN, + -1, + need_mon) + ) { + is_error = conn->thd->is_error(); + conn->mta_conn_mutex_unlock_later = TRUE; + error_num = spider_db_errorno(conn); + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !is_error + ) + conn->thd->clear_error(); + else { + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_db_mysql::xa_start( + XID *xid, + int *need_mon +) { + DBUG_ENTER("spider_db_mysql::xa_start"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +bool spider_db_mysql::xa_start_in_bulk_sql() +{ + DBUG_ENTER("spider_db_mysql::xa_start_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_db_mysql::xa_end( + XID *xid, + int *need_mon +) { + char sql_buf[SPIDER_SQL_XA_END_LEN + XIDDATASIZE + sizeof(long) + 9]; + spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); + DBUG_ENTER("spider_db_mysql::xa_end"); + DBUG_PRINT("info",("spider this=%p", this)); + sql_str.init_calc_mem(108); + + sql_str.length(0); + sql_str.q_append(SPIDER_SQL_XA_END_STR, SPIDER_SQL_XA_END_LEN); + spider_db_append_xid_str(&sql_str, xid); + if (spider_db_query( + conn, + sql_str.ptr(), + sql_str.length(), + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_db_mysql::xa_prepare( + XID *xid, + int *need_mon +) { + char sql_buf[SPIDER_SQL_XA_PREPARE_LEN + XIDDATASIZE + sizeof(long) + 9]; + spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); + DBUG_ENTER("spider_db_mysql::xa_prepare"); + DBUG_PRINT("info",("spider this=%p", this)); + sql_str.init_calc_mem(109); + + sql_str.length(0); + sql_str.q_append(SPIDER_SQL_XA_PREPARE_STR, SPIDER_SQL_XA_PREPARE_LEN); + spider_db_append_xid_str(&sql_str, xid); + if (spider_db_query( + conn, + sql_str.ptr(), + sql_str.length(), + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_db_mysql::xa_commit( + XID *xid, + int *need_mon +) { + char sql_buf[SPIDER_SQL_XA_COMMIT_LEN + XIDDATASIZE + sizeof(long) + 9]; + spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); + DBUG_ENTER("spider_db_mysql::xa_commit"); + DBUG_PRINT("info",("spider this=%p", this)); + sql_str.init_calc_mem(110); + + sql_str.length(0); + sql_str.q_append(SPIDER_SQL_XA_COMMIT_STR, SPIDER_SQL_XA_COMMIT_LEN); + spider_db_append_xid_str(&sql_str, xid); + if (spider_db_query( + conn, + sql_str.ptr(), + sql_str.length(), + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_db_mysql::xa_rollback( + XID *xid, + int *need_mon +) { + char sql_buf[SPIDER_SQL_XA_ROLLBACK_LEN + XIDDATASIZE + sizeof(long) + 9]; + spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); + DBUG_ENTER("spider_db_mysql::xa_rollback"); + DBUG_PRINT("info",("spider this=%p", this)); + sql_str.init_calc_mem(111); + + sql_str.length(0); + sql_str.q_append(SPIDER_SQL_XA_ROLLBACK_STR, SPIDER_SQL_XA_ROLLBACK_LEN); + spider_db_append_xid_str(&sql_str, xid); + if (spider_db_query( + conn, + sql_str.ptr(), + sql_str.length(), + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +bool spider_db_mysql::set_trx_isolation_in_bulk_sql() +{ + DBUG_ENTER("spider_db_mysql::set_trx_isolation_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_db_mysql::set_trx_isolation( + int trx_isolation, + int *need_mon +) { + DBUG_ENTER("spider_db_mysql::set_trx_isolation"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (trx_isolation) + { + case ISO_READ_UNCOMMITTED: + if (spider_db_query( + conn, + SPIDER_SQL_ISO_READ_UNCOMMITTED_STR, + SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + break; + case ISO_READ_COMMITTED: + if (spider_db_query( + conn, + SPIDER_SQL_ISO_READ_COMMITTED_STR, + SPIDER_SQL_ISO_READ_COMMITTED_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + break; + case ISO_REPEATABLE_READ: + if (spider_db_query( + conn, + SPIDER_SQL_ISO_REPEATABLE_READ_STR, + SPIDER_SQL_ISO_REPEATABLE_READ_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + break; + case ISO_SERIALIZABLE: + if (spider_db_query( + conn, + SPIDER_SQL_ISO_SERIALIZABLE_STR, + SPIDER_SQL_ISO_SERIALIZABLE_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + break; + default: + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } + DBUG_RETURN(0); +} + +bool spider_db_mysql::set_autocommit_in_bulk_sql() +{ + DBUG_ENTER("spider_db_mysql::set_autocommit_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_db_mysql::set_autocommit( + bool autocommit, + int *need_mon +) { + DBUG_ENTER("spider_db_mysql::set_autocommit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (autocommit) + { + if (spider_db_query( + conn, + SPIDER_SQL_AUTOCOMMIT_ON_STR, + SPIDER_SQL_AUTOCOMMIT_ON_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { + if (spider_db_query( + conn, + SPIDER_SQL_AUTOCOMMIT_OFF_STR, + SPIDER_SQL_AUTOCOMMIT_OFF_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(0); +} + +bool spider_db_mysql::set_sql_log_off_in_bulk_sql() +{ + DBUG_ENTER("spider_db_mysql::set_sql_log_off_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_db_mysql::set_sql_log_off( + bool sql_log_off, + int *need_mon +) { + DBUG_ENTER("spider_db_mysql::set_sql_log_off"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_log_off) + { + if (spider_db_query( + conn, + SPIDER_SQL_SQL_LOG_ON_STR, + SPIDER_SQL_SQL_LOG_ON_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { + if (spider_db_query( + conn, + SPIDER_SQL_SQL_LOG_OFF_STR, + SPIDER_SQL_SQL_LOG_OFF_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(0); +} + +bool spider_db_mysql::set_time_zone_in_bulk_sql() +{ + DBUG_ENTER("spider_db_mysql::set_time_zone_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_db_mysql::set_time_zone( + Time_zone *time_zone, + int *need_mon +) { + const String *tz_str = time_zone->get_name(); + char sql_buf[MAX_FIELD_WIDTH]; + spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); + DBUG_ENTER("spider_db_mysql::set_time_zone"); + DBUG_PRINT("info",("spider this=%p", this)); + sql_str.init_calc_mem(214); + sql_str.length(0); + if (sql_str.reserve(SPIDER_SQL_TIME_ZONE_LEN + + tz_str->length() + SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_str.q_append(SPIDER_SQL_TIME_ZONE_STR, SPIDER_SQL_TIME_ZONE_LEN); + sql_str.q_append(tz_str->ptr(), tz_str->length()); + sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if (spider_db_query( + conn, + sql_str.ptr(), + sql_str.length(), + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int spider_db_mysql::append_sql( + char *sql, + ulong sql_length, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_mysql::append_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_mysql::append_open_handler( + uint handler_id, + const char *db_name, + const char *table_name, + const char *index_name, + const char *sql, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_mysql::append_open_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_mysql::append_select( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_mysql::append_select"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_mysql::append_insert( + uint handler_id, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_mysql::append_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_mysql::append_update( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + int limit, + int skip, + bool increment, + bool decrement, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_mysql::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_mysql::append_delete( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_mysql::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +void spider_db_mysql::reset_request_queue() +{ + DBUG_ENTER("spider_db_mysql::reset_request_queue"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} +#endif + +size_t spider_db_mysql::escape_string( + char *to, + const char *from, + size_t from_length +) { + DBUG_ENTER("spider_db_mysql::escape_string"); + DBUG_PRINT("info",("spider this=%p", this)); + if (db_conn->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) + DBUG_RETURN(escape_quotes_for_mysql(db_conn->charset, to, 0, + from, from_length)); + DBUG_RETURN(escape_string_for_mysql(db_conn->charset, to, 0, + from, from_length)); +} + +bool spider_db_mysql::have_lock_table_list() +{ + DBUG_ENTER("spider_db_mysql::have_lock_table_list"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(lock_table_hash.records); +} + +int spider_db_mysql::append_lock_tables( + spider_string *str +) { + int error_num; + ha_spider *tmp_spider; + int lock_type; + uint conn_link_idx; + int tmp_link_idx; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash; + const char *db_name; + uint db_name_length; + CHARSET_INFO *db_name_charset; + const char *table_name; + uint table_name_length; + CHARSET_INFO *table_name_charset; + DBUG_ENTER("spider_db_mysql::lock_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_mysql_utility.append_lock_table_head(str))) + { + DBUG_RETURN(error_num); + } + while ((tmp_link_for_hash = + (SPIDER_LINK_FOR_HASH *) my_hash_element(&lock_table_hash, 0))) + { + tmp_spider = tmp_link_for_hash->spider; + tmp_link_idx = tmp_link_for_hash->link_idx; + switch (tmp_spider->lock_type) + { + case TL_READ: + lock_type = SPIDER_DB_TABLE_LOCK_READ_LOCAL; + break; + case TL_READ_NO_INSERT: + lock_type = SPIDER_DB_TABLE_LOCK_READ; + break; + case TL_WRITE_LOW_PRIORITY: + lock_type = SPIDER_DB_TABLE_LOCK_LOW_PRIORITY_WRITE; + break; + case TL_WRITE: + lock_type = SPIDER_DB_TABLE_LOCK_WRITE; + break; + default: + // no lock + DBUG_PRINT("info",("spider lock_type=%d", tmp_spider->lock_type)); + DBUG_RETURN(0); + } + conn_link_idx = tmp_spider->conn_link_idx[tmp_link_idx]; + spider_mysql_share *db_share = (spider_mysql_share *) + tmp_spider->share->dbton_share[conn->dbton_id]; + if (&db_share->db_names_str[conn_link_idx]) + { + db_name = db_share->db_names_str[conn_link_idx].ptr(); + db_name_length = db_share->db_names_str[conn_link_idx].length(); + db_name_charset = tmp_spider->share->access_charset; + } else { + db_name = tmp_spider->share->tgt_dbs[conn_link_idx]; + db_name_length = tmp_spider->share->tgt_dbs_lengths[conn_link_idx]; + db_name_charset = system_charset_info; + } + if (&db_share->table_names_str[conn_link_idx]) + { + table_name = db_share->table_names_str[conn_link_idx].ptr(); + table_name_length = db_share->table_names_str[conn_link_idx].length(); + table_name_charset = tmp_spider->share->access_charset; + } else { + table_name = tmp_spider->share->tgt_table_names[conn_link_idx]; + table_name_length = + tmp_spider->share->tgt_table_names_lengths[conn_link_idx]; + table_name_charset = system_charset_info; + } + if ((error_num = spider_db_mysql_utility. + append_lock_table_body( + str, + db_name, + db_name_length, + db_name_charset, + table_name, + table_name_length, + table_name_charset, + lock_type + ) + )) { + my_hash_reset(&lock_table_hash); + DBUG_RETURN(error_num); + } +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&lock_table_hash, + tmp_link_for_hash->db_table_str_hash_value, (uchar*) tmp_link_for_hash); +#else + my_hash_delete(&lock_table_hash, (uchar*) tmp_link_for_hash); +#endif + } + if ((error_num = spider_db_mysql_utility.append_lock_table_tail(str))) + { + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_db_mysql::append_unlock_tables( + spider_string *str +) { + int error_num; + DBUG_ENTER("spider_db_mysql::append_unlock_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_mysql_utility.append_unlock_table(str))) + { + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +uint spider_db_mysql::get_lock_table_hash_count() +{ + DBUG_ENTER("spider_db_mysql::get_lock_table_hash_count"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(lock_table_hash.records); +} + +void spider_db_mysql::reset_lock_table_hash() +{ + DBUG_ENTER("spider_db_mysql::reset_lock_table_hash"); + DBUG_PRINT("info",("spider this=%p", this)); + my_hash_reset(&lock_table_hash); + DBUG_VOID_RETURN; +} + +uint spider_db_mysql::get_opened_handler_count() +{ + DBUG_ENTER("spider_db_mysql::get_opened_handler_count"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(handler_open_array.elements); +} + +void spider_db_mysql::reset_opened_handler() +{ + ha_spider *tmp_spider; + int tmp_link_idx; + SPIDER_LINK_FOR_HASH **tmp_link_for_hash; + DBUG_ENTER("spider_db_mysql::reset_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + while ((tmp_link_for_hash = + (SPIDER_LINK_FOR_HASH **) pop_dynamic(&handler_open_array))) + { + tmp_spider = (*tmp_link_for_hash)->spider; + tmp_link_idx = (*tmp_link_for_hash)->link_idx; + tmp_spider->clear_handler_opened(tmp_link_idx, conn->conn_kind); + } + DBUG_VOID_RETURN; +} + +void spider_db_mysql::set_dup_key_idx( + ha_spider *spider, + int link_idx +) { + TABLE *table = spider->get_table(); + uint roop_count, pk_idx = table->s->primary_key; + int key_name_length; + int max_length = 0; + char *key_name; + DBUG_ENTER("spider_db_mysql::set_dup_key_idx"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider error_str=%s", conn->error_str)); + for (roop_count = 0; roop_count < table->s->keys; roop_count++) + { + if (roop_count == pk_idx) + { + DBUG_PRINT("info",("spider pk_idx=%u", roop_count)); + int all_link_idx = spider->conn_link_idx[link_idx]; + key_name = spider->share->tgt_pk_names[all_link_idx]; + key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx]; + } else { + key_name = table->s->key_info[roop_count].name; + key_name_length = strlen(key_name); + } + DBUG_PRINT("info",("spider key_name=%s", key_name)); + if ( + max_length < key_name_length && + conn->error_length - 1 >= key_name_length && + *(conn->error_str + conn->error_length - 2 - + key_name_length) == '\'' && + !strncasecmp(conn->error_str + + conn->error_length - 1 - key_name_length, + key_name, key_name_length) + ) { + max_length = key_name_length; + spider->dup_key_idx = roop_count; + } + } + if (max_length == 0) + spider->dup_key_idx = (uint) -1; + DBUG_PRINT("info",("spider dup_key_idx=%d", spider->dup_key_idx)); + DBUG_VOID_RETURN; +} + +bool spider_db_mysql::cmp_request_key_to_snd( + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_mysql::cmp_request_key_to_snd"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +spider_db_mysql_util::spider_db_mysql_util() : spider_db_util() +{ + DBUG_ENTER("spider_db_mysql_util::spider_db_mysql_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mysql_util::~spider_db_mysql_util() +{ + DBUG_ENTER("spider_db_mysql_util::~spider_db_mysql_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_mysql_util::append_name( + spider_string *str, + const char *name, + uint name_length +) { + DBUG_ENTER("spider_db_mysql_util::append_name"); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(name, name_length); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_name_with_charset( + spider_string *str, + const char *name, + uint name_length, + CHARSET_INFO *name_charset +) { + DBUG_ENTER("spider_db_mysql_util::append_name_with_charset"); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->append(name, name_length, name_charset); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + DBUG_RETURN(0); +} + +bool spider_db_mysql_util::is_name_quote( + const char head_code +) { + DBUG_ENTER("spider_db_mysql_util::is_name_quote"); + DBUG_RETURN(head_code == *name_quote_str); +} + +int spider_db_mysql_util::append_escaped_name_quote( + spider_string *str +) { + DBUG_ENTER("spider_db_mysql_util::append_escaped_name_quote"); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_column_value( + ha_spider *spider, + spider_string *str, + Field *field, + const uchar *new_ptr, + CHARSET_INFO *access_charset +) { + char buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin); + String *ptr; + uint length; + DBUG_ENTER("spider_db_mysql_util::append_column_value"); + tmp_str.init_calc_mem(113); + + if (new_ptr) + { + if ( + field->type() == MYSQL_TYPE_BLOB || + field->real_type() == MYSQL_TYPE_VARCHAR + ) { + length = uint2korr(new_ptr); + tmp_str.set_quick((char *) new_ptr + HA_KEY_BLOB_LENGTH, length, + &my_charset_bin); + ptr = tmp_str.get_str(); + } else if (field->type() == MYSQL_TYPE_GEOMETRY) + { +/* + uint mlength = SIZEOF_STORED_DOUBLE, lcnt; + uchar *dest = (uchar *) buf; + const uchar *source; + for (lcnt = 0; lcnt < 4; lcnt++) + { + mlength = SIZEOF_STORED_DOUBLE; + source = new_ptr + mlength + SIZEOF_STORED_DOUBLE * lcnt; + while (mlength--) + *dest++ = *--source; + } + tmp_str.length(SIZEOF_STORED_DOUBLE * lcnt); +*/ +#ifndef DBUG_OFF + double xmin, xmax, ymin, ymax; +/* + float8store(buf,xmin); + float8store(buf+8,xmax); + float8store(buf+16,ymin); + float8store(buf+24,ymax); + memcpy(&xmin,new_ptr,sizeof(xmin)); + memcpy(&xmax,new_ptr + 8,sizeof(xmax)); + memcpy(&ymin,new_ptr + 16,sizeof(ymin)); + memcpy(&ymax,new_ptr + 24,sizeof(ymax)); + float8get(xmin, buf); + float8get(xmax, buf + 8); + float8get(ymin, buf + 16); + float8get(ymax, buf + 24); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + DBUG_PRINT("info", ("spider geo is %.14g %.14g %.14g %.14g", + xmin, xmax, ymin, ymax)); +*/ + float8get(xmin, new_ptr); + float8get(xmax, new_ptr + 8); + float8get(ymin, new_ptr + 16); + float8get(ymax, new_ptr + 24); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); +/* + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 4); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 5); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 6); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 7); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 8); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 9); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 10); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 11); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 12); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 13); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 14); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 15); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); +*/ +#endif +/* + tmp_str.set_quick((char *) new_ptr, SIZEOF_STORED_DOUBLE * 4, + &my_charset_bin); +*/ + tmp_str.length(0); + tmp_str.q_append((char *) SPIDER_SQL_LINESTRING_HEAD_STR, + SPIDER_SQL_LINESTRING_HEAD_LEN); + tmp_str.q_append((char *) new_ptr, SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 2, + SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE, + SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 3, + SIZEOF_STORED_DOUBLE); + ptr = tmp_str.get_str(); + } else { + ptr = field->val_str(tmp_str.get_str(), new_ptr); + tmp_str.mem_calc(); + } + } else { + ptr = field->val_str(tmp_str.get_str()); + tmp_str.mem_calc(); + } + DBUG_PRINT("info", ("spider field->type() is %d", field->type())); + DBUG_PRINT("info", ("spider ptr->length() is %d", ptr->length())); +/* + if ( + field->type() == MYSQL_TYPE_BIT || + (field->type() >= MYSQL_TYPE_TINY_BLOB && + field->type() <= MYSQL_TYPE_BLOB) + ) { + uchar *hex_ptr = (uchar *) ptr->ptr(), *end_ptr; + char *str_ptr; + DBUG_PRINT("info", ("spider HEX")); + if (str->reserve(SPIDER_SQL_HEX_LEN + ptr->length() * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HEX_STR, SPIDER_SQL_HEX_LEN); + str_ptr = (char *) str->ptr() + str->length(); + for (end_ptr = hex_ptr + ptr->length(); hex_ptr < end_ptr; hex_ptr++) + { + *str_ptr++ = spider_dig_upper[(*hex_ptr) >> 4]; + *str_ptr++ = spider_dig_upper[(*hex_ptr) & 0x0F]; + } + str->length(str->length() + ptr->length() * 2); + } else +*/ + if (field->result_type() == STRING_RESULT) + { + DBUG_PRINT("info", ("spider STRING_RESULT")); + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if ( + field->type() == MYSQL_TYPE_VARCHAR || + (field->type() >= MYSQL_TYPE_ENUM && + field->type() <= MYSQL_TYPE_GEOMETRY) + ) { + DBUG_PRINT("info", ("spider append_escaped")); + char buf2[MAX_FIELD_WIDTH]; + spider_string tmp_str2(buf2, MAX_FIELD_WIDTH, access_charset); + tmp_str2.init_calc_mem(114); + tmp_str2.length(0); + if ( + tmp_str2.append(ptr->ptr(), ptr->length(), field->charset()) || + str->reserve(tmp_str2.length() * 2) || + append_escaped_util(str, tmp_str2.get_str()) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } else if (str->append(*ptr)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } else if (field->str_needs_quotes()) + { + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + ptr->length() * 2 + 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + append_escaped_util(str, ptr); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } else if (str->append(*ptr)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_from_with_alias( + spider_string *str, + const char **table_names, + uint *table_name_lengths, + const char **table_aliases, + uint *table_alias_lengths, + uint table_count, + int *table_name_pos, + bool over_write +) { + uint roop_count, length = 0; + DBUG_ENTER("spider_db_mysql_util::append_from_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!over_write) + { + for (roop_count = 0; roop_count < table_count; roop_count++) + length += table_name_lengths[roop_count] + SPIDER_SQL_SPACE_LEN + + table_alias_lengths[roop_count] + SPIDER_SQL_COMMA_LEN; + if (str->reserve(SPIDER_SQL_FROM_LEN + length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + *table_name_pos = str->length(); + } + for (roop_count = 0; roop_count < table_count; roop_count++) + { + str->q_append(table_names[roop_count], table_name_lengths[roop_count]); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + str->q_append(table_aliases[roop_count], table_alias_lengths[roop_count]); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_trx_isolation( + spider_string *str, + int trx_isolation +) { + DBUG_ENTER("spider_db_mysql_util::append_trx_isolation"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + + SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + switch (trx_isolation) + { + case ISO_READ_UNCOMMITTED: + str->q_append(SPIDER_SQL_ISO_READ_UNCOMMITTED_STR, + SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN); + break; + case ISO_READ_COMMITTED: + str->q_append(SPIDER_SQL_ISO_READ_COMMITTED_STR, + SPIDER_SQL_ISO_READ_COMMITTED_LEN); + break; + case ISO_REPEATABLE_READ: + str->q_append(SPIDER_SQL_ISO_REPEATABLE_READ_STR, + SPIDER_SQL_ISO_REPEATABLE_READ_LEN); + break; + case ISO_SERIALIZABLE: + str->q_append(SPIDER_SQL_ISO_SERIALIZABLE_STR, + SPIDER_SQL_ISO_SERIALIZABLE_LEN); + break; + default: + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_autocommit( + spider_string *str, + bool autocommit +) { + DBUG_ENTER("spider_db_mysql_util::append_autocommit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_AUTOCOMMIT_OFF_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + if (autocommit) + { + str->q_append(SPIDER_SQL_AUTOCOMMIT_ON_STR, + SPIDER_SQL_AUTOCOMMIT_ON_LEN); + } else { + str->q_append(SPIDER_SQL_AUTOCOMMIT_OFF_STR, + SPIDER_SQL_AUTOCOMMIT_OFF_LEN); + } + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_sql_log_off( + spider_string *str, + bool sql_log_off +) { + DBUG_ENTER("spider_db_mysql_util::append_sql_log_off"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_SQL_LOG_OFF_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + if (sql_log_off) + { + str->q_append(SPIDER_SQL_SQL_LOG_ON_STR, SPIDER_SQL_SQL_LOG_ON_LEN); + } else { + str->q_append(SPIDER_SQL_SQL_LOG_OFF_STR, SPIDER_SQL_SQL_LOG_OFF_LEN); + } + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_time_zone( + spider_string *str, + Time_zone *time_zone +) { + const String *tz_str = time_zone->get_name(); + DBUG_ENTER("spider_db_mysql_util::append_time_zone"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_TIME_ZONE_LEN + + tz_str->length() + SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + str->q_append(SPIDER_SQL_TIME_ZONE_STR, SPIDER_SQL_TIME_ZONE_LEN); + str->q_append(tz_str->ptr(), tz_str->length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_start_transaction( + spider_string *str +) { + DBUG_ENTER("spider_db_mysql_util::append_start_transaction"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + + SPIDER_SQL_START_TRANSACTION_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + str->q_append(SPIDER_SQL_START_TRANSACTION_STR, + SPIDER_SQL_START_TRANSACTION_LEN); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_xa_start( + spider_string *str, + XID *xid +) { + DBUG_ENTER("spider_db_mysql_util::append_xa_start"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + + SPIDER_SQL_XA_START_LEN + XIDDATASIZE + sizeof(long) + 9)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + str->q_append(SPIDER_SQL_XA_START_STR, SPIDER_SQL_XA_START_LEN); + spider_db_append_xid_str(str, xid); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_lock_table_head( + spider_string *str +) { + DBUG_ENTER("spider_db_mysql_util::append_lock_table_head"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_LOCK_TABLE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LOCK_TABLE_STR, SPIDER_SQL_LOCK_TABLE_LEN); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_lock_table_body( + spider_string *str, + const char *db_name, + uint db_name_length, + CHARSET_INFO *db_name_charset, + const char *table_name, + uint table_name_length, + CHARSET_INFO *table_name_charset, + int lock_type +) { + DBUG_ENTER("spider_db_mysql_util::append_lock_table_body"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ( + str->append(db_name, db_name_length, db_name_charset) || + str->reserve((SPIDER_SQL_NAME_QUOTE_LEN) * 2 + SPIDER_SQL_DOT_LEN) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ( + str->append(table_name, table_name_length, table_name_charset) || + str->reserve(SPIDER_SQL_NAME_QUOTE_LEN + + spider_db_table_lock_len[lock_type]) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(spider_db_table_lock_str[lock_type], + spider_db_table_lock_len[lock_type]); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_lock_table_tail( + spider_string *str +) { + DBUG_ENTER("spider_db_mysql_util::append_lock_table_tail"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_unlock_table( + spider_string *str +) { + DBUG_ENTER("spider_db_mysql_util::append_unlock_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_UNLOCK_TABLE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_UNLOCK_TABLE_STR, SPIDER_SQL_UNLOCK_TABLE_LEN); + DBUG_RETURN(0); +} + +int spider_db_mysql_util::open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length +) { + uint dbton_id = spider_dbton_mysql.dbton_id; + int error_num; + Item *item, **item_list = item_func->arguments(); + uint roop_count, item_count = item_func->argument_count(), start_item = 0; + const char *func_name = SPIDER_SQL_NULL_CHAR_STR, + *separete_str = SPIDER_SQL_NULL_CHAR_STR, + *last_str = SPIDER_SQL_NULL_CHAR_STR; + int func_name_length = SPIDER_SQL_NULL_CHAR_LEN, + separete_str_length = SPIDER_SQL_NULL_CHAR_LEN, + last_str_length = SPIDER_SQL_NULL_CHAR_LEN; + int use_pushdown_udf; + DBUG_ENTER("spider_db_mysql_util::open_item_func"); + if (str) + { + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + DBUG_PRINT("info",("spider functype = %d", item_func->functype())); + switch (item_func->functype()) + { + case Item_func::ISNULL_FUNC: + last_str = SPIDER_SQL_IS_NULL_STR; + last_str_length = SPIDER_SQL_IS_NULL_LEN; + break; + case Item_func::ISNOTNULL_FUNC: + last_str = SPIDER_SQL_IS_NOT_NULL_STR; + last_str_length = SPIDER_SQL_IS_NOT_NULL_LEN; + break; + case Item_func::UNKNOWN_FUNC: + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (func_name_length == 1 && + ( + !strncasecmp("+", func_name, func_name_length) || + !strncasecmp("-", func_name, func_name_length) || + !strncasecmp("*", func_name, func_name_length) || + !strncasecmp("/", func_name, func_name_length) || + !strncasecmp("%", func_name, func_name_length) || + !strncasecmp("&", func_name, func_name_length) || + !strncasecmp("|", func_name, func_name_length) || + !strncasecmp("^", func_name, func_name_length) + ) + ) { + /* no action */ + break; + } else if (func_name_length == 2 && + ( + !strncasecmp("<<", func_name, func_name_length) || + !strncasecmp(">>", func_name, func_name_length) + ) + ) { + /* no action */ + break; + } else if (func_name_length == 3 && + !strncasecmp("div", func_name, func_name_length) + ) { + /* no action */ + break; + } else if (func_name_length == 4) + { + if ( + !strncasecmp("rand", func_name, func_name_length) && + !item_func->arg_count + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if ( + !strncasecmp("case", func_name, func_name_length) + ) { +#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC + Item_func_case *item_func_case = (Item_func_case *) item_func; + if (str) + { + if (str->reserve(SPIDER_SQL_CASE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN); + } + if (item_func_case->first_expr_num != -1) + { + if ((error_num = spider_db_print_item_type( + item_list[item_func_case->first_expr_num], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + for (roop_count = 0; roop_count < item_func_case->ncases; + roop_count += 2) + { + if (str) + { + if (str->reserve(SPIDER_SQL_WHEN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[roop_count], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_THEN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[roop_count + 1], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (item_func_case->else_expr_num != -1) + { + if (str) + { + if (str->reserve(SPIDER_SQL_ELSE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[item_func_case->else_expr_num], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +#else + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); +#endif + } + } else if (func_name_length == 6 && + !strncasecmp("istrue", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_TRUE_STR; + last_str_length = SPIDER_SQL_IS_TRUE_LEN; + break; + } else if (func_name_length == 7) + { + if (!strncasecmp("isfalse", func_name, func_name_length)) + { + last_str = SPIDER_SQL_IS_FALSE_STR; + last_str_length = SPIDER_SQL_IS_FALSE_LEN; + break; + } else if ( + !strncasecmp("sysdate", func_name, func_name_length) || + !strncasecmp("curdate", func_name, func_name_length) || + !strncasecmp("curtime", func_name, func_name_length) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if ( + !strncasecmp("convert", func_name, func_name_length) + ) { + if (str) + { + if (str->reserve(func_name_length * 2 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, + SPIDER_SQL_OPEN_PAREN_LEN); + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } + } else if (func_name_length == 8 && + ( + !strncasecmp("utc_date", func_name, func_name_length) || + !strncasecmp("utc_time", func_name, func_name_length) + ) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if (func_name_length == 9 && + !strncasecmp("isnottrue", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_NOT_TRUE_STR; + last_str_length = SPIDER_SQL_IS_NOT_TRUE_LEN; + break; + } else if (func_name_length == 10 && + !strncasecmp("isnotfalse", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_NOT_FALSE_STR; + last_str_length = SPIDER_SQL_IS_NOT_FALSE_LEN; + break; + } else if (func_name_length == 12) + { + if (!strncasecmp("cast_as_date", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_DATE_STR; + last_str_length = SPIDER_SQL_AS_DATE_LEN; + break; + } else if (!strncasecmp("cast_as_time", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_TIME_STR; + last_str_length = SPIDER_SQL_AS_TIME_LEN; + break; + } + } else if (func_name_length == 13 && + !strncasecmp("utc_timestamp", func_name, func_name_length) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if (func_name_length == 14) + { + if (!strncasecmp("cast_as_binary", func_name, func_name_length)) + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(123); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_BINARY_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } else if (!strncasecmp("cast_as_signed", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_SIGNED_STR; + last_str_length = SPIDER_SQL_AS_SIGNED_LEN; + break; + } + } else if (func_name_length == 16) + { + if (!strncasecmp("cast_as_unsigned", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_UNSIGNED_STR; + last_str_length = SPIDER_SQL_AS_UNSIGNED_LEN; + break; + } else if (!strncasecmp("decimal_typecast", func_name, + func_name_length)) + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(124); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_DECIMAL_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } else if (!strncasecmp("cast_as_datetime", func_name, + func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_DATETIME_STR; + last_str_length = SPIDER_SQL_AS_DATETIME_LEN; + break; + } + } else if (func_name_length == 17) + { + if (!strncasecmp("date_add_interval", func_name, func_name_length)) + { + Item_date_add_interval *item_date_add_interval = + (Item_date_add_interval *) item_func; + func_name = spider_db_timefunc_interval_str[ + item_date_add_interval->int_type]; + func_name_length = strlen(func_name); + if ((error_num = spider_db_print_item_type(item_list[0], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (item_date_add_interval->date_sub_interval) + { + if (str->reserve(SPIDER_SQL_NEGINTERVAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NEGINTERVAL_STR, + SPIDER_SQL_NEGINTERVAL_LEN); + } else { + if (str->reserve(SPIDER_SQL_INTERVAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_INTERVAL_STR, SPIDER_SQL_INTERVAL_LEN); + } + } + if ((error_num = spider_db_print_item_type(item_list[1], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(func_name_length + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); + } + } + if (str) + { + if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::NOW_FUNC: + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::CHAR_TYPECAST_FUNC: + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(125); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_CHAR_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + } + break; + case Item_func::NOT_FUNC: + case Item_func::NEG_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + break; + case Item_func::IN_FUNC: + if (((Item_func_opt_neg *) item_func)->negated) + { + func_name = SPIDER_SQL_NOT_IN_STR; + func_name_length = SPIDER_SQL_NOT_IN_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } else { + func_name = SPIDER_SQL_IN_STR; + func_name_length = SPIDER_SQL_IN_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + case Item_func::BETWEEN: + if (((Item_func_opt_neg *) item_func)->negated) + { + func_name = SPIDER_SQL_NOT_BETWEEN_STR; + func_name_length = SPIDER_SQL_NOT_BETWEEN_LEN; + separete_str = SPIDER_SQL_AND_STR; + separete_str_length = SPIDER_SQL_AND_LEN; + } else { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + separete_str = SPIDER_SQL_AND_STR; + separete_str_length = SPIDER_SQL_AND_LEN; + } + break; + case Item_func::UDF_FUNC: + use_pushdown_udf = spider_param_use_pushdown_udf(spider->trx->thd, + spider->share->use_pushdown_udf); + if (!use_pushdown_udf) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; +#ifdef MARIADB_BASE_VERSION + case Item_func::XOR_FUNC: +#else + case Item_func::COND_XOR_FUNC: +#endif + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN( + spider_db_open_item_cond((Item_cond *) item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::TRIG_COND_FUNC: + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + case Item_func::GUSERVAR_FUNC: + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (item_func->result_type() == STRING_RESULT) + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + else + DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::FT_FUNC: + if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + start_item = 1; + if (str) + { + if (str->reserve(SPIDER_SQL_MATCH_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); + } + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::SP_EQUALS_FUNC: + if (str) + { + func_name = SPIDER_SQL_MBR_EQUAL_STR; + func_name_length = SPIDER_SQL_MBR_EQUAL_LEN; + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(func_name_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::SP_DISJOINT_FUNC: + case Item_func::SP_INTERSECTS_FUNC: + case Item_func::SP_TOUCHES_FUNC: + case Item_func::SP_CROSSES_FUNC: + case Item_func::SP_WITHIN_FUNC: + case Item_func::SP_CONTAINS_FUNC: + case Item_func::SP_OVERLAPS_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(SPIDER_SQL_MBR_LEN + func_name_length + + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::EQ_FUNC: + case Item_func::EQUAL_FUNC: + case Item_func::NE_FUNC: + case Item_func::LT_FUNC: + case Item_func::LE_FUNC: + case Item_func::GE_FUNC: + case Item_func::GT_FUNC: + case Item_func::LIKE_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + } + break; + default: + THD *thd = spider->trx->thd; + SPIDER_SHARE *share = spider->share; + if (spider_param_skip_default_condition(thd, + share->skip_default_condition)) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + } + break; + } + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + DBUG_PRINT("info",("spider separete_str = %s", separete_str)); + DBUG_PRINT("info",("spider separete_str_length = %d", separete_str_length)); + DBUG_PRINT("info",("spider last_str = %s", last_str)); + DBUG_PRINT("info",("spider last_str_length = %d", last_str_length)); + if (item_count) + { + item_count--; + for (roop_count = start_item; roop_count < item_count; roop_count++) + { + item = item_list[roop_count]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (roop_count == 1) + { + func_name = separete_str; + func_name_length = separete_str_length; + } + if (str) + { + if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + } + item = item_list[roop_count]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (item_func->functype() == Item_func::FT_FUNC) + { + Item_func_match *item_func_match = (Item_func_match *)item_func; + if (str) + { + if (str->reserve(SPIDER_SQL_AGAINST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); + } + item = item_list[0]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve( + ((item_func_match->flags & FT_BOOL) ? + SPIDER_SQL_IN_BOOLEAN_MODE_LEN : 0) + + ((item_func_match->flags & FT_EXPAND) ? + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN : 0) + )) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (item_func_match->flags & FT_BOOL) + str->q_append(SPIDER_SQL_IN_BOOLEAN_MODE_STR, + SPIDER_SQL_IN_BOOLEAN_MODE_LEN); + if (item_func_match->flags & FT_EXPAND) + str->q_append(SPIDER_SQL_WITH_QUERY_EXPANSION_STR, + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN); + } + } else if (item_func->functype() == Item_func::UNKNOWN_FUNC) + { + if ( + func_name_length == 7 && + !strncasecmp("convert", func_name, func_name_length) + ) { + if (str) + { + Item_func_conv_charset *item_func_conv_charset = + (Item_func_conv_charset *)item_func; + CHARSET_INFO *conv_charset = item_func_conv_charset->conv_charset; + uint cset_length = strlen(conv_charset->csname); + if (str->reserve(SPIDER_SQL_USING_LEN + cset_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_USING_STR, SPIDER_SQL_USING_LEN); + str->q_append(conv_charset->csname, cset_length); + } + } + } + if (str) + { + if (str->reserve(last_str_length + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(last_str, last_str_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_escaped_util( + spider_string *to, + String *from +) { + DBUG_ENTER("spider_db_mysql_util::append_escaped_util"); + DBUG_PRINT("info",("spider this=%p", this)); + append_escaped(to->get_str(), from); + to->mem_calc(); + DBUG_RETURN(0); +} + +spider_mysql_share::spider_mysql_share( + st_spider_share *share +) : spider_db_share( + share +), + table_select(NULL), + table_select_pos(0), + key_select(NULL), + key_select_pos(NULL), + key_hint(NULL), + show_table_status(NULL), + show_records(NULL), + show_index(NULL), + table_names_str(NULL), + db_names_str(NULL), + db_table_str(NULL), +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + db_table_str_hash_value(NULL), +#endif + table_nm_max_length(0), + db_nm_max_length(0), + column_name_str(NULL), + same_db_table_name(TRUE), + first_all_link_idx(-1) +{ + DBUG_ENTER("spider_mysql_share::spider_mysql_share"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_alloc_calc_mem_init(mem_calc, 71); + spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); + DBUG_VOID_RETURN; +} + +spider_mysql_share::~spider_mysql_share() +{ + DBUG_ENTER("spider_mysql_share::~spider_mysql_share"); + DBUG_PRINT("info",("spider this=%p", this)); + if (table_select) + delete [] table_select; + if (key_select) + delete [] key_select; + if (key_hint) + delete [] key_hint; + free_show_table_status(); + free_show_records(); + free_show_index(); + free_column_name_str(); + free_table_names_str(); + if (key_select_pos) + { + spider_free(spider_current_trx, key_select_pos, MYF(0)); + } + spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); + DBUG_VOID_RETURN; +} + +int spider_mysql_share::init() +{ + int error_num; + uint roop_count; + TABLE_SHARE *table_share = spider_share->table_share; + uint keys = table_share ? table_share->keys : 0; + DBUG_ENTER("spider_mysql_share::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(key_select_pos = (int *) + spider_bulk_alloc_mem(spider_current_trx, 112, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &key_select_pos, + sizeof(int) * keys, +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + &db_table_str_hash_value, + sizeof(my_hash_value_type) * spider_share->all_link_count, +#endif + NullS)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + if (keys > 0 && + !(key_hint = new spider_string[keys]) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + for (roop_count = 0; roop_count < keys; roop_count++) + { + key_hint[roop_count].init_calc_mem(189); + key_hint[roop_count].set_charset(spider_share->access_charset); + } + DBUG_PRINT("info",("spider key_hint=%p", key_hint)); + + if ( + !(table_select = new spider_string[1]) || + (keys > 0 && + !(key_select = new spider_string[keys]) + ) || + (error_num = create_table_names_str()) || + (table_share && + ( + (error_num = create_column_name_str()) || + (error_num = convert_key_hint_str()) || + (error_num = append_show_table_status()) || + (error_num = append_show_records()) || + (error_num = append_show_index()) + ) + ) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + table_select->init_calc_mem(96); + if (table_share && (error_num = append_table_select())) + DBUG_RETURN(error_num); + + for (roop_count = 0; roop_count < keys; roop_count++) + { + key_select[roop_count].init_calc_mem(97); + if ((error_num = append_key_select(roop_count))) + DBUG_RETURN(error_num); + } + + DBUG_RETURN(error_num); +} + +uint spider_mysql_share::get_column_name_length( + uint field_index +) { + DBUG_ENTER("spider_mysql_share::get_column_name_length"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(column_name_str[field_index].length()); +} + +int spider_mysql_share::append_column_name( + spider_string *str, + uint field_index +) { + int error_num; + DBUG_ENTER("spider_mysql_share::append_column_name"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = spider_db_mysql_utility.append_name(str, + column_name_str[field_index].ptr(), column_name_str[field_index].length()); + DBUG_RETURN(error_num); +} + +int spider_mysql_share::append_column_name_with_alias( + spider_string *str, + uint field_index, + const char *alias, + uint alias_length +) { + DBUG_ENTER("spider_mysql_share::append_column_name_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve( + alias_length + + column_name_str[field_index].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + append_column_name(str, field_index); + DBUG_RETURN(0); +} + +int spider_mysql_share::append_table_name( + spider_string *str, + int all_link_idx +) { + const char *db_nm = db_names_str[all_link_idx].ptr(); + uint db_nm_len = db_names_str[all_link_idx].length(); + const char *table_nm = table_names_str[all_link_idx].ptr(); + uint table_nm_len = table_names_str[all_link_idx].length(); + DBUG_ENTER("spider_mysql_share::append_table_name"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(db_nm_len + SPIDER_SQL_DOT_LEN + table_nm_len + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider_db_mysql_utility.append_name(str, db_nm, db_nm_len); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + spider_db_mysql_utility.append_name(str, table_nm, table_nm_len); + DBUG_RETURN(0); +} + +int spider_mysql_share::append_table_name_with_adjusting( + spider_string *str, + int all_link_idx +) { + const char *db_nm = db_names_str[all_link_idx].ptr(); + uint db_nm_len = db_names_str[all_link_idx].length(); + uint db_nm_max_len = db_nm_max_length; + const char *table_nm = table_names_str[all_link_idx].ptr(); + uint table_nm_len = table_names_str[all_link_idx].length(); + uint table_nm_max_len = table_nm_max_length; + DBUG_ENTER("spider_mysql_share::append_table_name_with_adjusting"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_db_mysql_utility.append_name(str, db_nm, db_nm_len); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + spider_db_mysql_utility.append_name(str, table_nm, table_nm_len); + uint length = + db_nm_max_len - db_nm_len + + table_nm_max_len - table_nm_len; + memset((char *) str->ptr() + str->length(), ' ', length); + str->length(str->length() + length); + DBUG_RETURN(0); +} + +int spider_mysql_share::append_from_with_adjusted_table_name( + spider_string *str, + int *table_name_pos +) { + const char *db_nm = db_names_str[0].ptr(); + uint db_nm_len = db_names_str[0].length(); + uint db_nm_max_len = db_nm_max_length; + const char *table_nm = table_names_str[0].ptr(); + uint table_nm_len = table_names_str[0].length(); + uint table_nm_max_len = table_nm_max_length; + DBUG_ENTER("spider_mysql_share::append_from_with_adjusted_table_name"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_FROM_LEN + db_nm_max_length + + SPIDER_SQL_DOT_LEN + table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + *table_name_pos = str->length(); + spider_db_mysql_utility.append_name(str, db_nm, db_nm_len); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + spider_db_mysql_utility.append_name(str, table_nm, table_nm_len); + uint length = + db_nm_max_len - db_nm_len + + table_nm_max_len - table_nm_len; + memset((char *) str->ptr() + str->length(), ' ', length); + str->length(str->length() + length); + DBUG_RETURN(0); +} + +int spider_mysql_share::create_table_names_str() +{ + int error_num, roop_count; + uint table_nm_len, db_nm_len; + spider_string *str, *first_tbl_nm_str, *first_db_nm_str, *first_db_tbl_str; + char *first_tbl_nm, *first_db_nm; + uint dbton_id = spider_dbton_mysql.dbton_id; + DBUG_ENTER("spider_mysql_share::create_table_names_str"); + table_names_str = NULL; + db_names_str = NULL; + db_table_str = NULL; + if ( + !(table_names_str = new spider_string[spider_share->all_link_count]) || + !(db_names_str = new spider_string[spider_share->all_link_count]) || + !(db_table_str = new spider_string[spider_share->all_link_count]) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + + same_db_table_name = TRUE; + first_tbl_nm = spider_share->tgt_table_names[0]; + first_db_nm = spider_share->tgt_dbs[0]; + table_nm_len = spider_share->tgt_table_names_lengths[0]; + db_nm_len = spider_share->tgt_dbs_lengths[0]; + first_tbl_nm_str = &table_names_str[0]; + first_db_nm_str = &db_names_str[0]; + first_db_tbl_str = &db_table_str[0]; + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + table_names_str[roop_count].init_calc_mem(86); + db_names_str[roop_count].init_calc_mem(87); + db_table_str[roop_count].init_calc_mem(88); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + if (first_all_link_idx == -1) + first_all_link_idx = roop_count; + + str = &table_names_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name && + spider_share->tgt_table_names_lengths[roop_count] == table_nm_len && + !memcmp(first_tbl_nm, spider_share->tgt_table_names[roop_count], + table_nm_len) + ) { + if (str->copy(*first_tbl_nm_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + spider_share->tgt_table_names[roop_count], dbton_id))) + goto error; + if (roop_count) + { + same_db_table_name = FALSE; + DBUG_PRINT("info", ("spider found different table name %s", + spider_share->tgt_table_names[roop_count])); + if (str->length() > table_nm_max_length) + table_nm_max_length = str->length(); + } else + table_nm_max_length = str->length(); + } + + str = &db_names_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name && + spider_share->tgt_dbs_lengths[roop_count] == db_nm_len && + !memcmp(first_db_nm, spider_share->tgt_dbs[roop_count], + db_nm_len) + ) { + if (str->copy(*first_db_nm_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + spider_share->tgt_dbs[roop_count], dbton_id))) + goto error; + if (roop_count) + { + same_db_table_name = FALSE; + DBUG_PRINT("info", ("spider found different db name %s", + spider_share->tgt_dbs[roop_count])); + if (str->length() > db_nm_max_length) + db_nm_max_length = str->length(); + } else + db_nm_max_length = str->length(); + } + + str = &db_table_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name + ) { + if (str->copy(*first_db_tbl_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = append_table_name(str, roop_count))) + goto error; + } +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + db_table_str_hash_value[roop_count] = my_calc_hash( + &spider_open_connections, (uchar*) str->ptr(), str->length()); +#endif + } + DBUG_RETURN(0); + +error: + if (db_table_str) + { + delete [] db_table_str; + db_table_str = NULL; + } + if (db_names_str) + { + delete [] db_names_str; + db_names_str = NULL; + } + if (table_names_str) + { + delete [] table_names_str; + table_names_str = NULL; + } + DBUG_RETURN(error_num); +} + +void spider_mysql_share::free_table_names_str() +{ + DBUG_ENTER("spider_mysql_share::free_table_names_str"); + if (db_table_str) + { + delete [] db_table_str; + db_table_str = NULL; + } + if (db_names_str) + { + delete [] db_names_str; + db_names_str = NULL; + } + if (table_names_str) + { + delete [] table_names_str; + table_names_str = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_share::create_column_name_str() +{ + spider_string *str; + int error_num; + Field **field; + TABLE_SHARE *table_share = spider_share->table_share; + uint dbton_id = spider_dbton_mysql.dbton_id; + DBUG_ENTER("spider_mysql_share::create_column_name_str"); + if ( + table_share->fields && + !(column_name_str = new spider_string[table_share->fields]) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + for (field = table_share->field, str = column_name_str; + *field; field++, str++) + { + str->init_calc_mem(89); + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + (char *) (*field)->field_name, dbton_id))) + goto error; + } + DBUG_RETURN(0); + +error: + if (column_name_str) + { + delete [] column_name_str; + column_name_str = NULL; + } + DBUG_RETURN(error_num); +} + +void spider_mysql_share::free_column_name_str() +{ + DBUG_ENTER("spider_mysql_share::free_column_name_str"); + if (column_name_str) + { + delete [] column_name_str; + column_name_str = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_share::convert_key_hint_str() +{ + spider_string *tmp_key_hint; + int roop_count; + TABLE_SHARE *table_share = spider_share->table_share; + DBUG_ENTER("spider_mysql_share::convert_key_hint_str"); + if (spider_share->access_charset->cset != system_charset_info->cset) + { + /* need convertion */ + for (roop_count = 0, tmp_key_hint = key_hint; + roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++) + { + tmp_key_hint->length(0); + if (tmp_key_hint->append(spider_share->key_hint->ptr(), + spider_share->key_hint->length(), system_charset_info)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } else { + for (roop_count = 0, tmp_key_hint = key_hint; + roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++) + { + if (tmp_key_hint->copy(spider_share->key_hint[roop_count])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + DBUG_RETURN(0); +} + +int spider_mysql_share::append_show_table_status() +{ + int roop_count; + spider_string *str; + uint dbton_id = spider_dbton_mysql.dbton_id; + DBUG_ENTER("spider_mysql_append_show_table_status"); + if (!(show_table_status = + new spider_string[2 * spider_share->all_link_count])) + goto error; + + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + show_table_status[0 + (2 * roop_count)].init_calc_mem(90); + show_table_status[1 + (2 * roop_count)].init_calc_mem(91); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + show_table_status[0 + (2 * roop_count)].reserve( + SPIDER_SQL_SHOW_TABLE_STATUS_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_LIKE_LEN + table_names_str[roop_count].length() + + ((SPIDER_SQL_NAME_QUOTE_LEN) * 2) + + ((SPIDER_SQL_VALUE_QUOTE_LEN) * 2)) || + show_table_status[1 + (2 * roop_count)].reserve( + SPIDER_SQL_SELECT_TABLES_STATUS_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_AND_LEN + SPIDER_SQL_TABLE_NAME_LEN + SPIDER_SQL_EQUAL_LEN + + table_names_str[roop_count].length() + + ((SPIDER_SQL_VALUE_QUOTE_LEN) * 4)) + ) + goto error; + str = &show_table_status[0 + (2 * roop_count)]; + str->q_append( + SPIDER_SQL_SHOW_TABLE_STATUS_STR, SPIDER_SQL_SHOW_TABLE_STATUS_LEN); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(db_names_str[roop_count].ptr(), + db_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(SPIDER_SQL_LIKE_STR, SPIDER_SQL_LIKE_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(table_names_str[roop_count].ptr(), + table_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str = &show_table_status[1 + (2 * roop_count)]; + str->q_append( + SPIDER_SQL_SELECT_TABLES_STATUS_STR, + SPIDER_SQL_SELECT_TABLES_STATUS_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(db_names_str[roop_count].ptr(), + db_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + str->q_append(SPIDER_SQL_TABLE_NAME_STR, SPIDER_SQL_TABLE_NAME_LEN); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(table_names_str[roop_count].ptr(), + table_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } + DBUG_RETURN(0); + +error: + if (show_table_status) + { + delete [] show_table_status; + show_table_status = NULL; + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +void spider_mysql_share::free_show_table_status() +{ + DBUG_ENTER("spider_mysql_free_show_table_status"); + if (show_table_status) + { + delete [] show_table_status; + show_table_status = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_share::append_show_records() +{ + int roop_count; + spider_string *str; + uint dbton_id = spider_dbton_mysql.dbton_id; + DBUG_ENTER("spider_mysql_share::append_show_records"); + if (!(show_records = new spider_string[spider_share->all_link_count])) + goto error; + + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + show_records[roop_count].init_calc_mem(92); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + show_records[roop_count].reserve( + SPIDER_SQL_SHOW_RECORDS_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_DOT_LEN + + table_names_str[roop_count].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4) + ) + goto error; + str = &show_records[roop_count]; + str->q_append(SPIDER_SQL_SHOW_RECORDS_STR, SPIDER_SQL_SHOW_RECORDS_LEN); + append_table_name(str, roop_count); + } + DBUG_RETURN(0); + +error: + if (show_records) + { + delete [] show_records; + show_records = NULL; + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +void spider_mysql_share::free_show_records() +{ + DBUG_ENTER("spider_mysql_share::free_show_records"); + if (show_records) + { + delete [] show_records; + show_records = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_share::append_show_index() +{ + int roop_count; + spider_string *str; + uint dbton_id = spider_dbton_mysql.dbton_id; + DBUG_ENTER("spider_mysql_share::append_show_index"); + if (!(show_index = new spider_string[2 * spider_share->all_link_count])) + goto error; + + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + show_index[0 + (2 * roop_count)].init_calc_mem(93); + show_index[1 + (2 * roop_count)].init_calc_mem(94); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + show_index[0 + (2 * roop_count)].reserve( + SPIDER_SQL_SHOW_INDEX_LEN + db_names_str[roop_count].length() + + SPIDER_SQL_DOT_LEN + + table_names_str[roop_count].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4) || + show_index[1 + (2 * roop_count)].reserve( + SPIDER_SQL_SELECT_STATISTICS_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_AND_LEN + SPIDER_SQL_TABLE_NAME_LEN + SPIDER_SQL_EQUAL_LEN + + table_names_str[roop_count].length() + + ((SPIDER_SQL_VALUE_QUOTE_LEN) * 4) + + SPIDER_SQL_GROUP_LEN + SPIDER_SQL_COLUMN_NAME_LEN) + ) + goto error; + str = &show_index[0 + (2 * roop_count)]; + str->q_append( + SPIDER_SQL_SHOW_INDEX_STR, SPIDER_SQL_SHOW_INDEX_LEN); + append_table_name(str, roop_count); + str = &show_index[1 + (2 * roop_count)]; + str->q_append( + SPIDER_SQL_SELECT_STATISTICS_STR, SPIDER_SQL_SELECT_STATISTICS_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(db_names_str[roop_count].ptr(), + db_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + str->q_append(SPIDER_SQL_TABLE_NAME_STR, SPIDER_SQL_TABLE_NAME_LEN); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(table_names_str[roop_count].ptr(), + table_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_GROUP_STR, SPIDER_SQL_GROUP_LEN); + str->q_append(SPIDER_SQL_COLUMN_NAME_STR, SPIDER_SQL_COLUMN_NAME_LEN); + } + DBUG_RETURN(0); + +error: + if (show_index) + { + delete [] show_index; + show_index = NULL; + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +void spider_mysql_share::free_show_index() +{ + DBUG_ENTER("spider_mysql_share::free_show_index"); + if (show_index) + { + delete [] show_index; + show_index = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_share::append_table_select() +{ + Field **field; + uint field_length; + spider_string *str = table_select; + TABLE_SHARE *table_share = spider_share->table_share; + DBUG_ENTER("spider_mysql_share::append_table_select"); + for (field = table_share->field; *field; field++) + { + field_length = column_name_str[(*field)->field_index].length(); + if (str->reserve(field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(append_from_with_adjusted_table_name(str, &table_select_pos)); +} + +int spider_mysql_share::append_key_select( + uint idx +) { + KEY_PART_INFO *key_part; + Field *field; + uint part_num; + uint field_length; + spider_string *str = &key_select[idx]; + TABLE_SHARE *table_share = spider_share->table_share; + const KEY *key_info = &table_share->key_info[idx]; + DBUG_ENTER("spider_mysql_share::append_key_select"); + for (key_part = key_info->key_part, part_num = 0; + part_num < key_info->key_parts; key_part++, part_num++) + { + field = key_part->field; + field_length = column_name_str[field->field_index].length(); + if (str->reserve(field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(append_from_with_adjusted_table_name(str, &key_select_pos[idx])); +} + +bool spider_mysql_share::need_change_db_table_name() +{ + DBUG_ENTER("spider_mysql_share::need_change_db_table_name"); + DBUG_RETURN(!same_db_table_name); +} + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +int spider_mysql_share::discover_table_structure( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str +) { + int roop_count, error_num = HA_ERR_WRONG_COMMAND; + char sql_buf[MAX_FIELD_WIDTH]; + spider_string sql_str(sql_buf, sizeof(sql_buf), system_charset_info); + uint dbton_id = spider_dbton_mysql.dbton_id; + uint strlen = str->length(); + DBUG_ENTER("spider_mysql_share::discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + sql_str.init_calc_mem(228); + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + { + DBUG_PRINT("info",("spider spider_share->sql_dbton_ids[%d]=%u", + roop_count, spider_share->sql_dbton_ids[roop_count])); + DBUG_PRINT("info",("spider dbton_id=%u", dbton_id)); + continue; + } + + str->length(strlen); + sql_str.length(0); + if (sql_str.reserve( + SPIDER_SQL_SHOW_COLUMNS_LEN + db_names_str[roop_count].length() + + SPIDER_SQL_DOT_LEN + table_names_str[roop_count].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + + SPIDER_SQL_SEMICOLON_LEN + + SPIDER_SQL_SHOW_INDEX_LEN + db_names_str[roop_count].length() + + SPIDER_SQL_DOT_LEN + table_names_str[roop_count].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + )) { + DBUG_PRINT("info",("spider alloc sql_str error")); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql_str.q_append(SPIDER_SQL_SHOW_COLUMNS_STR, SPIDER_SQL_SHOW_COLUMNS_LEN); + append_table_name(&sql_str, roop_count); + sql_str.q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + sql_str.q_append(SPIDER_SQL_SHOW_INDEX_STR, SPIDER_SQL_SHOW_INDEX_LEN); + append_table_name(&sql_str, roop_count); + + SPIDER_CONN *conn; + int need_mon; + if (!(conn = spider_get_conn( + spider_share, 0, spider_share->conn_keys[roop_count], trx, NULL, FALSE, + FALSE, SPIDER_CONN_KIND_MYSQL, &error_num)) + ) { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &need_mon; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(spider_share, conn, roop_count); + spider_conn_set_timeout_from_share(conn, roop_count, trx->thd, + spider_share); + if ( + (error_num = spider_db_set_names_internal(trx, spider_share, conn, + roop_count, &need_mon)) || + ( + spider_db_query( + conn, + sql_str.ptr(), + sql_str.length(), + -1, + &need_mon) && + (error_num = spider_db_errorno(conn)) + ) + ) { + DBUG_PRINT("info",("spider spider_get_trx error")); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + continue; + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = trx->spider_thread_id; + request_key.query_id = trx->thd->query_id; + request_key.handler = NULL; + request_key.request_id = 1; + request_key.next = NULL; + spider_db_result *res; + /* get column list */ + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + DBUG_PRINT("info",("spider column store error")); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + continue; + } + /* no record */ + DBUG_PRINT("info",("spider column no record error")); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + continue; + } + if ((error_num = res->fetch_columns_for_discover_table_structure(str, + spider_share->access_charset))) + { + DBUG_PRINT("info",("spider column fetch error")); + res->free_result(); + delete res; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + continue; + } + res->free_result(); + delete res; + if (conn->db_conn->next_result()) + { + DBUG_PRINT("info",("spider single result error")); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + continue; + } + /* get index list */ + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + DBUG_PRINT("info",("spider index store error")); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + continue; + } + /* no record */ + DBUG_PRINT("info",("spider index no record error")); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + continue; + } + if ((error_num = res->fetch_index_for_discover_table_structure(str, + spider_share->access_charset))) + { + DBUG_PRINT("info",("spider index fetch error")); + res->free_result(); + delete res; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + continue; + } + res->free_result(); + delete res; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if (!error_num) + break; + } + DBUG_RETURN(error_num); +} +#endif + +spider_mysql_handler::spider_mysql_handler( + ha_spider *spider, + spider_mysql_share *db_share +) : spider_db_handler( + spider, + db_share +), + where_pos(0), + order_pos(0), + limit_pos(0), + table_name_pos(0), + ha_read_pos(0), + ha_next_pos(0), + ha_where_pos(0), + ha_limit_pos(0), + ha_table_name_pos(0), + insert_pos(0), + insert_table_name_pos(0), + upd_tmp_tbl(NULL), + tmp_sql_pos1(0), + tmp_sql_pos2(0), + tmp_sql_pos3(0), + tmp_sql_pos4(0), + tmp_sql_pos5(0), + reading_from_bulk_tmp_table(FALSE), + mysql_share(db_share), + link_for_hash(NULL) +{ + DBUG_ENTER("spider_mysql_handler::spider_mysql_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_alloc_calc_mem_init(mem_calc, 183); + spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); + DBUG_VOID_RETURN; +} + +spider_mysql_handler::~spider_mysql_handler() +{ + DBUG_ENTER("spider_mysql_handler::~spider_mysql_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if (link_for_hash) + { + spider_free(spider_current_trx, link_for_hash, MYF(0)); + } + spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); + DBUG_VOID_RETURN; +} + +int spider_mysql_handler::init() +{ + uint roop_count; + THD *thd = spider->trx->thd; + st_spider_share *share = spider->share; + int init_sql_alloc_size = + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); + DBUG_ENTER("spider_mysql_handler::init"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.init_calc_mem(59); + sql_part.init_calc_mem(60); + sql_part2.init_calc_mem(61); + ha_sql.init_calc_mem(62); + insert_sql.init_calc_mem(64); + update_sql.init_calc_mem(65); + tmp_sql.init_calc_mem(66); + dup_update_sql.init_calc_mem(166); + if ( + (sql.real_alloc(init_sql_alloc_size)) || + (insert_sql.real_alloc(init_sql_alloc_size)) || + (update_sql.real_alloc(init_sql_alloc_size)) || + (tmp_sql.real_alloc(init_sql_alloc_size)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.set_charset(share->access_charset); + sql_part.set_charset(share->access_charset); + ha_sql.set_charset(share->access_charset); + insert_sql.set_charset(share->access_charset); + update_sql.set_charset(share->access_charset); + tmp_sql.set_charset(share->access_charset); + upd_tmp_tbl_prm.init(); + upd_tmp_tbl_prm.field_count = 1; + if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *) + spider_bulk_alloc_mem(spider_current_trx, 141, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &link_for_hash, + sizeof(SPIDER_LINK_FOR_HASH) * share->link_count, + NullS)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + link_for_hash[roop_count].spider = spider; + link_for_hash[roop_count].link_idx = roop_count; + link_for_hash[roop_count].db_table_str = + &mysql_share->db_table_str[roop_count]; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + link_for_hash[roop_count].db_table_str_hash_value = + mysql_share->db_table_str_hash_value[roop_count]; +#endif + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + hs_upds.init(); +#endif + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_table_name_with_adjusting( + spider_string *str, + int link_idx, + ulong sql_type +) { + int error_num = 0; + DBUG_ENTER("spider_mysql_handler::append_table_name_with_adjusting"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type == SPIDER_SQL_TYPE_HANDLER) + { + str->q_append(spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_LEN); + } else { + error_num = mysql_share->append_table_name_with_adjusting(str, + spider->conn_link_idx[link_idx]); + } + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_key_column_types( + const key_range *start_key, + spider_string *str +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + KEY *key_info = result_list->key_info; + uint key_name_length, key_count; + key_part_map full_key_part_map = make_prev_keypart_map(key_info->key_parts); + key_part_map start_key_part_map; + KEY_PART_INFO *key_part; + Field *field; + char tmp_buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(tmp_buf, sizeof(tmp_buf), system_charset_info); + DBUG_ENTER("spider_mysql_handler::append_key_column_types"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_str.init_calc_mem(115); + + start_key_part_map = start_key->keypart_map & full_key_part_map; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", key_info->key_parts)); + DBUG_PRINT("info", ("spider full_key_part_map=%lu", full_key_part_map)); + DBUG_PRINT("info", ("spider start_key_part_map=%lu", start_key_part_map)); + + if (!start_key_part_map) + DBUG_RETURN(0); + + for ( + key_part = key_info->key_part, + key_count = 0; + start_key_part_map; + start_key_part_map >>= 1, + key_part++, + key_count++ + ) { + field = key_part->field; + key_name_length = my_sprintf(tmp_buf, (tmp_buf, "c%u", key_count)); + if (str->reserve(key_name_length + SPIDER_SQL_SPACE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(tmp_buf, key_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + + if (tmp_str.ptr() != tmp_buf) + tmp_str.set(tmp_buf, sizeof(tmp_buf), system_charset_info); + else + tmp_str.set_charset(system_charset_info); + field->sql_type(*tmp_str.get_str()); + tmp_str.mem_calc(); + str->append(tmp_str); + if (field->has_charset()) + { + CHARSET_INFO *cs = field->charset(); + uint coll_length = strlen(cs->name); + if (str->reserve(SPIDER_SQL_COLLATE_LEN + coll_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COLLATE_STR, SPIDER_SQL_COLLATE_LEN); + str->q_append(cs->name, coll_length); + } + + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_key_join_columns_for_bka( + const key_range *start_key, + spider_string *str, + const char **table_aliases, + uint *table_alias_lengths +) { + KEY *key_info = spider->result_list.key_info; + uint length, key_name_length, key_count; + key_part_map full_key_part_map = make_prev_keypart_map(key_info->key_parts); + key_part_map start_key_part_map; + KEY_PART_INFO *key_part; + Field *field; + char tmp_buf[MAX_FIELD_WIDTH]; + bool start_where = ((int) str->length() == where_pos); + DBUG_ENTER("spider_mysql_handler::append_key_join_columns_for_bka"); + DBUG_PRINT("info",("spider this=%p", this)); + start_key_part_map = start_key->keypart_map & full_key_part_map; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", key_info->key_parts)); + DBUG_PRINT("info", ("spider full_key_part_map=%lu", full_key_part_map)); + DBUG_PRINT("info", ("spider start_key_part_map=%lu", start_key_part_map)); + + if (!start_key_part_map) + DBUG_RETURN(0); + + if (start_where) + { + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + } else { + if (str->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + + for ( + key_part = key_info->key_part, + key_count = 0; + start_key_part_map; + start_key_part_map >>= 1, + key_part++, + key_count++ + ) { + field = key_part->field; + key_name_length = + mysql_share->column_name_str[field->field_index].length(); + length = my_sprintf(tmp_buf, (tmp_buf, "c%u", key_count)); + if (str->reserve(length + table_alias_lengths[0] + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + table_alias_lengths[1] + SPIDER_SQL_PF_EQUAL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(table_aliases[0], table_alias_lengths[0]); + str->q_append(tmp_buf, length); + str->q_append(SPIDER_SQL_PF_EQUAL_STR, SPIDER_SQL_PF_EQUAL_LEN); + str->q_append(table_aliases[1], table_alias_lengths[1]); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + str->length(str->length() - SPIDER_SQL_AND_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_tmp_table_and_sql_for_bka( + const key_range *start_key +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_tmp_table_and_sql_for_bka"); + DBUG_PRINT("info",("spider this=%p", this)); + char tmp_table_name[MAX_FIELD_WIDTH * 2], + tgt_table_name[MAX_FIELD_WIDTH * 2]; + int tmp_table_name_length; + spider_string tgt_table_name_str(tgt_table_name, MAX_FIELD_WIDTH * 2, + mysql_share->db_names_str[0].charset()); + const char *table_names[2], *table_aliases[2], *table_dot_aliases[2]; + uint table_name_lengths[2], table_alias_lengths[2], + table_dot_alias_lengths[2]; + tgt_table_name_str.init_calc_mem(99); + tgt_table_name_str.length(0); + create_tmp_bka_table_name(tmp_table_name, &tmp_table_name_length, + first_link_idx); + if ((error_num = append_table_name_with_adjusting(&tgt_table_name_str, + first_link_idx, SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + table_names[0] = tmp_table_name; + table_names[1] = tgt_table_name_str.c_ptr_safe(); + table_name_lengths[0] = tmp_table_name_length; + table_name_lengths[1] = tgt_table_name_str.length(); + table_aliases[0] = SPIDER_SQL_A_STR; + table_aliases[1] = SPIDER_SQL_B_STR; + table_alias_lengths[0] = SPIDER_SQL_A_LEN; + table_alias_lengths[1] = SPIDER_SQL_B_LEN; + table_dot_aliases[0] = SPIDER_SQL_A_DOT_STR; + table_dot_aliases[1] = SPIDER_SQL_B_DOT_STR; + table_dot_alias_lengths[0] = SPIDER_SQL_A_DOT_LEN; + table_dot_alias_lengths[1] = SPIDER_SQL_B_DOT_LEN; + if ( + (error_num = append_drop_tmp_bka_table( + &tmp_sql, tmp_table_name, tmp_table_name_length, + &tmp_sql_pos1, &tmp_sql_pos5, TRUE)) || + (error_num = append_create_tmp_bka_table( + start_key, + &tmp_sql, tmp_table_name, + tmp_table_name_length, + &tmp_sql_pos2, spider->share->table_share->table_charset)) || + (error_num = append_insert_tmp_bka_table( + start_key, + &tmp_sql, tmp_table_name, + tmp_table_name_length, &tmp_sql_pos3)) + ) + DBUG_RETURN(error_num); + tmp_sql_pos4 = tmp_sql.length(); + if ((error_num = spider_db_append_select(spider))) + DBUG_RETURN(error_num); + if (sql.reserve(SPIDER_SQL_A_DOT_LEN + SPIDER_SQL_ID_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_A_DOT_STR, SPIDER_SQL_A_DOT_LEN); + sql.q_append(SPIDER_SQL_ID_STR, SPIDER_SQL_ID_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + if ( + (error_num = append_select_columns_with_alias(&sql, + SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)) || + (error_num = spider_db_mysql_utility.append_from_with_alias(&sql, + table_names, table_name_lengths, + table_aliases, table_alias_lengths, 2, + &table_name_pos, FALSE)) + ) + DBUG_RETURN(error_num); + if ( + mysql_share->key_hint && + (error_num = spider_db_append_hint_after_table(spider, + &sql, &mysql_share->key_hint[spider->active_index])) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + where_pos = sql.length(); + if ( + (error_num = append_key_join_columns_for_bka( + start_key, &sql, + table_dot_aliases, table_dot_alias_lengths)) || + (error_num = append_condition_part( + SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN, + SPIDER_SQL_TYPE_SELECT_SQL, FALSE)) || + ( + spider->result_list.direct_order_limit && + (error_num = append_key_order_for_direct_order_limit_with_alias(&sql, + SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)) + ) + ) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +} + +int spider_mysql_handler::reuse_tmp_table_and_sql_for_bka() +{ + DBUG_ENTER("spider_mysql_handler::reuse_tmp_table_and_sql_for_bka"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_sql.length(tmp_sql_pos4); + sql.length(limit_pos); + ha_sql.length(ha_limit_pos); + DBUG_RETURN(0); +} + +void spider_mysql_handler::create_tmp_bka_table_name( + char *tmp_table_name, + int *tmp_table_name_length, + int link_idx +) { + uint adjust_length = + mysql_share->db_nm_max_length - + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].length() + + mysql_share->table_nm_max_length - + mysql_share->table_names_str[spider->conn_link_idx[link_idx]].length(), + length; + DBUG_ENTER("spider_mysql_handler::create_tmp_bka_table_name"); + *tmp_table_name_length = mysql_share->db_nm_max_length + + mysql_share->table_nm_max_length; + memset(tmp_table_name, ' ', adjust_length); + tmp_table_name += adjust_length; + memcpy(tmp_table_name, mysql_share->db_names_str[link_idx].c_ptr(), + mysql_share->db_names_str[link_idx].length()); + tmp_table_name += mysql_share->db_names_str[link_idx].length(); + length = my_sprintf(tmp_table_name, (tmp_table_name, + "%s%s%p%s", SPIDER_SQL_DOT_STR, SPIDER_SQL_TMP_BKA_STR, spider, + SPIDER_SQL_UNDERSCORE_STR)); + *tmp_table_name_length += length; + tmp_table_name += length; + memcpy(tmp_table_name, + mysql_share->table_names_str[spider->conn_link_idx[link_idx]].c_ptr(), + mysql_share->table_names_str[spider->conn_link_idx[link_idx]].length()); + DBUG_VOID_RETURN; +} + +int spider_mysql_handler::append_create_tmp_bka_table( + const key_range *start_key, + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos, + CHARSET_INFO *table_charset +) { + int error_num; + SPIDER_SHARE *share = spider->share; + THD *thd = spider->trx->thd; + char *bka_engine = spider_param_bka_engine(thd, share->bka_engine); + uint bka_engine_length = strlen(bka_engine), + cset_length = strlen(table_charset->csname), + coll_length = strlen(table_charset->name); + DBUG_ENTER("spider_mysql_handler::append_create_tmp_bka_table"); + if (str->reserve(SPIDER_SQL_CREATE_TMP_LEN + tmp_table_name_length + + SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_ID_LEN + SPIDER_SQL_ID_TYPE_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CREATE_TMP_STR, SPIDER_SQL_CREATE_TMP_LEN); + *db_name_pos = str->length(); + str->q_append(tmp_table_name, tmp_table_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + str->q_append(SPIDER_SQL_ID_STR, SPIDER_SQL_ID_LEN); + str->q_append(SPIDER_SQL_ID_TYPE_STR, SPIDER_SQL_ID_TYPE_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + if ((error_num = append_key_column_types(start_key, str))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_ENGINE_LEN + bka_engine_length + + SPIDER_SQL_DEF_CHARSET_LEN + cset_length + SPIDER_SQL_COLLATE_LEN + + coll_length + SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ENGINE_STR, SPIDER_SQL_ENGINE_LEN); + str->q_append(bka_engine, bka_engine_length); + str->q_append(SPIDER_SQL_DEF_CHARSET_STR, SPIDER_SQL_DEF_CHARSET_LEN); + str->q_append(table_charset->csname, cset_length); + str->q_append(SPIDER_SQL_COLLATE_STR, SPIDER_SQL_COLLATE_LEN); + str->q_append(table_charset->name, coll_length); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_drop_tmp_bka_table( + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos, + int *drop_table_end_pos, + bool with_semicolon +) { + DBUG_ENTER("spider_mysql_handler::append_drop_tmp_bka_table"); + if (str->reserve(SPIDER_SQL_DROP_TMP_LEN + tmp_table_name_length + + (with_semicolon ? SPIDER_SQL_SEMICOLON_LEN : 0))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_DROP_TMP_STR, SPIDER_SQL_DROP_TMP_LEN); + *db_name_pos = str->length(); + str->q_append(tmp_table_name, tmp_table_name_length); + *drop_table_end_pos = str->length(); + if (with_semicolon) + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_insert_tmp_bka_table( + const key_range *start_key, + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_insert_tmp_bka_table"); + if (str->reserve(SPIDER_SQL_INSERT_LEN + SPIDER_SQL_INTO_LEN + + tmp_table_name_length + SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_ID_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); + str->q_append(SPIDER_SQL_INTO_STR, SPIDER_SQL_INTO_LEN); + *db_name_pos = str->length(); + str->q_append(tmp_table_name, tmp_table_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + str->q_append(SPIDER_SQL_ID_STR, SPIDER_SQL_ID_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + if ((error_num = spider_db_append_key_columns(start_key, spider, str))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_insert_for_recovery( + ulong sql_type, + int link_idx +) { + const TABLE *table = spider->get_table(); + SPIDER_SHARE *share = spider->share; + Field **field; + uint field_name_length = 0; + bool add_value = FALSE; + spider_string *insert_sql; + DBUG_ENTER("spider_mysql_handler::append_insert_for_recovery"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type == SPIDER_SQL_TYPE_INSERT_SQL) + { + insert_sql = &spider->result_list.insert_sqls[link_idx]; + insert_sql->length(0); + } else { + insert_sql = &spider->result_list.update_sqls[link_idx]; + } + if (insert_sql->reserve( + SPIDER_SQL_INSERT_LEN + SPIDER_SQL_SQL_IGNORE_LEN + + SPIDER_SQL_INTO_LEN + mysql_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + mysql_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + insert_sql->q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); + insert_sql->q_append(SPIDER_SQL_SQL_IGNORE_STR, SPIDER_SQL_SQL_IGNORE_LEN); + insert_sql->q_append(SPIDER_SQL_INTO_STR, SPIDER_SQL_INTO_LEN); + mysql_share->append_table_name(insert_sql, spider->conn_link_idx[link_idx]); + insert_sql->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + for (field = table->field; *field; field++) + { + field_name_length = + mysql_share->column_name_str[(*field)->field_index].length(); + if (insert_sql->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(insert_sql, (*field)->field_index); + insert_sql->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + if (field_name_length) + insert_sql->length(insert_sql->length() - SPIDER_SQL_COMMA_LEN); + if (insert_sql->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + insert_sql->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN); + insert_sql->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + for (field = table->field; *field; field++) + { + add_value = TRUE; + if ((*field)->is_null()) + { + if (insert_sql->reserve(SPIDER_SQL_NULL_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + insert_sql->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else { + if ( + spider_db_mysql_utility. + append_column_value(spider, insert_sql, *field, NULL, + share->access_charset) || + insert_sql->reserve(SPIDER_SQL_COMMA_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + insert_sql->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + if (add_value) + insert_sql->length(insert_sql->length() - SPIDER_SQL_COMMA_LEN); + if (insert_sql->reserve(SPIDER_SQL_CLOSE_PAREN_LEN, SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + insert_sql->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + if (sql_type == SPIDER_SQL_TYPE_INSERT_SQL) + { + exec_insert_sql = insert_sql; + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff +) { + int error_num; + spider_string *str = &update_sql; + DBUG_ENTER("spider_mysql_handler::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->length() > 0) + { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + + if ( + (error_num = append_update(str, 0)) || + (error_num = append_update_set(str)) || + (error_num = append_update_where(str, table, ptr_diff)) + ) + DBUG_RETURN(error_num); + filled_up = (str->length() >= (uint) spider->result_list.bulk_update_size); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.update_sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->length() > 0) + { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + + if ( + (error_num = append_update(str, link_idx)) || + (error_num = append_update_set(str)) || + (error_num = append_update_where(str, table, ptr_diff)) + ) + DBUG_RETURN(error_num); + + if ( + spider->pk_update && + share->link_statuses[link_idx] == SPIDER_LINK_STATUS_RECOVERY + ) { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + if ((error_num = append_insert_for_recovery( + SPIDER_SQL_TYPE_UPDATE_SQL, link_idx))) + DBUG_RETURN(error_num); + } + + if (!filled_up) + filled_up = (str->length() >= (uint) spider->result_list.bulk_update_size); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff +) { + int error_num; + spider_string *str = &update_sql; + DBUG_ENTER("spider_mysql_handler::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->length() > 0) + { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + + if ( + (error_num = append_delete(str)) || + (error_num = append_from(str, SPIDER_SQL_TYPE_DELETE_SQL, + first_link_idx)) || + (error_num = append_update_where(str, table, ptr_diff)) + ) + DBUG_RETURN(error_num); + filled_up = (str->length() >= (uint) spider->result_list.bulk_update_size); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx +) { + int error_num; + spider_string *str = &spider->result_list.update_sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->length() > 0) + { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + + if ( + (error_num = append_delete(str)) || + (error_num = append_from(str, SPIDER_SQL_TYPE_DELETE_SQL, link_idx)) || + (error_num = append_update_where(str, table, ptr_diff)) + ) + DBUG_RETURN(error_num); + if (!filled_up) + filled_up = (str->length() >= (uint) spider->result_list.bulk_update_size); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_insert_part() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::append_insert_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_insert(&insert_sql, 0); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_insert( + spider_string *str, + int link_idx +) { + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_mysql_handler::append_insert"); + if ( + ( + spider->write_can_replace || + /* for direct_dup_insert without patch for partition */ + spider->sql_command == SQLCOM_REPLACE || + spider->sql_command == SQLCOM_REPLACE_SELECT + ) && + spider->direct_dup_insert + ) { + if (str->reserve(SPIDER_SQL_REPLACE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_REPLACE_STR, SPIDER_SQL_REPLACE_LEN); + } else { + if (str->reserve(SPIDER_SQL_INSERT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); + } + if (spider->low_priority) + { + if (str->reserve(SPIDER_SQL_LOW_PRIORITY_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN); + } + else if (spider->insert_delayed) + { + if (share->internal_delayed) + { + if (str->reserve(SPIDER_SQL_SQL_DELAYED_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_DELAYED_STR, SPIDER_SQL_SQL_DELAYED_LEN); + } + } + else if ( + spider->lock_type >= TL_WRITE && + !spider->write_can_replace && + /* for direct_dup_insert without patch for partition */ + spider->sql_command != SQLCOM_REPLACE && + spider->sql_command != SQLCOM_REPLACE_SELECT + ) { + if (str->reserve(SPIDER_SQL_HIGH_PRIORITY_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HIGH_PRIORITY_STR, SPIDER_SQL_HIGH_PRIORITY_LEN); + } + if ( + spider->ignore_dup_key && + spider->direct_dup_insert && + !spider->write_can_replace && + !spider->insert_with_update && + /* for direct_dup_insert without patch for partition */ + spider->sql_command != SQLCOM_REPLACE && + spider->sql_command != SQLCOM_REPLACE_SELECT + ) { + if (str->reserve(SPIDER_SQL_SQL_IGNORE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_IGNORE_STR, SPIDER_SQL_SQL_IGNORE_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_update_part() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::append_update_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_update(&update_sql, 0); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_update( + spider_string *str, + int link_idx +) { + DBUG_ENTER("spider_mysql_handler::append_update"); + if (str->reserve(SPIDER_SQL_UPDATE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_UPDATE_STR, SPIDER_SQL_UPDATE_LEN); + if (spider->low_priority) + { + if (str->reserve(SPIDER_SQL_LOW_PRIORITY_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN); + } + if ( + spider->ignore_dup_key && + !spider->insert_with_update + ) { + if (str->reserve(SPIDER_SQL_SQL_IGNORE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_IGNORE_STR, SPIDER_SQL_SQL_IGNORE_LEN); + } + if (str->reserve(mysql_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + mysql_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + table_name_pos = str->length(); + append_table_name_with_adjusting(str, link_idx, SPIDER_SQL_TYPE_UPDATE_SQL); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_delete_part() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::append_delete_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_delete(&update_sql); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_delete( + spider_string *str +) { + DBUG_ENTER("spider_mysql_handler::append_delete"); + if (str->reserve(SPIDER_SQL_DELETE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_DELETE_STR, SPIDER_SQL_DELETE_LEN); + if (spider->low_priority) + { + if (str->reserve(SPIDER_SQL_LOW_PRIORITY_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN); + } + if (spider->quick_mode) + { + if (str->reserve(SPIDER_SQL_SQL_QUICK_MODE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_QUICK_MODE_STR, + SPIDER_SQL_SQL_QUICK_MODE_LEN); + } + if (spider->ignore_dup_key) + { + if (str->reserve(SPIDER_SQL_SQL_IGNORE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_IGNORE_STR, SPIDER_SQL_SQL_IGNORE_LEN); + } + str->length(str->length() - 1); + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_mysql_handler::append_increment_update_set_part() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::append_increment_update_set_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_increment_update_set(&update_sql); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_increment_update_set( + spider_string *str +) { + uint field_name_length; + uint roop_count; + Field *field; + DBUG_ENTER("spider_mysql_handler::append_increment_update_set"); + if (str->reserve(SPIDER_SQL_SET_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); + const SPIDER_HS_STRING_REF *value = hs_upds.ptr(); + for (roop_count = 0; roop_count < hs_upds.size(); + roop_count++) + { + if ( + value[roop_count].size() == 1 && + *(value[roop_count].begin()) == '0' + ) + continue; + + Field *top_table_field = + spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); + if (!(field = spider->field_exchange(top_table_field))) + continue; + field_name_length = + mysql_share->column_name_str[field->field_index].length(); + + if (str->reserve(field_name_length * 2 + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 4 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_HS_INCREMENT_LEN + + SPIDER_SQL_COMMA_LEN + value[roop_count].size())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + mysql_share->append_column_name(str, field->field_index); + if (spider->hs_increment) + str->q_append(SPIDER_SQL_HS_INCREMENT_STR, + SPIDER_SQL_HS_INCREMENT_LEN); + else + str->q_append(SPIDER_SQL_HS_DECREMENT_STR, + SPIDER_SQL_HS_DECREMENT_LEN); + str->q_append(value[roop_count].begin(), value[roop_count].size()); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} +#endif +#endif + +int spider_mysql_handler::append_update_set_part() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::append_update_set_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_update_set(&update_sql); + where_pos = update_sql.length(); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_update_set( + spider_string *str +) { + uint field_name_length; + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + Field **fields; + DBUG_ENTER("spider_mysql_handler::append_update_set"); + if (str->reserve(SPIDER_SQL_SET_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); + for (fields = table->field; *fields; fields++) + { + if (bitmap_is_set(table->write_set, (*fields)->field_index)) + { + field_name_length = + mysql_share->column_name_str[(*fields)->field_index].length(); + if ((*fields)->is_null()) + { + if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, (*fields)->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else { + if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 2 + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, (*fields)->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, + table->read_set); +#endif + if ( + spider_db_mysql_utility. + append_column_value(spider, str, *fields, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN) + ) { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_mysql_handler::append_direct_update_set_part() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::append_direct_update_set_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_direct_update_set(&update_sql); + where_pos = update_sql.length(); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_direct_update_set( + spider_string *str +) { + uint field_name_length; + SPIDER_SHARE *share = spider->share; +#ifndef DBUG_OFF + TABLE *table = spider->get_table(); +#endif + DBUG_ENTER("spider_mysql_handler::append_direct_update_set"); + if ( + spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && + spider->direct_update_fields + ) { + if (str->reserve(SPIDER_SQL_SET_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); + DBUG_RETURN(spider_db_append_update_columns(spider, str, NULL, 0, + spider_dbton_mysql.dbton_id)); + } + + if ( + (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) + ) { + size_t roop_count; + Field *field; + if (str->reserve(SPIDER_SQL_SET_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); + for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; + roop_count++) + { + Field *top_table_field = + spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); + if (!(field = spider->field_exchange(top_table_field))) + continue; + field_name_length = + mysql_share->column_name_str[field->field_index].length(); + if (top_table_field->is_null()) + { + if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else { + if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 2 + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, + table->read_set); +#endif + if ( + spider_db_mysql_utility. + append_column_value(spider, str, top_table_field, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN) + ) { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_dup_update_pushdown_part( + const char *alias, + uint alias_length +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_dup_update_pushdown_part"); + DBUG_PRINT("info",("spider this=%p", this)); + dup_update_sql.length(0); + error_num = append_update_columns(&dup_update_sql, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_update_columns_part( + const char *alias, + uint alias_length +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_update_columns_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_update_columns(&update_sql, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::check_update_columns_part() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::check_update_columns_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_update_columns(NULL, NULL, 0); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_update_columns( + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_update_columns"); + error_num = spider_db_append_update_columns(spider, str, + alias, alias_length, spider_dbton_mysql.dbton_id); + DBUG_RETURN(error_num); +} +#endif + +int spider_mysql_handler::append_select_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_select(str, sql_type); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_select( + spider_string *str, + ulong sql_type +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_mysql_handler::append_select"); + if (sql_type == SPIDER_SQL_TYPE_HANDLER) + { + if (str->reserve(SPIDER_SQL_HANDLER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HANDLER_STR, SPIDER_SQL_HANDLER_LEN); + } else { + if (str->reserve(SPIDER_SQL_SELECT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN); + if (result_list->lock_type != F_WRLCK && spider->lock_mode < 1) + { + /* no lock */ + if (spider->share->query_cache == 1) + { + if (str->reserve(SPIDER_SQL_SQL_CACHE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_CACHE_STR, SPIDER_SQL_SQL_CACHE_LEN); + } else if (spider->share->query_cache == 2) + { + if (str->reserve(SPIDER_SQL_SQL_NO_CACHE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_NO_CACHE_STR, + SPIDER_SQL_SQL_NO_CACHE_LEN); + } + } + if (spider->high_priority) + { + if (str->reserve(SPIDER_SQL_HIGH_PRIORITY_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HIGH_PRIORITY_STR, + SPIDER_SQL_HIGH_PRIORITY_LEN); + } + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_table_select_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_table_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_table_select(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_table_select( + spider_string *str +) { + DBUG_ENTER("spider_mysql_handler::append_table_select"); + table_name_pos = str->length() + mysql_share->table_select_pos; + if (str->append(*(mysql_share->table_select))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_key_select_part( + ulong sql_type, + uint idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_key_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_select(str, idx); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_key_select( + spider_string *str, + uint idx +) { + DBUG_ENTER("spider_mysql_handler::append_key_select"); + table_name_pos = str->length() + mysql_share->key_select_pos[idx]; + if (str->append(mysql_share->key_select[idx])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_minimum_select_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_minimum_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_minimum_select(str, sql_type); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_minimum_select( + spider_string *str, + ulong sql_type +) { + TABLE *table = spider->get_table(); + Field **field; + int field_length; + bool appended = FALSE; + DBUG_ENTER("spider_mysql_handler::append_minimum_select"); + for (field = table->field; *field; field++) + { + if ( + spider_bit_is_set(spider->searched_bitmap, (*field)->field_index) | + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + ) { + field_length = + mysql_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + appended = TRUE; + } + } + if (appended) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + else { + if (str->reserve(SPIDER_SQL_ONE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ONE_STR, SPIDER_SQL_ONE_LEN); + } + DBUG_RETURN(append_from(str, sql_type, first_link_idx)); +} + +int spider_mysql_handler::append_table_select_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + TABLE *table = spider->get_table(); + Field **field; + int field_length; + DBUG_ENTER("spider_mysql_handler::append_table_select_with_alias"); + for (field = table->field; *field; field++) + { + field_length = + mysql_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(alias_length + field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_key_select_with_alias( + spider_string *str, + const KEY *key_info, + const char *alias, + uint alias_length +) { + KEY_PART_INFO *key_part; + Field *field; + uint part_num; + int field_length; + DBUG_ENTER("spider_mysql_handler::append_key_select_with_alias"); + for (key_part = key_info->key_part, part_num = 0; + part_num < key_info->key_parts; key_part++, part_num++) + { + field = key_part->field; + field_length = mysql_share->column_name_str[field->field_index].length(); + if (str->reserve(alias_length + field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_minimum_select_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + TABLE *table = spider->get_table(); + Field **field; + int field_length; + bool appended = FALSE; + DBUG_ENTER("spider_mysql_handler::append_minimum_select_with_alias"); + for (field = table->field; *field; field++) + { + if ( + spider_bit_is_set(spider->searched_bitmap, (*field)->field_index) | + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + ) { + field_length = + mysql_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(alias_length + field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + appended = TRUE; + } + } + if (appended) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + else { + if (str->reserve(SPIDER_SQL_ONE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ONE_STR, SPIDER_SQL_ONE_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_select_columns_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_mysql_handler::append_select_columns_with_alias"); + if ((error_num = append_match_select(str, alias, alias_length))) + DBUG_RETURN(error_num); + if (!spider->select_column_mode) + { + if (result_list->keyread) + DBUG_RETURN(append_key_select_with_alias( + str, result_list->key_info, alias, alias_length)); + else + DBUG_RETURN(append_table_select_with_alias( + str, alias, alias_length)); + } + DBUG_RETURN(append_minimum_select_with_alias(str, alias, alias_length)); +} + +int spider_mysql_handler::append_hint_after_table_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_hint_after_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_hint_after_table(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_hint_after_table( + spider_string *str +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_hint_after_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + mysql_share->key_hint && + (error_num = spider_db_append_hint_after_table(spider, + str, &mysql_share->key_hint[spider->active_index])) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(0); +} + +void spider_mysql_handler::set_where_pos( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::set_where_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + where_pos = sql.length(); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + where_pos = update_sql.length(); + break; + case SPIDER_SQL_TYPE_HANDLER: + ha_read_pos = ha_sql.length(); + break; + default: + break; + } + DBUG_VOID_RETURN; +} + +void spider_mysql_handler::set_where_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::set_where_to_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + sql.length(where_pos); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + update_sql.length(where_pos); + break; + case SPIDER_SQL_TYPE_HANDLER: + ha_sql.length(ha_read_pos); + break; + default: + break; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_handler::check_item_type( + Item *item +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::check_item_type"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = spider_db_print_item_type(item, spider, NULL, NULL, 0, + spider_dbton_mysql.dbton_id); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_values_connector_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_values_connector_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_values_connector(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_values_connector( + spider_string *str +) { + DBUG_ENTER("spider_mysql_handler::append_values_connector"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + + SPIDER_SQL_COMMA_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_values_terminator_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_values_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_values_terminator(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_values_terminator( + spider_string *str +) { + DBUG_ENTER("spider_mysql_handler::append_values_terminator"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(str->length() - + SPIDER_SQL_COMMA_LEN - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_key_column_values_part( + const key_range *start_key, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_key_column_values_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_column_values(str, start_key); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_key_column_values( + spider_string *str, + const key_range *start_key +) { + int error_num; + const uchar *ptr; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_SHARE *share = spider->share; + KEY *key_info = result_list->key_info; + uint length; + uint store_length; + key_part_map full_key_part_map = make_prev_keypart_map(key_info->key_parts); + key_part_map start_key_part_map; + KEY_PART_INFO *key_part; + Field *field; + DBUG_ENTER("spider_mysql_handler::append_key_column_values"); + start_key_part_map = start_key->keypart_map & full_key_part_map; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", key_info->key_parts)); + DBUG_PRINT("info", ("spider full_key_part_map=%lu", full_key_part_map)); + DBUG_PRINT("info", ("spider start_key_part_map=%lu", start_key_part_map)); + + if (!start_key_part_map) + DBUG_RETURN(0); + + for ( + key_part = key_info->key_part, + length = 0; + start_key_part_map; + start_key_part_map >>= 1, + key_part++, + length += store_length + ) { + store_length = key_part->store_length; + ptr = start_key->key + length; + field = key_part->field; + if ((error_num = spider_db_append_null_value(str, key_part, &ptr))) + { + if (error_num > 0) + DBUG_RETURN(error_num); + } else { + if (spider_db_mysql_utility.append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_key_where_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type +) { + int error_num; + spider_string *str, *str_part = NULL, *str_part2 = NULL; + bool set_order; + DBUG_ENTER("spider_mysql_handler::append_key_where_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + set_order = FALSE; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + set_order = FALSE; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + ha_read_pos = str->length(); + str_part = &sql_part; + str_part2 = &sql_part2; + str_part->length(0); + str_part2->length(0); + set_order = TRUE; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_where(str, str_part, str_part2, start_key, end_key, + sql_type, set_order); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_key_where( + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + const key_range *start_key, + const key_range *end_key, + ulong sql_type, + bool set_order +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_key_where"); + error_num = spider_db_append_key_where_internal(str, str_part, str_part2, + start_key, end_key, spider, set_order, sql_type, + spider_dbton_mysql.dbton_id); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_is_null_part( + ulong sql_type, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq +) { + int error_num; + spider_string *str, *str_part = NULL, *str_part2 = NULL; + DBUG_ENTER("spider_mysql_handler::append_is_null_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + str_part = &sql_part; + str_part2 = &sql_part2; + break; + default: + DBUG_RETURN(0); + } + error_num = append_is_null(sql_type, str, str_part, str_part2, + key_part, key, ptr, key_eq); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_is_null( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq +) { + DBUG_ENTER("spider_mysql_handler::append_is_null"); + DBUG_PRINT("info",("spider this=%p", this)); + if (key_part->null_bit) + { + if (*(*ptr)++) + { + if (sql_type == SPIDER_SQL_TYPE_HANDLER) + { + str = str_part; + if ( + key_eq || + key->flag == HA_READ_KEY_EXACT || + key->flag == HA_READ_KEY_OR_NEXT + ) { + if (str->reserve(SPIDER_SQL_IS_NULL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN); + } else { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + ha_next_pos = str->length(); + if (str->reserve(SPIDER_SQL_FIRST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FIRST_STR, SPIDER_SQL_FIRST_LEN); + spider->result_list.ha_read_kind = 1; + } + str = str_part2; + } + if ( + key_eq || + key->flag == HA_READ_KEY_EXACT || + key->flag == HA_READ_KEY_OR_NEXT + ) { + if (str->reserve(SPIDER_SQL_IS_NULL_LEN + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + mysql_share->column_name_str[key_part->field->field_index].length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, key_part->field->field_index); + str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN); + } else { + if (str->reserve(SPIDER_SQL_IS_NOT_NULL_LEN + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + mysql_share->column_name_str[key_part->field->field_index].length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, key_part->field->field_index); + str->q_append(SPIDER_SQL_IS_NOT_NULL_STR, SPIDER_SQL_IS_NOT_NULL_LEN); + } + DBUG_RETURN(-1); + } + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_where_terminator_part( + ulong sql_type, + bool set_order, + int key_count +) { + int error_num; + spider_string *str, *str_part = NULL, *str_part2 = NULL; + DBUG_ENTER("spider_mysql_handler::append_where_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + str_part = &sql_part; + str_part2 = &sql_part2; + break; + default: + DBUG_RETURN(0); + } + error_num = append_where_terminator(sql_type, str, str_part, str_part2, + set_order, key_count); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_where_terminator( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + bool set_order, + int key_count +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_mysql_handler::append_where_terminator"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type != SPIDER_SQL_TYPE_HANDLER) + { + str->length(str->length() - SPIDER_SQL_AND_LEN); + if (!set_order) + result_list->key_order = key_count; + } else { + str_part2->length(str_part2->length() - SPIDER_SQL_AND_LEN); + + str_part->length(str_part->length() - SPIDER_SQL_COMMA_LEN); + if (!result_list->ha_read_kind) + str_part->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + if (str->append(*str_part)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + uint clause_length = str->length() - ha_next_pos; + if (clause_length < SPIDER_SQL_NEXT_LEN) + { + int roop_count; + clause_length = SPIDER_SQL_NEXT_LEN - clause_length; + if (str->reserve(clause_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + for (roop_count = 0; roop_count < (int) clause_length; roop_count++) + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_match_where_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_match_where_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_ASSERT(0); + DBUG_RETURN(0); + } + error_num = append_match_where(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_match_where( + spider_string *str +) { + int error_num; + bool first = TRUE; + st_spider_ft_info *ft_info = spider->ft_first; + DBUG_ENTER("spider_mysql_handler::append_match_where"); + if (spider->ft_current) + { + while (TRUE) + { + if (ft_info->used_in_where) + { + if (first) + { + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + first = FALSE; + } + if ((error_num = append_match_against(str, ft_info, NULL, 0))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + + if (ft_info == spider->ft_current) + break; + ft_info = ft_info->next; + } + if (!first) + str->length(str->length() - SPIDER_SQL_AND_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_update_where( + spider_string *str, + const TABLE *table, + my_ptrdiff_t ptr_diff +) { + uint field_name_length; + Field **field; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_mysql_handler::append_update_where"); + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + for (field = table->field; *field; field++) + { + if ( + table->s->primary_key == MAX_KEY || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { + field_name_length = + mysql_share->column_name_str[(*field)->field_index].length(); + if ((*field)->is_null(ptr_diff)) + { + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_IS_NULL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN); + } else { + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + (*field)->move_field_offset(ptr_diff); + if ( + spider_db_mysql_utility. + append_column_value(spider, str, *field, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_AND_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + (*field)->move_field_offset(-ptr_diff); + } + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + } + str->length(str->length() - SPIDER_SQL_AND_LEN); + if (str->reserve(SPIDER_SQL_LIMIT1_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LIMIT1_STR, SPIDER_SQL_LIMIT1_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_condition_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg +) { + int error_num; + spider_string *str; + bool start_where = FALSE; + DBUG_ENTER("spider_mysql_handler::append_condition_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + if (test_flg) + { + str = NULL; + } else { + str = &sql; + start_where = ((int) str->length() == where_pos); + } + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + if (test_flg) + { + str = NULL; + } else { + str = &update_sql; + start_where = ((int) str->length() == where_pos); + } + break; + case SPIDER_SQL_TYPE_HANDLER: + if (test_flg) + { + str = NULL; + } else { + str = &ha_sql; + start_where = TRUE; + if (spider->active_index == MAX_KEY) + { + set_where_pos(SPIDER_SQL_TYPE_HANDLER); + if (str->reserve(SPIDER_SQL_READ_LEN + SPIDER_SQL_FIRST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_READ_STR, SPIDER_SQL_READ_LEN); + ha_next_pos = str->length(); + str->q_append(SPIDER_SQL_FIRST_STR, SPIDER_SQL_FIRST_LEN); + sql_part2.length(0); + } + ha_where_pos = str->length(); + + if (sql_part2.length()) + { + str->append(sql_part2); + start_where = FALSE; + } + } + break; + default: + DBUG_RETURN(0); + } + error_num = append_condition(str, alias, alias_length, start_where, + sql_type); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_condition( + spider_string *str, + const char *alias, + uint alias_length, + bool start_where, + ulong sql_type +) { + int error_num, restart_pos = 0, start_where_pos; + SPIDER_CONDITION *tmp_cond = spider->condition; + DBUG_ENTER("spider_mysql_handler::append_condition"); + if (str && start_where) + { + start_where_pos = str->length(); + } else { + start_where_pos = 0; + } + + if (spider->is_clone && !tmp_cond) + { + tmp_cond = spider->pt_clone_source_handler->condition; + } + + while (tmp_cond) + { + if (str) + { + restart_pos = str->length(); + if (start_where) + { + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + start_where = FALSE; + } else { + if (str->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + } + if ((error_num = spider_db_print_item_type( + (Item *) tmp_cond->cond, spider, str, alias, alias_length, + spider_dbton_mysql.dbton_id))) + { + if (str && error_num == ER_SPIDER_COND_SKIP_NUM) + { + DBUG_PRINT("info",("spider COND skip")); + str->length(restart_pos); + start_where = (restart_pos == start_where_pos); + } else + DBUG_RETURN(error_num); + } + tmp_cond = tmp_cond->next; + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_match_against_part( + ulong sql_type, + st_spider_ft_info *ft_info, + const char *alias, + uint alias_length +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_match_against_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_match_against(str, ft_info, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_match_against( + spider_string *str, + st_spider_ft_info *ft_info, + const char *alias, + uint alias_length +) { + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + String *ft_init_key; + KEY *key_info; + uint key_name_length; + int key_count; + KEY_PART_INFO *key_part; + Field *field; + DBUG_ENTER("spider_mysql_handler::append_match_against"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_MATCH_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); + + ft_init_key = ft_info->key; + key_info = &table->key_info[ft_info->inx]; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", + key_info->key_parts)); + + for ( + key_part = key_info->key_part, + key_count = 0; + key_count < (int) key_info->key_parts; + key_part++, + key_count++ + ) { + field = key_part->field; + key_name_length = + mysql_share->column_name_str[field->field_index].length(); + if (alias_length) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + } else { + if (str->reserve(key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_AGAINST_LEN + SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + + char buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, share->access_charset); + tmp_str.init_calc_mem(116); + tmp_str.length(0); + if ( + tmp_str.append(ft_init_key->ptr(), ft_init_key->length(), + ft_init_key->charset()) || + str->reserve(tmp_str.length() * 2) || + spider_db_mysql_utility.append_escaped_util(str, tmp_str.get_str()) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->mem_calc(); + + if (str->reserve( + SPIDER_SQL_VALUE_QUOTE_LEN + SPIDER_SQL_CLOSE_PAREN_LEN + + ((ft_info->flags & FT_BOOL) ? SPIDER_SQL_IN_BOOLEAN_MODE_LEN : 0) + + ((ft_info->flags & FT_EXPAND) ? + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN : 0) + )) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if (ft_info->flags & FT_BOOL) + str->q_append(SPIDER_SQL_IN_BOOLEAN_MODE_STR, + SPIDER_SQL_IN_BOOLEAN_MODE_LEN); + if (ft_info->flags & FT_EXPAND) + str->q_append(SPIDER_SQL_WITH_QUERY_EXPANSION_STR, + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_match_select_part( + ulong sql_type, + const char *alias, + uint alias_length +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_match_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_match_select(str, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_match_select( + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_match_select"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider->ft_current) + { + st_spider_ft_info *ft_info = spider->ft_first; + while (TRUE) + { + if ((error_num = append_match_against(str, ft_info, + alias, alias_length))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + if (ft_info == spider->ft_current) + break; + ft_info = ft_info->next; + } + } + DBUG_RETURN(0); +} + +void spider_mysql_handler::set_order_pos( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::set_order_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + order_pos = sql.length(); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + order_pos = update_sql.length(); + break; + case SPIDER_SQL_TYPE_HANDLER: + ha_next_pos = ha_sql.length(); + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_VOID_RETURN; +} + +void spider_mysql_handler::set_order_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::set_order_to_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + sql.length(order_pos); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + update_sql.length(order_pos); + break; + case SPIDER_SQL_TYPE_HANDLER: + ha_sql.length(ha_next_pos); + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_handler::append_key_order_for_merge_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_key_order_for_merge_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + ha_limit_pos = ha_sql.length(); + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_order_for_merge_with_alias(str, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_key_order_for_merge_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + /* sort for index merge */ + TABLE *table = spider->get_table(); + int length; + Field *field; + uint key_name_length; + DBUG_ENTER("spider_mysql_handler::append_key_order_for_merge_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if (table->s->primary_key < MAX_KEY) + { + /* sort by primary key */ + KEY *key_info = &table->key_info[table->s->primary_key]; + KEY_PART_INFO *key_part; + for ( + key_part = key_info->key_part, + length = 1; + length <= (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + mysql_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + if (length > 1) + { + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + } else { + /* sort by all columns */ + Field **fieldp; + for ( + fieldp = table->field, length = 1; + *fieldp; + fieldp++, length++ + ) { + key_name_length = + mysql_share->column_name_str[(*fieldp)->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, (*fieldp)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + if (length > 1) + { + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + } + limit_pos = str->length(); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_order_for_direct_order_limit_with_alias( + str, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + ORDER *order; + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + DBUG_ENTER("spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_get_select_limit(spider, &select_lex, &select_limit, + &offset_limit); + if (select_lex->order_list.first) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + for (order = (ORDER *) select_lex->order_list.first; order; + order = order->next) + { + if ((error_num = + spider_db_print_item_type((*order->item), spider, str, alias, + alias_length, spider_dbton_mysql.dbton_id))) + { + DBUG_PRINT("info",("spider error=%d", error_num)); + DBUG_RETURN(error_num); + } + if (order->asc) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (str->reserve(SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + limit_pos = str->length(); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_key_order_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_key_order_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + error_num = append_key_order_for_handler(str, alias, alias_length); + DBUG_RETURN(error_num); + default: + DBUG_RETURN(0); + } + error_num = append_key_order_with_alias(str, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_key_order_for_handler( + spider_string *str, + const char *alias, + uint alias_length +) { + DBUG_ENTER("spider_mysql_handler::append_key_order_for_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider ha_next_pos=%d", ha_next_pos)); + DBUG_PRINT("info",("spider ha_where_pos=%d", ha_where_pos)); + str->q_append(alias, alias_length); + memset((char *) str->ptr() + str->length(), ' ', + ha_where_pos - ha_next_pos - alias_length); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_key_order_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + KEY *key_info = result_list->key_info; + int length; + KEY_PART_INFO *key_part; + Field *field; + uint key_name_length; + DBUG_ENTER("spider_mysql_handler::append_key_order_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if (result_list->sorted == TRUE) + { + if (result_list->desc_flg == TRUE) + { + for ( + key_part = key_info->key_part + result_list->key_order, + length = 1; + length + result_list->key_order < (int) key_info->key_parts && + length < result_list->max_order; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + mysql_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if ( + length + result_list->key_order <= (int) key_info->key_parts && + length <= result_list->max_order + ) { + field = key_part->field; + key_name_length = + mysql_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + } else { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_DESC_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + } + } + } else { + for ( + key_part = key_info->key_part + result_list->key_order, + length = 1; + length + result_list->key_order < (int) key_info->key_parts && + length < result_list->max_order; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + mysql_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if ( + length + result_list->key_order <= (int) key_info->key_parts && + length <= result_list->max_order + ) { + field = key_part->field; + key_name_length = + mysql_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_DESC_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + } else { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + mysql_share->append_column_name(str, field->field_index); + } + } + } + } + limit_pos = str->length(); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_limit_part( + longlong offset, + longlong limit, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_limit_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + limit_pos = str->length(); + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + limit_pos = str->length(); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + limit_pos = str->length(); + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + ha_limit_pos = str->length(); + break; + default: + DBUG_RETURN(0); + } + error_num = append_limit(str, offset, limit); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::reappend_limit_part( + longlong offset, + longlong limit, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::reappend_limit_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + str->length(limit_pos); + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + str->length(limit_pos); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + str->length(limit_pos); + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + str->length(ha_limit_pos); + break; + default: + DBUG_RETURN(0); + } + error_num = append_limit(str, offset, limit); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_limit( + spider_string *str, + longlong offset, + longlong limit +) { + char buf[SPIDER_LONGLONG_LEN + 1]; + uint32 length; + DBUG_ENTER("spider_mysql_handler::append_limit"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info", ("spider offset=%lld", offset)); + DBUG_PRINT("info", ("spider limit=%lld", limit)); + if (offset || limit < 9223372036854775807LL) + { + if (str->reserve(SPIDER_SQL_LIMIT_LEN + SPIDER_SQL_COMMA_LEN + + ((SPIDER_LONGLONG_LEN) * 2))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LIMIT_STR, SPIDER_SQL_LIMIT_LEN); + if (offset) + { + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, offset); + str->q_append(buf, length); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + str->q_append(buf, length); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_select_lock_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_select_lock_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_select_lock(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_select_lock( + spider_string *str +) { + int lock_mode = spider_conn_lock_mode(spider); + DBUG_ENTER("spider_mysql_handler::append_select_lock"); + DBUG_PRINT("info",("spider this=%p", this)); + if (lock_mode == SPIDER_LOCK_MODE_EXCLUSIVE) + { + if (str->reserve(SPIDER_SQL_FOR_UPDATE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FOR_UPDATE_STR, SPIDER_SQL_FOR_UPDATE_LEN); + } else if (lock_mode == SPIDER_LOCK_MODE_SHARED) + { + if (str->reserve(SPIDER_SQL_SHARED_LOCK_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SHARED_LOCK_STR, SPIDER_SQL_SHARED_LOCK_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_union_all_start_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_union_all_start_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_union_all_start(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_union_all_start( + spider_string *str +) { + DBUG_ENTER("spider_mysql_handler::append_union_all_start"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_union_all_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_union_all_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_union_all(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_union_all( + spider_string *str +) { + DBUG_ENTER("spider_mysql_handler::append_union_all"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_UNION_ALL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_UNION_ALL_STR, SPIDER_SQL_UNION_ALL_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_union_all_end_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_union_all_end_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_union_all_end(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_union_all_end( + spider_string *str +) { + DBUG_ENTER("spider_mysql_handler::append_union_all_end"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(str->length() - + SPIDER_SQL_UNION_ALL_LEN + SPIDER_SQL_CLOSE_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_multi_range_cnt_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_multi_range_cnt_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_multi_range_cnt(str, multi_range_cnt, with_comma); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_multi_range_cnt( + spider_string *str, + uint multi_range_cnt, + bool with_comma +) { + int range_cnt_length; + char range_cnt_str[SPIDER_SQL_INT_LEN]; + DBUG_ENTER("spider_mysql_handler::append_multi_range_cnt"); + DBUG_PRINT("info",("spider this=%p", this)); + range_cnt_length = my_sprintf(range_cnt_str, (range_cnt_str, "%u", + multi_range_cnt)); + if (with_comma) + { + if (str->reserve(range_cnt_length + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(range_cnt_str, range_cnt_length); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (str->reserve(range_cnt_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(range_cnt_str, range_cnt_length); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_open_handler_part( + ulong sql_type, + uint handler_id, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_open_handler_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_open_handler(str, handler_id, conn, link_idx); + exec_ha_sql = str; + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_open_handler( + spider_string *str, + uint handler_id, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_open_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); + DBUG_PRINT("info",("spider m_handler_cid=%s", + spider->m_handler_cid[link_idx])); + if (str->reserve(SPIDER_SQL_HANDLER_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_HANDLER_STR, SPIDER_SQL_HANDLER_LEN); + if ((error_num = mysql_share->append_table_name(str, + spider->conn_link_idx[link_idx]))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_OPEN_LEN + SPIDER_SQL_AS_LEN + + SPIDER_SQL_HANDLER_CID_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_OPEN_STR, SPIDER_SQL_OPEN_LEN); + str->q_append(SPIDER_SQL_AS_STR, SPIDER_SQL_AS_LEN); + str->q_append(spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_close_handler_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_close_handler_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_close_handler(str, link_idx); + exec_ha_sql = str; + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_close_handler( + spider_string *str, + int link_idx +) { + DBUG_ENTER("spider_mysql_handler::append_close_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_HANDLER_LEN + SPIDER_SQL_CLOSE_LEN + + SPIDER_SQL_HANDLER_CID_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HANDLER_STR, SPIDER_SQL_HANDLER_LEN); + str->q_append(spider->m_handler_cid[link_idx], + SPIDER_SQL_HANDLER_CID_LEN); + str->q_append(SPIDER_SQL_CLOSE_STR, SPIDER_SQL_CLOSE_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_insert_terminator_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_insert_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + str = &insert_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_insert_terminator(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_insert_terminator( + spider_string *str +) { + DBUG_ENTER("spider_mysql_handler::append_insert_terminator"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider->result_list.insert_dup_update_pushdown) + { + DBUG_PRINT("info",("spider add duplicate key update")); + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_DUPLICATE_KEY_UPDATE_LEN + + dup_update_sql.length())) + { + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_DUPLICATE_KEY_UPDATE_STR, + SPIDER_SQL_DUPLICATE_KEY_UPDATE_LEN); + if (str->append(dup_update_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } else { + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_insert_values_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_insert_values_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + str = &insert_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_insert_values(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_insert_values( + spider_string *str +) { + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + Field **field; + bool add_value = FALSE; + DBUG_ENTER("spider_mysql_handler::append_insert_values"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + { + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + for (field = table->field; *field; field++) + { + DBUG_PRINT("info",("spider field_index=%u", (*field)->field_index)); + if ( + bitmap_is_set(table->write_set, (*field)->field_index) || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->read_set); +#endif + add_value = TRUE; + DBUG_PRINT("info",("spider is_null()=%s", + (*field)->is_null() ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider table->next_number_field=%p", + table->next_number_field)); + DBUG_PRINT("info",("spider *field=%p", *field)); + DBUG_PRINT("info",("spider force_auto_increment=%s", + (table->next_number_field && spider->force_auto_increment) ? + "TRUE" : "FALSE")); + if ( + (*field)->is_null() || + ( + table->next_number_field == *field && + !table->auto_increment_field_not_null && + !spider->force_auto_increment + ) + ) { + if (str->reserve(SPIDER_SQL_NULL_LEN + SPIDER_SQL_COMMA_LEN)) + { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else { + if ( + spider_db_mysql_utility. + append_column_value(spider, str, *field, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN) + ) { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + } + } + if (add_value) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_COMMA_LEN)) + { + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_into_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_into_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + str = &insert_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_into(str); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_into( + spider_string *str +) { + const TABLE *table = spider->get_table(); + Field **field; + uint field_name_length = 0; + DBUG_ENTER("spider_mysql_handler::append_into"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_INTO_LEN + mysql_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + mysql_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_INTO_STR, SPIDER_SQL_INTO_LEN); + insert_table_name_pos = str->length(); + append_table_name_with_adjusting(str, first_link_idx, + SPIDER_SQL_TYPE_INSERT_SQL); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + for (field = table->field; *field; field++) + { + if ( + bitmap_is_set(table->write_set, (*field)->field_index) || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { + field_name_length = + mysql_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if (field_name_length) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_VALUES_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN); + insert_pos = str->length(); + DBUG_RETURN(0); +} + +void spider_mysql_handler::set_insert_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::set_insert_to_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + insert_sql.length(insert_pos); + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_handler::append_from_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_from_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + default: + str = &sql; + break; + } + error_num = append_from(str, sql_type, link_idx); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_from( + spider_string *str, + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_mysql_handler::append_from"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); + if (sql_type == SPIDER_SQL_TYPE_HANDLER) + { + ha_table_name_pos = str->length(); + DBUG_PRINT("info",("spider ha_table_name_pos=%u", ha_table_name_pos)); + ha_sql_handler_id = spider->m_handler_id[link_idx]; + DBUG_PRINT("info",("spider ha_sql_handler_id=%u", ha_sql_handler_id)); + if (str->reserve(SPIDER_SQL_HANDLER_CID_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_LEN); + DBUG_PRINT("info",("spider m_handler_cid=%s", + spider->m_handler_cid[link_idx])); + } else { + if (str->reserve(SPIDER_SQL_FROM_LEN + mysql_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + mysql_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + table_name_pos = str->length(); + append_table_name_with_adjusting(str, link_idx, sql_type); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_flush_tables_part( + ulong sql_type, + int link_idx, + bool lock +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_flush_tables_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_flush_tables(str, link_idx, lock); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_flush_tables( + spider_string *str, + int link_idx, + bool lock +) { + DBUG_ENTER("spider_mysql_handler::append_flush_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + if (lock) + { + if (str->reserve(SPIDER_SQL_FLUSH_TABLES_LEN + + SPIDER_SQL_WITH_READ_LOCK_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FLUSH_TABLES_STR, SPIDER_SQL_FLUSH_TABLES_LEN); + str->q_append(SPIDER_SQL_WITH_READ_LOCK_STR, + SPIDER_SQL_WITH_READ_LOCK_LEN); + } else { + if (str->reserve(SPIDER_SQL_FLUSH_TABLES_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FLUSH_TABLES_STR, SPIDER_SQL_FLUSH_TABLES_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_optimize_table_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_optimize_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_optimize_table(str, link_idx); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_optimize_table( + spider_string *str, + int link_idx +) { + SPIDER_SHARE *share = spider->share; + int conn_link_idx = spider->conn_link_idx[link_idx]; + int local_length = spider_param_internal_optimize_local(spider->trx->thd, + share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; + DBUG_ENTER("spider_mysql_handler::append_optimize_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_OPTIMIZE_LEN + SPIDER_SQL_SQL_TABLE_LEN + + local_length + + mysql_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + mysql_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_OPTIMIZE_STR, SPIDER_SQL_SQL_OPTIMIZE_LEN); + if (local_length) + str->q_append(SPIDER_SQL_SQL_LOCAL_STR, SPIDER_SQL_SQL_LOCAL_LEN); + str->q_append(SPIDER_SQL_SQL_TABLE_STR, SPIDER_SQL_SQL_TABLE_LEN); + mysql_share->append_table_name(str, conn_link_idx); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_analyze_table_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_analyze_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_analyze_table(str, link_idx); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_analyze_table( + spider_string *str, + int link_idx +) { + SPIDER_SHARE *share = spider->share; + int conn_link_idx = spider->conn_link_idx[link_idx]; + int local_length = spider_param_internal_optimize_local(spider->trx->thd, + share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; + DBUG_ENTER("spider_mysql_handler::append_analyze_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_ANALYZE_LEN + SPIDER_SQL_SQL_TABLE_LEN + + local_length + + mysql_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + mysql_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_ANALYZE_STR, SPIDER_SQL_SQL_ANALYZE_LEN); + if (local_length) + str->q_append(SPIDER_SQL_SQL_LOCAL_STR, SPIDER_SQL_SQL_LOCAL_LEN); + str->q_append(SPIDER_SQL_SQL_TABLE_STR, SPIDER_SQL_SQL_TABLE_LEN); + mysql_share->append_table_name(str, conn_link_idx); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_repair_table_part( + ulong sql_type, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_repair_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_repair_table(str, link_idx, check_opt); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_repair_table( + spider_string *str, + int link_idx, + HA_CHECK_OPT* check_opt +) { + SPIDER_SHARE *share = spider->share; + int conn_link_idx = spider->conn_link_idx[link_idx]; + int local_length = spider_param_internal_optimize_local(spider->trx->thd, + share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; + DBUG_ENTER("spider_mysql_handler::append_repair_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_REPAIR_LEN + SPIDER_SQL_SQL_TABLE_LEN + + local_length + + mysql_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + mysql_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_REPAIR_STR, SPIDER_SQL_SQL_REPAIR_LEN); + if (local_length) + str->q_append(SPIDER_SQL_SQL_LOCAL_STR, SPIDER_SQL_SQL_LOCAL_LEN); + str->q_append(SPIDER_SQL_SQL_TABLE_STR, SPIDER_SQL_SQL_TABLE_LEN); + mysql_share->append_table_name(str, conn_link_idx); + if (check_opt->flags & T_QUICK) + { + if (str->reserve(SPIDER_SQL_SQL_QUICK_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_QUICK_STR, SPIDER_SQL_SQL_QUICK_LEN); + } + if (check_opt->flags & T_EXTEND) + { + if (str->reserve(SPIDER_SQL_SQL_EXTENDED_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_EXTENDED_STR, SPIDER_SQL_SQL_EXTENDED_LEN); + } + if (check_opt->sql_flags & TT_USEFRM) + { + if (str->reserve(SPIDER_SQL_SQL_USE_FRM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_USE_FRM_STR, SPIDER_SQL_SQL_USE_FRM_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_check_table_part( + ulong sql_type, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_check_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_check_table(str, link_idx, check_opt); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_check_table( + spider_string *str, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int conn_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_mysql_handler::append_check_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_CHECK_TABLE_LEN + + mysql_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + mysql_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_CHECK_TABLE_STR, + SPIDER_SQL_SQL_CHECK_TABLE_LEN); + mysql_share->append_table_name(str, conn_link_idx); + if (check_opt->flags & T_QUICK) + { + if (str->reserve(SPIDER_SQL_SQL_QUICK_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_QUICK_STR, SPIDER_SQL_SQL_QUICK_LEN); + } + if (check_opt->flags & T_FAST) + { + if (str->reserve(SPIDER_SQL_SQL_FAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_FAST_STR, SPIDER_SQL_SQL_FAST_LEN); + } + if (check_opt->flags & T_MEDIUM) + { + if (str->reserve(SPIDER_SQL_SQL_MEDIUM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_MEDIUM_STR, SPIDER_SQL_SQL_MEDIUM_LEN); + } + if (check_opt->flags & T_EXTEND) + { + if (str->reserve(SPIDER_SQL_SQL_EXTENDED_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_EXTENDED_STR, SPIDER_SQL_SQL_EXTENDED_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_enable_keys_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_enable_keys_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_enable_keys(str, link_idx); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_enable_keys( + spider_string *str, + int link_idx +) { + int conn_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_mysql_handler::append_enable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_ALTER_TABLE_LEN + + mysql_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + mysql_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_SQL_ENABLE_KEYS_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_ALTER_TABLE_STR, + SPIDER_SQL_SQL_ALTER_TABLE_LEN); + mysql_share->append_table_name(str, conn_link_idx); + str->q_append(SPIDER_SQL_SQL_ENABLE_KEYS_STR, + SPIDER_SQL_SQL_ENABLE_KEYS_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_disable_keys_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_disable_keys_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_disable_keys(str, link_idx); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_disable_keys( + spider_string *str, + int link_idx +) { + int conn_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_mysql_handler::append_disable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_ALTER_TABLE_LEN + + mysql_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + mysql_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_SQL_DISABLE_KEYS_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_ALTER_TABLE_STR, + SPIDER_SQL_SQL_ALTER_TABLE_LEN); + mysql_share->append_table_name(str, conn_link_idx); + str->q_append(SPIDER_SQL_SQL_DISABLE_KEYS_STR, + SPIDER_SQL_SQL_DISABLE_KEYS_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_delete_all_rows_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_delete_all_rows_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_DELETE_SQL: + str = &update_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_delete_all_rows(str, sql_type); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_delete_all_rows( + spider_string *str, + ulong sql_type +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_delete_all_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider->sql_command == SQLCOM_TRUNCATE) + { + if ((error_num = append_truncate(str, sql_type, first_link_idx))) + DBUG_RETURN(error_num); + } else { + if ( + (error_num = append_delete(str)) || + (error_num = append_from(str, sql_type, first_link_idx)) + ) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_truncate( + spider_string *str, + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_mysql_handler::append_truncate"); + if (str->reserve(SPIDER_SQL_TRUNCATE_TABLE_LEN + + mysql_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + mysql_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_TRUNCATE_TABLE_STR, SPIDER_SQL_TRUNCATE_TABLE_LEN); + table_name_pos = str->length(); + append_table_name_with_adjusting(str, link_idx, sql_type); + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_explain_select_part( + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_mysql_handler::append_explain_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = + append_explain_select(str, start_key, end_key, sql_type, link_idx); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::append_explain_select( + spider_string *str, + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::append_explain_select"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_EXPLAIN_SELECT_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_EXPLAIN_SELECT_STR, SPIDER_SQL_EXPLAIN_SELECT_LEN); + if ( + (error_num = append_from(str, sql_type, link_idx)) || + (error_num = append_key_where(str, NULL, NULL, start_key, end_key, + sql_type, FALSE)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + DBUG_RETURN(0); +} + +bool spider_mysql_handler::is_bulk_insert_exec_period( + bool bulk_end +) { + DBUG_ENTER("spider_mysql_handler::is_bulk_insert_exec_period"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider insert_sql.length=%u", insert_sql.length())); + DBUG_PRINT("info",("spider insert_pos=%d", insert_pos)); + DBUG_PRINT("info",("spider insert_sql=%s", insert_sql.c_ptr_safe())); + if ( + (bulk_end || (int) insert_sql.length() >= spider->bulk_size) && + (int) insert_sql.length() > insert_pos + ) { + DBUG_RETURN(TRUE); + } + DBUG_RETURN(FALSE); +} + +bool spider_mysql_handler::sql_is_filled_up( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::sql_is_filled_up"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(filled_up); +} + +bool spider_mysql_handler::sql_is_empty( + ulong sql_type +) { + bool is_empty; + DBUG_ENTER("spider_mysql_handler::sql_is_empty"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + is_empty = (sql.length() == 0); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + is_empty = (insert_sql.length() == 0); + break; + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + is_empty = (update_sql.length() == 0); + break; + case SPIDER_SQL_TYPE_TMP_SQL: + is_empty = (tmp_sql.length() == 0); + break; + case SPIDER_SQL_TYPE_HANDLER: + is_empty = (ha_sql.length() == 0); + break; + default: + is_empty = TRUE; + break; + } + DBUG_RETURN(is_empty); +} + +bool spider_mysql_handler::support_multi_split_read() +{ + DBUG_ENTER("spider_mysql_handler::support_multi_split_read"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +bool spider_mysql_handler::support_bulk_update() +{ + DBUG_ENTER("spider_mysql_handler::support_bulk_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_mysql_handler::bulk_tmp_table_insert() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = store_sql_to_bulk_tmp_table(&update_sql, upd_tmp_tbl); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::bulk_tmp_table_insert( + int link_idx +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = store_sql_to_bulk_tmp_table( + &spider->result_list.update_sqls[link_idx], + spider->result_list.upd_tmp_tbls[link_idx]); + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::bulk_tmp_table_end_bulk_insert() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_end_bulk_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = upd_tmp_tbl->file->ha_end_bulk_insert())) + { + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::bulk_tmp_table_rnd_init() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_rnd_init"); + DBUG_PRINT("info",("spider this=%p", this)); + upd_tmp_tbl->file->extra(HA_EXTRA_CACHE); + if ((error_num = upd_tmp_tbl->file->ha_rnd_init(TRUE))) + { + DBUG_RETURN(error_num); + } + reading_from_bulk_tmp_table = TRUE; + DBUG_RETURN(0); +} + +int spider_mysql_handler::bulk_tmp_table_rnd_next() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_rnd_next"); + DBUG_PRINT("info",("spider this=%p", this)); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + error_num = upd_tmp_tbl->file->ha_rnd_next(upd_tmp_tbl->record[0]); +#else + error_num = upd_tmp_tbl->file->rnd_next(upd_tmp_tbl->record[0]); +#endif + if (!error_num) + { + error_num = restore_sql_from_bulk_tmp_table(&insert_sql, upd_tmp_tbl); + } + DBUG_RETURN(error_num); +} + +int spider_mysql_handler::bulk_tmp_table_rnd_end() +{ + int error_num; + DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_rnd_end"); + DBUG_PRINT("info",("spider this=%p", this)); + reading_from_bulk_tmp_table = FALSE; + if ((error_num = upd_tmp_tbl->file->ha_rnd_end())) + { + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +bool spider_mysql_handler::need_copy_for_update( + int link_idx +) { + int all_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_mysql_handler::need_copy_for_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(!mysql_share->same_db_table_name || + spider->share->link_statuses[all_link_idx] == SPIDER_LINK_STATUS_RECOVERY); +} + +bool spider_mysql_handler::bulk_tmp_table_created() +{ + DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_created"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(upd_tmp_tbl); +} + +int spider_mysql_handler::mk_bulk_tmp_table_and_bulk_start() +{ + THD *thd = spider->trx->thd; + TABLE *table = spider->get_table(); + DBUG_ENTER("spider_mysql_handler::mk_bulk_tmp_table_and_bulk_start"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!upd_tmp_tbl) + { + if (!(upd_tmp_tbl = spider_mk_sys_tmp_table( + thd, table, &upd_tmp_tbl_prm, "a", update_sql.charset()))) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + upd_tmp_tbl->file->extra(HA_EXTRA_WRITE_CACHE); + upd_tmp_tbl->file->ha_start_bulk_insert((ha_rows) 0); + } + DBUG_RETURN(0); +} + +void spider_mysql_handler::rm_bulk_tmp_table() +{ + DBUG_ENTER("spider_mysql_handler::rm_bulk_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (upd_tmp_tbl) + { + spider_rm_sys_tmp_table(spider->trx->thd, upd_tmp_tbl, &upd_tmp_tbl_prm); + upd_tmp_tbl = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_mysql_handler::store_sql_to_bulk_tmp_table( + spider_string *str, + TABLE *tmp_table +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::store_sql_to_bulk_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_table->field[0]->set_notnull(); + tmp_table->field[0]->store(str->ptr(), str->length(), str->charset()); + if ((error_num = tmp_table->file->ha_write_row(tmp_table->record[0]))) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +} + +int spider_mysql_handler::restore_sql_from_bulk_tmp_table( + spider_string *str, + TABLE *tmp_table +) { + DBUG_ENTER("spider_mysql_handler::restore_sql_from_bulk_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_table->field[0]->val_str(str->get_str()); + str->mem_calc(); + DBUG_RETURN(0); +} + +int spider_mysql_handler::insert_lock_tables_list( + SPIDER_CONN *conn, + int link_idx +) { + spider_db_mysql *db_conn = (spider_db_mysql *) conn->db_conn; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash2 = &link_for_hash[link_idx]; + DBUG_ENTER("spider_mysql_handler::insert_lock_tables_list"); + DBUG_PRINT("info",("spider this=%p", this)); + uint old_elements = + db_conn->lock_table_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value( + &db_conn->lock_table_hash, + tmp_link_for_hash2->db_table_str_hash_value, + (uchar*) tmp_link_for_hash2)) +#else + if (my_hash_insert(&db_conn->lock_table_hash, + (uchar*) tmp_link_for_hash2)) +#endif + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (db_conn->lock_table_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + db_conn->lock_table_hash, + (db_conn->lock_table_hash.array.max_element - old_elements) * + db_conn->lock_table_hash.array.size_of_element); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::append_lock_tables_list( + SPIDER_CONN *conn, + int link_idx, + int *appended +) { + int error_num; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash, *tmp_link_for_hash2; + int conn_link_idx = spider->conn_link_idx[link_idx]; + spider_db_mysql *db_conn = (spider_db_mysql *) conn->db_conn; + DBUG_ENTER("spider_mysql_handler::append_lock_tables_list"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_link_for_hash2 = &link_for_hash[link_idx]; + tmp_link_for_hash2->db_table_str = + &mysql_share->db_table_str[conn_link_idx]; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + tmp_link_for_hash2->db_table_str_hash_value = + mysql_share->db_table_str_hash_value[conn_link_idx]; + if (!(tmp_link_for_hash = (SPIDER_LINK_FOR_HASH *) + my_hash_search_using_hash_value( + &db_conn->lock_table_hash, + tmp_link_for_hash2->db_table_str_hash_value, + (uchar*) tmp_link_for_hash2->db_table_str->ptr(), + tmp_link_for_hash2->db_table_str->length()))) +#else + if (!(tmp_link_for_hash = (SPIDER_LINK_FOR_HASH *) my_hash_search( + &db_conn->lock_table_hash, + (uchar*) tmp_link_for_hash2->db_table_str->ptr(), + tmp_link_for_hash2->db_table_str->length()))) +#endif + { + if ((error_num = insert_lock_tables_list(conn, link_idx))) + DBUG_RETURN(error_num); + *appended = 1; + } else { + if (tmp_link_for_hash->spider->lock_type < spider->lock_type) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value( + &db_conn->lock_table_hash, + tmp_link_for_hash->db_table_str_hash_value, + (uchar*) tmp_link_for_hash); +#else + my_hash_delete(&db_conn->lock_table_hash, + (uchar*) tmp_link_for_hash); +#endif + uint old_elements = + db_conn->lock_table_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value( + &db_conn->lock_table_hash, + tmp_link_for_hash2->db_table_str_hash_value, + (uchar*) tmp_link_for_hash2)) +#else + if (my_hash_insert(&db_conn->lock_table_hash, + (uchar*) tmp_link_for_hash2)) +#endif + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (db_conn->lock_table_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + db_conn->lock_table_hash, + (db_conn->lock_table_hash.array.max_element - old_elements) * + db_conn->lock_table_hash.array.size_of_element); + } + } + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::realloc_sql( + ulong *realloced +) { + THD *thd = spider->trx->thd; + st_spider_share *share = spider->share; + int init_sql_alloc_size = + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); + DBUG_ENTER("spider_mysql_handler::realloc_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((int) sql.alloced_length() > init_sql_alloc_size * 2) + { + sql.free(); + if (sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_SELECT_SQL; + } + if ((int) ha_sql.alloced_length() > init_sql_alloc_size * 2) + { + ha_sql.free(); + if (ha_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_SELECT_SQL; + } + if ((int) dup_update_sql.alloced_length() > init_sql_alloc_size * 2) + { + dup_update_sql.free(); + if (dup_update_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if ((int) insert_sql.alloced_length() > init_sql_alloc_size * 2) + { + insert_sql.free(); + if (insert_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_INSERT_SQL; + } + if ((int) update_sql.alloced_length() > init_sql_alloc_size * 2) + { + update_sql.free(); + if (update_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= (SPIDER_SQL_TYPE_UPDATE_SQL | SPIDER_SQL_TYPE_DELETE_SQL); + } + update_sql.length(0); + if ((int) tmp_sql.alloced_length() > init_sql_alloc_size * 2) + { + tmp_sql.free(); + if (tmp_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_TMP_SQL; + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::reset_sql( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::reset_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & SPIDER_SQL_TYPE_SELECT_SQL) + { + sql.length(0); + } + if (sql_type & SPIDER_SQL_TYPE_INSERT_SQL) + { + insert_sql.length(0); + } + if (sql_type & (SPIDER_SQL_TYPE_UPDATE_SQL | SPIDER_SQL_TYPE_DELETE_SQL | + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + update_sql.length(0); + } + if (sql_type & SPIDER_SQL_TYPE_TMP_SQL) + { + tmp_sql.length(0); + } + if (sql_type & SPIDER_SQL_TYPE_HANDLER) + { + ha_sql.length(0); + } + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int spider_mysql_handler::reset_keys( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::reset_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_mysql_handler::reset_upds( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::reset_upds"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_upds.clear(); + DBUG_RETURN(0); +} + +int spider_mysql_handler::reset_strs( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::reset_strs"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_mysql_handler::reset_strs_pos( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::reset_strs_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_mysql_handler::push_back_upds( + SPIDER_HS_STRING_REF &info +) { + int error_num; + DBUG_ENTER("spider_mysql_handler::push_back_upds"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = hs_upds.push_back(info); + DBUG_RETURN(error_num); +} +#endif + +bool spider_mysql_handler::need_lock_before_set_sql_for_exec( + ulong sql_type +) { + DBUG_ENTER("spider_mysql_handler::need_lock_before_set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_mysql_handler::set_sql_for_exec( + ulong sql_type, + int link_idx +) { + int error_num; + uint tmp_pos; + SPIDER_SHARE *share = spider->share; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + int all_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_mysql_handler::set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & (SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL)) + { + if (mysql_share->same_db_table_name || link_idx == first_link_idx) + { + if (sql_type & SPIDER_SQL_TYPE_SELECT_SQL) + exec_sql = &sql; + if (sql_type & SPIDER_SQL_TYPE_TMP_SQL) + exec_tmp_sql = &tmp_sql; + } else { + char tmp_table_name[MAX_FIELD_WIDTH * 2], + tgt_table_name[MAX_FIELD_WIDTH * 2]; + int tmp_table_name_length; + spider_string tgt_table_name_str(tgt_table_name, + MAX_FIELD_WIDTH * 2, + mysql_share->db_names_str[link_idx].charset()); + const char *table_names[2], *table_aliases[2]; + uint table_name_lengths[2], table_alias_lengths[2]; + tgt_table_name_str.init_calc_mem(104); + tgt_table_name_str.length(0); + if (result_list->tmp_table_join) + { + create_tmp_bka_table_name(tmp_table_name, &tmp_table_name_length, + link_idx); + append_table_name_with_adjusting(&tgt_table_name_str, link_idx, + SPIDER_SQL_TYPE_TMP_SQL); + table_names[0] = tmp_table_name; + table_names[1] = tgt_table_name_str.c_ptr(); + table_name_lengths[0] = tmp_table_name_length; + table_name_lengths[1] = tgt_table_name_str.length(); + table_aliases[0] = SPIDER_SQL_A_STR; + table_aliases[1] = SPIDER_SQL_B_STR; + table_alias_lengths[0] = SPIDER_SQL_A_LEN; + table_alias_lengths[1] = SPIDER_SQL_B_LEN; + } + if (sql_type & SPIDER_SQL_TYPE_SELECT_SQL) + { + exec_sql = &result_list->sqls[link_idx]; + if (exec_sql->copy(sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + else { + tmp_pos = exec_sql->length(); + exec_sql->length(table_name_pos); + if (result_list->tmp_table_join) + { + if ((error_num = spider_db_mysql_utility.append_from_with_alias( + exec_sql, table_names, table_name_lengths, + table_aliases, table_alias_lengths, 2, + &table_name_pos, TRUE)) + ) + DBUG_RETURN(error_num); + } else { + append_table_name_with_adjusting(exec_sql, link_idx, + SPIDER_SQL_TYPE_SELECT_SQL); + } + exec_sql->length(tmp_pos); + } + } + if (sql_type & SPIDER_SQL_TYPE_TMP_SQL) + { + exec_tmp_sql = &result_list->tmp_sqls[link_idx]; + if (result_list->tmp_table_join) + { + if (exec_tmp_sql->copy(tmp_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + else { + tmp_pos = exec_tmp_sql->length(); + exec_tmp_sql->length(tmp_sql_pos1); + exec_tmp_sql->q_append(tmp_table_name, tmp_table_name_length); + exec_tmp_sql->length(tmp_sql_pos2); + exec_tmp_sql->q_append(tmp_table_name, tmp_table_name_length); + exec_tmp_sql->length(tmp_sql_pos3); + exec_tmp_sql->q_append(tmp_table_name, tmp_table_name_length); + exec_tmp_sql->length(tmp_pos); + } + } + } + } + } + if (sql_type & SPIDER_SQL_TYPE_INSERT_SQL) + { + if (mysql_share->same_db_table_name || link_idx == first_link_idx) + exec_insert_sql = &insert_sql; + else { + exec_insert_sql = &result_list->insert_sqls[link_idx]; + if (exec_insert_sql->copy(insert_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_PRINT("info",("spider exec_insert_sql=%s", + exec_insert_sql->c_ptr_safe())); + tmp_pos = exec_insert_sql->length(); + exec_insert_sql->length(insert_table_name_pos); + append_table_name_with_adjusting(exec_insert_sql, link_idx, + sql_type); + exec_insert_sql->length(tmp_pos); + DBUG_PRINT("info",("spider exec_insert_sql->length=%u", + exec_insert_sql->length())); + DBUG_PRINT("info",("spider exec_insert_sql=%s", + exec_insert_sql->c_ptr_safe())); + } + } + if (sql_type & SPIDER_SQL_TYPE_BULK_UPDATE_SQL) + { + if (reading_from_bulk_tmp_table) + { + if ( + mysql_share->same_db_table_name && + share->link_statuses[all_link_idx] != SPIDER_LINK_STATUS_RECOVERY + ) { + exec_update_sql = &insert_sql; + } else if (!spider->result_list.upd_tmp_tbls[link_idx]) + { + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + } else { + exec_update_sql = &spider->result_list.insert_sqls[link_idx]; + if ((error_num = restore_sql_from_bulk_tmp_table(exec_update_sql, + spider->result_list.upd_tmp_tbls[link_idx]))) + { + DBUG_RETURN(error_num); + } + } + } else { + if ( + mysql_share->same_db_table_name && + share->link_statuses[all_link_idx] != SPIDER_LINK_STATUS_RECOVERY + ) { + exec_update_sql = &update_sql; + } else { + exec_update_sql = &spider->result_list.update_sqls[link_idx]; + } + } + } else if (sql_type & + (SPIDER_SQL_TYPE_UPDATE_SQL | SPIDER_SQL_TYPE_DELETE_SQL)) + { + if (mysql_share->same_db_table_name || link_idx == first_link_idx) + exec_update_sql = &update_sql; + else { + exec_update_sql = &spider->result_list.update_sqls[link_idx]; + if (exec_update_sql->copy(update_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_pos = exec_update_sql->length(); + exec_update_sql->length(table_name_pos); + append_table_name_with_adjusting(exec_update_sql, link_idx, + sql_type); + exec_update_sql->length(tmp_pos); + } + } + if (sql_type & SPIDER_SQL_TYPE_HANDLER) + { + if (spider->m_handler_id[link_idx] == ha_sql_handler_id) + exec_ha_sql = &ha_sql; + else { + exec_ha_sql = &result_list->sqls[link_idx]; + if (exec_ha_sql->copy(ha_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + else { + tmp_pos = exec_ha_sql->length(); + exec_ha_sql->length(ha_table_name_pos); + append_table_name_with_adjusting(exec_ha_sql, link_idx, + SPIDER_SQL_TYPE_HANDLER); + exec_ha_sql->length(tmp_pos); + } + } + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::set_sql_for_exec( + spider_db_copy_table *tgt_ct, + ulong sql_type +) { + spider_mysql_copy_table *mysql_ct = (spider_mysql_copy_table *) tgt_ct; + DBUG_ENTER("spider_mysql_handler::set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + exec_insert_sql = &mysql_ct->sql; + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::execute_sql( + ulong sql_type, + SPIDER_CONN *conn, + int quick_mode, + int *need_mon +) { + spider_string *tgt_sql; + uint tgt_length; + DBUG_ENTER("spider_mysql_handler::execute_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_SELECT_SQL")); + tgt_sql = exec_sql; + tgt_length = tgt_sql->length(); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_SELECT_SQL")); + tgt_sql = exec_insert_sql; + tgt_length = tgt_sql->length(); + break; + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + DBUG_PRINT("info",("spider %s", + sql_type == SPIDER_SQL_TYPE_UPDATE_SQL ? "SPIDER_SQL_TYPE_UPDATE_SQL" : + sql_type == SPIDER_SQL_TYPE_DELETE_SQL ? "SPIDER_SQL_TYPE_DELETE_SQL" : + "SPIDER_SQL_TYPE_BULK_UPDATE_SQL" + )); + tgt_sql = exec_update_sql; + tgt_length = tgt_sql->length(); + break; + case SPIDER_SQL_TYPE_TMP_SQL: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_TMP_SQL")); + tgt_sql = exec_tmp_sql; + tgt_length = tgt_sql->length(); + break; + case SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL")); + tgt_sql = exec_tmp_sql; + tgt_length = tmp_sql_pos5; + break; + case SPIDER_SQL_TYPE_HANDLER: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_HANDLER")); + tgt_sql = exec_ha_sql; + tgt_length = tgt_sql->length(); + break; + default: + /* nothing to do */ + DBUG_PRINT("info",("spider default")); + DBUG_RETURN(0); + } + DBUG_RETURN(spider_db_query( + conn, + tgt_sql->ptr(), + tgt_length, + quick_mode, + need_mon + )); +} + +int spider_mysql_handler::reset() +{ + DBUG_ENTER("spider_mysql_handler::reset"); + DBUG_PRINT("info",("spider this=%p", this)); + update_sql.length(0); + DBUG_RETURN(0); +} + +int spider_mysql_handler::sts_mode_exchange( + int sts_mode +) { + DBUG_ENTER("spider_mysql_handler::sts_mode_exchange"); + DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); + DBUG_RETURN(sts_mode); +} + +int spider_mysql_handler::show_table_status( + int link_idx, + int sts_mode, + uint flag +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_DB_RESULT *res; + SPIDER_SHARE *share = spider->share; + uint pos = (2 * spider->conn_link_idx[link_idx]); + DBUG_ENTER("spider_mysql_handler::show_table_status"); + DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); + if (sts_mode == 1) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + mysql_share->show_table_status[0 + pos].ptr(), + mysql_share->show_table_status[0 + pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + mysql_share->show_table_status[0 + pos].ptr(), + mysql_share->show_table_status[0 + pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (error_num || (error_num = spider_db_errorno(conn))) + DBUG_RETURN(error_num); + else { + my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, + ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_status( + sts_mode, + share->records, + share->mean_rec_length, + share->data_file_length, + share->max_data_file_length, + share->index_file_length, + share->auto_increment_value, + share->create_time, + share->update_time, + share->check_time + ); + res->free_result(); + delete res; + if (error_num) + { + switch (error_num) + { + case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM: + my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, + ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + break; + case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM: + my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM, + ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + break; + default: + break; + } + DBUG_RETURN(error_num); + } + } else { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + mysql_share->show_table_status[1 + pos].ptr(), + mysql_share->show_table_status[1 + pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + mysql_share->show_table_status[1 + pos].ptr(), + mysql_share->show_table_status[1 + pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (error_num || (error_num = spider_db_errorno(conn))) + DBUG_RETURN(error_num); + else + DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_status( + sts_mode, + share->records, + share->mean_rec_length, + share->data_file_length, + share->max_data_file_length, + share->index_file_length, + share->auto_increment_value, + share->create_time, + share->update_time, + share->check_time + ); + res->free_result(); + delete res; + if (error_num) + { + switch (error_num) + { + case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM: + my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, + ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + break; + case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM: + my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM, + ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + break; + default: + break; + } + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::crd_mode_exchange( + int crd_mode +) { + DBUG_ENTER("spider_mysql_handler::crd_mode_exchange"); + DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); + DBUG_RETURN(crd_mode); +} + +int spider_mysql_handler::show_index( + int link_idx, + int crd_mode +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + SPIDER_DB_RESULT *res; + int roop_count; + longlong *tmp_cardinality; + uint pos = (2 * spider->conn_link_idx[link_idx]); + DBUG_ENTER("spider_mysql_handler::show_index"); + DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); + if (crd_mode == 1) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + mysql_share->show_index[0 + pos].ptr(), + mysql_share->show_index[0 + pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + mysql_share->show_index[0 + pos].ptr(), + mysql_share->show_index[0 + pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + /* no record is ok */ + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if (res) + { + error_num = res->fetch_table_cardinality( + crd_mode, + table, + share->cardinality, + share->cardinality_upd, + share->bitmap_size + ); + } + for (roop_count = 0, tmp_cardinality = share->cardinality; + roop_count < (int) table->s->fields; + roop_count++, tmp_cardinality++) + { + if (!spider_bit_is_set(share->cardinality_upd, roop_count)) + { + DBUG_PRINT("info", + ("spider init column cardinality id=%d", roop_count)); + *tmp_cardinality = 1; + } + } + if (res) + { + res->free_result(); + delete res; + } + if (error_num) + { + switch (error_num) + { + case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM: + my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, + ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + break; + case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM: + my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM, + ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + break; + default: + break; + } + DBUG_RETURN(error_num); + } + } else { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + mysql_share->show_index[1 + pos].ptr(), + mysql_share->show_index[1 + pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + mysql_share->show_index[1 + pos].ptr(), + mysql_share->show_index[1 + pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + /* no record is ok */ + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if (res) + { + error_num = res->fetch_table_cardinality( + crd_mode, + table, + share->cardinality, + share->cardinality_upd, + share->bitmap_size + ); + } + for (roop_count = 0, tmp_cardinality = share->cardinality; + roop_count < (int) table->s->fields; + roop_count++, tmp_cardinality++) + { + if (!spider_bit_is_set(share->cardinality_upd, roop_count)) + { + DBUG_PRINT("info", + ("spider init column cardinality id=%d", roop_count)); + *tmp_cardinality = 1; + } + } + if (res) + { + res->free_result(); + delete res; + } + if (error_num) + { + switch (error_num) + { + case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM: + my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, + ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + break; + case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM: + my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM, + ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0), + mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + mysql_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + break; + default: + break; + } + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::show_records( + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_DB_RESULT *res; + SPIDER_SHARE *share = spider->share; + uint pos = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_mysql_handler::show_records"); + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + mysql_share->show_records[pos].ptr(), + mysql_share->show_records[pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + mysql_share->show_records[pos].ptr(), + mysql_share->show_records[pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_PRINT("info", ("spider error_num=%d 3", error_num)); + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (error_num || (error_num = spider_db_errorno(conn))) + { + DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); + DBUG_RETURN(error_num); + } else { + DBUG_PRINT("info", ("spider error_num=%d 6", + ER_QUERY_ON_FOREIGN_DATA_SOURCE)); + DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_records( + 1, + share->records + ); + res->free_result(); + delete res; + if (error_num) + { + DBUG_PRINT("info", ("spider error_num=%d 7", error_num)); + DBUG_RETURN(error_num); + } + spider->trx->direct_aggregate_count++; + DBUG_RETURN(0); +} + +int spider_mysql_handler::show_last_insert_id( + int link_idx, + ulonglong &last_insert_id +) { + SPIDER_CONN *conn = spider->conns[link_idx]; + DBUG_ENTER("spider_mysql_handler::show_last_insert_id"); + last_insert_id = conn->db_conn->last_insert_id(); + DBUG_RETURN(0); +} + +ha_rows spider_mysql_handler::explain_select( + key_range *start_key, + key_range *end_key, + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + spider_string *str = &result_list->sqls[link_idx]; + SPIDER_DB_RESULT *res; + ha_rows rows; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + DBUG_ENTER("spider_mysql_handler::explain_select"); + if ((error_num = dbton_hdl->append_explain_select_part( + start_key, end_key, SPIDER_SQL_TYPE_OTHER_SQL, link_idx))) + { + my_errno = error_num; + DBUG_RETURN(HA_POS_ERROR); + } + + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(spider->share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider->share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider->share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + } else { + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } else { + my_errno = ER_QUERY_ON_FOREIGN_DATA_SOURCE; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_records( + 2, + rows + ); + res->free_result(); + delete res; + if (error_num) + { + my_errno = error_num; + DBUG_RETURN(HA_POS_ERROR); + } + DBUG_RETURN(rows); +} + +int spider_mysql_handler::lock_tables( + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + spider_string *str = &sql; + DBUG_ENTER("spider_mysql_handler::lock_tables"); + str->length(0); + if ((error_num = conn->db_conn->append_lock_tables(str))) + { + DBUG_RETURN(error_num); + } + if (str->length()) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider->share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + if (!conn->table_locked) + { + conn->table_locked = TRUE; + spider->trx->locked_connections++; + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::unlock_tables( + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + DBUG_ENTER("spider_mysql_handler::unlock_tables"); + if (conn->table_locked) + { + spider_string *str = &sql; + conn->table_locked = FALSE; + spider->trx->locked_connections--; + + str->length(0); + if ((error_num = conn->db_conn->append_unlock_tables(str))) + { + DBUG_RETURN(error_num); + } + if (str->length()) + { + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider->share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::disable_keys( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::disable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_disable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_mysql_handler::enable_keys( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::enable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_enable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_mysql_handler::check_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::check_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_check_table_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx, check_opt))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_mysql_handler::repair_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::repair_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_repair_table_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx, check_opt))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_mysql_handler::analyze_table( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::analyze_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_analyze_table_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_mysql_handler::optimize_table( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::optimize_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_optimize_table_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_mysql_handler::flush_tables( + SPIDER_CONN *conn, + int link_idx, + bool lock +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_mysql_handler::flush_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_flush_tables_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx, lock))) + { + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_mysql_handler::flush_logs( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_mysql_handler::flush_logs"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + SPIDER_SQL_FLUSH_LOGS_STR, + SPIDER_SQL_FLUSH_LOGS_LEN, + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_mysql_handler::insert_opened_handler( + SPIDER_CONN *conn, + int link_idx +) { + spider_db_mysql *db_conn = (spider_db_mysql *) conn->db_conn; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash = &link_for_hash[link_idx]; + DBUG_ASSERT(tmp_link_for_hash->spider == spider); + DBUG_ASSERT(tmp_link_for_hash->link_idx == link_idx); + uint old_elements = db_conn->handler_open_array.max_element; + DBUG_ENTER("spider_mysql_handler::insert_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if (insert_dynamic(&db_conn->handler_open_array, + (uchar*) &tmp_link_for_hash)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (db_conn->handler_open_array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + db_conn->handler_open_array, + (db_conn->handler_open_array.max_element - old_elements) * + db_conn->handler_open_array.size_of_element); + } + DBUG_RETURN(0); +} + +int spider_mysql_handler::delete_opened_handler( + SPIDER_CONN *conn, + int link_idx +) { + spider_db_mysql *db_conn = (spider_db_mysql *) conn->db_conn; + uint roop_count, elements = db_conn->handler_open_array.elements; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash; + DBUG_ENTER("spider_mysql_handler::delete_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + for (roop_count = 0; roop_count < elements; roop_count++) + { + get_dynamic(&db_conn->handler_open_array, (uchar *) &tmp_link_for_hash, + roop_count); + if (tmp_link_for_hash == &link_for_hash[link_idx]) + { + delete_dynamic_element(&db_conn->handler_open_array, roop_count); + break; + } + } + DBUG_ASSERT(roop_count < elements); + DBUG_RETURN(0); +} + +int spider_mysql_handler::sync_from_clone_source( + spider_db_handler *dbton_hdl +) { + DBUG_ENTER("spider_mysql_handler::sync_from_clone_source"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +bool spider_mysql_handler::support_use_handler( + int use_handler +) { + DBUG_ENTER("spider_mysql_handler::support_use_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +spider_mysql_copy_table::spider_mysql_copy_table( + spider_mysql_share *db_share +) : spider_db_copy_table( + db_share +), + mysql_share(db_share) +{ + DBUG_ENTER("spider_mysql_copy_table::spider_mysql_copy_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_mysql_copy_table::~spider_mysql_copy_table() +{ + DBUG_ENTER("spider_mysql_copy_table::~spider_mysql_copy_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_mysql_copy_table::init() +{ + DBUG_ENTER("spider_mysql_copy_table::init"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.init_calc_mem(78); + DBUG_RETURN(0); +} + +void spider_mysql_copy_table::set_sql_charset( + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_mysql_copy_table::set_sql_charset"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.set_charset(cs); + DBUG_VOID_RETURN; +} + +int spider_mysql_copy_table::append_select_str() +{ + DBUG_ENTER("spider_mysql_copy_table::append_select_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_SELECT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_insert_str( + int insert_flg +) { + DBUG_ENTER("spider_mysql_copy_table::append_insert_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (insert_flg & SPIDER_DB_INSERT_REPLACE) + { + if (sql.reserve(SPIDER_SQL_REPLACE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_REPLACE_STR, SPIDER_SQL_REPLACE_LEN); + } else { + if (sql.reserve(SPIDER_SQL_INSERT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); + } + if (insert_flg & SPIDER_DB_INSERT_LOW_PRIORITY) + { + if (sql.reserve(SPIDER_SQL_LOW_PRIORITY_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN); + } + else if (insert_flg & SPIDER_DB_INSERT_DELAYED) + { + if (sql.reserve(SPIDER_SQL_SQL_DELAYED_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_SQL_DELAYED_STR, SPIDER_SQL_SQL_DELAYED_LEN); + } + else if (insert_flg & SPIDER_DB_INSERT_HIGH_PRIORITY) + { + if (sql.reserve(SPIDER_SQL_HIGH_PRIORITY_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_HIGH_PRIORITY_STR, SPIDER_SQL_HIGH_PRIORITY_LEN); + } + if (insert_flg & SPIDER_DB_INSERT_IGNORE) + { + if (sql.reserve(SPIDER_SQL_SQL_IGNORE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_SQL_IGNORE_STR, SPIDER_SQL_SQL_IGNORE_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_table_columns( + TABLE_SHARE *table_share +) { + int error_num; + Field **field; + DBUG_ENTER("spider_mysql_copy_table::append_table_columns"); + DBUG_PRINT("info",("spider this=%p", this)); + for (field = table_share->field; *field; field++) + { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql, + (char *) (*field)->field_name, spider_dbton_mysql.dbton_id))) + DBUG_RETURN(error_num); + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + sql.length(sql.length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_from_str() +{ + DBUG_ENTER("spider_mysql_copy_table::append_from_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_table_name( + int link_idx +) { + int error_num; + DBUG_ENTER("spider_mysql_copy_table::append_table_name"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = mysql_share->append_table_name(&sql, link_idx); + DBUG_RETURN(error_num); +} + +void spider_mysql_copy_table::set_sql_pos() +{ + DBUG_ENTER("spider_mysql_copy_table::set_sql_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + pos = sql.length(); + DBUG_VOID_RETURN; +} + +void spider_mysql_copy_table::set_sql_to_pos() +{ + DBUG_ENTER("spider_mysql_copy_table::set_sql_to_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.length(pos); + DBUG_VOID_RETURN; +} + +int spider_mysql_copy_table::append_copy_where( + spider_db_copy_table *source_ct, + KEY *key_info, + ulong *last_row_pos, + ulong *last_lengths +) { + int error_num, roop_count, roop_count2; + DBUG_ENTER("spider_mysql_copy_table::append_copy_where"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_WHERE_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + Field *field; + KEY_PART_INFO *key_part = key_info->key_part; + for (roop_count = key_info->key_parts - 1; roop_count >= 0; roop_count--) + { + for (roop_count2 = 0; roop_count2 < roop_count; roop_count2++) + { + field = key_part[roop_count2].field; + if ((error_num = copy_key_row(source_ct, + field, &last_row_pos[field->field_index], + &last_lengths[field->field_index], + SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN))) + { + DBUG_RETURN(error_num); + } + } + field = key_part[roop_count2].field; + if ((error_num = copy_key_row(source_ct, + field, &last_row_pos[field->field_index], + &last_lengths[field->field_index], + SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN))) + { + DBUG_RETURN(error_num); + } + sql.length(sql.length() - SPIDER_SQL_AND_LEN); + if (sql.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + + SPIDER_SQL_OR_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + sql.q_append(SPIDER_SQL_OR_STR, SPIDER_SQL_OR_LEN); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + sql.length(sql.length() - SPIDER_SQL_OR_LEN - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_key_order_str( + KEY *key_info, + int start_pos, + bool desc_flg +) { + int length, error_num; + KEY_PART_INFO *key_part; + Field *field; + DBUG_ENTER("spider_mysql_copy_table::append_key_order_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((int) key_info->key_parts > start_pos) + { + if (sql.reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + if (desc_flg == TRUE) + { + for ( + key_part = key_info->key_part + start_pos, + length = 0; + length + start_pos < (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql, + (char *) field->field_name, spider_dbton_mysql.dbton_id))) + DBUG_RETURN(error_num); + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_DESC_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } else { + for ( + key_part = key_info->key_part + start_pos, + length = 0; + length + start_pos < (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql, + (char *) field->field_name, spider_dbton_mysql.dbton_id))) + DBUG_RETURN(error_num); + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_DESC_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } + sql.length(sql.length() - SPIDER_SQL_COMMA_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_limit( + longlong offset, + longlong limit +) { + char buf[SPIDER_LONGLONG_LEN + 1]; + uint32 length; + DBUG_ENTER("spider_mysql_copy_table::append_limit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (offset || limit < 9223372036854775807LL) + { + if (sql.reserve(SPIDER_SQL_LIMIT_LEN + SPIDER_SQL_COMMA_LEN + + ((SPIDER_LONGLONG_LEN) * 2))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_LIMIT_STR, SPIDER_SQL_LIMIT_LEN); + if (offset) + { + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, offset); + sql.q_append(buf, length); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + sql.q_append(buf, length); + } + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_into_str() +{ + DBUG_ENTER("spider_mysql_copy_table::append_into_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_INTO_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_INTO_STR, SPIDER_SQL_INTO_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_open_paren_str() +{ + DBUG_ENTER("spider_mysql_copy_table::append_open_paren_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_values_str() +{ + DBUG_ENTER("spider_mysql_copy_table::append_values_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_select_lock_str( + int lock_mode +) { + DBUG_ENTER("spider_mysql_copy_table::append_select_lock_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (lock_mode == SPIDER_LOCK_MODE_EXCLUSIVE) + { + if (sql.reserve(SPIDER_SQL_FOR_UPDATE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_FOR_UPDATE_STR, SPIDER_SQL_FOR_UPDATE_LEN); + } else if (lock_mode == SPIDER_LOCK_MODE_SHARED) + { + if (sql.reserve(SPIDER_SQL_SHARED_LOCK_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_SHARED_LOCK_STR, SPIDER_SQL_SHARED_LOCK_LEN); + } + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::exec_query( + SPIDER_CONN *conn, + int quick_mode, + int *need_mon +) { + int error_num; + DBUG_ENTER("spider_mysql_copy_table::exec_query"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = spider_db_query(conn, sql.ptr(), sql.length(), quick_mode, + need_mon); + DBUG_RETURN(error_num); +} + +int spider_mysql_copy_table::copy_key_row( + spider_db_copy_table *source_ct, + Field *field, + ulong *row_pos, + ulong *length, + const char *joint_str, + const int joint_length +) { + int error_num; + spider_string *source_str = &((spider_mysql_copy_table *) source_ct)->sql; + DBUG_ENTER("spider_mysql_copy_table::copy_key_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql, + (char *) field->field_name, spider_dbton_mysql.dbton_id))) + DBUG_RETURN(error_num); + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + joint_length + *length + + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(joint_str, joint_length); + sql.q_append(source_str->ptr() + *row_pos, *length); + sql.q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::copy_row( + Field *field, + SPIDER_DB_ROW *row +) { + int error_num; + DBUG_ENTER("spider_mysql_copy_table::copy_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (row->is_null()) + { + if (sql.reserve(SPIDER_SQL_NULL_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else if (field->str_needs_quotes()) + { + if (sql.reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if ((error_num = row->append_escaped_to_str(&sql, + spider_dbton_mysql.dbton_id))) + DBUG_RETURN(error_num); + if (sql.reserve(SPIDER_SQL_VALUE_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } else { + if ((error_num = row->append_to_str(&sql))) + DBUG_RETURN(error_num); + if (sql.reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::copy_rows( + TABLE *table, + SPIDER_DB_ROW *row, + ulong **last_row_pos, + ulong **last_lengths +) { + int error_num; + Field **field; + ulong *lengths2, *row_pos2; + DBUG_ENTER("spider_mysql_copy_table::copy_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + row_pos2 = *last_row_pos; + lengths2 = *last_lengths; + + for ( + field = table->field; + *field; + field++, + lengths2++ + ) { + *row_pos2 = sql.length(); + if ((error_num = + copy_row(*field, row))) + DBUG_RETURN(error_num); + *lengths2 = sql.length() - *row_pos2 - SPIDER_SQL_COMMA_LEN; + row->next(); + row_pos2++; + } + sql.length(sql.length() - SPIDER_SQL_COMMA_LEN); + if (sql.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + + SPIDER_SQL_COMMA_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::copy_rows( + TABLE *table, + SPIDER_DB_ROW *row +) { + int error_num; + Field **field; + DBUG_ENTER("spider_mysql_copy_table::copy_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + for ( + field = table->field; + *field; + field++ + ) { + if ((error_num = + copy_row(*field, row))) + DBUG_RETURN(error_num); + row->next(); + } + sql.length(sql.length() - SPIDER_SQL_COMMA_LEN); + if (sql.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + + SPIDER_SQL_COMMA_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::append_insert_terminator() +{ + DBUG_ENTER("spider_mysql_copy_table::append_insert_terminator"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.length(sql.length() - SPIDER_SQL_COMMA_LEN - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_mysql_copy_table::copy_insert_values( + spider_db_copy_table *source_ct +) { + spider_mysql_copy_table *tmp_ct = (spider_mysql_copy_table *) source_ct; + spider_string *source_str = &tmp_ct->sql; + int values_length = source_str->length() - tmp_ct->pos; + const char *values_ptr = source_str->ptr() + tmp_ct->pos; + DBUG_ENTER("spider_mysql_copy_table::copy_insert_values"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(values_length)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(values_ptr, values_length); + DBUG_RETURN(0); +} diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h new file mode 100644 index 00000000000..761537ba0a0 --- /dev/null +++ b/storage/spider/spd_db_mysql.h @@ -0,0 +1,1295 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +class spider_db_mysql_util: public spider_db_util +{ +public: + spider_db_mysql_util(); + ~spider_db_mysql_util(); + int append_name( + spider_string *str, + const char *name, + uint name_length + ); + int append_name_with_charset( + spider_string *str, + const char *name, + uint name_length, + CHARSET_INFO *name_charset + ); + bool is_name_quote( + const char head_code + ); + int append_escaped_name_quote( + spider_string *str + ); + int append_column_value( + ha_spider *spider, + spider_string *str, + Field *field, + const uchar *new_ptr, + CHARSET_INFO *access_charset + ); + int append_from_with_alias( + spider_string *str, + const char **table_names, + uint *table_name_lengths, + const char **table_aliases, + uint *table_alias_lengths, + uint table_count, + int *table_name_pos, + bool over_write + ); + int append_trx_isolation( + spider_string *str, + int trx_isolation + ); + int append_autocommit( + spider_string *str, + bool autocommit + ); + int append_sql_log_off( + spider_string *str, + bool sql_log_off + ); + int append_time_zone( + spider_string *str, + Time_zone *time_zone + ); + int append_start_transaction( + spider_string *str + ); + int append_xa_start( + spider_string *str, + XID *xid + ); + int append_lock_table_head( + spider_string *str + ); + int append_lock_table_body( + spider_string *str, + const char *db_name, + uint db_name_length, + CHARSET_INFO *db_name_charset, + const char *table_name, + uint table_name_length, + CHARSET_INFO *table_name_charset, + int lock_type + ); + int append_lock_table_tail( + spider_string *str + ); + int append_unlock_table( + spider_string *str + ); + int open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length + ); + int append_escaped_util( + spider_string *to, + String *from + ); +}; + +class spider_db_mysql_row: public spider_db_row +{ +public: + MYSQL_ROW row; + MYSQL_ROW row_first; + ulong *lengths; + ulong *lengths_first; + uint field_count; + bool cloned; + spider_db_mysql_row(); + ~spider_db_mysql_row(); + int store_to_field( + Field *field, + CHARSET_INFO *access_charset + ); + int append_to_str( + spider_string *str + ); + int append_escaped_to_str( + spider_string *str, + uint dbton_id + ); + void first(); + void next(); + bool is_null(); + int val_int(); + double val_real(); + SPIDER_DB_ROW *clone(); + int store_to_tmp_table( + TABLE *tmp_table, + spider_string *str + ); +}; + +class spider_db_mysql_result: public spider_db_result +{ +public: + MYSQL_RES *db_result; + spider_db_mysql_row row; + MYSQL_ROW_OFFSET first_row; + int store_error_num; + spider_db_mysql_result(); + ~spider_db_mysql_result(); + bool has_result(); + void free_result(); + SPIDER_DB_ROW *current_row(); + SPIDER_DB_ROW *fetch_row(); + SPIDER_DB_ROW *fetch_row_from_result_buffer( + spider_db_result_buffer *spider_res_buf + ); + SPIDER_DB_ROW *fetch_row_from_tmp_table( + TABLE *tmp_table + ); + int fetch_table_status( + int mode, + ha_rows &records, + ulong &mean_rec_length, + ulonglong &data_file_length, + ulonglong &max_data_file_length, + ulonglong &index_file_length, + ulonglong &auto_increment_value, + time_t &create_time, + time_t &update_time, + time_t &check_time + ); + int fetch_table_records( + int mode, + ha_rows &records + ); + int fetch_table_cardinality( + int mode, + TABLE *table, + longlong *cardinality, + uchar *cardinality_upd, + int bitmap_size + ); + int fetch_table_mon_status( + int &status + ); + longlong num_rows(); + uint num_fields(); + void move_to_pos( + longlong pos + ); + int get_errno(); +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + int fetch_columns_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset + ); + int fetch_index_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset + ); +#endif +}; + +class spider_db_mysql: public spider_db_conn +{ + MYSQL *db_conn; + int stored_error; +public: + HASH lock_table_hash; + bool lock_table_hash_inited; + uint lock_table_hash_id; + const char *lock_table_hash_func_name; + const char *lock_table_hash_file_name; + ulong lock_table_hash_line_no; + DYNAMIC_ARRAY handler_open_array; + bool handler_open_array_inited; + uint handler_open_array_id; + const char *handler_open_array_func_name; + const char *handler_open_array_file_name; + ulong handler_open_array_line_no; + spider_db_mysql( + SPIDER_CONN *conn + ); + ~spider_db_mysql(); + int init(); + bool is_connected(); + void bg_connect(); + int connect( + char *tgt_host, + char *tgt_username, + char *tgt_password, + long tgt_port, + char *tgt_socket, + char *server_name, + int connect_retry_count, + longlong connect_retry_interval + ); + int ping(); + void bg_disconnect(); + void disconnect(); + int set_net_timeout(); + int exec_query( + const char *query, + uint length, + int quick_mode + ); + int get_errno(); + const char *get_error(); + bool is_server_gone_error( + int error_num + ); + bool is_dup_entry_error( + int error_num + ); + bool is_xa_nota_error( + int error_num + ); + spider_db_result *store_result( + spider_db_result_buffer **spider_res_buf, + st_spider_db_request_key *request_key, + int *error_num + ); + spider_db_result *use_result( + st_spider_db_request_key *request_key, + int *error_num + ); + int next_result(); + uint affected_rows(); + ulonglong last_insert_id(); + int set_character_set( + const char *csname + ); + int select_db( + const char *dbname + ); + int consistent_snapshot( + int *need_mon + ); + bool trx_start_in_bulk_sql(); + int start_transaction( + int *need_mon + ); + int commit( + int *need_mon + ); + int rollback( + int *need_mon + ); + bool xa_start_in_bulk_sql(); + int xa_start( + XID *xid, + int *need_mon + ); + int xa_end( + XID *xid, + int *need_mon + ); + int xa_prepare( + XID *xid, + int *need_mon + ); + int xa_commit( + XID *xid, + int *need_mon + ); + int xa_rollback( + XID *xid, + int *need_mon + ); + bool set_trx_isolation_in_bulk_sql(); + int set_trx_isolation( + int trx_isolation, + int *need_mon + ); + bool set_autocommit_in_bulk_sql(); + int set_autocommit( + bool autocommit, + int *need_mon + ); + bool set_sql_log_off_in_bulk_sql(); + int set_sql_log_off( + bool sql_log_off, + int *need_mon + ); + bool set_time_zone_in_bulk_sql(); + int set_time_zone( + Time_zone *time_zone, + int *need_mon + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int append_sql( + char *sql, + ulong sql_length, + st_spider_db_request_key *request_key + ); + int append_open_handler( + uint handler_id, + const char *db_name, + const char *table_name, + const char *index_name, + const char *sql, + st_spider_db_request_key *request_key + ); + int append_select( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key + ); + int append_insert( + uint handler_id, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + st_spider_db_request_key *request_key + ); + int append_update( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + int limit, + int skip, + bool increment, + bool decrement, + st_spider_db_request_key *request_key + ); + int append_delete( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key + ); + void reset_request_queue(); +#endif + size_t escape_string( + char *to, + const char *from, + size_t from_length + ); + bool have_lock_table_list(); + int append_lock_tables( + spider_string *str + ); + int append_unlock_tables( + spider_string *str + ); + uint get_lock_table_hash_count(); + void reset_lock_table_hash(); + uint get_opened_handler_count(); + void reset_opened_handler(); + void set_dup_key_idx( + ha_spider *spider, + int link_idx + ); + bool cmp_request_key_to_snd( + st_spider_db_request_key *request_key + ); +}; + +class spider_mysql_share: public spider_db_share +{ +public: + spider_string *table_select; + int table_select_pos; + spider_string *key_select; + int *key_select_pos; + spider_string *key_hint; + spider_string *show_table_status; + spider_string *show_records; + spider_string *show_index; + spider_string *table_names_str; + spider_string *db_names_str; + spider_string *db_table_str; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type *db_table_str_hash_value; +#endif + uint table_nm_max_length; + uint db_nm_max_length; + spider_string *column_name_str; + bool same_db_table_name; + int first_all_link_idx; + + spider_mysql_share( + st_spider_share *share + ); + ~spider_mysql_share(); + int init(); + uint get_column_name_length( + uint field_index + ); + int append_column_name( + spider_string *str, + uint field_index + ); + int append_column_name_with_alias( + spider_string *str, + uint field_index, + const char *alias, + uint alias_length + ); + int append_table_name( + spider_string *str, + int all_link_idx + ); + int append_table_name_with_adjusting( + spider_string *str, + int all_link_idx + ); + int append_from_with_adjusted_table_name( + spider_string *str, + int *table_name_pos + ); + bool need_change_db_table_name(); +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + int discover_table_structure( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str + ); +#endif +private: + int create_table_names_str(); + void free_table_names_str(); + int create_column_name_str(); + void free_column_name_str(); + int convert_key_hint_str(); + int append_show_table_status(); + void free_show_table_status(); + int append_show_records(); + void free_show_records(); + int append_show_index(); + void free_show_index(); + int append_table_select(); + int append_key_select( + uint idx + ); +}; + +class spider_mysql_handler: public spider_db_handler +{ + spider_string sql; + spider_string sql_part; + spider_string sql_part2; + spider_string ha_sql; + int where_pos; + int order_pos; + int limit_pos; + int table_name_pos; + int ha_read_pos; + int ha_next_pos; + int ha_where_pos; + int ha_limit_pos; + int ha_table_name_pos; + uint ha_sql_handler_id; + spider_string insert_sql; + int insert_pos; + int insert_table_name_pos; + spider_string update_sql; + TABLE *upd_tmp_tbl; + TMP_TABLE_PARAM upd_tmp_tbl_prm; + spider_string tmp_sql; + int tmp_sql_pos1; /* drop db nm pos at tmp_table_join */ + int tmp_sql_pos2; /* create db nm pos at tmp_table_join */ + int tmp_sql_pos3; /* insert db nm pos at tmp_table_join */ + int tmp_sql_pos4; /* insert val pos at tmp_table_join */ + int tmp_sql_pos5; /* end of drop tbl at tmp_table_join */ + spider_string dup_update_sql; + spider_string *exec_sql; + spider_string *exec_insert_sql; + spider_string *exec_update_sql; + spider_string *exec_tmp_sql; + spider_string *exec_ha_sql; + bool reading_from_bulk_tmp_table; + bool filled_up; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; +#endif +public: + spider_mysql_share *mysql_share; + SPIDER_LINK_FOR_HASH *link_for_hash; + spider_mysql_handler( + ha_spider *spider, + spider_mysql_share *share + ); + ~spider_mysql_handler(); + int init(); + int append_table_name_with_adjusting( + spider_string *str, + int link_idx, + ulong sql_type + ); + int append_key_column_types( + const key_range *start_key, + spider_string *str + ); + int append_key_join_columns_for_bka( + const key_range *start_key, + spider_string *str, + const char **table_aliases, + uint *table_alias_lengths + ); + int append_tmp_table_and_sql_for_bka( + const key_range *start_key + ); + int reuse_tmp_table_and_sql_for_bka(); + void create_tmp_bka_table_name( + char *tmp_table_name, + int *tmp_table_name_length, + int link_idx + ); + int append_create_tmp_bka_table( + const key_range *start_key, + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos, + CHARSET_INFO *table_charset + ); + int append_drop_tmp_bka_table( + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos, + int *drop_table_end_pos, + bool with_semicolon + ); + int append_insert_tmp_bka_table( + const key_range *start_key, + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos + ); + int append_insert_for_recovery( + ulong sql_type, + int link_idx + ); + int append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff + ); + int append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx + ); + int append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff + ); + int append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx + ); + int append_insert_part(); + int append_insert( + spider_string *str, + int link_idx + ); + int append_update_part(); + int append_update( + spider_string *str, + int link_idx + ); + int append_delete_part(); + int append_delete( + spider_string *str + ); + #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_increment_update_set_part(); + int append_increment_update_set( + spider_string *str + ); + #endif + #endif + int append_update_set_part(); + int append_update_set( + spider_string *str + ); + #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_direct_update_set_part(); + int append_direct_update_set( + spider_string *str + ); + int append_dup_update_pushdown_part( + const char *alias, + uint alias_length + ); + int append_update_columns_part( + const char *alias, + uint alias_length + ); + int check_update_columns_part(); + int append_update_columns( + spider_string *str, + const char *alias, + uint alias_length + ); + #endif + int append_select_part( + ulong sql_type + ); + int append_select( + spider_string *str, + ulong sql_type + ); + int append_table_select_part( + ulong sql_type + ); + int append_table_select( + spider_string *str + ); + int append_key_select_part( + ulong sql_type, + uint idx + ); + int append_key_select( + spider_string *str, + uint idx + ); + int append_minimum_select_part( + ulong sql_type + ); + int append_minimum_select( + spider_string *str, + ulong sql_type + ); + int append_table_select_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_key_select_with_alias( + spider_string *str, + const KEY *key_info, + const char *alias, + uint alias_length + ); + int append_minimum_select_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_select_columns_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_hint_after_table_part( + ulong sql_type + ); + int append_hint_after_table( + spider_string *str + ); + void set_where_pos( + ulong sql_type + ); + void set_where_to_pos( + ulong sql_type + ); + int check_item_type( + Item *item + ); + int append_values_connector_part( + ulong sql_type + ); + int append_values_connector( + spider_string *str + ); + int append_values_terminator_part( + ulong sql_type + ); + int append_values_terminator( + spider_string *str + ); + int append_key_column_values_part( + const key_range *start_key, + ulong sql_type + ); + int append_key_column_values( + spider_string *str, + const key_range *start_key + ); + int append_key_where_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type + ); + int append_key_where( + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + const key_range *start_key, + const key_range *end_key, + ulong sql_type, + bool set_order + ); + int append_is_null_part( + ulong sql_type, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq + ); + int append_is_null( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq + ); + int append_where_terminator_part( + ulong sql_type, + bool set_order, + int key_count + ); + int append_where_terminator( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + bool set_order, + int key_count + ); + int append_match_where_part( + ulong sql_type + ); + int append_match_where( + spider_string *str + ); + int append_update_where( + spider_string *str, + const TABLE *table, + my_ptrdiff_t ptr_diff + ); + int append_condition_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg + ); + int append_condition( + spider_string *str, + const char *alias, + uint alias_length, + bool start_where, + ulong sql_type + ); + int append_match_against_part( + ulong sql_type, + st_spider_ft_info *ft_info, + const char *alias, + uint alias_length + ); + int append_match_against( + spider_string *str, + st_spider_ft_info *ft_info, + const char *alias, + uint alias_length + ); + int append_match_select_part( + ulong sql_type, + const char *alias, + uint alias_length + ); + int append_match_select( + spider_string *str, + const char *alias, + uint alias_length + ); + void set_order_pos( + ulong sql_type + ); + void set_order_to_pos( + ulong sql_type + ); + int append_key_order_for_merge_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_for_merge_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_key_order_for_direct_order_limit_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_for_direct_order_limit_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_key_order_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_for_handler( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_key_order_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_limit_part( + longlong offset, + longlong limit, + ulong sql_type + ); + int reappend_limit_part( + longlong offset, + longlong limit, + ulong sql_type + ); + int append_limit( + spider_string *str, + longlong offset, + longlong limit + ); + int append_select_lock_part( + ulong sql_type + ); + int append_select_lock( + spider_string *str + ); + int append_union_all_start_part( + ulong sql_type + ); + int append_union_all_start( + spider_string *str + ); + int append_union_all_part( + ulong sql_type + ); + int append_union_all( + spider_string *str + ); + int append_union_all_end_part( + ulong sql_type + ); + int append_union_all_end( + spider_string *str + ); + int append_multi_range_cnt_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma + ); + int append_multi_range_cnt( + spider_string *str, + uint multi_range_cnt, + bool with_comma + ); + int append_open_handler_part( + ulong sql_type, + uint handler_id, + SPIDER_CONN *conn, + int link_idx + ); + int append_open_handler( + spider_string *str, + uint handler_id, + SPIDER_CONN *conn, + int link_idx + ); + int append_close_handler_part( + ulong sql_type, + int link_idx + ); + int append_close_handler( + spider_string *str, + int link_idx + ); + int append_insert_terminator_part( + ulong sql_type + ); + int append_insert_terminator( + spider_string *str + ); + int append_insert_values_part( + ulong sql_type + ); + int append_insert_values( + spider_string *str + ); + int append_into_part( + ulong sql_type + ); + int append_into( + spider_string *str + ); + void set_insert_to_pos( + ulong sql_type + ); + int append_from_part( + ulong sql_type, + int link_idx + ); + int append_from( + spider_string *str, + ulong sql_type, + int link_idx + ); + int append_flush_tables_part( + ulong sql_type, + int link_idx, + bool lock + ); + int append_flush_tables( + spider_string *str, + int link_idx, + bool lock + ); + int append_optimize_table_part( + ulong sql_type, + int link_idx + ); + int append_optimize_table( + spider_string *str, + int link_idx + ); + int append_analyze_table_part( + ulong sql_type, + int link_idx + ); + int append_analyze_table( + spider_string *str, + int link_idx + ); + int append_repair_table_part( + ulong sql_type, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int append_repair_table( + spider_string *str, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int append_check_table_part( + ulong sql_type, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int append_check_table( + spider_string *str, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int append_enable_keys_part( + ulong sql_type, + int link_idx + ); + int append_enable_keys( + spider_string *str, + int link_idx + ); + int append_disable_keys_part( + ulong sql_type, + int link_idx + ); + int append_disable_keys( + spider_string *str, + int link_idx + ); + int append_delete_all_rows_part( + ulong sql_type + ); + int append_delete_all_rows( + spider_string *str, + ulong sql_type + ); + int append_truncate( + spider_string *str, + ulong sql_type, + int link_idx + ); + int append_explain_select_part( + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx + ); + int append_explain_select( + spider_string *str, + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx + ); + bool is_bulk_insert_exec_period( + bool bulk_end + ); + bool sql_is_filled_up( + ulong sql_type + ); + bool sql_is_empty( + ulong sql_type + ); + bool support_multi_split_read(); + bool support_bulk_update(); + int bulk_tmp_table_insert(); + int bulk_tmp_table_insert( + int link_idx + ); + int bulk_tmp_table_end_bulk_insert(); + int bulk_tmp_table_rnd_init(); + int bulk_tmp_table_rnd_next(); + int bulk_tmp_table_rnd_end(); + bool need_copy_for_update( + int link_idx + ); + bool bulk_tmp_table_created(); + int mk_bulk_tmp_table_and_bulk_start(); + void rm_bulk_tmp_table(); + int store_sql_to_bulk_tmp_table( + spider_string *str, + TABLE *tmp_table + ); + int restore_sql_from_bulk_tmp_table( + spider_string *str, + TABLE *tmp_table + ); + int insert_lock_tables_list( + SPIDER_CONN *conn, + int link_idx + ); + int append_lock_tables_list( + SPIDER_CONN *conn, + int link_idx, + int *appended + ); + int realloc_sql( + ulong *realloced + ); + int reset_sql( + ulong sql_type + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int reset_keys( + ulong sql_type + ); + int reset_upds( + ulong sql_type + ); + int reset_strs( + ulong sql_type + ); + int reset_strs_pos( + ulong sql_type + ); + int push_back_upds( + SPIDER_HS_STRING_REF &info + ); +#endif + bool need_lock_before_set_sql_for_exec( + ulong sql_type + ); + int set_sql_for_exec( + ulong sql_type, + int link_idx + ); + int set_sql_for_exec( + spider_db_copy_table *tgt_ct, + ulong sql_type + ); + int execute_sql( + ulong sql_type, + SPIDER_CONN *conn, + int quick_mode, + int *need_mon + ); + int reset(); + int sts_mode_exchange( + int sts_mode + ); + int show_table_status( + int link_idx, + int sts_mode, + uint flag + ); + int crd_mode_exchange( + int crd_mode + ); + int show_index( + int link_idx, + int crd_mode + ); + int show_records( + int link_idx + ); + int show_last_insert_id( + int link_idx, + ulonglong &last_insert_id + ); + ha_rows explain_select( + key_range *start_key, + key_range *end_key, + int link_idx + ); + int lock_tables( + int link_idx + ); + int unlock_tables( + int link_idx + ); + int disable_keys( + SPIDER_CONN *conn, + int link_idx + ); + int enable_keys( + SPIDER_CONN *conn, + int link_idx + ); + int check_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int repair_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int analyze_table( + SPIDER_CONN *conn, + int link_idx + ); + int optimize_table( + SPIDER_CONN *conn, + int link_idx + ); + int flush_tables( + SPIDER_CONN *conn, + int link_idx, + bool lock + ); + int flush_logs( + SPIDER_CONN *conn, + int link_idx + ); + int insert_opened_handler( + SPIDER_CONN *conn, + int link_idx + ); + int delete_opened_handler( + SPIDER_CONN *conn, + int link_idx + ); + int sync_from_clone_source( + spider_db_handler *dbton_hdl + ); + bool support_use_handler( + int use_handler + ); +}; + +class spider_mysql_copy_table: public spider_db_copy_table +{ +public: + spider_mysql_share *mysql_share; + spider_string sql; + uint pos; + spider_mysql_copy_table( + spider_mysql_share *db_share + ); + ~spider_mysql_copy_table(); + int init(); + void set_sql_charset( + CHARSET_INFO *cs + ); + int append_select_str(); + int append_insert_str( + int insert_flg + ); + int append_table_columns( + TABLE_SHARE *table_share + ); + int append_from_str(); + int append_table_name( + int link_idx + ); + void set_sql_pos(); + void set_sql_to_pos(); + int append_copy_where( + spider_db_copy_table *source_ct, + KEY *key_info, + ulong *last_row_pos, + ulong *last_lengths + ); + int append_key_order_str( + KEY *key_info, + int start_pos, + bool desc_flg + ); + int append_limit( + longlong offset, + longlong limit + ); + int append_into_str(); + int append_open_paren_str(); + int append_values_str(); + int append_select_lock_str( + int lock_mode + ); + int exec_query( + SPIDER_CONN *conn, + int quick_mode, + int *need_mon + ); + int copy_key_row( + spider_db_copy_table *source_ct, + Field *field, + ulong *row_pos, + ulong *length, + const char *joint_str, + const int joint_length + ); + int copy_row( + Field *field, + SPIDER_DB_ROW *row + ); + int copy_rows( + TABLE *table, + SPIDER_DB_ROW *row, + ulong **last_row_pos, + ulong **last_lengths + ); + int copy_rows( + TABLE *table, + SPIDER_DB_ROW *row + ); + int append_insert_terminator(); + int copy_insert_values( + spider_db_copy_table *source_ct + ); +}; diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc new file mode 100644 index 00000000000..7c40b3a4477 --- /dev/null +++ b/storage/spider/spd_db_oracle.cc @@ -0,0 +1,11764 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_partition.h" +#include "sql_analyse.h" +#endif + +#ifdef HAVE_ORACLE_OCI +#include +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_db_oracle.h" +#include "ha_spider.h" +#include "spd_conn.h" +#include "spd_db_conn.h" +#include "spd_malloc.h" +#include "spd_sys_table.h" +#include "spd_table.h" + +extern struct charset_info_st *spd_charset_utf8_bin; + +extern handlerton *spider_hton_ptr; +extern pthread_mutex_t spider_open_conn_mutex; +extern HASH spider_open_connections; +extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; +extern const char spider_dig_upper[]; + +#define SPIDER_DB_WRAPPER_ORACLE "oracle" + +#define SPIDER_SQL_NAME_QUOTE_STR "\"" +#define SPIDER_SQL_NAME_QUOTE_LEN (sizeof(SPIDER_SQL_NAME_QUOTE_STR) - 1) +static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; + +#define SPIDER_SQL_ISO_READ_COMMITTED_STR "set transaction isolation level read committed" +#define SPIDER_SQL_ISO_READ_COMMITTED_LEN sizeof(SPIDER_SQL_ISO_READ_COMMITTED_STR) - 1 +#define SPIDER_SQL_ISO_SERIALIZABLE_STR "set transaction isolation level serializable" +#define SPIDER_SQL_ISO_SERIALIZABLE_LEN sizeof(SPIDER_SQL_ISO_SERIALIZABLE_STR) - 1 + +#define SPIDER_SQL_START_TRANSACTION_STR "set transaction read write" +#define SPIDER_SQL_START_TRANSACTION_LEN sizeof(SPIDER_SQL_START_TRANSACTION_STR) - 1 + +#define SPIDER_SQL_AUTOCOMMIT_OFF_STR "set autocommit off" +#define SPIDER_SQL_AUTOCOMMIT_OFF_LEN sizeof(SPIDER_SQL_AUTOCOMMIT_OFF_STR) - 1 +#define SPIDER_SQL_AUTOCOMMIT_ON_STR "set autocommit on" +#define SPIDER_SQL_AUTOCOMMIT_ON_LEN sizeof(SPIDER_SQL_AUTOCOMMIT_ON_STR) - 1 + +#define SPIDER_SQL_LOCK_TABLE_STR "lock table " +#define SPIDER_SQL_LOCK_TABLE_LEN (sizeof(SPIDER_SQL_LOCK_TABLE_STR) - 1) +#define SPIDER_SQL_UNLOCK_TABLE_STR "unlock tables" +#define SPIDER_SQL_UNLOCK_TABLE_LEN (sizeof(SPIDER_SQL_UNLOCK_TABLE_STR) - 1) +#define SPIDER_SQL_LOCK_TABLE_SHARE_MODE_STR " in share mode" +#define SPIDER_SQL_LOCK_TABLE_SHARE_MODE_LEN (sizeof(SPIDER_SQL_LOCK_TABLE_SHARE_MODE_STR) - 1) +#define SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_STR " in exclusive mode" +#define SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_LEN (sizeof(SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_STR) - 1) + +#define SPIDER_SQL_COMMIT_STR "commit" +#define SPIDER_SQL_COMMIT_LEN sizeof(SPIDER_SQL_COMMIT_STR) - 1 + +#define SPIDER_SQL_SET_NLS_DATE_FORMAT_STR "alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'" +#define SPIDER_SQL_SET_NLS_DATE_FORMAT_LEN sizeof(SPIDER_SQL_SET_NLS_DATE_FORMAT_STR) - 1 +#define SPIDER_SQL_SET_NLS_TIME_FORMAT_STR "alter session set nls_time_format='HH24:MI:SSXFF'" +#define SPIDER_SQL_SET_NLS_TIME_FORMAT_LEN sizeof(SPIDER_SQL_SET_NLS_TIME_FORMAT_STR) - 1 +#define SPIDER_SQL_SET_NLS_TIMESTAMP_FORMAT_STR "alter session set nls_timestamp_format='YYYY-MM-DD HH24:MI:SSXFF'" +#define SPIDER_SQL_SET_NLS_TIMESTAMP_FORMAT_LEN sizeof(SPIDER_SQL_SET_NLS_TIMESTAMP_FORMAT_STR) - 1 + +#define SPIDER_SQL_SELECT_WRAPPER_HEAD_STR "select * from (" +#define SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN sizeof(SPIDER_SQL_SELECT_WRAPPER_HEAD_STR) - 1 +#define SPIDER_SQL_UPDATE_WRAPPER_HEAD_STR " where rowid in (select rowid from (select rowid, row_number() over (order by " +#define SPIDER_SQL_UPDATE_WRAPPER_HEAD_LEN sizeof(SPIDER_SQL_UPDATE_WRAPPER_HEAD_STR) - 1 +#define SPIDER_SQL_ROW_NUMBER_HEAD_STR ", row_number() over (order by " +#define SPIDER_SQL_ROW_NUMBER_HEAD_LEN sizeof(SPIDER_SQL_ROW_NUMBER_HEAD_STR) - 1 +#define SPIDER_SQL_ROW_NUMBER_TAIL_STR "rowid) row_num" +#define SPIDER_SQL_ROW_NUMBER_TAIL_LEN sizeof(SPIDER_SQL_ROW_NUMBER_TAIL_STR) - 1 +#define SPIDER_SQL_ROW_NUMBER_DESC_TAIL_STR "rowid desc) row_num" +#define SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN sizeof(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_STR) - 1 +#define SPIDER_SQL_SELECT_WRAPPER_TAIL_STR ") where row_num " +#define SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN sizeof(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR) - 1 +#define SPIDER_SQL_ROW_NUM_STR "row_num" +#define SPIDER_SQL_ROW_NUM_LEN sizeof(SPIDER_SQL_ROW_NUM_STR) - 1 +#define SPIDER_SQL_ROWNUM_STR "rownum" +#define SPIDER_SQL_ROWNUM_LEN sizeof(SPIDER_SQL_ROWNUM_STR) - 1 +#define SPIDER_SQL_NEXTVAL_STR ".nextval" +#define SPIDER_SQL_NEXTVAL_LEN sizeof(SPIDER_SQL_NEXTVAL_STR) - 1 +#define SPIDER_SQL_CURRVAL_STR ".currval" +#define SPIDER_SQL_CURRVAL_LEN sizeof(SPIDER_SQL_CURRVAL_STR) - 1 +#define SPIDER_SQL_FROM_DUAL_STR " from dual" +#define SPIDER_SQL_FROM_DUAL_LEN sizeof(SPIDER_SQL_FROM_DUAL_STR) - 1 + +#define SPIDER_SQL_SHOW_TABLE_STATUS_STR "show table status from " +#define SPIDER_SQL_SHOW_TABLE_STATUS_LEN sizeof(SPIDER_SQL_SHOW_TABLE_STATUS_STR) - 1 +#define SPIDER_SQL_SELECT_TABLES_STATUS_STR "select `table_rows`,`avg_row_length`,`data_length`,`max_data_length`,`index_length`,`auto_increment`,`create_time`,`update_time`,`check_time` from `information_schema`.`tables` where `table_schema` = " +#define SPIDER_SQL_SELECT_TABLES_STATUS_LEN sizeof(SPIDER_SQL_SELECT_TABLES_STATUS_STR) - 1 + +#define SPIDER_SQL_LIKE_STR " like " +#define SPIDER_SQL_LIKE_LEN (sizeof(SPIDER_SQL_LIKE_STR) - 1) +#define SPIDER_SQL_LIMIT1_STR "rownum = 1" +#define SPIDER_SQL_LIMIT1_LEN (sizeof(SPIDER_SQL_LIMIT1_STR) - 1) + +#define SPIDER_SQL_ADD_MONTHS_STR "add_months" +#define SPIDER_SQL_ADD_MONTHS_LEN (sizeof(SPIDER_SQL_ADD_MONTHS_STR) - 1) + +#define SPIDER_ORACLE_ERR_BUF_LEN 512 + +static uchar SPIDER_SQL_LINESTRING_HEAD_STR[] = + {0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00}; +#define SPIDER_SQL_LINESTRING_HEAD_LEN sizeof(SPIDER_SQL_LINESTRING_HEAD_STR) + +static const char *spider_db_table_lock_str[] = +{ + " in share mode", + " in share mode", + " in exclusive mode", + " in exclusive mode" +}; +static const int spider_db_table_lock_len[] = +{ + sizeof(" in share mode") - 1, + sizeof(" in share mode") - 1, + sizeof(" in exclusive mode") - 1, + sizeof(" in exclusive mode") - 1 +}; + +int spider_db_oracle_get_error( + sword res, + dvoid *hndlp, + int error_num, + const char *error1, + const char *error2, + CHARSET_INFO *access_charset, + char *stored_error_msg +) { + sb4 error_code; + char buf[SPIDER_ORACLE_ERR_BUF_LEN]; + char buf2[SPIDER_ORACLE_ERR_BUF_LEN]; + spider_string tmp_str(buf2, SPIDER_ORACLE_ERR_BUF_LEN, system_charset_info); + DBUG_ENTER("spider_db_oracle_get_error"); + tmp_str.init_calc_mem(176); + tmp_str.length(0); + + switch (res) + { + case OCI_SUCCESS: + DBUG_PRINT("info",("spider res=OCI_SUCCESS")); + break; + case OCI_SUCCESS_WITH_INFO: + DBUG_PRINT("info",("spider res=OCI_SUCCESS_WITH_INFO")); + OCIErrorGet(hndlp, 1, NULL, &error_code, (OraText *) buf, sizeof(buf), + OCI_HTYPE_ERROR); + DBUG_PRINT("info",("spider error_code=%d error='%s'",error_code ,buf)); + if (access_charset && access_charset->cset != system_charset_info->cset) + { + tmp_str.append(buf, strlen(buf), access_charset); + } else { + tmp_str.set(buf, strlen(buf), system_charset_info); + } + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_SPIDER_ORACLE_NUM, ER_SPIDER_ORACLE_STR, res, error_code, + tmp_str.c_ptr_safe()); + break; + case OCI_NO_DATA: + DBUG_PRINT("info",("spider res=OCI_NO_DATA")); + DBUG_RETURN(HA_ERR_END_OF_FILE); + case OCI_ERROR: + DBUG_PRINT("info",("spider res=OCI_ERROR")); + OCIErrorGet(hndlp, 1, NULL, &error_code, (OraText *) buf, sizeof(buf), + OCI_HTYPE_ERROR); + DBUG_PRINT("info",("spider error_code=%d error='%s'",error_code ,buf)); + if (error_code == 1) + { + DBUG_PRINT("info",("spider found dupp key")); + if (stored_error_msg) + strmov(stored_error_msg, buf); + DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); + } + if (error_num) + { + if (error1) + { + if (error2) + { + my_printf_error(error_num, error1, MYF(0), error2); + } else { + my_printf_error(error_num, error1, MYF(0)); + } + } else if (error2) { + my_error(error_num, MYF(0), error2); + } else { + my_error(error_num, MYF(0)); + } + } + if (access_charset && access_charset->cset != system_charset_info->cset) + { + tmp_str.append(buf, strlen(buf), access_charset); + } else { + tmp_str.set(buf, strlen(buf), system_charset_info); + } + my_printf_error(ER_SPIDER_ORACLE_NUM, ER_SPIDER_ORACLE_STR, MYF(0), + res, error_code, tmp_str.c_ptr_safe()); + if (error_num) + { + DBUG_RETURN(error_num); + } else { + DBUG_RETURN(ER_SPIDER_ORACLE_NUM); + } + case OCI_INVALID_HANDLE: + case OCI_NEED_DATA: + if (res == OCI_INVALID_HANDLE) + DBUG_PRINT("info",("spider res=OCI_INVALID_HANDLE")); + else + DBUG_PRINT("info",("spider res=OCI_NEED_DATA")); + default: + DBUG_PRINT("info",("spider res=%d", res)); + if (error_num) + { + if (error1) + { + if (error2) + { + my_printf_error(error_num, error1, MYF(0), error2); + } else { + my_printf_error(error_num, error1, MYF(0)); + } + } else if (error2) { + my_error(error_num, MYF(0), error2); + } else { + my_error(error_num, MYF(0)); + } + } + my_printf_error(ER_SPIDER_ORACLE_NUM, ER_SPIDER_ORACLE_STR, MYF(0), + res, 0, ""); + if (error_num) + { + DBUG_RETURN(error_num); + } else { + DBUG_RETURN(ER_SPIDER_ORACLE_NUM); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_init() +{ + DBUG_ENTER("spider_oracle_init"); + DBUG_RETURN(0); +} + +int spider_oracle_deinit() +{ + DBUG_ENTER("spider_oracle_deinit"); + DBUG_RETURN(0); +} + +spider_db_share *spider_oracle_create_share( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_oracle_create_share"); + DBUG_RETURN(new spider_oracle_share(share)); +} + +spider_db_handler *spider_oracle_create_handler( + ha_spider *spider, + spider_db_share *db_share +) { + DBUG_ENTER("spider_oracle_create_handler"); + DBUG_RETURN(new spider_oracle_handler(spider, + (spider_oracle_share *) db_share)); +} + +spider_db_copy_table *spider_oracle_create_copy_table( + spider_db_share *db_share +) { + DBUG_ENTER("spider_oracle_create_copy_table"); + DBUG_RETURN(new spider_oracle_copy_table( + (spider_oracle_share *) db_share)); +} + +SPIDER_DB_CONN *spider_oracle_create_conn( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_oracle_create_conn"); + DBUG_RETURN(new spider_db_oracle(conn)); +} + +spider_db_oracle_util spider_db_oracle_utility; + +SPIDER_DBTON spider_dbton_oracle = { + 0, + SPIDER_DB_WRAPPER_ORACLE, + SPIDER_DB_ACCESS_TYPE_SQL, + spider_oracle_init, + spider_oracle_deinit, + spider_oracle_create_share, + spider_oracle_create_handler, + spider_oracle_create_copy_table, + spider_oracle_create_conn, + &spider_db_oracle_utility +}; + +spider_db_oracle_row::spider_db_oracle_row() : spider_db_row(), + db_conn(NULL), result(NULL), + ind(NULL), val(NULL), rlen(NULL), ind_first(NULL), val_first(NULL), + rlen_first(NULL), val_str(NULL), val_str_first(NULL), defnp(NULL), + lobhp(NULL), colhp(NULL), coltp(NULL), colsz(NULL), field_count(0), + row_size(NULL), row_size_first(NULL), access_charset(NULL), cloned(FALSE) +{ + DBUG_ENTER("spider_db_oracle_row::spider_db_oracle_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_oracle_row::~spider_db_oracle_row() +{ + DBUG_ENTER("spider_db_oracle_row::~spider_db_oracle_row"); + DBUG_PRINT("info",("spider this=%p", this)); + deinit(); + DBUG_VOID_RETURN; +} + +int spider_db_oracle_row::store_to_field( + Field *field, + CHARSET_INFO *access_charset +) { + DBUG_ENTER("spider_db_oracle_row::store_to_field"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider ind=%d", *ind)); + if (*ind == -1) + { + DBUG_PRINT("info", ("spider field is null")); + field->set_null(); + field->reset(); + } else { + DBUG_PRINT("info", ("spider field->type()=%u", field->type())); + field->set_notnull(); + if (field->type() == MYSQL_TYPE_YEAR) + { + field->store(val_str->ptr(), 4, + field->table->s->table_charset); + } else if (field->type() == MYSQL_TYPE_DATE) + { + field->store(val_str->ptr(), 10, + field->table->s->table_charset); + } else if (field->type() == MYSQL_TYPE_TIME) + { + field->store(val_str->ptr() + 11, 8, + field->table->s->table_charset); + } else { + DBUG_PRINT("info", ("spider val_str->length()=%u", val_str->length())); + if (field->flags & BLOB_FLAG) + { + DBUG_PRINT("info", ("spider blob field")); + ((Field_blob *)field)->set_ptr( + val_str->length(), (uchar *) val_str->ptr()); + } else { + field->store(val_str->ptr(), val_str->length(), + field->table->s->table_charset); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_oracle_row::append_to_str( + spider_string *str +) { + DBUG_ENTER("spider_db_oracle_row::append_to_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(val_str->length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(val_str->ptr(), val_str->length()); + DBUG_RETURN(0); +} + +int spider_db_oracle_row::append_escaped_to_str( + spider_string *str, + uint dbton_id +) { + DBUG_ENTER("spider_db_oracle_row::append_escaped_to_str"); + DBUG_PRINT("info",("spider this=%p", this)); +/* + spider_string tmp_str(*val, *rlen, str->charset()); + tmp_str.init_calc_mem(174); + tmp_str.length(*rlen); +#ifndef DBUG_OFF + tmp_str.c_ptr_safe(); +#endif + if (str->reserve(*rlen * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + util.append_escaped(str, tmp_str.get_str()); +*/ + if (str->reserve(val_str->length() * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + spider_dbton[dbton_id].db_util->append_escaped_util(str, val_str->get_str()); + DBUG_RETURN(0); +} + +void spider_db_oracle_row::first() +{ + DBUG_ENTER("spider_db_oracle_row::first"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider ind_first=%p", ind_first)); + ind = ind_first; + DBUG_PRINT("info",("spider val_first=%p", val_first)); + val = val_first; + DBUG_PRINT("info",("spider rlen_first=%p", rlen_first)); + rlen = rlen_first; + DBUG_PRINT("info",("spider row_size_first=%p", row_size_first)); + row_size = row_size_first; + DBUG_PRINT("info",("spider val_str_first=%p", val_str_first)); + val_str = val_str_first; + DBUG_VOID_RETURN; +} + +void spider_db_oracle_row::next() +{ + DBUG_ENTER("spider_db_oracle_row::next"); + DBUG_PRINT("info",("spider this=%p", this)); + ind++; + val++; + rlen++; + row_size++; + val_str++; + DBUG_VOID_RETURN; +} + +bool spider_db_oracle_row::is_null() +{ + DBUG_ENTER("spider_db_oracle_row::is_null"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((*ind == -1)); +} + +int spider_db_oracle_row::val_int() +{ + DBUG_ENTER("spider_db_oracle_row::val_int"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((*ind != -1) ? atoi(*val) : 0); +} + +double spider_db_oracle_row::val_real() +{ + DBUG_ENTER("spider_db_oracle_row::val_real"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((*ind != -1) ? my_atof(*val) : 0.0); +} + +SPIDER_DB_ROW *spider_db_oracle_row::clone() +{ + uint i; + spider_db_oracle_row *clone_row; + DBUG_ENTER("spider_db_oracle_row::clone"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(clone_row = new spider_db_oracle_row())) + { + DBUG_RETURN(NULL); + } + clone_row->db_conn = db_conn; + clone_row->result = result; + clone_row->field_count = field_count; + clone_row->access_charset = access_charset; + clone_row->cloned = TRUE; + if (clone_row->init()) + { + delete clone_row; + DBUG_RETURN(NULL); + } + memcpy(clone_row->ind, ind_first, sizeof(ub2) * field_count * 4 + + sizeof(ulong) * field_count); + for (i = 0; i < field_count; i++) + { + if (clone_row->val_str[i].copy(val_str_first[i])) + { + delete clone_row; + DBUG_RETURN(NULL); + } + } + DBUG_RETURN((SPIDER_DB_ROW *) clone_row); +} + +int spider_db_oracle_row::store_to_tmp_table( + TABLE *tmp_table, + spider_string *str +) { + uint i; + DBUG_ENTER("spider_db_oracle_row::store_to_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + for (i = 0; i < field_count; i++) + { + if (row_size_first[i]) + { + if (str->reserve(val_str_first[i].length())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(val_str_first[i].ptr(), val_str_first[i].length()); + } + } + tmp_table->field[0]->set_notnull(); + tmp_table->field[0]->store( + (const char *) row_size_first, + sizeof(ulong) * field_count, &my_charset_bin); + tmp_table->field[1]->set_notnull(); + tmp_table->field[1]->store( + str->ptr(), str->length(), &my_charset_bin); + tmp_table->field[2]->set_notnull(); + tmp_table->field[2]->store( + (char *) ind_first, (uint) (sizeof(sb2) * field_count), &my_charset_bin); + DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); +} + +int spider_db_oracle_row::init() +{ + char *tmp_val; + uint i; + DBUG_ENTER("spider_db_oracle_row::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + !(ind = (sb2 *) + spider_bulk_malloc(spider_current_trx, 161, MYF(MY_WME | MY_ZEROFILL), + &ind, sizeof(sb2) * field_count, + &rlen, sizeof(ub2) * field_count, + &coltp, sizeof(ub2) * field_count, + &colsz, sizeof(ub2) * field_count, + &row_size, sizeof(ulong) * field_count, + &val, sizeof(char *) * field_count, + &tmp_val, MAX_FIELD_WIDTH * field_count, + &defnp, sizeof(OCIDefine *) * field_count, + &lobhp, sizeof(OCILobLocator *) * field_count, + &colhp, sizeof(OCIParam *) * field_count, + NullS) + ) || + !(val_str = new spider_string[field_count]) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + ind_first = ind; + val_first = val; + rlen_first = rlen; + row_size_first = row_size; + val_str_first = val_str; + for (i = 0; i < field_count; i++) + { + val[i] = tmp_val; + val_str[i].init_calc_mem(177); + val_str[i].set(tmp_val, MAX_FIELD_WIDTH, access_charset); + tmp_val += MAX_FIELD_WIDTH; + } + DBUG_RETURN(0); +} + +void spider_db_oracle_row::deinit() +{ + uint i; + DBUG_ENTER("spider_db_oracle_row::deinit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!cloned) + { + for (i = 0; i < field_count; i++) + { + if (defnp && defnp[i]) + { + OCIHandleFree(defnp[i], OCI_HTYPE_DEFINE); + defnp[i] = NULL; + } + if (lobhp && lobhp[i]) + { + OCIDescriptorFree(lobhp[i], OCI_DTYPE_LOB); + lobhp[i] = NULL; + } + } + } + if (val_str_first) + { + delete [] val_str_first; + val_str_first = NULL; + } + if (ind_first) + { + spider_free(spider_current_trx, ind_first, MYF(0)); + ind_first = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_db_oracle_row::define() +{ + sword res; + uint i; + DBUG_ENTER("spider_db_oracle_row::define"); + DBUG_PRINT("info",("spider this=%p", this)); + for (i = 0; i < field_count; i++) + { + if (coltp[i] == SQLT_BLOB) + { + res = OCIDescriptorAlloc(db_conn->envhp, (dvoid **) &lobhp[i], + OCI_DTYPE_LOB, 0, 0); + if (res != OCI_SUCCESS) + { + DBUG_RETURN( + spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, NULL, + access_charset, NULL)); + } + res = OCIDefineByPos(result->stmtp, &defnp[i], db_conn->errhp, i + 1, + &lobhp[i], 0, SQLT_BLOB, &ind[i], &rlen[i], NULL, + OCI_DEFAULT); + } else if (coltp[i] == SQLT_DAT) + { + res = OCIDefineByPos(result->stmtp, &defnp[i], db_conn->errhp, i + 1, + (char *) val_str[i].ptr() + 20, sizeof(ub1) * 7, SQLT_DAT, &ind[i], + &rlen[i], NULL, OCI_DEFAULT); + } else { + if (val_str[i].alloc(colsz[i])) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + res = OCIDefineByPos(result->stmtp, &defnp[i], db_conn->errhp, i + 1, + (char *) val_str[i].ptr(), colsz[i], SQLT_CHR, &ind[i], &rlen[i], NULL, + OCI_DEFAULT); + } + if (res != OCI_SUCCESS) + { + DBUG_RETURN( + spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, NULL, + access_charset, NULL)); + } + } + DBUG_RETURN(0); +} + +int spider_db_oracle_row::fetch() +{ + sword res; + uint i; + DBUG_ENTER("spider_db_oracle_row::fetch"); + DBUG_PRINT("info",("spider this=%p", this)); + for (i = 0; i < field_count; i++) + { + if (ind[i] == -1) + { + DBUG_PRINT("info",("spider NULL")); + val_str[i].length(0); + } else { + if (coltp[i] == SQLT_BLOB) + { + DBUG_PRINT("info",("spider SQLT_BLOB")); + oraub8 len; + res = OCILobGetLength2(db_conn->svchp, db_conn->errhp, lobhp[i], &len); + if (res != OCI_SUCCESS) + { + DBUG_RETURN( + spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, NULL, + access_charset, NULL)); + } +#ifndef DBUG_OFF + { + ulonglong print_len = len; + DBUG_PRINT("info",("spider len=%llu", print_len)); + } +#endif + if (val_str[i].alloc(len)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + res = OCILobRead2(db_conn->svchp, db_conn->errhp, lobhp[i], &len, + NULL, 1, (char *) val_str[i].ptr(), len, OCI_ONE_PIECE, NULL, NULL, + 0, 0); + if (res != OCI_SUCCESS) + { + DBUG_RETURN( + spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, NULL, + access_charset, NULL)); + } +#ifndef DBUG_OFF + { + ulonglong print_len = len; + DBUG_PRINT("info",("spider lenb=%llu", print_len)); + } +#endif + val_str[i].length(len); + } else if (coltp[i] == SQLT_DAT) + { + DBUG_PRINT("info",("spider SQLT_DAT")); + char *val = (char *) val_str[i].ptr(); + ub1 *src = (ub1 *) val + 20; + val_str[i].length(19); + if (src[0] < 100) + my_sprintf(val, (val, "0000-00-00 00:00:00")); + else + my_sprintf(val, (val, "%02u%02u-%02u-%02u %02u:%02u:%02u", + src[0] - 100, src[1] - 100, src[2], src[3], + src[4] - 1, src[5] - 1, src[6] - 1)); + } else { + val_str[i].length(rlen[i]); + } + } + row_size[i] = val_str[i].length(); + } + DBUG_RETURN(0); +} + +spider_db_oracle_result::spider_db_oracle_result() : spider_db_result(), + db_conn(NULL), stmtp(NULL), field_count(0), access_charset(NULL), + fetched(FALSE) +{ + DBUG_ENTER("spider_db_oracle_result::spider_db_oracle_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_oracle_result::~spider_db_oracle_result() +{ + DBUG_ENTER("spider_db_oracle_result::~spider_db_oracle_result"); + DBUG_PRINT("info",("spider this=%p", this)); + free_result(); + DBUG_VOID_RETURN; +} + +bool spider_db_oracle_result::has_result() +{ + DBUG_ENTER("spider_db_oracle_result::has_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(stmtp); +} + +void spider_db_oracle_result::free_result() +{ + DBUG_ENTER("spider_db_oracle_result::free_result"); + DBUG_PRINT("info",("spider this=%p", this)); + if (stmtp) + { + OCIHandleFree(stmtp, OCI_HTYPE_STMT); + stmtp = NULL; + } + DBUG_VOID_RETURN; +} + +SPIDER_DB_ROW *spider_db_oracle_result::current_row() +{ + DBUG_ENTER("spider_db_oracle_result::current_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN((SPIDER_DB_ROW *) row.clone()); +} + +SPIDER_DB_ROW *spider_db_oracle_result::fetch_row() +{ + sword res; + DBUG_ENTER("spider_db_oracle_result::fetch_row"); + DBUG_PRINT("info",("spider this=%p", this)); + row.ind = row.ind_first; + row.val = row.val_first; + row.rlen = row.rlen_first; + row.row_size = row.row_size_first; + row.val_str = row.val_str_first; + if (fetched) + { + /* already fetched */ + fetched = FALSE; + } else { + res = OCIStmtFetch2(stmtp, db_conn->errhp, 1, OCI_FETCH_NEXT, 0, + OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + store_error_num = spider_db_oracle_get_error(res, db_conn->errhp, 0, + NULL, NULL, access_charset, NULL); + DBUG_RETURN(NULL); + } + } + if ((store_error_num = row.fetch())) + { + DBUG_RETURN(NULL); + } + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +SPIDER_DB_ROW *spider_db_oracle_result::fetch_row_from_result_buffer( + spider_db_result_buffer *spider_res_buf +) { + sword res; + DBUG_ENTER("spider_db_oracle_result::fetch_row_from_result_buffer"); + DBUG_PRINT("info",("spider this=%p", this)); + row.ind = row.ind_first; + row.val = row.val_first; + row.rlen = row.rlen_first; + row.row_size = row.row_size_first; + row.val_str = row.val_str_first; + if (fetched) + { + /* already fetched */ + fetched = FALSE; + } else { + res = OCIStmtFetch2(stmtp, db_conn->errhp, 1, OCI_FETCH_NEXT, 0, + OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + store_error_num = spider_db_oracle_get_error(res, db_conn->errhp, 0, + NULL, NULL, access_charset, NULL); + DBUG_RETURN(NULL); + } + } + if ((store_error_num = row.fetch())) + { + DBUG_RETURN(NULL); + } + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +SPIDER_DB_ROW *spider_db_oracle_result::fetch_row_from_tmp_table( + TABLE *tmp_table +) { + uint i; + const char *str; + spider_string tmp_str1, tmp_str2, tmp_str3; + DBUG_ENTER("spider_db_oracle_result::fetch_row_from_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_str1.init_calc_mem(175); + tmp_str2.init_calc_mem(178); + tmp_str3.init_calc_mem(179); + tmp_table->field[0]->val_str(tmp_str1.get_str()); + tmp_table->field[1]->val_str(tmp_str2.get_str()); + tmp_table->field[2]->val_str(tmp_str3.get_str()); + tmp_str1.mem_calc(); + tmp_str2.mem_calc(); + tmp_str3.mem_calc(); + row.ind = row.ind_first; + row.val = row.val_first; + row.rlen = row.rlen_first; + row.row_size = row.row_size_first; + row.val_str = row.val_str_first; + DBUG_PRINT("info",("spider tmp_str1.length()=%u", tmp_str1.length())); + DBUG_PRINT("info",("spider tmp_str2.length()=%u", tmp_str2.length())); + DBUG_PRINT("info",("spider tmp_str3.length()=%u", tmp_str3.length())); + memcpy(row.ind, tmp_str3.ptr(), tmp_str3.length()); + memcpy(row.row_size, tmp_str1.ptr(), tmp_str1.length()); + row.field_count = tmp_str1.length() / sizeof(ulong); + str = tmp_str2.ptr(); + for (i = 0; i < row.field_count; i++) + { + row.val_str[i].length(0); + if (row.row_size[i]) + { + if (row.val_str[i].reserve(row.row_size[i])) + { + store_error_num = HA_ERR_OUT_OF_MEM; + DBUG_RETURN(NULL); + } + row.val_str[i].q_append(str, row.row_size[i]); + str += row.row_size[i]; + } + } + DBUG_RETURN((SPIDER_DB_ROW *) &row); +} + +int spider_db_oracle_result::fetch_table_status( + int mode, + ha_rows &records, + ulong &mean_rec_length, + ulonglong &data_file_length, + ulonglong &max_data_file_length, + ulonglong &index_file_length, + ulonglong &auto_increment_value, + time_t &create_time, + time_t &update_time, + time_t &check_time +) { + DBUG_ENTER("spider_db_oracle_result::fetch_table_status"); + DBUG_PRINT("info",("spider this=%p", this)); + /* TODO: develop later */ + records = 2; + mean_rec_length = 65535; + data_file_length = 65535; + max_data_file_length = 65535; + index_file_length = 65535; +/* + auto_increment_value = 0; +*/ + create_time = (time_t) 0; + update_time = (time_t) 0; + check_time = (time_t) 0; + DBUG_RETURN(0); +} + +int spider_db_oracle_result::fetch_table_records( + int mode, + ha_rows &records +) { + DBUG_ENTER("spider_db_oracle_result::fetch_table_records"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!fetch_row()) + { + records = 0; + } else { + records = row.val_int(); + } + DBUG_RETURN(0); +} + +int spider_db_oracle_result::fetch_table_cardinality( + int mode, + TABLE *table, + longlong *cardinality, + uchar *cardinality_upd, + int bitmap_size +) { + DBUG_ENTER("spider_db_oracle_result::fetch_table_cardinality"); + DBUG_PRINT("info",("spider this=%p", this)); + /* TODO: develop later */ + DBUG_RETURN(0); +} + +int spider_db_oracle_result::fetch_table_mon_status( + int &status +) { + DBUG_ENTER("spider_db_oracle_result::fetch_table_mon_status"); + DBUG_PRINT("info",("spider this=%p", this)); + /* TODO: develop later */ + status = SPIDER_LINK_MON_OK; + DBUG_RETURN(0); +} + +longlong spider_db_oracle_result::num_rows() +{ + sword res; + ub4 rowcnt; + DBUG_ENTER("spider_db_oracle_result::num_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + res = OCIAttrGet(stmtp, OCI_HTYPE_STMT, &rowcnt, 0, + OCI_ATTR_ROW_COUNT, db_conn->errhp); + if (res != OCI_SUCCESS) + { + spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, NULL, + access_charset, NULL); + DBUG_RETURN(0); + } + DBUG_PRINT("info",("spider rowcnt=%u", rowcnt)); + DBUG_RETURN((longlong) rowcnt); +} + +uint spider_db_oracle_result::num_fields() +{ + sword res; + ub4 parmcnt; + DBUG_ENTER("spider_db_oracle_result::num_fields"); + DBUG_PRINT("info",("spider this=%p", this)); + res = OCIAttrGet(stmtp, OCI_HTYPE_STMT, &parmcnt, 0, + OCI_ATTR_PARAM_COUNT, db_conn->errhp); + if (res != OCI_SUCCESS) + { + spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, NULL, + access_charset, NULL); + DBUG_RETURN(0); + } + DBUG_RETURN((uint) parmcnt); +} + +void spider_db_oracle_result::move_to_pos( + longlong pos +) { + sword res; + DBUG_ENTER("spider_db_oracle_result::move_to_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider pos=%lld", pos)); + res = OCIStmtFetch2(stmtp, db_conn->errhp, 1, OCI_FETCH_ABSOLUTE, pos, + OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, NULL, + access_charset, NULL); + } + DBUG_VOID_RETURN; +} + +int spider_db_oracle_result::set_column_info() +{ + sword res; + uint i; + DBUG_ENTER("spider_db_oracle_result::set_column_info"); + DBUG_PRINT("info",("spider this=%p", this)); + for (i = 0; i < field_count; i++) + { + res = OCIParamGet(stmtp, OCI_HTYPE_STMT, db_conn->errhp, + (dvoid **) &row.colhp[i], i + 1); + if (res != OCI_SUCCESS) + { + DBUG_RETURN(spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, + NULL, access_charset, NULL)); + } + res = OCIAttrGet(row.colhp[i], OCI_DTYPE_PARAM, &row.coltp[i], NULL, + OCI_ATTR_DATA_TYPE, db_conn->errhp); + if (res != OCI_SUCCESS) + { + DBUG_RETURN(spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, + NULL, access_charset, NULL)); + } + res = OCIAttrGet(row.colhp[i], OCI_DTYPE_PARAM, &row.colsz[i], NULL, + OCI_ATTR_DATA_SIZE, db_conn->errhp); + if (res != OCI_SUCCESS) + { + DBUG_RETURN(spider_db_oracle_get_error(res, db_conn->errhp, 0, NULL, + NULL, access_charset, NULL)); + } + } + DBUG_RETURN(0); +} + +int spider_db_oracle_result::get_errno() +{ + DBUG_ENTER("spider_db_oracle_result::get_errno"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider store_error_num=%d", store_error_num)); + DBUG_RETURN(store_error_num); +} + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +int spider_db_oracle_result::fetch_columns_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset +) { + DBUG_ENTER("spider_db_oracle_result::fetch_columns_for_discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +} + +int spider_db_oracle_result::fetch_index_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset +) { + DBUG_ENTER("spider_db_oracle_result::fetch_index_for_discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +} +#endif + +spider_db_oracle::spider_db_oracle( + SPIDER_CONN *conn +) : spider_db_conn(conn), envhp(NULL), errhp(NULL), srvhp(NULL), svchp(NULL), + usrhp(NULL), stmtp(NULL), txnhp(NULL), result(NULL), table_lock_mode(0), + lock_table_hash_inited(FALSE), handler_open_array_inited(FALSE) +{ + DBUG_ENTER("spider_db_oracle::spider_db_oracle"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_oracle::~spider_db_oracle() +{ + DBUG_ENTER("spider_db_oracle::~spider_db_oracle"); + DBUG_PRINT("info",("spider this=%p", this)); + if (handler_open_array_inited) + { + reset_opened_handler(); + spider_free_mem_calc(spider_current_trx, + handler_open_array_id, + handler_open_array.max_element * + handler_open_array.size_of_element); + delete_dynamic(&handler_open_array); + } + if (lock_table_hash_inited) + { + spider_free_mem_calc(spider_current_trx, + lock_table_hash_id, + lock_table_hash.array.max_element * + lock_table_hash.array.size_of_element); + my_hash_free(&lock_table_hash); + } + disconnect(); + DBUG_VOID_RETURN; +} + +int spider_db_oracle::init() +{ + DBUG_ENTER("spider_db_oracle::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + my_hash_init(&lock_table_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_link_get_key, 0, 0) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider_alloc_calc_mem_init(lock_table_hash, 199); + spider_alloc_calc_mem(spider_current_trx, + lock_table_hash, + lock_table_hash.array.max_element * + lock_table_hash.array.size_of_element); + lock_table_hash_inited = TRUE; + + if ( + SPD_INIT_DYNAMIC_ARRAY2(&handler_open_array, + sizeof(SPIDER_LINK_FOR_HASH *), NULL, 16, 16, MYF(MY_WME)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider_alloc_calc_mem_init(handler_open_array, 164); + spider_alloc_calc_mem(spider_current_trx, + handler_open_array, + handler_open_array.max_element * + handler_open_array.size_of_element); + handler_open_array_inited = TRUE; + DBUG_RETURN(0); +} + +bool spider_db_oracle::is_connected() +{ + DBUG_ENTER("spider_db_oracle::is_connected"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(svchp); +} + +void spider_db_oracle::bg_connect() +{ + sword res; + DBUG_ENTER("spider_db_oracle::bg_connect"); + DBUG_PRINT("info",("spider this=%p", this)); + res = OCIEnvNlsCreate(&envhp, OCI_DEFAULT, 0, 0, 0, 0, 0, 0, 0, 0); +/* + res = OCIEnvCreate(&envhp, OCI_THREADED, 0, 0, 0, 0, 0, 0); +*/ + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider create environment error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + goto error; + } + DBUG_PRINT("info",("spider OCI init envhp=%p", envhp)); + + res = OCIHandleAlloc(envhp, (dvoid **) &errhp, OCI_HTYPE_ERROR, 0, 0); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider create error handler error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + DBUG_PRINT("info",("spider OCI init errhp=%p", errhp)); + + res = OCIHandleAlloc(envhp, (dvoid **) &srvhp, OCI_HTYPE_SERVER, 0, 0); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider create server handler error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + DBUG_PRINT("info",("spider OCI init srvhp=%p", srvhp)); + + res = OCIServerAttach(srvhp, errhp, (OraText *) tgt_host, strlen(tgt_host), + OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider attach server error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + + res = OCIHandleAlloc(envhp, (dvoid **) &svchp, OCI_HTYPE_SVCCTX, 0, 0); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider create service context error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + DBUG_PRINT("info",("spider OCI init svchp=%p", svchp)); + + res = OCIAttrSet(svchp, OCI_HTYPE_SVCCTX, srvhp, 0, OCI_ATTR_SERVER, errhp); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider set server attr error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + + res = OCIHandleAlloc(envhp, (dvoid **) &usrhp, OCI_HTYPE_SESSION, 0, 0); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider create session handler error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + DBUG_PRINT("info",("spider OCI init usrhp=%p", usrhp)); + + res = OCIAttrSet(usrhp, OCI_HTYPE_SESSION, + tgt_username, strlen(tgt_username), OCI_ATTR_USERNAME, errhp); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider set username attr error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + + res = OCIAttrSet(usrhp, OCI_HTYPE_SESSION, + tgt_password, strlen(tgt_password), OCI_ATTR_PASSWORD, errhp); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider set password attr error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + + res = OCISessionBegin(svchp, errhp, usrhp, OCI_CRED_RDBMS, OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider session begin error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + DBUG_PRINT("info",("spider OCISessionBegin")); + + // set the session in the context handle + res = OCIAttrSet(svchp, OCI_HTYPE_SVCCTX, usrhp, 0, OCI_ATTR_SESSION, errhp); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider set session attr error")); + stored_error_num = set_error(res, errhp, 0, NULL, NULL); + bg_disconnect(); + goto error; + } + + if ( + (stored_error_num = exec_query(SPIDER_SQL_SET_NLS_DATE_FORMAT_STR, + SPIDER_SQL_SET_NLS_DATE_FORMAT_LEN, -1)) || + (stored_error_num = exec_query(SPIDER_SQL_SET_NLS_TIME_FORMAT_STR, + SPIDER_SQL_SET_NLS_TIME_FORMAT_LEN, -1)) || + (stored_error_num = exec_query(SPIDER_SQL_SET_NLS_TIMESTAMP_FORMAT_STR, + SPIDER_SQL_SET_NLS_TIMESTAMP_FORMAT_LEN, -1)) + ) { + DBUG_PRINT("info",("spider init connection error")); + bg_disconnect(); + goto error; + } + DBUG_VOID_RETURN; + +error: +#if MYSQL_VERSION_ID < 50500 + strmov(stored_error_msg, current_thd->main_da.message()); +#else + strmov(stored_error_msg, current_thd->stmt_da->message()); +#endif + current_thd->clear_error(); + DBUG_VOID_RETURN; +} + +int spider_db_oracle::connect( + char *tgt_host, + char *tgt_username, + char *tgt_password, + long tgt_port, + char *tgt_socket, + char *server_name, + int connect_retry_count, + longlong connect_retry_interval +) { + int error_num; + DBUG_ENTER("spider_db_oracle::connect"); + DBUG_PRINT("info",("spider this=%p", this)); + this->tgt_host = tgt_host; + this->tgt_username = tgt_username; + this->tgt_password = tgt_password; + this->tgt_port = tgt_port; + this->tgt_socket = tgt_socket; + this->server_name = server_name; + this->connect_retry_count = connect_retry_count; + this->connect_retry_interval = connect_retry_interval; + if ((error_num = spider_create_conn_thread(conn))) + DBUG_RETURN(error_num); + spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_CONNECT); + + if (stored_error_num) + { + my_message(stored_error_num, stored_error_msg, MYF(0)); + DBUG_RETURN(stored_error_num); + } + DBUG_RETURN(0); +} + +int spider_db_oracle::ping( +) { + sword res; + DBUG_ENTER("spider_db_oracle::ping"); + DBUG_PRINT("info",("spider this=%p", this)); + res = OCIPing(svchp, errhp, OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider ping error %d", res)); + DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); + } + DBUG_RETURN(0); +} + +void spider_db_oracle::bg_disconnect() +{ + DBUG_ENTER("spider_db_oracle::bg_disconnect"); + DBUG_PRINT("info",("spider this=%p", this)); + if (result) + { + delete result; + result = NULL; + } + if (txnhp) + { + DBUG_PRINT("info",("spider OCI free txnhp=%p", txnhp)); + OCIHandleFree(txnhp, OCI_HTYPE_TRANS); + txnhp = NULL; + } + if (stmtp) + { + DBUG_PRINT("info",("spider OCI free stmtp=%p", stmtp)); + OCIHandleFree(stmtp, OCI_HTYPE_STMT); + stmtp = NULL; + } + if (svchp && errhp && usrhp) + { + DBUG_PRINT("info",("spider OCISessionEnd")); + OCISessionEnd(svchp, errhp, usrhp, OCI_DEFAULT); + } + if (usrhp) + { + DBUG_PRINT("info",("spider OCI free usrhp=%p", usrhp)); + OCIHandleFree(usrhp, OCI_HTYPE_SESSION); + usrhp = NULL; + } + if (svchp) + { + DBUG_PRINT("info",("spider OCI free svchp=%p", svchp)); + OCIHandleFree(svchp, OCI_HTYPE_SVCCTX); + svchp = NULL; + } + if (srvhp) + { + DBUG_PRINT("info",("spider OCI free srvhp=%p", srvhp)); + OCIServerDetach(srvhp, errhp, OCI_DEFAULT); + OCIHandleFree(srvhp, OCI_HTYPE_SERVER); + srvhp = NULL; + } + if (errhp) + { + DBUG_PRINT("info",("spider OCI free errhp=%p", errhp)); + OCIHandleFree(errhp, OCI_HTYPE_ERROR); + errhp = NULL; + } + if (envhp) + { + DBUG_PRINT("info",("spider OCI free envhp=%p", envhp)); + OCIHandleFree(envhp, OCI_HTYPE_ENV); + envhp = NULL; + } + DBUG_VOID_RETURN; +} + +void spider_db_oracle::disconnect() +{ + DBUG_ENTER("spider_db_oracle::disconnect"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!conn->bg_init) + DBUG_VOID_RETURN; + spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_DISCONNECT); + DBUG_VOID_RETURN; +} + +int spider_db_oracle::set_net_timeout() +{ + DBUG_ENTER("spider_db_oracle::set_net_timeout"); + DBUG_PRINT("info",("spider this=%p", this)); + /* TODO: develop later */ + DBUG_RETURN(0); +} + +int spider_db_oracle::exec_query( + const char *query, + uint length, + int quick_mode +) { + sword res; + int error_num; + DBUG_ENTER("spider_db_oracle::exec_query"); + DBUG_PRINT("info",("spider this=%p", this)); + stored_error_num = 0; + if (table_lock_mode && !conn->in_before_query) + { + DBUG_PRINT("info",("spider table_lock_mode=%d", table_lock_mode)); + table_lock_mode = 0; + if ((error_num = exec_query(exec_lock_sql->ptr(), exec_lock_sql->length(), + -1))) { + DBUG_RETURN(error_num); + } + } + + if (length) + { + if (result) + { + delete result; + result = NULL; + } + + if (!stmtp) + { + DBUG_PRINT("info",("spider create stmt")); + res = OCIHandleAlloc(envhp, (dvoid **) &stmtp, OCI_HTYPE_STMT, 0, 0); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider create stmt handler error")); + DBUG_RETURN(set_error(res, errhp, 0, NULL, NULL)); + } + } + + res = OCIStmtPrepare(stmtp, errhp, (OraText *) query, length, + OCI_NTV_SYNTAX, OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider stmt prepare error")); + DBUG_RETURN(set_error(res, errhp, 0, NULL, NULL)); + } + +/* + if ((result = new spider_db_oracle_result())) + { + result->db_conn = this; + result->stmtp = stmtp; + stmtp = NULL; + result->field_count = result->num_fields(); + result->row.field_count = result->field_count; + result->row.db_conn = this; + result->row.result = result; + if ((error_num = result->row.init())) + { + delete result; + result = NULL; + DBUG_RETURN(error_num); + } + } else { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +*/ + + /* select statement check */ + ub4 iters; + if ( + !strncasecmp(query, "select ", sizeof("select ") - 1) || + !strncasecmp(query, "(select ", sizeof("(select ") - 1) + ) { + iters = 0; + } else { + iters = 1; + } + + if (quick_mode) + { + DBUG_PRINT("info",("spider use OCI_DEFAULT")); + res = OCIStmtExecute(svchp, stmtp, errhp, iters, 0, NULL, NULL, + OCI_DEFAULT); + } else { + DBUG_PRINT("info",("spider use OCI_STMT_SCROLLABLE_READONLY")); + res = OCIStmtExecute(svchp, stmtp, errhp, iters, 0, NULL, NULL, + OCI_STMT_SCROLLABLE_READONLY); +/* + if (res == OCI_SUCCESS) + { + DBUG_PRINT("info",("spider fetch last for row count")); + res = OCIStmtFetch2(result->stmtp, errhp, 1, OCI_FETCH_LAST, 0, + OCI_DEFAULT); + } + if (res == OCI_SUCCESS) + { + DBUG_PRINT("info",("spider fetch first for row count")); + res = OCIStmtFetch2(result->stmtp, errhp, 1, OCI_FETCH_FIRST, 0, + OCI_DEFAULT); + } +*/ + } + if (res == OCI_SUCCESS && iters) + { + DBUG_PRINT("info",("spider get row count")); + ub4 row_count; + res = OCIAttrGet(stmtp, OCI_HTYPE_STMT, &row_count, 0, + OCI_ATTR_ROW_COUNT, errhp); + update_rows = (uint) row_count; + DBUG_PRINT("info",("spider row_count=%u", update_rows)); + } + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider stmt execute error")); + error_num = set_error(res, errhp, 0, NULL, NULL); + if (error_num == HA_ERR_END_OF_FILE) + DBUG_RETURN(0); + DBUG_RETURN(error_num); + } + + if ((result = new spider_db_oracle_result())) + { + result->db_conn = this; + result->stmtp = stmtp; + stmtp = NULL; + result->field_count = result->num_fields(); + result->row.field_count = result->field_count; + result->row.db_conn = this; + result->row.result = result; + result->row.access_charset = conn->access_charset; + result->access_charset = conn->access_charset; + if ( + (error_num = result->row.init()) || + (error_num = result->set_column_info()) + ) { + delete result; + result = NULL; + DBUG_RETURN(error_num); + } + result->row.define(); + } else { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + if (!quick_mode && !iters) + { + if (res == OCI_SUCCESS) + { + DBUG_PRINT("info",("spider fetch last for row count")); + res = OCIStmtFetch2(result->stmtp, errhp, 1, OCI_FETCH_LAST, 0, + OCI_DEFAULT); + } + if (res == OCI_SUCCESS) + { + DBUG_PRINT("info",("spider fetch first for row count")); + res = OCIStmtFetch2(result->stmtp, errhp, 1, OCI_FETCH_FIRST, 0, + OCI_DEFAULT); + } + if (res != OCI_SUCCESS) + { + DBUG_PRINT("info",("spider stmt execute error")); + error_num = set_error(res, errhp, 0, NULL, NULL); + if (error_num == HA_ERR_END_OF_FILE) + DBUG_RETURN(0); + DBUG_RETURN(error_num); + } + result->fetched = TRUE; + } + } + DBUG_RETURN(0); +} + +int spider_db_oracle::get_errno() +{ + DBUG_ENTER("spider_db_oracle::get_errno"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider stored_error=%d", stored_error_num)); + DBUG_RETURN(stored_error_num); +} + +const char *spider_db_oracle::get_error() +{ + DBUG_ENTER("spider_db_oracle::get_error"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider error=%s", stored_error)); + DBUG_RETURN(stored_error); +} + +bool spider_db_oracle::is_server_gone_error( + int error_num +) { + DBUG_ENTER("spider_db_oracle::is_server_gone_error"); + DBUG_PRINT("info",("spider this=%p", this)); + /* TODO: develop later */ + DBUG_RETURN(FALSE); +} + +bool spider_db_oracle::is_dup_entry_error( + int error_num +) { + DBUG_ENTER("spider_db_oracle::is_dup_entry_error"); + DBUG_PRINT("info",("spider this=%p", this)); + if (error_num == HA_ERR_FOUND_DUPP_KEY) + DBUG_RETURN(TRUE); + DBUG_RETURN(FALSE); +} + +bool spider_db_oracle::is_xa_nota_error( + int error_num +) { + DBUG_ENTER("spider_db_oracle::is_xa_nota_error"); + DBUG_PRINT("info",("spider this=%p", this)); + /* TODO: develop later */ + DBUG_RETURN(FALSE); +} + +spider_db_result *spider_db_oracle::store_result( + spider_db_result_buffer **spider_res_buf, + st_spider_db_request_key *request_key, + int *error_num +) { + spider_db_oracle_result *tmp_result = result; + DBUG_ENTER("spider_db_oracle::store_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(!spider_res_buf); + if (stored_error_num == HA_ERR_END_OF_FILE) + { + *error_num = HA_ERR_END_OF_FILE; + DBUG_RETURN(NULL); + } + + *error_num = 0; + result = NULL; + DBUG_RETURN(tmp_result); +} + +spider_db_result *spider_db_oracle::use_result( + st_spider_db_request_key *request_key, + int *error_num +) { + spider_db_oracle_result *tmp_result = result; + DBUG_ENTER("spider_db_oracle::use_result"); + DBUG_PRINT("info",("spider this=%p", this)); + if (stored_error_num == HA_ERR_END_OF_FILE) + { + *error_num = HA_ERR_END_OF_FILE; + DBUG_RETURN(NULL); + } + + *error_num = 0; + result = NULL; + DBUG_RETURN(tmp_result); +} + +int spider_db_oracle::next_result() +{ + DBUG_ENTER("spider_db_oracle::next_result"); + DBUG_PRINT("info",("spider this=%p", this)); + /* TODO: develop later */ + DBUG_RETURN(-1); +} + +uint spider_db_oracle::affected_rows() +{ + DBUG_ENTER("spider_db_oracle::affected_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(update_rows); +} + +ulonglong spider_db_oracle::last_insert_id() +{ + DBUG_ENTER("spider_db_oracle::last_insert_id"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(stored_last_insert_id); +} + +int spider_db_oracle::set_character_set( + const char *csname +) { + DBUG_ENTER("spider_db_oracle::set_character_set"); + DBUG_PRINT("info",("spider this=%p", this)); + /* TODO: develop later */ + DBUG_RETURN(0); +} + +int spider_db_oracle::select_db( + const char *dbname +) { + DBUG_ENTER("spider_db_oracle::select_db"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do for oracle */ + DBUG_RETURN(0); +} + +int spider_db_oracle::consistent_snapshot( + int *need_mon +) { + DBUG_ENTER("spider_db_oracle::consistent_snapshot"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do for oracle */ + DBUG_RETURN(0); +} + +bool spider_db_oracle::trx_start_in_bulk_sql() +{ + DBUG_ENTER("spider_db_oracle::trx_start_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_oracle::start_transaction( + int *need_mon +) { + DBUG_ENTER("spider_db_oracle::start_transaction"); + DBUG_PRINT("info",("spider this=%p", this)); + if (conn->in_before_query) + { + if (conn->queued_semi_trx_isolation) + { + if (conn->queued_semi_trx_isolation_val != conn->trx_isolation) + { + /* nothing to do */ + DBUG_RETURN(0); + } + } else if (conn->queued_trx_isolation) + { + if (conn->queued_trx_isolation_val != conn->trx_isolation) + { + /* nothing to do */ + DBUG_RETURN(0); + } + } + DBUG_RETURN(set_trx_isolation(conn->trx_isolation, need_mon)); + } + if (spider_db_query( + conn, + SPIDER_SQL_START_TRANSACTION_STR, + SPIDER_SQL_START_TRANSACTION_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_db_oracle::commit( + int *need_mon +) { + sword res; + DBUG_ENTER("spider_db_oracle::commit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (conn->table_locked) + { + conn->table_locked = FALSE; + spider_current_trx->locked_connections--; + } + res = OCITransCommit(svchp, errhp, OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + *need_mon = set_error(res, errhp, 0, NULL, NULL); + DBUG_RETURN(*need_mon); + } + DBUG_RETURN(0); +} + +int spider_db_oracle::rollback( + int *need_mon +) { + sword res; + DBUG_ENTER("spider_db_oracle::rollback"); + DBUG_PRINT("info",("spider this=%p", this)); + if (conn->table_locked) + { + conn->table_locked = FALSE; + spider_current_trx->locked_connections--; + } + if (svchp && errhp) + { + res = OCITransRollback(svchp, errhp, OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + *need_mon = set_error(res, errhp, 0, NULL, NULL); + DBUG_RETURN(*need_mon); + } + } + DBUG_RETURN(0); +} + +bool spider_db_oracle::xa_start_in_bulk_sql() +{ + DBUG_ENTER("spider_db_oracle::xa_start_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_oracle::xa_start( + XID *xid, + int *need_mon +) { + sword res; + DBUG_ENTER("spider_db_oracle::xa_start"); + DBUG_PRINT("info",("spider this=%p", this)); + if (txnhp) + { + OCIHandleFree(txnhp, OCI_HTYPE_TRANS); + txnhp = NULL; + } + OCIHandleAlloc((dvoid *)envhp, (dvoid **)&txnhp, OCI_HTYPE_TRANS, 0, 0); + OCIAttrSet((dvoid *)svchp, OCI_HTYPE_SVCCTX, (dvoid *)txnhp, 0, + OCI_ATTR_TRANS, errhp); + OCIAttrSet((dvoid *)txnhp, OCI_HTYPE_TRANS, (dvoid *)xid, sizeof(XID), + OCI_ATTR_XID, errhp); + + res = OCITransStart(svchp, errhp, 31622400, OCI_TRANS_NEW); + if (res != OCI_SUCCESS) + { + *need_mon = set_error(res, errhp, 0, NULL, NULL); + DBUG_RETURN(*need_mon); + } + DBUG_RETURN(0); +} + +int spider_db_oracle::xa_end( + XID *xid, + int *need_mon +) { + DBUG_ENTER("spider_db_oracle::xa_end"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do for oracle */ + DBUG_RETURN(0); +} + +int spider_db_oracle::xa_prepare( + XID *xid, + int *need_mon +) { + sword res; + DBUG_ENTER("spider_db_oracle::xa_prepare"); + DBUG_PRINT("info",("spider this=%p", this)); + res = OCITransPrepare(svchp, errhp, OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + *need_mon = set_error(res, errhp, 0, NULL, NULL); + DBUG_RETURN(*need_mon); + } + DBUG_RETURN(0); +} + +int spider_db_oracle::xa_commit( + XID *xid, + int *need_mon +) { + sword res; + DBUG_ENTER("spider_db_oracle::xa_commit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (conn->table_locked) + { + conn->table_locked = FALSE; + spider_current_trx->locked_connections--; + } + res = OCITransCommit(svchp, errhp, OCI_TRANS_TWOPHASE); + if (res != OCI_SUCCESS) + { + *need_mon = set_error(res, errhp, 0, NULL, NULL); + if (txnhp) + { + OCIHandleFree(txnhp, OCI_HTYPE_TRANS); + txnhp = NULL; + } + DBUG_RETURN(*need_mon); + } + if (txnhp) + { + OCIHandleFree(txnhp, OCI_HTYPE_TRANS); + txnhp = NULL; + } + DBUG_RETURN(0); +} + +int spider_db_oracle::xa_rollback( + XID *xid, + int *need_mon +) { + sword res; + DBUG_ENTER("spider_db_oracle::xa_rollback"); + DBUG_PRINT("info",("spider this=%p", this)); + if (svchp && errhp) + { + res = OCITransRollback(svchp, errhp, OCI_DEFAULT); + if (res != OCI_SUCCESS) + { + *need_mon = set_error(res, errhp, 0, NULL, NULL); + if (txnhp) + { + OCIHandleFree(txnhp, OCI_HTYPE_TRANS); + txnhp = NULL; + } + DBUG_RETURN(*need_mon); + } + } + if (txnhp) + { + OCIHandleFree(txnhp, OCI_HTYPE_TRANS); + txnhp = NULL; + } + DBUG_RETURN(0); +} + +bool spider_db_oracle::set_trx_isolation_in_bulk_sql() +{ + DBUG_ENTER("spider_db_oracle::set_trx_isolation_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_oracle::set_trx_isolation( + int trx_isolation, + int *need_mon +) { + DBUG_ENTER("spider_db_oracle::set_trx_isolation"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (trx_isolation) + { + case ISO_READ_UNCOMMITTED: + case ISO_READ_COMMITTED: + if (conn->in_before_query) + { + DBUG_RETURN(exec_query(SPIDER_SQL_ISO_READ_COMMITTED_STR, + SPIDER_SQL_ISO_READ_COMMITTED_LEN, -1)); + } + if (spider_db_query( + conn, + SPIDER_SQL_ISO_READ_COMMITTED_STR, + SPIDER_SQL_ISO_READ_COMMITTED_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + break; + case ISO_REPEATABLE_READ: + case ISO_SERIALIZABLE: + if (conn->in_before_query) + { + DBUG_RETURN(exec_query(SPIDER_SQL_ISO_SERIALIZABLE_STR, + SPIDER_SQL_ISO_SERIALIZABLE_LEN, -1)); + } + if (spider_db_query( + conn, + SPIDER_SQL_ISO_SERIALIZABLE_STR, + SPIDER_SQL_ISO_SERIALIZABLE_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + break; + default: + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } + DBUG_RETURN(0); +} + +bool spider_db_oracle::set_autocommit_in_bulk_sql() +{ + DBUG_ENTER("spider_db_oracle::set_autocommit_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_oracle::set_autocommit( + bool autocommit, + int *need_mon +) { + DBUG_ENTER("spider_db_oracle::set_autocommit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (autocommit) + { + if (conn->in_before_query) + { + DBUG_RETURN(exec_query(SPIDER_SQL_AUTOCOMMIT_ON_STR, + SPIDER_SQL_AUTOCOMMIT_ON_LEN, -1)); + } + if (spider_db_query( + conn, + SPIDER_SQL_AUTOCOMMIT_ON_STR, + SPIDER_SQL_AUTOCOMMIT_ON_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } else { + if (conn->in_before_query) + { + DBUG_RETURN(exec_query(SPIDER_SQL_AUTOCOMMIT_OFF_STR, + SPIDER_SQL_AUTOCOMMIT_OFF_LEN, -1)); + } + if (spider_db_query( + conn, + SPIDER_SQL_AUTOCOMMIT_OFF_STR, + SPIDER_SQL_AUTOCOMMIT_OFF_LEN, + -1, + need_mon) + ) + DBUG_RETURN(spider_db_errorno(conn)); + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + DBUG_RETURN(0); +} + +bool spider_db_oracle::set_sql_log_off_in_bulk_sql() +{ + DBUG_ENTER("spider_db_oracle::set_sql_log_off_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_oracle::set_sql_log_off( + bool sql_log_off, + int *need_mon +) { + DBUG_ENTER("spider_db_oracle::set_sql_log_off"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +bool spider_db_oracle::set_time_zone_in_bulk_sql() +{ + DBUG_ENTER("spider_db_oracle::set_time_zone_in_bulk_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_db_oracle::set_time_zone( + Time_zone *time_zone, + int *need_mon +) { + DBUG_ENTER("spider_db_oracle::set_time_zone"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int spider_db_oracle::append_sql( + char *sql, + ulong sql_length, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_oracle::append_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_oracle::append_open_handler( + uint handler_id, + const char *db_name, + const char *table_name, + const char *index_name, + const char *sql, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_oracle::append_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_oracle::append_select( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_oracle::append_select"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_oracle::append_insert( + uint handler_id, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_oracle::append_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_oracle::append_update( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + int limit, + int skip, + bool increment, + bool decrement, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_oracle::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_oracle::append_delete( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_oracle::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +void spider_db_oracle::reset_request_queue() +{ + DBUG_ENTER("spider_db_oracle::reset_request_queue"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} +#endif + +size_t spider_db_oracle::escape_string( + char *to, + const char *from, + size_t from_length +) { + DBUG_ENTER("spider_db_oracle::escape_string"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(util.escape_string(to, from, from_length, conn->access_charset)); +} + +bool spider_db_oracle::have_lock_table_list() +{ + DBUG_ENTER("spider_db_oracle::have_lock_table_list"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(lock_table_hash.records); +} + +int spider_db_oracle::append_lock_tables( + spider_string *str +) { + int error_num; + ha_spider *tmp_spider; + int lock_type; + uint conn_link_idx; + int tmp_link_idx; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash; + const char *db_name; + uint db_name_length; + CHARSET_INFO *db_name_charset; + const char *table_name; + uint table_name_length; + CHARSET_INFO *table_name_charset; + DBUG_ENTER("spider_db_oracle::lock_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((tmp_link_for_hash = + (SPIDER_LINK_FOR_HASH *) my_hash_element(&lock_table_hash, 0))) + { + if ((error_num = spider_db_oracle_utility.append_lock_table_head(str))) + { + DBUG_RETURN(error_num); + } + + tmp_spider = tmp_link_for_hash->spider; + tmp_link_idx = tmp_link_for_hash->link_idx; + switch (tmp_spider->lock_type) + { + case TL_READ: + lock_type = SPIDER_DB_TABLE_LOCK_READ_LOCAL; + break; + case TL_READ_NO_INSERT: + lock_type = SPIDER_DB_TABLE_LOCK_READ; + break; + case TL_WRITE_LOW_PRIORITY: + lock_type = SPIDER_DB_TABLE_LOCK_LOW_PRIORITY_WRITE; + break; + case TL_WRITE: + lock_type = SPIDER_DB_TABLE_LOCK_WRITE; + break; + default: + // no lock + DBUG_PRINT("info",("spider lock_type=%d", tmp_spider->lock_type)); + DBUG_RETURN(0); + } + conn_link_idx = tmp_spider->conn_link_idx[tmp_link_idx]; + spider_oracle_share *db_share = (spider_oracle_share *) + tmp_spider->share->dbton_share[conn->dbton_id]; + if (&db_share->db_names_str[conn_link_idx]) + { + db_name = db_share->db_names_str[conn_link_idx].ptr(); + db_name_length = db_share->db_names_str[conn_link_idx].length(); + db_name_charset = tmp_spider->share->access_charset; + } else { + db_name = tmp_spider->share->tgt_dbs[conn_link_idx]; + db_name_length = tmp_spider->share->tgt_dbs_lengths[conn_link_idx]; + db_name_charset = system_charset_info; + } + if (&db_share->table_names_str[conn_link_idx]) + { + table_name = db_share->table_names_str[conn_link_idx].ptr(); + table_name_length = db_share->table_names_str[conn_link_idx].length(); + table_name_charset = tmp_spider->share->access_charset; + } else { + table_name = tmp_spider->share->tgt_table_names[conn_link_idx]; + table_name_length = + tmp_spider->share->tgt_table_names_lengths[conn_link_idx]; + table_name_charset = system_charset_info; + } + if ((error_num = spider_db_oracle_utility. + append_lock_table_body( + str, + db_name, + db_name_length, + db_name_charset, + table_name, + table_name_length, + table_name_charset, + lock_type + ) + )) { + my_hash_reset(&lock_table_hash); + DBUG_RETURN(error_num); + } +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&lock_table_hash, + tmp_link_for_hash->db_table_str_hash_value, (uchar*) tmp_link_for_hash); +#else + my_hash_delete(&lock_table_hash, (uchar*) tmp_link_for_hash); +#endif + + if ((error_num = spider_db_oracle_utility.append_lock_table_tail(str))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int spider_db_oracle::append_unlock_tables( + spider_string *str +) { + int error_num; + DBUG_ENTER("spider_db_oracle::append_unlock_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = spider_db_oracle_utility.append_unlock_table(str))) + { + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +uint spider_db_oracle::get_lock_table_hash_count() +{ + DBUG_ENTER("spider_db_oracle::get_lock_table_hash_count"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(lock_table_hash.records); +} + +void spider_db_oracle::reset_lock_table_hash() +{ + DBUG_ENTER("spider_db_oracle::reset_lock_table_hash"); + DBUG_PRINT("info",("spider this=%p", this)); + my_hash_reset(&lock_table_hash); + DBUG_VOID_RETURN; +} + +uint spider_db_oracle::get_opened_handler_count() +{ + DBUG_ENTER("spider_db_oracle::get_opened_handler_count"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(handler_open_array.elements); +} + +void spider_db_oracle::reset_opened_handler() +{ + ha_spider *tmp_spider; + int tmp_link_idx; + SPIDER_LINK_FOR_HASH **tmp_link_for_hash; + DBUG_ENTER("spider_db_oracle::reset_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + while ((tmp_link_for_hash = + (SPIDER_LINK_FOR_HASH **) pop_dynamic(&handler_open_array))) + { + tmp_spider = (*tmp_link_for_hash)->spider; + tmp_link_idx = (*tmp_link_for_hash)->link_idx; + tmp_spider->clear_handler_opened(tmp_link_idx, conn->conn_kind); + } + DBUG_VOID_RETURN; +} + +void spider_db_oracle::set_dup_key_idx( + ha_spider *spider, + int link_idx +) { + TABLE *table = spider->get_table(); + uint roop_count, pk_idx = table->s->primary_key; + int key_name_length; + int max_length = 0; + char *key_name, *tmp_pos; + char buf[SPIDER_ORACLE_ERR_BUF_LEN]; + DBUG_ENTER("spider_db_oracle::set_dup_key_idx"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider error_str=%s", stored_error_msg)); + memcpy(buf, spider->share->tgt_dbs[link_idx], + spider->share->tgt_dbs_lengths[link_idx]); + tmp_pos = buf + spider->share->tgt_dbs_lengths[link_idx]; + *tmp_pos = '.'; + ++tmp_pos; + for (roop_count = 0; roop_count < table->s->keys; roop_count++) + { + if (roop_count == pk_idx) + { + DBUG_PRINT("info",("spider pk_idx=%u", roop_count)); + int all_link_idx = spider->conn_link_idx[link_idx]; + key_name = spider->share->tgt_pk_names[all_link_idx]; + key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx]; + } else { + key_name = table->s->key_info[roop_count].name; + key_name_length = strlen(key_name); + } + memcpy(tmp_pos, key_name, key_name_length + 1); + DBUG_PRINT("info",("spider key_name=%s", key_name)); + DBUG_PRINT("info",("spider full key name=%s", buf)); + if ( + max_length < key_name_length && + strcasestr(stored_error_msg, buf) + ) { + max_length = key_name_length; + spider->dup_key_idx = roop_count; + } + } + if (max_length == 0) + spider->dup_key_idx = (uint) -1; + DBUG_PRINT("info",("spider dup_key_idx=%d", spider->dup_key_idx)); + DBUG_VOID_RETURN; +} + +bool spider_db_oracle::cmp_request_key_to_snd( + st_spider_db_request_key *request_key +) { + DBUG_ENTER("spider_db_oracle::cmp_request_key_to_snd"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(TRUE); +} + +int spider_db_oracle::set_error( + sword res, + dvoid *hndlp, + int error_num, + const char *error1, + const char *error2 +) { + DBUG_ENTER("spider_db_oracle::set_error"); + DBUG_PRINT("info",("spider this=%p", this)); + stored_error_num = + spider_db_oracle_get_error(res, hndlp, error_num, error1, error2, + conn->access_charset, stored_error_msg); + if (stored_error_num) + stored_error = ER_SPIDER_ORACLE_ERR; + else + stored_error = ""; + DBUG_RETURN(stored_error_num); +} + +spider_db_oracle_util::spider_db_oracle_util() : spider_db_util() +{ + DBUG_ENTER("spider_db_oracle_util::spider_db_oracle_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_oracle_util::~spider_db_oracle_util() +{ + DBUG_ENTER("spider_db_oracle_util::~spider_db_oracle_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_oracle_util::append_name( + spider_string *str, + const char *name, + uint name_length +) { + DBUG_ENTER("spider_db_oracle_util::append_name"); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(name, name_length); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_name_with_charset( + spider_string *str, + const char *name, + uint name_length, + CHARSET_INFO *name_charset +) { + DBUG_ENTER("spider_db_oracle_util::append_name_with_charset"); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->append(name, name_length, name_charset); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + DBUG_RETURN(0); +} + +bool spider_db_oracle_util::is_name_quote( + const char head_code +) { + DBUG_ENTER("spider_db_oracle_util::is_name_quote"); + DBUG_RETURN(head_code == *name_quote_str); +} + +int spider_db_oracle_util::append_escaped_name_quote( + spider_string *str +) { + DBUG_ENTER("spider_db_oracle_util::append_escaped_name_quote"); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_column_value( + ha_spider *spider, + spider_string *str, + Field *field, + const uchar *new_ptr, + CHARSET_INFO *access_charset +) { + char buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin); + String *ptr; + uint length; + DBUG_ENTER("spider_db_oracle_util::append_column_value"); + tmp_str.init_calc_mem(181); + + if (new_ptr) + { + if ( + field->type() == MYSQL_TYPE_BLOB || + field->real_type() == MYSQL_TYPE_VARCHAR + ) { + length = uint2korr(new_ptr); + tmp_str.set_quick((char *) new_ptr + HA_KEY_BLOB_LENGTH, length, + &my_charset_bin); + ptr = tmp_str.get_str(); + } else if (field->type() == MYSQL_TYPE_GEOMETRY) + { +/* + uint mlength = SIZEOF_STORED_DOUBLE, lcnt; + uchar *dest = (uchar *) buf; + const uchar *source; + for (lcnt = 0; lcnt < 4; lcnt++) + { + mlength = SIZEOF_STORED_DOUBLE; + source = new_ptr + mlength + SIZEOF_STORED_DOUBLE * lcnt; + while (mlength--) + *dest++ = *--source; + } + tmp_str.length(SIZEOF_STORED_DOUBLE * lcnt); +*/ + double xmin, xmax, ymin, ymax; +/* + float8store(buf,xmin); + float8store(buf+8,xmax); + float8store(buf+16,ymin); + float8store(buf+24,ymax); + memcpy(&xmin,new_ptr,sizeof(xmin)); + memcpy(&xmax,new_ptr + 8,sizeof(xmax)); + memcpy(&ymin,new_ptr + 16,sizeof(ymin)); + memcpy(&ymax,new_ptr + 24,sizeof(ymax)); + float8get(xmin, buf); + float8get(xmax, buf + 8); + float8get(ymin, buf + 16); + float8get(ymax, buf + 24); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + DBUG_PRINT("info", ("spider geo is %.14g %.14g %.14g %.14g", + xmin, xmax, ymin, ymax)); +*/ + float8get(xmin, new_ptr); + float8get(xmax, new_ptr + 8); + float8get(ymin, new_ptr + 16); + float8get(ymax, new_ptr + 24); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); +/* + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 4); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 5); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 6); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 7); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 8); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 9); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 10); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 11); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); + float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 12); + float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 13); + float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 14); + float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 15); + DBUG_PRINT("info", ("spider geo is %f %f %f %f", + xmin, xmax, ymin, ymax)); +*/ +/* + tmp_str.set_quick((char *) new_ptr, SIZEOF_STORED_DOUBLE * 4, + &my_charset_bin); +*/ + tmp_str.length(0); + tmp_str.q_append((char *) SPIDER_SQL_LINESTRING_HEAD_STR, + SPIDER_SQL_LINESTRING_HEAD_LEN); + tmp_str.q_append((char *) new_ptr, SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 2, + SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE, + SIZEOF_STORED_DOUBLE); + tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 3, + SIZEOF_STORED_DOUBLE); + ptr = tmp_str.get_str(); + } else { + ptr = field->val_str(tmp_str.get_str(), new_ptr); + tmp_str.mem_calc(); + } + } else { + ptr = field->val_str(tmp_str.get_str()); + tmp_str.mem_calc(); + } + DBUG_PRINT("info", ("spider field->type() is %d", field->type())); + DBUG_PRINT("info", ("spider ptr->length() is %d", ptr->length())); +/* + if ( + field->type() == MYSQL_TYPE_BIT || + (field->type() >= MYSQL_TYPE_TINY_BLOB && + field->type() <= MYSQL_TYPE_BLOB) + ) { + uchar *hex_ptr = (uchar *) ptr->ptr(), *end_ptr; + char *str_ptr; + DBUG_PRINT("info", ("spider HEX")); + if (str->reserve(SPIDER_SQL_HEX_LEN + ptr->length() * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HEX_STR, SPIDER_SQL_HEX_LEN); + str_ptr = (char *) str->ptr() + str->length(); + for (end_ptr = hex_ptr + ptr->length(); hex_ptr < end_ptr; hex_ptr++) + { + *str_ptr++ = spider_dig_upper[(*hex_ptr) >> 4]; + *str_ptr++ = spider_dig_upper[(*hex_ptr) & 0x0F]; + } + str->length(str->length() + ptr->length() * 2); + } else +*/ + if (field->result_type() == STRING_RESULT) + { + DBUG_PRINT("info", ("spider STRING_RESULT")); + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if ( + field->type() == MYSQL_TYPE_VARCHAR || + (field->type() >= MYSQL_TYPE_ENUM && + field->type() <= MYSQL_TYPE_GEOMETRY) + ) { + DBUG_PRINT("info", ("spider append_escaped")); + char buf2[MAX_FIELD_WIDTH]; + spider_string tmp_str2(buf2, MAX_FIELD_WIDTH, access_charset); + tmp_str2.init_calc_mem(182); + tmp_str2.length(0); + if ( + tmp_str2.append(ptr->ptr(), ptr->length(), field->charset()) || + str->reserve(tmp_str2.length() * 2) || + append_escaped_util(str, tmp_str2.get_str()) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } else if (str->append(*ptr)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } else if (field->str_needs_quotes()) + { + if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + ptr->length() * 2 + 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + append_escaped_util(str, ptr); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } else if (str->append(*ptr)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_from_with_alias( + spider_string *str, + const char **table_names, + uint *table_name_lengths, + const char **table_aliases, + uint *table_alias_lengths, + uint table_count, + int *table_name_pos, + bool over_write +) { + uint roop_count, length = 0; + DBUG_ENTER("spider_db_oracle_util::append_from_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!over_write) + { + for (roop_count = 0; roop_count < table_count; roop_count++) + length += table_name_lengths[roop_count] + SPIDER_SQL_SPACE_LEN + + table_alias_lengths[roop_count] + SPIDER_SQL_COMMA_LEN; + if (str->reserve(SPIDER_SQL_FROM_LEN + length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + *table_name_pos = str->length(); + } + for (roop_count = 0; roop_count < table_count; roop_count++) + { + str->q_append(table_names[roop_count], table_name_lengths[roop_count]); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + str->q_append(table_aliases[roop_count], table_alias_lengths[roop_count]); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_trx_isolation( + spider_string *str, + int trx_isolation +) { + DBUG_ENTER("spider_db_oracle_util::append_trx_isolation"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + + SPIDER_SQL_ISO_READ_COMMITTED_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + switch (trx_isolation) + { + case ISO_READ_UNCOMMITTED: + case ISO_READ_COMMITTED: + str->q_append(SPIDER_SQL_ISO_READ_COMMITTED_STR, + SPIDER_SQL_ISO_READ_COMMITTED_LEN); + break; + case ISO_REPEATABLE_READ: + case ISO_SERIALIZABLE: + str->q_append(SPIDER_SQL_ISO_SERIALIZABLE_STR, + SPIDER_SQL_ISO_SERIALIZABLE_LEN); + break; + default: + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_autocommit( + spider_string *str, + bool autocommit +) { + DBUG_ENTER("spider_db_oracle_util::append_autocommit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_AUTOCOMMIT_OFF_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + if (autocommit) + { + str->q_append(SPIDER_SQL_AUTOCOMMIT_ON_STR, + SPIDER_SQL_AUTOCOMMIT_ON_LEN); + } else { + str->q_append(SPIDER_SQL_AUTOCOMMIT_OFF_STR, + SPIDER_SQL_AUTOCOMMIT_OFF_LEN); + } + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_sql_log_off( + spider_string *str, + bool sql_log_off +) { + DBUG_ENTER("spider_db_oracle_util::append_sql_log_off"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_time_zone( + spider_string *str, + Time_zone *time_zone +) { + DBUG_ENTER("spider_db_oracle_util::append_time_zone"); + DBUG_PRINT("info",("spider this=%p", this)); + /* nothing to do */ + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_start_transaction( + spider_string *str +) { + DBUG_ENTER("spider_db_oracle_util::append_start_transaction"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + + SPIDER_SQL_START_TRANSACTION_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + str->q_append(SPIDER_SQL_START_TRANSACTION_STR, + SPIDER_SQL_START_TRANSACTION_LEN); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_xa_start( + spider_string *str, + XID *xid +) { + DBUG_ENTER("spider_db_oracle_util::append_xa_start"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_lock_table_head( + spider_string *str +) { + DBUG_ENTER("spider_db_oracle_util::append_lock_table_head"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_lock_table_body( + spider_string *str, + const char *db_name, + uint db_name_length, + CHARSET_INFO *db_name_charset, + const char *table_name, + uint table_name_length, + CHARSET_INFO *table_name_charset, + int lock_type +) { + DBUG_ENTER("spider_db_oracle_util::append_lock_table_body"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_LOCK_TABLE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (str->length()) + { + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + str->q_append(SPIDER_SQL_LOCK_TABLE_STR, SPIDER_SQL_LOCK_TABLE_LEN); + if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ( + str->append(db_name, db_name_length, db_name_charset) || + str->reserve((SPIDER_SQL_NAME_QUOTE_LEN) * 2 + SPIDER_SQL_DOT_LEN) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ( + str->append(table_name, table_name_length, table_name_charset) || + str->reserve(SPIDER_SQL_NAME_QUOTE_LEN + + spider_db_table_lock_len[lock_type]) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(spider_db_table_lock_str[lock_type], + spider_db_table_lock_len[lock_type]); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_lock_table_tail( + spider_string *str +) { + DBUG_ENTER("spider_db_oracle_util::append_lock_table_tail"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::append_unlock_table( + spider_string *str +) { + DBUG_ENTER("spider_db_oracle_util::append_unlock_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_COMMIT_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_COMMIT_STR, SPIDER_SQL_COMMIT_LEN); + DBUG_RETURN(0); +} + +int spider_db_oracle_util::open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length +) { + uint dbton_id = spider_dbton_oracle.dbton_id; + int error_num; + Item *item, **item_list = item_func->arguments(); + uint roop_count, item_count = item_func->argument_count(), start_item = 0; + const char *func_name = SPIDER_SQL_NULL_CHAR_STR, + *separete_str = SPIDER_SQL_NULL_CHAR_STR, + *last_str = SPIDER_SQL_NULL_CHAR_STR; + int func_name_length = SPIDER_SQL_NULL_CHAR_LEN, + separete_str_length = SPIDER_SQL_NULL_CHAR_LEN, + last_str_length = SPIDER_SQL_NULL_CHAR_LEN; + int use_pushdown_udf; + DBUG_ENTER("spider_db_oracle_util::open_item_func"); + if (str) + { + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + DBUG_PRINT("info",("spider functype = %d", item_func->functype())); + switch (item_func->functype()) + { + case Item_func::ISNULL_FUNC: + last_str = SPIDER_SQL_IS_NULL_STR; + last_str_length = SPIDER_SQL_IS_NULL_LEN; + break; + case Item_func::ISNOTNULL_FUNC: + last_str = SPIDER_SQL_IS_NOT_NULL_STR; + last_str_length = SPIDER_SQL_IS_NOT_NULL_LEN; + break; + case Item_func::UNKNOWN_FUNC: + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (func_name_length == 1 && + ( + !strncasecmp("+", func_name, func_name_length) || + !strncasecmp("-", func_name, func_name_length) || + !strncasecmp("*", func_name, func_name_length) || + !strncasecmp("/", func_name, func_name_length) || + !strncasecmp("%", func_name, func_name_length) || + !strncasecmp("&", func_name, func_name_length) || + !strncasecmp("|", func_name, func_name_length) || + !strncasecmp("^", func_name, func_name_length) + ) + ) { + /* no action */ + break; + } else if (func_name_length == 2 && + ( + !strncasecmp("<<", func_name, func_name_length) || + !strncasecmp(">>", func_name, func_name_length) + ) + ) { + /* no action */ + break; + } else if (func_name_length == 3 && + !strncasecmp("div", func_name, func_name_length) + ) { + /* no action */ + break; + } else if (func_name_length == 4) + { + if ( + !strncasecmp("rand", func_name, func_name_length) && + !item_func->arg_count + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if ( + !strncasecmp("case", func_name, func_name_length) + ) { +#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC + Item_func_case *item_func_case = (Item_func_case *) item_func; + if (str) + { + if (str->reserve(SPIDER_SQL_CASE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN); + } + if (item_func_case->first_expr_num != -1) + { + if ((error_num = spider_db_print_item_type( + item_list[item_func_case->first_expr_num], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + for (roop_count = 0; roop_count < item_func_case->ncases; + roop_count += 2) + { + if (str) + { + if (str->reserve(SPIDER_SQL_WHEN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[roop_count], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_THEN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[roop_count + 1], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (item_func_case->else_expr_num != -1) + { + if (str) + { + if (str->reserve(SPIDER_SQL_ELSE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[item_func_case->else_expr_num], spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +#else + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); +#endif + } + } else if (func_name_length == 6 && + !strncasecmp("istrue", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_TRUE_STR; + last_str_length = SPIDER_SQL_IS_TRUE_LEN; + break; + } else if (func_name_length == 7) + { + if (!strncasecmp("isfalse", func_name, func_name_length)) + { + last_str = SPIDER_SQL_IS_FALSE_STR; + last_str_length = SPIDER_SQL_IS_FALSE_LEN; + break; + } else if ( + !strncasecmp("sysdate", func_name, func_name_length) || + !strncasecmp("curdate", func_name, func_name_length) || + !strncasecmp("curtime", func_name, func_name_length) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if ( + !strncasecmp("convert", func_name, func_name_length) + ) { + if (str) + { + if (str->reserve(func_name_length * 2 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, + SPIDER_SQL_OPEN_PAREN_LEN); + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } + } else if (func_name_length == 8 && + ( + !strncasecmp("utc_date", func_name, func_name_length) || + !strncasecmp("utc_time", func_name, func_name_length) + ) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if (func_name_length == 9 && + !strncasecmp("isnottrue", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_NOT_TRUE_STR; + last_str_length = SPIDER_SQL_IS_NOT_TRUE_LEN; + break; + } else if (func_name_length == 10 && + !strncasecmp("isnotfalse", func_name, func_name_length) + ) { + last_str = SPIDER_SQL_IS_NOT_FALSE_STR; + last_str_length = SPIDER_SQL_IS_NOT_FALSE_LEN; + break; + } else if (func_name_length == 12) + { + if (!strncasecmp("cast_as_date", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_DATE_STR; + last_str_length = SPIDER_SQL_AS_DATE_LEN; + break; + } else if (!strncasecmp("cast_as_time", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_TIME_STR; + last_str_length = SPIDER_SQL_AS_TIME_LEN; + break; + } + } else if (func_name_length == 13 && + !strncasecmp("utc_timestamp", func_name, func_name_length) + ) { + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + } else if (func_name_length == 14) + { + if (!strncasecmp("cast_as_binary", func_name, func_name_length)) + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(123); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_BINARY_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } else if (!strncasecmp("cast_as_signed", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_SIGNED_STR; + last_str_length = SPIDER_SQL_AS_SIGNED_LEN; + break; + } + } else if (func_name_length == 16) + { + if (!strncasecmp("cast_as_unsigned", func_name, func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_UNSIGNED_STR; + last_str_length = SPIDER_SQL_AS_UNSIGNED_LEN; + break; + } else if (!strncasecmp("decimal_typecast", func_name, + func_name_length)) + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(124); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_DECIMAL_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + } else if (!strncasecmp("cast_as_datetime", func_name, + func_name_length)) + { + if (str) + { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); + } + last_str = SPIDER_SQL_AS_DATETIME_STR; + last_str_length = SPIDER_SQL_AS_DATETIME_LEN; + break; + } + } else if (func_name_length == 17) + { + if (!strncasecmp("date_add_interval", func_name, func_name_length)) + { + Item_date_add_interval *item_date_add_interval = + (Item_date_add_interval *) item_func; + switch (item_date_add_interval->int_type) + { + case INTERVAL_YEAR: + case INTERVAL_QUARTER: + case INTERVAL_MONTH: + if (str) + { + if (str->reserve(SPIDER_SQL_ADD_MONTHS_LEN + + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ADD_MONTHS_STR, + SPIDER_SQL_ADD_MONTHS_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, + SPIDER_SQL_OPEN_PAREN_LEN); + } + if ((error_num = spider_db_print_item_type(item_list[0], spider, + str, alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (item_date_add_interval->date_sub_interval) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN + + SPIDER_SQL_MINUS_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->q_append(SPIDER_SQL_MINUS_STR, SPIDER_SQL_MINUS_LEN); + } else { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if ((error_num = spider_db_print_item_type(item_list[1], spider, + str, alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (item_date_add_interval->int_type == INTERVAL_YEAR) + { + func_name = " * 12"; + func_name_length = sizeof(" * 12") - 1; + if (str->reserve(func_name_length + + (SPIDER_SQL_CLOSE_PAREN_LEN * 2))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } else if (item_date_add_interval->int_type == + INTERVAL_QUARTER) + { + func_name = " * 3"; + func_name_length = sizeof(" * 3") - 1; + if (str->reserve(func_name_length + + (SPIDER_SQL_CLOSE_PAREN_LEN * 2))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } else { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + } + break; + case INTERVAL_WEEK: + case INTERVAL_DAY: + case INTERVAL_HOUR: + case INTERVAL_MINUTE: + case INTERVAL_SECOND: + case INTERVAL_MICROSECOND: + if ((error_num = spider_db_print_item_type(item_list[0], spider, + str, alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (item_date_add_interval->date_sub_interval) + { + if (str->reserve(SPIDER_SQL_MINUS_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MINUS_STR, SPIDER_SQL_MINUS_LEN); + } else { + if (str->reserve(SPIDER_SQL_PLUS_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_PLUS_STR, SPIDER_SQL_PLUS_LEN); + } + } + if ((error_num = spider_db_print_item_type(item_list[1], spider, + str, alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (item_date_add_interval->int_type == INTERVAL_WEEK) + { + func_name = " * 7"; + func_name_length = sizeof(" * 7") - 1; + if (str->reserve(func_name_length + + (SPIDER_SQL_CLOSE_PAREN_LEN))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } else if (item_date_add_interval->int_type == INTERVAL_HOUR) + { + func_name = " / 24"; + func_name_length = sizeof(" / 24") - 1; + if (str->reserve(func_name_length + + (SPIDER_SQL_CLOSE_PAREN_LEN))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } else if (item_date_add_interval->int_type == INTERVAL_MINUTE) + { + func_name = " / 1440"; + func_name_length = sizeof(" / 1440") - 1; + if (str->reserve(func_name_length + + (SPIDER_SQL_CLOSE_PAREN_LEN))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } else if (item_date_add_interval->int_type == INTERVAL_SECOND) + { + func_name = " / 86400"; + func_name_length = sizeof(" / 86400") - 1; + if (str->reserve(func_name_length + + (SPIDER_SQL_CLOSE_PAREN_LEN))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } else if (item_date_add_interval->int_type == + INTERVAL_MICROSECOND) + { + func_name = " / 86400000000"; + func_name_length = sizeof(" / 86400000000") - 1; + if (str->reserve(func_name_length + + (SPIDER_SQL_CLOSE_PAREN_LEN))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } else { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + } + break; + default: + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + } + DBUG_RETURN(0); + break; + } + } + if (str) + { + if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::NOW_FUNC: + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::CHAR_TYPECAST_FUNC: + { + if (str) + { + char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; + spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); + tmp_str.init_calc_mem(125); + tmp_str.length(0); + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (str->reserve(SPIDER_SQL_CAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); +#if MYSQL_VERSION_ID < 50500 + item_func->print(tmp_str.get_str(), QT_IS); +#else + item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); +#endif + tmp_str.mem_calc(); + if (tmp_str.reserve(1)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_ptr = tmp_str.c_ptr_quick(); + DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); + while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_CHAR_STR))) + tmp_ptr = tmp_ptr2 + 1; + last_str = tmp_ptr - 1; + last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; + } + } + break; + case Item_func::NOT_FUNC: + case Item_func::NEG_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + break; + case Item_func::IN_FUNC: + if (((Item_func_opt_neg *) item_func)->negated) + { + func_name = SPIDER_SQL_NOT_IN_STR; + func_name_length = SPIDER_SQL_NOT_IN_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } else { + func_name = SPIDER_SQL_IN_STR; + func_name_length = SPIDER_SQL_IN_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + } + break; + case Item_func::BETWEEN: + if (((Item_func_opt_neg *) item_func)->negated) + { + func_name = SPIDER_SQL_NOT_BETWEEN_STR; + func_name_length = SPIDER_SQL_NOT_BETWEEN_LEN; + separete_str = SPIDER_SQL_AND_STR; + separete_str_length = SPIDER_SQL_AND_LEN; + } else { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + separete_str = SPIDER_SQL_AND_STR; + separete_str_length = SPIDER_SQL_AND_LEN; + } + break; + case Item_func::UDF_FUNC: + use_pushdown_udf = spider_param_use_pushdown_udf(spider->trx->thd, + spider->share->use_pushdown_udf); + if (!use_pushdown_udf) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; +#ifdef MARIADB_BASE_VERSION + case Item_func::XOR_FUNC: +#else + case Item_func::COND_XOR_FUNC: +#endif + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN( + spider_db_open_item_cond((Item_cond *) item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::TRIG_COND_FUNC: + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + case Item_func::GUSERVAR_FUNC: + if (str) + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + if (item_func->result_type() == STRING_RESULT) + DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + alias, alias_length, dbton_id)); + else + DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + alias, alias_length, dbton_id)); + case Item_func::FT_FUNC: + if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + start_item = 1; + if (str) + { + if (str->reserve(SPIDER_SQL_MATCH_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); + } + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::SP_EQUALS_FUNC: + if (str) + { + func_name = SPIDER_SQL_MBR_EQUAL_STR; + func_name_length = SPIDER_SQL_MBR_EQUAL_LEN; + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(func_name_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::SP_DISJOINT_FUNC: + case Item_func::SP_INTERSECTS_FUNC: + case Item_func::SP_TOUCHES_FUNC: + case Item_func::SP_CROSSES_FUNC: + case Item_func::SP_WITHIN_FUNC: + case Item_func::SP_CONTAINS_FUNC: + case Item_func::SP_OVERLAPS_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + if (str->reserve(SPIDER_SQL_MBR_LEN + func_name_length + + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + func_name = SPIDER_SQL_COMMA_STR; + func_name_length = SPIDER_SQL_COMMA_LEN; + separete_str = SPIDER_SQL_COMMA_STR; + separete_str_length = SPIDER_SQL_COMMA_LEN; + last_str = SPIDER_SQL_CLOSE_PAREN_STR; + last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; + break; + case Item_func::EQ_FUNC: + case Item_func::EQUAL_FUNC: + case Item_func::NE_FUNC: + case Item_func::LT_FUNC: + case Item_func::LE_FUNC: + case Item_func::GE_FUNC: + case Item_func::GT_FUNC: + case Item_func::LIKE_FUNC: + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + } + break; + default: + THD *thd = spider->trx->thd; + SPIDER_SHARE *share = spider->share; + if (spider_param_skip_default_condition(thd, + share->skip_default_condition)) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (str) + { + func_name = (char*) item_func->func_name(); + func_name_length = strlen(func_name); + } + break; + } + DBUG_PRINT("info",("spider func_name = %s", func_name)); + DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); + DBUG_PRINT("info",("spider separete_str = %s", separete_str)); + DBUG_PRINT("info",("spider separete_str_length = %d", separete_str_length)); + DBUG_PRINT("info",("spider last_str = %s", last_str)); + DBUG_PRINT("info",("spider last_str_length = %d", last_str_length)); + if (item_count) + { + item_count--; + for (roop_count = start_item; roop_count < item_count; roop_count++) + { + item = item_list[roop_count]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (roop_count == 1) + { + func_name = separete_str; + func_name_length = separete_str_length; + } + if (str) + { + if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN * 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + str->q_append(func_name, func_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + } + item = item_list[roop_count]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + } + if (item_func->functype() == Item_func::FT_FUNC) + { + Item_func_match *item_func_match = (Item_func_match *)item_func; + if (str) + { + if (str->reserve(SPIDER_SQL_AGAINST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); + } + item = item_list[0]; + if ((error_num = spider_db_print_item_type(item, spider, str, + alias, alias_length, dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve( + ((item_func_match->flags & FT_BOOL) ? + SPIDER_SQL_IN_BOOLEAN_MODE_LEN : 0) + + ((item_func_match->flags & FT_EXPAND) ? + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN : 0) + )) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (item_func_match->flags & FT_BOOL) + str->q_append(SPIDER_SQL_IN_BOOLEAN_MODE_STR, + SPIDER_SQL_IN_BOOLEAN_MODE_LEN); + if (item_func_match->flags & FT_EXPAND) + str->q_append(SPIDER_SQL_WITH_QUERY_EXPANSION_STR, + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN); + } + } else if (item_func->functype() == Item_func::UNKNOWN_FUNC) + { + if ( + func_name_length == 7 && + !strncasecmp("convert", func_name, func_name_length) + ) { + if (str) + { + Item_func_conv_charset *item_func_conv_charset = + (Item_func_conv_charset *)item_func; + CHARSET_INFO *conv_charset = item_func_conv_charset->conv_charset; + uint cset_length = strlen(conv_charset->csname); + if (str->reserve(SPIDER_SQL_USING_LEN + cset_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_USING_STR, SPIDER_SQL_USING_LEN); + str->q_append(conv_charset->csname, cset_length); + } + } + } + if (str) + { + if (str->reserve(last_str_length + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(last_str, last_str_length); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +} + +size_t spider_db_oracle_util::escape_string( + char *to, + const char *from, + size_t from_length, + CHARSET_INFO *access_charset +) { + DBUG_ENTER("spider_db_oracle::escape_string"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(escape_quotes_for_mysql(access_charset, to, 0, + from, from_length)); +} + +int spider_db_oracle_util::append_escaped_util( + spider_string *to, + String *from +) { + size_t copy_length; + DBUG_ENTER("spider_db_oracle_util::append_escaped_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider to=%s", to->c_ptr_safe())); + DBUG_PRINT("info",("spider from=%s", from->c_ptr_safe())); + copy_length = escape_string((char *) to->ptr() + to->length(), from->ptr(), + from->length(), to->charset()); + DBUG_PRINT("info",("spider copy_length=%zu", copy_length)); + to->length(to->length() + copy_length); + to->mem_calc(); + DBUG_RETURN(0); +} + +spider_oracle_share::spider_oracle_share( + st_spider_share *share +) : spider_db_share( + share +), + table_select(NULL), + table_select_pos(0), + key_select(NULL), + key_select_pos(NULL), + key_hint(NULL), + show_table_status(NULL), + show_records(NULL), + show_autoinc(NULL), + show_last_insert_id(NULL), + show_index(NULL), + table_names_str(NULL), + db_names_str(NULL), + db_table_str(NULL), + nextval_str(NULL), +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + db_table_str_hash_value(NULL), +#endif + table_nm_max_length(0), + db_nm_max_length(0), + nextval_max_length(0), + column_name_str(NULL), + same_db_table_name(TRUE), + first_all_link_idx(-1) +{ + DBUG_ENTER("spider_oracle_share::spider_oracle_share"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_alloc_calc_mem_init(mem_calc, 220); + spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); + DBUG_VOID_RETURN; +} + +spider_oracle_share::~spider_oracle_share() +{ + DBUG_ENTER("spider_oracle_share::~spider_oracle_share"); + DBUG_PRINT("info",("spider this=%p", this)); + if (table_select) + delete [] table_select; + if (key_select) + delete [] key_select; + if (key_hint) + delete [] key_hint; + free_show_table_status(); + free_show_records(); + free_show_autoinc(); + free_show_last_insert_id(); + free_show_index(); + free_column_name_str(); + free_table_names_str(); + if (key_select_pos) + { + spider_free(spider_current_trx, key_select_pos, MYF(0)); + } + spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); + DBUG_VOID_RETURN; +} + +int spider_oracle_share::init() +{ + int error_num; + uint roop_count; + TABLE_SHARE *table_share = spider_share->table_share; + uint keys = table_share ? table_share->keys : 0; + DBUG_ENTER("spider_oracle_share::init"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!(key_select_pos = (int *) + spider_bulk_alloc_mem(spider_current_trx, 221, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &key_select_pos, + sizeof(int) * keys, +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + &db_table_str_hash_value, + sizeof(my_hash_value_type) * spider_share->all_link_count, +#endif + NullS)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + if (keys > 0 && + !(key_hint = new spider_string[keys]) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + for (roop_count = 0; roop_count < keys; roop_count++) + { + key_hint[roop_count].init_calc_mem(190); + key_hint[roop_count].set_charset(spider_share->access_charset); + } + DBUG_PRINT("info",("spider key_hint=%p", key_hint)); + + if ( + !(table_select = new spider_string[1]) || + (keys > 0 && + !(key_select = new spider_string[keys]) + ) || + (error_num = create_table_names_str()) || + (table_share && + ( + (error_num = create_column_name_str()) || + (error_num = convert_key_hint_str()) || + (error_num = append_show_table_status()) || + (error_num = append_show_records()) || + (error_num = append_show_autoinc()) || + (error_num = append_show_last_insert_id()) || + (error_num = append_show_index()) + ) + ) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + table_select->init_calc_mem(191); + if (table_share && (error_num = append_table_select())) + DBUG_RETURN(error_num); + + for (roop_count = 0; roop_count < keys; roop_count++) + { + key_select[roop_count].init_calc_mem(192); + if ((error_num = append_key_select(roop_count))) + DBUG_RETURN(error_num); + } + + DBUG_RETURN(error_num); +} + +uint spider_oracle_share::get_column_name_length( + uint field_index +) { + DBUG_ENTER("spider_oracle_share::get_column_name_length"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(column_name_str[field_index].length()); +} + +int spider_oracle_share::append_column_name( + spider_string *str, + uint field_index +) { + int error_num; + DBUG_ENTER("spider_oracle_share::append_column_name"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = spider_db_oracle_utility.append_name(str, + column_name_str[field_index].ptr(), column_name_str[field_index].length()); + DBUG_RETURN(error_num); +} + +int spider_oracle_share::append_column_name_with_alias( + spider_string *str, + uint field_index, + const char *alias, + uint alias_length +) { + DBUG_ENTER("spider_oracle_share::append_column_name_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve( + alias_length + + column_name_str[field_index].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + append_column_name(str, field_index); + DBUG_RETURN(0); +} + +int spider_oracle_share::append_table_name( + spider_string *str, + int all_link_idx +) { + const char *db_nm = db_names_str[all_link_idx].ptr(); + uint db_nm_len = db_names_str[all_link_idx].length(); + const char *table_nm = table_names_str[all_link_idx].ptr(); + uint table_nm_len = table_names_str[all_link_idx].length(); + DBUG_ENTER("spider_oracle_share::append_table_name"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(db_nm_len + SPIDER_SQL_DOT_LEN + table_nm_len + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider_db_oracle_utility.append_name(str, db_nm, db_nm_len); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + spider_db_oracle_utility.append_name(str, table_nm, table_nm_len); + DBUG_RETURN(0); +} + +int spider_oracle_share::append_table_name_with_adjusting( + spider_string *str, + int all_link_idx +) { + const char *db_nm = db_names_str[all_link_idx].ptr(); + uint db_nm_len = db_names_str[all_link_idx].length(); + uint db_nm_max_len = db_nm_max_length; + const char *table_nm = table_names_str[all_link_idx].ptr(); + uint table_nm_len = table_names_str[all_link_idx].length(); + uint table_nm_max_len = table_nm_max_length; + DBUG_ENTER("spider_oracle_share::append_table_name_with_adjusting"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_db_oracle_utility.append_name(str, db_nm, db_nm_len); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + spider_db_oracle_utility.append_name(str, table_nm, table_nm_len); + uint length = + db_nm_max_len - db_nm_len + + table_nm_max_len - table_nm_len; + memset((char *) str->ptr() + str->length(), ' ', length); + str->length(str->length() + length); + DBUG_RETURN(0); +} + +int spider_oracle_share::append_from_with_adjusted_table_name( + spider_string *str, + int *table_name_pos +) { + const char *db_nm = db_names_str[0].ptr(); + uint db_nm_len = db_names_str[0].length(); + uint db_nm_max_len = db_nm_max_length; + const char *table_nm = table_names_str[0].ptr(); + uint table_nm_len = table_names_str[0].length(); + uint table_nm_max_len = table_nm_max_length; + DBUG_ENTER("spider_oracle_share::append_from_with_adjusted_table_name"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_FROM_LEN + db_nm_max_length + + SPIDER_SQL_DOT_LEN + table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + *table_name_pos = str->length(); + spider_db_oracle_utility.append_name(str, db_nm, db_nm_len); + str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + spider_db_oracle_utility.append_name(str, table_nm, table_nm_len); + uint length = + db_nm_max_len - db_nm_len + + table_nm_max_len - table_nm_len; + memset((char *) str->ptr() + str->length(), ' ', length); + str->length(str->length() + length); + DBUG_RETURN(0); +} + +int spider_oracle_share::create_table_names_str() +{ + int error_num, roop_count; + uint table_nm_len, db_nm_len; + spider_string *str, *first_tbl_nm_str, *first_db_nm_str, *first_db_tbl_str; + char *first_tbl_nm, *first_db_nm; + uint dbton_id = spider_dbton_oracle.dbton_id; + DBUG_ENTER("spider_oracle_share::create_table_names_str"); + table_names_str = NULL; + db_names_str = NULL; + db_table_str = NULL; + if ( + !(table_names_str = new spider_string[spider_share->all_link_count]) || + !(db_names_str = new spider_string[spider_share->all_link_count]) || + !(db_table_str = new spider_string[spider_share->all_link_count]) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + + same_db_table_name = TRUE; + first_tbl_nm = spider_share->tgt_table_names[0]; + first_db_nm = spider_share->tgt_dbs[0]; + table_nm_len = spider_share->tgt_table_names_lengths[0]; + db_nm_len = spider_share->tgt_dbs_lengths[0]; + first_tbl_nm_str = &table_names_str[0]; + first_db_nm_str = &db_names_str[0]; + first_db_tbl_str = &db_table_str[0]; + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + table_names_str[roop_count].init_calc_mem(193); + db_names_str[roop_count].init_calc_mem(194); + db_table_str[roop_count].init_calc_mem(195); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + if (first_all_link_idx == -1) + first_all_link_idx = roop_count; + + str = &table_names_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name && + spider_share->tgt_table_names_lengths[roop_count] == table_nm_len && + !memcmp(first_tbl_nm, spider_share->tgt_table_names[roop_count], + table_nm_len) + ) { + if (str->copy(*first_tbl_nm_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + spider_share->tgt_table_names[roop_count], dbton_id))) + goto error; + if (roop_count) + { + same_db_table_name = FALSE; + DBUG_PRINT("info", ("spider found different table name %s", + spider_share->tgt_table_names[roop_count])); + if (str->length() > table_nm_max_length) + table_nm_max_length = str->length(); + } else + table_nm_max_length = str->length(); + } + + str = &db_names_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name && + spider_share->tgt_dbs_lengths[roop_count] == db_nm_len && + !memcmp(first_db_nm, spider_share->tgt_dbs[roop_count], + db_nm_len) + ) { + if (str->copy(*first_db_nm_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + spider_share->tgt_dbs[roop_count], dbton_id))) + goto error; + if (roop_count) + { + same_db_table_name = FALSE; + DBUG_PRINT("info", ("spider found different db name %s", + spider_share->tgt_dbs[roop_count])); + if (str->length() > db_nm_max_length) + db_nm_max_length = str->length(); + } else + db_nm_max_length = str->length(); + } + + str = &db_table_str[roop_count]; + if ( + roop_count != 0 && + same_db_table_name + ) { + if (str->copy(*first_db_tbl_str)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + } else { + str->set_charset(spider_share->access_charset); + if ((error_num = append_table_name(str, roop_count))) + goto error; + } +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + db_table_str_hash_value[roop_count] = my_calc_hash( + &spider_open_connections, (uchar*) str->ptr(), str->length()); +#endif + } + DBUG_RETURN(0); + +error: + if (db_table_str) + { + delete [] db_table_str; + db_table_str = NULL; + } + if (db_names_str) + { + delete [] db_names_str; + db_names_str = NULL; + } + if (table_names_str) + { + delete [] table_names_str; + table_names_str = NULL; + } + DBUG_RETURN(error_num); +} + +void spider_oracle_share::free_table_names_str() +{ + DBUG_ENTER("spider_oracle_share::free_table_names_str"); + if (db_table_str) + { + delete [] db_table_str; + db_table_str = NULL; + } + if (db_names_str) + { + delete [] db_names_str; + db_names_str = NULL; + } + if (table_names_str) + { + delete [] table_names_str; + table_names_str = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_share::create_column_name_str() +{ + spider_string *str; + int error_num; + Field **field; + TABLE_SHARE *table_share = spider_share->table_share; + uint dbton_id = spider_dbton_oracle.dbton_id; + DBUG_ENTER("spider_oracle_share::create_column_name_str"); + if ( + table_share->fields && + !(column_name_str = new spider_string[table_share->fields]) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + for (field = table_share->field, str = column_name_str; + *field; field++, str++) + { + str->init_calc_mem(196); + str->set_charset(spider_share->access_charset); + if ((error_num = spider_db_append_name_with_quote_str(str, + (char *) (*field)->field_name, dbton_id))) + goto error; + } + DBUG_RETURN(0); + +error: + if (column_name_str) + { + delete [] column_name_str; + column_name_str = NULL; + } + DBUG_RETURN(error_num); +} + +void spider_oracle_share::free_column_name_str() +{ + DBUG_ENTER("spider_oracle_share::free_column_name_str"); + if (column_name_str) + { + delete [] column_name_str; + column_name_str = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_share::convert_key_hint_str() +{ + spider_string *tmp_key_hint; + int roop_count; + TABLE_SHARE *table_share = spider_share->table_share; + DBUG_ENTER("spider_oracle_share::convert_key_hint_str"); + if (spider_share->access_charset->cset != system_charset_info->cset) + { + /* need convertion */ + for (roop_count = 0, tmp_key_hint = key_hint; + roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++) + { + tmp_key_hint->length(0); + if (tmp_key_hint->append(spider_share->key_hint->ptr(), + spider_share->key_hint->length(), system_charset_info)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } else { + for (roop_count = 0, tmp_key_hint = key_hint; + roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++) + { + if (tmp_key_hint->copy(spider_share->key_hint[roop_count])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_share::append_show_table_status() +{ + int roop_count; + spider_string *str; + uint dbton_id = spider_dbton_oracle.dbton_id; + DBUG_ENTER("spider_oracle_append_show_table_status"); + if (!(show_table_status = + new spider_string[2 * spider_share->all_link_count])) + goto error; + + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + show_table_status[0 + (2 * roop_count)].init_calc_mem(197); + show_table_status[1 + (2 * roop_count)].init_calc_mem(207); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + show_table_status[0 + (2 * roop_count)].reserve( + SPIDER_SQL_SHOW_TABLE_STATUS_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_LIKE_LEN + table_names_str[roop_count].length() + + ((SPIDER_SQL_NAME_QUOTE_LEN) * 2) + + ((SPIDER_SQL_VALUE_QUOTE_LEN) * 2)) || + show_table_status[1 + (2 * roop_count)].reserve( + SPIDER_SQL_SELECT_TABLES_STATUS_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_AND_LEN + SPIDER_SQL_TABLE_NAME_LEN + SPIDER_SQL_EQUAL_LEN + + table_names_str[roop_count].length() + + ((SPIDER_SQL_VALUE_QUOTE_LEN) * 4)) + ) + goto error; + str = &show_table_status[0 + (2 * roop_count)]; + str->q_append( + SPIDER_SQL_SHOW_TABLE_STATUS_STR, SPIDER_SQL_SHOW_TABLE_STATUS_LEN); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(db_names_str[roop_count].ptr(), + db_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + str->q_append(SPIDER_SQL_LIKE_STR, SPIDER_SQL_LIKE_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(table_names_str[roop_count].ptr(), + table_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str = &show_table_status[1 + (2 * roop_count)]; + str->q_append( + SPIDER_SQL_SELECT_TABLES_STATUS_STR, + SPIDER_SQL_SELECT_TABLES_STATUS_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(db_names_str[roop_count].ptr(), + db_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + str->q_append(SPIDER_SQL_TABLE_NAME_STR, SPIDER_SQL_TABLE_NAME_LEN); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(table_names_str[roop_count].ptr(), + table_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + } + DBUG_RETURN(0); + +error: + if (show_table_status) + { + delete [] show_table_status; + show_table_status = NULL; + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +void spider_oracle_share::free_show_table_status() +{ + DBUG_ENTER("spider_oracle_free_show_table_status"); + if (show_table_status) + { + delete [] show_table_status; + show_table_status = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_share::append_show_records() +{ + int roop_count; + spider_string *str; + uint dbton_id = spider_dbton_oracle.dbton_id; + DBUG_ENTER("spider_oracle_share::append_show_records"); + if (!(show_records = new spider_string[spider_share->all_link_count])) + goto error; + + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + show_records[roop_count].init_calc_mem(208); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + show_records[roop_count].reserve( + SPIDER_SQL_SHOW_RECORDS_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_DOT_LEN + + table_names_str[roop_count].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4) + ) + goto error; + str = &show_records[roop_count]; + str->q_append(SPIDER_SQL_SHOW_RECORDS_STR, SPIDER_SQL_SHOW_RECORDS_LEN); + append_table_name(str, roop_count); + } + DBUG_RETURN(0); + +error: + if (show_records) + { + delete [] show_records; + show_records = NULL; + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +void spider_oracle_share::free_show_records() +{ + DBUG_ENTER("spider_oracle_share::free_show_records"); + if (show_records) + { + delete [] show_records; + show_records = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_share::append_show_autoinc() +{ + uint roop_count, field_length; + spider_string *str; + uint dbton_id = spider_dbton_oracle.dbton_id; + Field **found_next_number_field = + spider_share->table_share->found_next_number_field; + DBUG_ENTER("spider_oracle_share::append_show_autoinc"); + if (!found_next_number_field) + DBUG_RETURN(0); + + if (!(show_autoinc = new spider_string[spider_share->all_link_count])) + goto error; + + field_length = + column_name_str[(*found_next_number_field)->field_index].length(); + for (roop_count = 0; roop_count < spider_share->all_link_count; + roop_count++) + { + show_autoinc[roop_count].init_calc_mem(224); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + show_autoinc[roop_count].reserve( + SPIDER_SQL_SELECT_LEN + + SPIDER_SQL_MAX_LEN + + SPIDER_SQL_OPEN_PAREN_LEN + + field_length + + SPIDER_SQL_CLOSE_PAREN_LEN + + SPIDER_SQL_FROM_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_DOT_LEN + + table_names_str[roop_count].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 6) + ) + goto error; + str = &show_autoinc[roop_count]; + str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN); + str->q_append(SPIDER_SQL_MAX_STR, SPIDER_SQL_MAX_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + append_column_name(str, (*found_next_number_field)->field_index); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + append_table_name(str, roop_count); + } + DBUG_RETURN(0); + +error: + if (show_autoinc) + { + delete [] show_autoinc; + show_autoinc = NULL; + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +void spider_oracle_share::free_show_autoinc() +{ + DBUG_ENTER("spider_oracle_share::free_show_autoinc"); + if (show_autoinc) + { + delete [] show_autoinc; + show_autoinc = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_share::append_show_last_insert_id() +{ + uint roop_count; + spider_string *str; + uint dbton_id = spider_dbton_oracle.dbton_id; + Field **found_next_number_field = + spider_share->table_share->found_next_number_field; + uint seq_nm_max_length = 0; + DBUG_ENTER("spider_oracle_share::append_show_last_insert_id"); + if (!found_next_number_field) + DBUG_RETURN(0); + + if ( + !(show_last_insert_id = new spider_string[spider_share->all_link_count]) || + !(nextval_str = new spider_string[spider_share->all_link_count]) + ) + goto error; + + for (roop_count = 0; roop_count < spider_share->all_link_count; + roop_count++) + { + show_last_insert_id[roop_count].init_calc_mem(225); + nextval_str[roop_count].init_calc_mem(226); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + show_last_insert_id[roop_count].reserve( + SPIDER_SQL_SELECT_LEN + + spider_share->tgt_sequence_names_lengths[roop_count] + + SPIDER_SQL_CURRVAL_LEN + + SPIDER_SQL_FROM_DUAL_LEN + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2) + ) + goto error; + str = &show_last_insert_id[roop_count]; + str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN); + spider_db_oracle_utility.append_name(str, + spider_share->tgt_sequence_names[roop_count], + spider_share->tgt_sequence_names_lengths[roop_count]); + str->q_append(SPIDER_SQL_CURRVAL_STR, SPIDER_SQL_CURRVAL_LEN); + str->q_append(SPIDER_SQL_FROM_DUAL_STR, SPIDER_SQL_FROM_DUAL_LEN); + + if (seq_nm_max_length < + spider_share->tgt_sequence_names_lengths[roop_count]) + { + seq_nm_max_length = + spider_share->tgt_sequence_names_lengths[roop_count]; + } + } + for (roop_count = 0; roop_count < spider_share->all_link_count; + roop_count++) + { + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + nextval_str[roop_count].reserve( + seq_nm_max_length + + SPIDER_SQL_NEXTVAL_LEN + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2) + ) + goto error; + str = &nextval_str[roop_count]; + spider_db_oracle_utility.append_name(str, + spider_share->tgt_sequence_names[roop_count], + spider_share->tgt_sequence_names_lengths[roop_count]); + str->q_append(SPIDER_SQL_NEXTVAL_STR, SPIDER_SQL_NEXTVAL_LEN); + uint length = + seq_nm_max_length - spider_share->tgt_sequence_names_lengths[roop_count]; + memset((char *) str->ptr() + str->length(), ' ', length); + str->length(str->length() + length); + nextval_max_length = str->length(); + } + DBUG_RETURN(0); + +error: + if (show_last_insert_id) + { + delete [] show_last_insert_id; + show_last_insert_id = NULL; + } + if (nextval_str) + { + delete [] nextval_str; + nextval_str = NULL; + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +void spider_oracle_share::free_show_last_insert_id() +{ + DBUG_ENTER("spider_oracle_share::free_show_last_insert_id"); + if (show_last_insert_id) + { + delete [] show_last_insert_id; + show_last_insert_id = NULL; + } + if (nextval_str) + { + delete [] nextval_str; + nextval_str = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_share::append_show_index() +{ + int roop_count; + spider_string *str; + uint dbton_id = spider_dbton_oracle.dbton_id; + DBUG_ENTER("spider_oracle_share::append_show_index"); + if (!(show_index = new spider_string[2 * spider_share->all_link_count])) + goto error; + + for (roop_count = 0; roop_count < (int) spider_share->all_link_count; + roop_count++) + { + show_index[0 + (2 * roop_count)].init_calc_mem(209); + show_index[1 + (2 * roop_count)].init_calc_mem(210); + if (spider_share->sql_dbton_ids[roop_count] != dbton_id) + continue; + + if ( + show_index[0 + (2 * roop_count)].reserve( + SPIDER_SQL_SHOW_INDEX_LEN + db_names_str[roop_count].length() + + SPIDER_SQL_DOT_LEN + + table_names_str[roop_count].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4) || + show_index[1 + (2 * roop_count)].reserve( + SPIDER_SQL_SELECT_STATISTICS_LEN + + db_names_str[roop_count].length() + + SPIDER_SQL_AND_LEN + SPIDER_SQL_TABLE_NAME_LEN + SPIDER_SQL_EQUAL_LEN + + table_names_str[roop_count].length() + + ((SPIDER_SQL_VALUE_QUOTE_LEN) * 4) + + SPIDER_SQL_GROUP_LEN + SPIDER_SQL_COLUMN_NAME_LEN) + ) + goto error; + str = &show_index[0 + (2 * roop_count)]; + str->q_append( + SPIDER_SQL_SHOW_INDEX_STR, SPIDER_SQL_SHOW_INDEX_LEN); + append_table_name(str, roop_count); + str = &show_index[1 + (2 * roop_count)]; + str->q_append( + SPIDER_SQL_SELECT_STATISTICS_STR, SPIDER_SQL_SELECT_STATISTICS_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(db_names_str[roop_count].ptr(), + db_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + str->q_append(SPIDER_SQL_TABLE_NAME_STR, SPIDER_SQL_TABLE_NAME_LEN); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(table_names_str[roop_count].ptr(), + table_names_str[roop_count].length()); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str->q_append(SPIDER_SQL_GROUP_STR, SPIDER_SQL_GROUP_LEN); + str->q_append(SPIDER_SQL_COLUMN_NAME_STR, SPIDER_SQL_COLUMN_NAME_LEN); + } + DBUG_RETURN(0); + +error: + if (show_index) + { + delete [] show_index; + show_index = NULL; + } + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +void spider_oracle_share::free_show_index() +{ + DBUG_ENTER("spider_oracle_share::free_show_index"); + if (show_index) + { + delete [] show_index; + show_index = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_share::append_table_select() +{ + Field **field; + uint field_length; + spider_string *str = table_select; + TABLE_SHARE *table_share = spider_share->table_share; + DBUG_ENTER("spider_oracle_share::append_table_select"); + for (field = table_share->field; *field; field++) + { + field_length = column_name_str[(*field)->field_index].length(); + if (str->reserve(field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(append_from_with_adjusted_table_name(str, &table_select_pos)); +} + +int spider_oracle_share::append_key_select( + uint idx +) { + KEY_PART_INFO *key_part; + Field *field; + uint part_num; + uint field_length; + spider_string *str = &key_select[idx]; + TABLE_SHARE *table_share = spider_share->table_share; + const KEY *key_info = &table_share->key_info[idx]; + DBUG_ENTER("spider_oracle_share::append_key_select"); + for (key_part = key_info->key_part, part_num = 0; + part_num < key_info->key_parts; key_part++, part_num++) + { + field = key_part->field; + field_length = column_name_str[field->field_index].length(); + if (str->reserve(field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(append_from_with_adjusted_table_name(str, &key_select_pos[idx])); +} + +bool spider_oracle_share::need_change_db_table_name() +{ + DBUG_ENTER("spider_oracle_share::need_change_db_table_name"); + DBUG_RETURN(!same_db_table_name); +} + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +int spider_oracle_share::discover_table_structure( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str +) { + DBUG_ENTER("spider_oracle_share::discover_table_structure"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(HA_ERR_WRONG_COMMAND); +} +#endif + +spider_oracle_handler::spider_oracle_handler( + ha_spider *spider, + spider_oracle_share *db_share +) : spider_db_handler( + spider, + db_share +), + where_pos(0), + order_pos(0), + limit_pos(0), + table_name_pos(0), + update_set_pos(0), + ha_read_pos(0), + ha_next_pos(0), + ha_where_pos(0), + ha_limit_pos(0), + ha_table_name_pos(0), + insert_pos(0), + insert_table_name_pos(0), + upd_tmp_tbl(NULL), + tmp_sql_pos1(0), + tmp_sql_pos2(0), + tmp_sql_pos3(0), + tmp_sql_pos4(0), + tmp_sql_pos5(0), + table_lock_mode(0), + reading_from_bulk_tmp_table(FALSE), + filled_up(FALSE), + select_rownum_appended(FALSE), + update_rownum_appended(FALSE), + oracle_share(db_share), + link_for_hash(NULL) +{ + DBUG_ENTER("spider_oracle_handler::spider_oracle_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_alloc_calc_mem_init(mem_calc, 222); + spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); + DBUG_VOID_RETURN; +} + +spider_oracle_handler::~spider_oracle_handler() +{ + DBUG_ENTER("spider_oracle_handler::~spider_oracle_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if (link_for_hash) + { + spider_free(spider_current_trx, link_for_hash, MYF(0)); + } + spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); + DBUG_VOID_RETURN; +} + +int spider_oracle_handler::init() +{ + uint roop_count; + THD *thd = spider->trx->thd; + st_spider_share *share = spider->share; + int init_sql_alloc_size = + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); + DBUG_ENTER("spider_oracle_handler::init"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.init_calc_mem(67); + sql_part.init_calc_mem(68); + sql_part2.init_calc_mem(69); + ha_sql.init_calc_mem(70); + insert_sql.init_calc_mem(72); + update_sql.init_calc_mem(73); + tmp_sql.init_calc_mem(74); + dup_update_sql.init_calc_mem(167); + if ( + (sql.real_alloc(init_sql_alloc_size)) || + (insert_sql.real_alloc(init_sql_alloc_size)) || + (update_sql.real_alloc(init_sql_alloc_size)) || + (tmp_sql.real_alloc(init_sql_alloc_size)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.set_charset(share->access_charset); + sql_part.set_charset(share->access_charset); + ha_sql.set_charset(share->access_charset); + insert_sql.set_charset(share->access_charset); + update_sql.set_charset(share->access_charset); + tmp_sql.set_charset(share->access_charset); + upd_tmp_tbl_prm.init(); + upd_tmp_tbl_prm.field_count = 1; + if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *) + spider_bulk_alloc_mem(spider_current_trx, 223, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &link_for_hash, + sizeof(SPIDER_LINK_FOR_HASH) * share->link_count, + NullS)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + for (roop_count = 0; roop_count < share->link_count; roop_count++) + { + link_for_hash[roop_count].spider = spider; + link_for_hash[roop_count].link_idx = roop_count; + link_for_hash[roop_count].db_table_str = + &oracle_share->db_table_str[roop_count]; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + link_for_hash[roop_count].db_table_str_hash_value = + oracle_share->db_table_str_hash_value[roop_count]; +#endif + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + hs_upds.init(); +#endif + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_table_name_with_adjusting( + spider_string *str, + int link_idx, + ulong sql_type +) { + int error_num = 0; + DBUG_ENTER("spider_oracle_handler::append_table_name_with_adjusting"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type == SPIDER_SQL_TYPE_HANDLER) + { + str->q_append(spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_LEN); + } else { + error_num = oracle_share->append_table_name_with_adjusting(str, + spider->conn_link_idx[link_idx]); + } + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_key_column_types( + const key_range *start_key, + spider_string *str +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + KEY *key_info = result_list->key_info; + uint key_name_length, key_count; + key_part_map full_key_part_map = make_prev_keypart_map(key_info->key_parts); + key_part_map start_key_part_map; + KEY_PART_INFO *key_part; + Field *field; + char tmp_buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(tmp_buf, sizeof(tmp_buf), system_charset_info); + DBUG_ENTER("spider_oracle_handler::append_key_column_types"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_str.init_calc_mem(227); + + start_key_part_map = start_key->keypart_map & full_key_part_map; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", key_info->key_parts)); + DBUG_PRINT("info", ("spider full_key_part_map=%lu", full_key_part_map)); + DBUG_PRINT("info", ("spider start_key_part_map=%lu", start_key_part_map)); + + if (!start_key_part_map) + DBUG_RETURN(0); + + for ( + key_part = key_info->key_part, + key_count = 0; + start_key_part_map; + start_key_part_map >>= 1, + key_part++, + key_count++ + ) { + field = key_part->field; + key_name_length = my_sprintf(tmp_buf, (tmp_buf, "c%u", key_count)); + if (str->reserve(key_name_length + SPIDER_SQL_SPACE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(tmp_buf, key_name_length); + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + + if (tmp_str.ptr() != tmp_buf) + tmp_str.set(tmp_buf, sizeof(tmp_buf), system_charset_info); + else + tmp_str.set_charset(system_charset_info); + field->sql_type(*tmp_str.get_str()); + tmp_str.mem_calc(); + str->append(tmp_str); + + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_key_join_columns_for_bka( + const key_range *start_key, + spider_string *str, + const char **table_aliases, + uint *table_alias_lengths +) { + KEY *key_info = spider->result_list.key_info; + uint length, key_name_length, key_count; + key_part_map full_key_part_map = make_prev_keypart_map(key_info->key_parts); + key_part_map start_key_part_map; + KEY_PART_INFO *key_part; + Field *field; + char tmp_buf[MAX_FIELD_WIDTH]; + bool start_where = ((int) str->length() == where_pos); + DBUG_ENTER("spider_oracle_handler::append_key_join_columns_for_bka"); + DBUG_PRINT("info",("spider this=%p", this)); + start_key_part_map = start_key->keypart_map & full_key_part_map; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", key_info->key_parts)); + DBUG_PRINT("info", ("spider full_key_part_map=%lu", full_key_part_map)); + DBUG_PRINT("info", ("spider start_key_part_map=%lu", start_key_part_map)); + + if (!start_key_part_map) + DBUG_RETURN(0); + + if (start_where) + { + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + } else { + if (str->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + + for ( + key_part = key_info->key_part, + key_count = 0; + start_key_part_map; + start_key_part_map >>= 1, + key_part++, + key_count++ + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + length = my_sprintf(tmp_buf, (tmp_buf, "c%u", key_count)); + if (str->reserve(length + table_alias_lengths[0] + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + table_alias_lengths[1] + SPIDER_SQL_PF_EQUAL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(table_aliases[0], table_alias_lengths[0]); + str->q_append(tmp_buf, length); + str->q_append(SPIDER_SQL_PF_EQUAL_STR, SPIDER_SQL_PF_EQUAL_LEN); + str->q_append(table_aliases[1], table_alias_lengths[1]); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + str->length(str->length() - SPIDER_SQL_AND_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_tmp_table_and_sql_for_bka( + const key_range *start_key +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_tmp_table_and_sql_for_bka"); + DBUG_PRINT("info",("spider this=%p", this)); + char tmp_table_name[MAX_FIELD_WIDTH * 2], + tgt_table_name[MAX_FIELD_WIDTH * 2]; + int tmp_table_name_length; + spider_string tgt_table_name_str(tgt_table_name, MAX_FIELD_WIDTH * 2, + oracle_share->db_names_str[0].charset()); + const char *table_names[2], *table_aliases[2], *table_dot_aliases[2]; + uint table_name_lengths[2], table_alias_lengths[2], + table_dot_alias_lengths[2]; + tgt_table_name_str.init_calc_mem(200); + tgt_table_name_str.length(0); + create_tmp_bka_table_name(tmp_table_name, &tmp_table_name_length, + first_link_idx); + if ((error_num = append_table_name_with_adjusting(&tgt_table_name_str, + first_link_idx, SPIDER_SQL_TYPE_SELECT_SQL))) + { + DBUG_RETURN(error_num); + } + table_names[0] = tmp_table_name; + table_names[1] = tgt_table_name_str.c_ptr_safe(); + table_name_lengths[0] = tmp_table_name_length; + table_name_lengths[1] = tgt_table_name_str.length(); + table_aliases[0] = SPIDER_SQL_A_STR; + table_aliases[1] = SPIDER_SQL_B_STR; + table_alias_lengths[0] = SPIDER_SQL_A_LEN; + table_alias_lengths[1] = SPIDER_SQL_B_LEN; + table_dot_aliases[0] = SPIDER_SQL_A_DOT_STR; + table_dot_aliases[1] = SPIDER_SQL_B_DOT_STR; + table_dot_alias_lengths[0] = SPIDER_SQL_A_DOT_LEN; + table_dot_alias_lengths[1] = SPIDER_SQL_B_DOT_LEN; + if ( + (error_num = append_drop_tmp_bka_table( + &tmp_sql, tmp_table_name, tmp_table_name_length, + &tmp_sql_pos1, &tmp_sql_pos5, TRUE)) || + (error_num = append_create_tmp_bka_table( + start_key, + &tmp_sql, tmp_table_name, + tmp_table_name_length, + &tmp_sql_pos2, spider->share->table_share->table_charset)) || + (error_num = append_insert_tmp_bka_table( + start_key, + &tmp_sql, tmp_table_name, + tmp_table_name_length, &tmp_sql_pos3)) + ) + DBUG_RETURN(error_num); + tmp_sql_pos4 = tmp_sql.length(); + if ((error_num = spider_db_append_select(spider))) + DBUG_RETURN(error_num); + if (sql.reserve(SPIDER_SQL_A_DOT_LEN + SPIDER_SQL_ID_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_A_DOT_STR, SPIDER_SQL_A_DOT_LEN); + sql.q_append(SPIDER_SQL_ID_STR, SPIDER_SQL_ID_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + if ( + (error_num = append_select_columns_with_alias(&sql, + SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)) || + (error_num = spider_db_oracle_utility.append_from_with_alias(&sql, + table_names, table_name_lengths, + table_aliases, table_alias_lengths, 2, + &table_name_pos, FALSE)) + ) + DBUG_RETURN(error_num); + if ( + oracle_share->key_hint && + (error_num = spider_db_append_hint_after_table(spider, + &sql, &oracle_share->key_hint[spider->active_index])) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + where_pos = sql.length(); + if ( + (error_num = append_key_join_columns_for_bka( + start_key, &sql, + table_dot_aliases, table_dot_alias_lengths)) || + (error_num = append_condition_part( + SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN, + SPIDER_SQL_TYPE_SELECT_SQL, FALSE)) || + ( + spider->result_list.direct_order_limit && + (error_num = append_key_order_for_direct_order_limit_with_alias(&sql, + SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)) + ) + ) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +} + +int spider_oracle_handler::reuse_tmp_table_and_sql_for_bka() +{ + DBUG_ENTER("spider_oracle_handler::reuse_tmp_table_and_sql_for_bka"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_sql.length(tmp_sql_pos4); + sql.length(limit_pos); + ha_sql.length(ha_limit_pos); + DBUG_RETURN(0); +} + +void spider_oracle_handler::create_tmp_bka_table_name( + char *tmp_table_name, + int *tmp_table_name_length, + int link_idx +) { + uint adjust_length = + oracle_share->db_nm_max_length - + oracle_share->db_names_str[spider->conn_link_idx[link_idx]].length() + + oracle_share->table_nm_max_length - + oracle_share->table_names_str[spider->conn_link_idx[link_idx]].length(), + length; + DBUG_ENTER("spider_oracle_handler::create_tmp_bka_table_name"); + *tmp_table_name_length = oracle_share->db_nm_max_length + + oracle_share->table_nm_max_length; + memset(tmp_table_name, ' ', adjust_length); + tmp_table_name += adjust_length; + memcpy(tmp_table_name, oracle_share->db_names_str[link_idx].c_ptr(), + oracle_share->db_names_str[link_idx].length()); + tmp_table_name += oracle_share->db_names_str[link_idx].length(); + length = my_sprintf(tmp_table_name, (tmp_table_name, + "%s%s%p%s", SPIDER_SQL_DOT_STR, SPIDER_SQL_TMP_BKA_STR, spider, + SPIDER_SQL_UNDERSCORE_STR)); + *tmp_table_name_length += length; + tmp_table_name += length; + memcpy(tmp_table_name, + oracle_share->table_names_str[spider->conn_link_idx[link_idx]].c_ptr(), + oracle_share->table_names_str[spider->conn_link_idx[link_idx]].length()); + DBUG_VOID_RETURN; +} + +int spider_oracle_handler::append_create_tmp_bka_table( + const key_range *start_key, + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos, + CHARSET_INFO *table_charset +) { + int error_num; + SPIDER_SHARE *share = spider->share; + THD *thd = spider->trx->thd; + char *bka_engine = spider_param_bka_engine(thd, share->bka_engine); + uint bka_engine_length = strlen(bka_engine), + cset_length = strlen(table_charset->csname); + DBUG_ENTER("spider_oracle_handler::append_create_tmp_bka_table"); + if (str->reserve(SPIDER_SQL_CREATE_TMP_LEN + tmp_table_name_length + + SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_ID_LEN + SPIDER_SQL_ID_TYPE_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CREATE_TMP_STR, SPIDER_SQL_CREATE_TMP_LEN); + *db_name_pos = str->length(); + str->q_append(tmp_table_name, tmp_table_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + str->q_append(SPIDER_SQL_ID_STR, SPIDER_SQL_ID_LEN); + str->q_append(SPIDER_SQL_ID_TYPE_STR, SPIDER_SQL_ID_TYPE_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + if ((error_num = append_key_column_types(start_key, str))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_ENGINE_LEN + bka_engine_length + + SPIDER_SQL_DEF_CHARSET_LEN + cset_length + SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ENGINE_STR, SPIDER_SQL_ENGINE_LEN); + str->q_append(bka_engine, bka_engine_length); + str->q_append(SPIDER_SQL_DEF_CHARSET_STR, SPIDER_SQL_DEF_CHARSET_LEN); + str->q_append(table_charset->csname, cset_length); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_drop_tmp_bka_table( + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos, + int *drop_table_end_pos, + bool with_semicolon +) { + DBUG_ENTER("spider_oracle_handler::append_drop_tmp_bka_table"); + if (str->reserve(SPIDER_SQL_DROP_TMP_LEN + tmp_table_name_length + + (with_semicolon ? SPIDER_SQL_SEMICOLON_LEN : 0))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_DROP_TMP_STR, SPIDER_SQL_DROP_TMP_LEN); + *db_name_pos = str->length(); + str->q_append(tmp_table_name, tmp_table_name_length); + *drop_table_end_pos = str->length(); + if (with_semicolon) + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_insert_tmp_bka_table( + const key_range *start_key, + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_insert_tmp_bka_table"); + if (str->reserve(SPIDER_SQL_INSERT_LEN + SPIDER_SQL_INTO_LEN + + tmp_table_name_length + SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_ID_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); + str->q_append(SPIDER_SQL_INTO_STR, SPIDER_SQL_INTO_LEN); + *db_name_pos = str->length(); + str->q_append(tmp_table_name, tmp_table_name_length); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + str->q_append(SPIDER_SQL_ID_STR, SPIDER_SQL_ID_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + if ((error_num = spider_db_append_key_columns(start_key, spider, str))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_insert_for_recovery( + ulong sql_type, + int link_idx +) { + const TABLE *table = spider->get_table(); + SPIDER_SHARE *share = spider->share; + Field **field; + uint field_name_length = 0; + bool add_value = FALSE; + spider_string *insert_sql; + DBUG_ENTER("spider_oracle_handler::append_insert_for_recovery"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type == SPIDER_SQL_TYPE_INSERT_SQL) + { + insert_sql = &spider->result_list.insert_sqls[link_idx]; + insert_sql->length(0); + } else { + insert_sql = &spider->result_list.update_sqls[link_idx]; + } + if (insert_sql->reserve( + SPIDER_SQL_INSERT_LEN + SPIDER_SQL_SQL_IGNORE_LEN + + SPIDER_SQL_INTO_LEN + oracle_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + oracle_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + insert_sql->q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); + insert_sql->q_append(SPIDER_SQL_SQL_IGNORE_STR, SPIDER_SQL_SQL_IGNORE_LEN); + insert_sql->q_append(SPIDER_SQL_INTO_STR, SPIDER_SQL_INTO_LEN); + oracle_share->append_table_name(insert_sql, spider->conn_link_idx[link_idx]); + insert_sql->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + for (field = table->field; *field; field++) + { + field_name_length = + oracle_share->column_name_str[(*field)->field_index].length(); + if (insert_sql->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(insert_sql, (*field)->field_index); + insert_sql->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + if (field_name_length) + insert_sql->length(insert_sql->length() - SPIDER_SQL_COMMA_LEN); + if (insert_sql->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + insert_sql->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN); + insert_sql->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + for (field = table->field; *field; field++) + { + add_value = TRUE; + if ((*field)->is_null()) + { + if (insert_sql->reserve(SPIDER_SQL_NULL_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + insert_sql->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else { + if ( + spider_db_oracle_utility. + append_column_value(spider, insert_sql, *field, NULL, + share->access_charset) || + insert_sql->reserve(SPIDER_SQL_COMMA_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + insert_sql->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + if (add_value) + insert_sql->length(insert_sql->length() - SPIDER_SQL_COMMA_LEN); + if (insert_sql->reserve(SPIDER_SQL_CLOSE_PAREN_LEN, SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + insert_sql->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + if (sql_type == SPIDER_SQL_TYPE_INSERT_SQL) + { + exec_insert_sql = insert_sql; + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff +) { + int error_num; + spider_string *str = &update_sql; + DBUG_ENTER("spider_oracle_handler::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->length() > 0) + { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + + if ( + (error_num = append_update(str, 0)) || + (error_num = append_update_set(str)) || + (error_num = append_update_where(str, table, ptr_diff)) + ) + DBUG_RETURN(error_num); + filled_up = (str->length() >= (uint) spider->result_list.bulk_update_size); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.update_sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::append_update"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->length() > 0) + { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + + if ( + (error_num = append_update(str, link_idx)) || + (error_num = append_update_set(str)) || + (error_num = append_update_where(str, table, ptr_diff)) + ) + DBUG_RETURN(error_num); + + if ( + spider->pk_update && + share->link_statuses[link_idx] == SPIDER_LINK_STATUS_RECOVERY + ) { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + if ((error_num = append_insert_for_recovery( + SPIDER_SQL_TYPE_UPDATE_SQL, link_idx))) + DBUG_RETURN(error_num); + } + + if (!filled_up) + filled_up = (str->length() >= (uint) spider->result_list.bulk_update_size); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff +) { + int error_num; + spider_string *str = &update_sql; + DBUG_ENTER("spider_oracle_handler::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->length() > 0) + { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + + if ( + (error_num = append_delete(str)) || + (error_num = append_from(str, SPIDER_SQL_TYPE_DELETE_SQL, + first_link_idx)) || + (error_num = append_update_where(str, table, ptr_diff)) + ) + DBUG_RETURN(error_num); + filled_up = (str->length() >= (uint) spider->result_list.bulk_update_size); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx +) { + int error_num; + spider_string *str = &spider->result_list.update_sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::append_delete"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->length() > 0) + { + if (str->reserve(SPIDER_SQL_SEMICOLON_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SEMICOLON_STR, SPIDER_SQL_SEMICOLON_LEN); + } + + if ( + (error_num = append_delete(str)) || + (error_num = append_from(str, SPIDER_SQL_TYPE_DELETE_SQL, link_idx)) || + (error_num = append_update_where(str, table, ptr_diff)) + ) + DBUG_RETURN(error_num); + if (!filled_up) + filled_up = (str->length() >= (uint) spider->result_list.bulk_update_size); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_insert_part() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::append_insert_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_insert(&insert_sql, 0); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_insert( + spider_string *str, + int link_idx +) { + DBUG_ENTER("spider_oracle_handler::append_insert"); + if (str->reserve(SPIDER_SQL_INSERT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_update_part() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::append_update_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_update(&update_sql, 0); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_update( + spider_string *str, + int link_idx +) { + DBUG_ENTER("spider_oracle_handler::append_update"); + if (str->reserve(SPIDER_SQL_UPDATE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_UPDATE_STR, SPIDER_SQL_UPDATE_LEN); + if (str->reserve(oracle_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + oracle_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + table_name_pos = str->length(); + append_table_name_with_adjusting(str, link_idx, SPIDER_SQL_TYPE_UPDATE_SQL); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_delete_part() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::append_delete_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_delete(&update_sql); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_delete( + spider_string *str +) { + DBUG_ENTER("spider_oracle_handler::append_delete"); + if (str->reserve(SPIDER_SQL_DELETE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_DELETE_STR, SPIDER_SQL_DELETE_LEN); + str->length(str->length() - 1); + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_oracle_handler::append_increment_update_set_part() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::append_increment_update_set_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_increment_update_set(&update_sql); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_increment_update_set( + spider_string *str +) { + uint field_name_length; + uint roop_count; + Field *field; + DBUG_ENTER("spider_oracle_handler::append_increment_update_set"); + if (str->reserve(SPIDER_SQL_SET_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); + const SPIDER_HS_STRING_REF *value = hs_upds.ptr(); + for (roop_count = 0; roop_count < hs_upds.size(); + roop_count++) + { + DBUG_PRINT("info",("spider value_size[%u]=%zu", roop_count, + value[roop_count].size())); +#ifndef DBUG_OFF + char print_buf[MAX_FIELD_WIDTH]; + if (value[roop_count].size() < MAX_FIELD_WIDTH) + { + memcpy(print_buf, value[roop_count].begin(), value[roop_count].size()); + print_buf[value[roop_count].size()] = '\0'; + DBUG_PRINT("info",("spider value[%u]=%s", roop_count, print_buf)); + } +#endif + if ( + value[roop_count].size() == 1 && + *(value[roop_count].begin()) == '0' + ) + continue; + + Field *top_table_field = + spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); + if (!(field = spider->field_exchange(top_table_field))) + continue; + field_name_length = + oracle_share->column_name_str[field->field_index].length(); + + if (str->reserve(field_name_length * 2 + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 4 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_HS_INCREMENT_LEN + + SPIDER_SQL_COMMA_LEN + value[roop_count].size())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + oracle_share->append_column_name(str, field->field_index); + if (spider->hs_increment) + str->q_append(SPIDER_SQL_HS_INCREMENT_STR, + SPIDER_SQL_HS_INCREMENT_LEN); + else + str->q_append(SPIDER_SQL_HS_DECREMENT_STR, + SPIDER_SQL_HS_DECREMENT_LEN); + str->q_append(value[roop_count].begin(), value[roop_count].size()); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} +#endif +#endif + +int spider_oracle_handler::append_update_set_part() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::append_update_set_part"); + DBUG_PRINT("info",("spider this=%p", this)); + update_set_pos = update_sql.length(); + error_num = append_update_set(&update_sql); + where_pos = update_sql.length(); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_update_set( + spider_string *str +) { + uint field_name_length; + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + Field **fields; + DBUG_ENTER("spider_oracle_handler::append_update_set"); + if (str->reserve(SPIDER_SQL_SET_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); + for (fields = table->field; *fields; fields++) + { + if (bitmap_is_set(table->write_set, (*fields)->field_index)) + { + field_name_length = + oracle_share->column_name_str[(*fields)->field_index].length(); + if ((*fields)->is_null()) + { + if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, (*fields)->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else { + if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 2 + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, (*fields)->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, + table->read_set); +#endif + if ( + spider_db_oracle_utility. + append_column_value(spider, str, *fields, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN) + ) { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +int spider_oracle_handler::append_direct_update_set_part() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::append_direct_update_set_part"); + DBUG_PRINT("info",("spider this=%p", this)); + update_set_pos = update_sql.length(); + error_num = append_direct_update_set(&update_sql); + where_pos = update_sql.length(); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_direct_update_set( + spider_string *str +) { + uint field_name_length; + SPIDER_SHARE *share = spider->share; +#ifndef DBUG_OFF + TABLE *table = spider->get_table(); +#endif + DBUG_ENTER("spider_oracle_handler::append_direct_update_set"); + if ( + spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && + spider->direct_update_fields + ) { + if (str->reserve(SPIDER_SQL_SET_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); + DBUG_RETURN(append_update_columns(str, NULL, 0)); + } + + if ( + (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) + ) { + size_t roop_count; + Field *field; + if (str->reserve(SPIDER_SQL_SET_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); + for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; + roop_count++) + { + Field *top_table_field = + spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); + if (!(field = spider->field_exchange(top_table_field))) + continue; + field_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (top_table_field->is_null()) + { + if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else { + if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ + 2 + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, + table->read_set); +#endif + if ( + spider_db_oracle_utility. + append_column_value(spider, str, top_table_field, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN) + ) { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_dup_update_pushdown_part( + const char *alias, + uint alias_length +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_dup_update_pushdown_part"); + DBUG_PRINT("info",("spider this=%p", this)); + dup_update_sql.length(0); + error_num = append_update_columns(&dup_update_sql, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_update_columns_part( + const char *alias, + uint alias_length +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_update_columns_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_update_columns(&update_sql, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::check_update_columns_part() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::check_update_columns_part"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = append_update_columns(NULL, NULL, 0); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_update_columns( + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + List_iterator_fast fi(*spider->direct_update_fields), + vi(*spider->direct_update_values); + Item *field, *value; + DBUG_ENTER("spider_oracle_handler::append_update_columns"); + while ((field = fi++)) + { + value = vi++; + if ((error_num = spider_db_print_item_type( + (Item *) field, spider, str, alias, alias_length, + spider_dbton_oracle.dbton_id))) + { + if ( + error_num == ER_SPIDER_COND_SKIP_NUM && + field->type() == Item::FIELD_ITEM && + ((Item_field *) field)->field + ) + continue; + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + } + if ((error_num = spider_db_print_item_type( + (Item *) value, spider, str, alias, alias_length, + spider_dbton_oracle.dbton_id))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if (str) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +/* + error_num = spider_db_append_update_columns(spider, str, + alias, alias_length, spider_dbton_oracle.dbton_id); + DBUG_RETURN(error_num); +*/ +} +#endif + +int spider_oracle_handler::append_select_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_select(str, sql_type); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_select( + spider_string *str, + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::append_select"); + if (sql_type == SPIDER_SQL_TYPE_HANDLER) + { + if (str->reserve(SPIDER_SQL_HANDLER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HANDLER_STR, SPIDER_SQL_HANDLER_LEN); + } else { + if (str->reserve(SPIDER_SQL_SELECT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_table_select_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_table_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_table_select(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_table_select( + spider_string *str +) { + DBUG_ENTER("spider_oracle_handler::append_table_select"); + table_name_pos = str->length() + oracle_share->table_select_pos; + if (str->append(*(oracle_share->table_select))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_key_select_part( + ulong sql_type, + uint idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_key_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_select(str, idx); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_key_select( + spider_string *str, + uint idx +) { + DBUG_ENTER("spider_oracle_handler::append_key_select"); + table_name_pos = str->length() + oracle_share->key_select_pos[idx]; + if (str->append(oracle_share->key_select[idx])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_minimum_select_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_minimum_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_minimum_select(str, sql_type); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_minimum_select( + spider_string *str, + ulong sql_type +) { + TABLE *table = spider->get_table(); + Field **field; + int field_length; + bool appended = FALSE; + DBUG_ENTER("spider_oracle_handler::append_minimum_select"); + for (field = table->field; *field; field++) + { + if ( + spider_bit_is_set(spider->searched_bitmap, (*field)->field_index) | + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + ) { + field_length = + oracle_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + appended = TRUE; + } + } + if (appended) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + else { + if (str->reserve(SPIDER_SQL_ONE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ONE_STR, SPIDER_SQL_ONE_LEN); + } + DBUG_RETURN(append_from(str, sql_type, first_link_idx)); +} + +int spider_oracle_handler::append_table_select_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + TABLE *table = spider->get_table(); + Field **field; + int field_length; + DBUG_ENTER("spider_oracle_handler::append_table_select_with_alias"); + for (field = table->field; *field; field++) + { + field_length = + oracle_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(alias_length + field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_key_select_with_alias( + spider_string *str, + const KEY *key_info, + const char *alias, + uint alias_length +) { + KEY_PART_INFO *key_part; + Field *field; + uint part_num; + int field_length; + DBUG_ENTER("spider_oracle_handler::append_key_select_with_alias"); + for (key_part = key_info->key_part, part_num = 0; + part_num < key_info->key_parts; key_part++, part_num++) + { + field = key_part->field; + field_length = oracle_share->column_name_str[field->field_index].length(); + if (str->reserve(alias_length + field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_minimum_select_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + TABLE *table = spider->get_table(); + Field **field; + int field_length; + bool appended = FALSE; + DBUG_ENTER("spider_oracle_handler::append_minimum_select_with_alias"); + for (field = table->field; *field; field++) + { + if ( + spider_bit_is_set(spider->searched_bitmap, (*field)->field_index) | + bitmap_is_set(table->read_set, (*field)->field_index) | + bitmap_is_set(table->write_set, (*field)->field_index) + ) { + field_length = + oracle_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(alias_length + field_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + appended = TRUE; + } + } + if (appended) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + else { + if (str->reserve(SPIDER_SQL_ONE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ONE_STR, SPIDER_SQL_ONE_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_select_columns_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_oracle_handler::append_select_columns_with_alias"); + if ((error_num = append_match_select(str, alias, alias_length))) + DBUG_RETURN(error_num); + if (!spider->select_column_mode) + { + if (result_list->keyread) + DBUG_RETURN(append_key_select_with_alias( + str, result_list->key_info, alias, alias_length)); + else + DBUG_RETURN(append_table_select_with_alias( + str, alias, alias_length)); + } + DBUG_RETURN(append_minimum_select_with_alias(str, alias, alias_length)); +} + +int spider_oracle_handler::append_hint_after_table_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_hint_after_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_hint_after_table(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_hint_after_table( + spider_string *str +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_hint_after_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + oracle_share->key_hint && + (error_num = spider_db_append_hint_after_table(spider, + str, &oracle_share->key_hint[spider->active_index])) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_RETURN(0); +} + +void spider_oracle_handler::set_where_pos( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::set_where_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + where_pos = sql.length(); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + where_pos = update_sql.length(); + break; + case SPIDER_SQL_TYPE_HANDLER: + ha_read_pos = ha_sql.length(); + break; + default: + break; + } + DBUG_VOID_RETURN; +} + +void spider_oracle_handler::set_where_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::set_where_to_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + sql.length(where_pos); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + update_sql.length(where_pos); + break; + case SPIDER_SQL_TYPE_HANDLER: + ha_sql.length(ha_read_pos); + break; + default: + break; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_handler::check_item_type( + Item *item +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::check_item_type"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = spider_db_print_item_type(item, spider, NULL, NULL, 0, + spider_dbton_oracle.dbton_id); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_values_connector_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_values_connector_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_values_connector(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_values_connector( + spider_string *str +) { + DBUG_ENTER("spider_oracle_handler::append_values_connector"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + + SPIDER_SQL_COMMA_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_values_terminator_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_values_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_values_terminator(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_values_terminator( + spider_string *str +) { + DBUG_ENTER("spider_oracle_handler::append_values_terminator"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(str->length() - + SPIDER_SQL_COMMA_LEN - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_key_column_values_part( + const key_range *start_key, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_key_column_values_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_column_values(str, start_key); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_key_column_values( + spider_string *str, + const key_range *start_key +) { + int error_num; + const uchar *ptr; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_SHARE *share = spider->share; + KEY *key_info = result_list->key_info; + uint length; + uint store_length; + key_part_map full_key_part_map = make_prev_keypart_map(key_info->key_parts); + key_part_map start_key_part_map; + KEY_PART_INFO *key_part; + Field *field; + DBUG_ENTER("spider_oracle_handler::append_key_column_values"); + start_key_part_map = start_key->keypart_map & full_key_part_map; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", key_info->key_parts)); + DBUG_PRINT("info", ("spider full_key_part_map=%lu", full_key_part_map)); + DBUG_PRINT("info", ("spider start_key_part_map=%lu", start_key_part_map)); + + if (!start_key_part_map) + DBUG_RETURN(0); + + for ( + key_part = key_info->key_part, + length = 0; + start_key_part_map; + start_key_part_map >>= 1, + key_part++, + length += store_length + ) { + store_length = key_part->store_length; + ptr = start_key->key + length; + field = key_part->field; + if ((error_num = spider_db_append_null_value(str, key_part, &ptr))) + { + if (error_num > 0) + DBUG_RETURN(error_num); + } else { + if (spider_db_oracle_utility.append_column_value(spider, str, field, ptr, + share->access_charset)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_key_where_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type +) { + int error_num; + spider_string *str, *str_part = NULL, *str_part2 = NULL; + bool set_order; + DBUG_ENTER("spider_oracle_handler::append_key_where_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + set_order = FALSE; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + set_order = FALSE; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + ha_read_pos = str->length(); + str_part = &sql_part; + str_part2 = &sql_part2; + str_part->length(0); + str_part2->length(0); + set_order = TRUE; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_where(str, str_part, str_part2, start_key, end_key, + sql_type, set_order); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_key_where( + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + const key_range *start_key, + const key_range *end_key, + ulong sql_type, + bool set_order +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_key_where"); + error_num = spider_db_append_key_where_internal(str, str_part, str_part2, + start_key, end_key, spider, set_order, sql_type, + spider_dbton_oracle.dbton_id); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_is_null_part( + ulong sql_type, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq +) { + int error_num; + spider_string *str, *str_part = NULL, *str_part2 = NULL; + DBUG_ENTER("spider_oracle_handler::append_is_null_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + str_part = &sql_part; + str_part2 = &sql_part2; + break; + default: + DBUG_RETURN(0); + } + error_num = append_is_null(sql_type, str, str_part, str_part2, + key_part, key, ptr, key_eq); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_is_null( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq +) { + DBUG_ENTER("spider_oracle_handler::append_is_null"); + DBUG_PRINT("info",("spider this=%p", this)); + if (key_part->null_bit) + { + if (*(*ptr)++) + { + if (sql_type == SPIDER_SQL_TYPE_HANDLER) + { + str = str_part; + if ( + key_eq || + key->flag == HA_READ_KEY_EXACT || + key->flag == HA_READ_KEY_OR_NEXT + ) { + if (str->reserve(SPIDER_SQL_IS_NULL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN); + } else { + str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); + ha_next_pos = str->length(); + if (str->reserve(SPIDER_SQL_FIRST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FIRST_STR, SPIDER_SQL_FIRST_LEN); + spider->result_list.ha_read_kind = 1; + } + str = str_part2; + } + if ( + key_eq || + key->flag == HA_READ_KEY_EXACT || + key->flag == HA_READ_KEY_OR_NEXT + ) { + if (str->reserve(SPIDER_SQL_IS_NULL_LEN + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + oracle_share->column_name_str[key_part->field->field_index].length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, key_part->field->field_index); + str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN); + } else { + if (str->reserve(SPIDER_SQL_IS_NOT_NULL_LEN + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + oracle_share->column_name_str[key_part->field->field_index].length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, key_part->field->field_index); + str->q_append(SPIDER_SQL_IS_NOT_NULL_STR, SPIDER_SQL_IS_NOT_NULL_LEN); + } + DBUG_RETURN(-1); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_where_terminator_part( + ulong sql_type, + bool set_order, + int key_count +) { + int error_num; + spider_string *str, *str_part = NULL, *str_part2 = NULL; + DBUG_ENTER("spider_oracle_handler::append_where_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + str_part = &sql_part; + str_part2 = &sql_part2; + break; + default: + DBUG_RETURN(0); + } + error_num = append_where_terminator(sql_type, str, str_part, str_part2, + set_order, key_count); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_where_terminator( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + bool set_order, + int key_count +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_oracle_handler::append_where_terminator"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type != SPIDER_SQL_TYPE_HANDLER) + { + str->length(str->length() - SPIDER_SQL_AND_LEN); + if (!set_order) + result_list->key_order = key_count; + } else { + str_part2->length(str_part2->length() - SPIDER_SQL_AND_LEN); + + str_part->length(str_part->length() - SPIDER_SQL_COMMA_LEN); + if (!result_list->ha_read_kind) + str_part->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + if (str->append(*str_part)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + uint clause_length = str->length() - ha_next_pos; + if (clause_length < SPIDER_SQL_NEXT_LEN) + { + int roop_count; + clause_length = SPIDER_SQL_NEXT_LEN - clause_length; + if (str->reserve(clause_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + for (roop_count = 0; roop_count < (int) clause_length; roop_count++) + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_match_where_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_match_where_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_ASSERT(0); + DBUG_RETURN(0); + } + error_num = append_match_where(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_match_where( + spider_string *str +) { + int error_num; + bool first = TRUE; + st_spider_ft_info *ft_info = spider->ft_first; + DBUG_ENTER("spider_oracle_handler::append_match_where"); + if (spider->ft_current) + { + while (TRUE) + { + if (ft_info->used_in_where) + { + if (first) + { + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + first = FALSE; + } + if ((error_num = append_match_against(str, ft_info, NULL, 0))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + + if (ft_info == spider->ft_current) + break; + ft_info = ft_info->next; + } + if (!first) + str->length(str->length() - SPIDER_SQL_AND_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_update_where( + spider_string *str, + const TABLE *table, + my_ptrdiff_t ptr_diff +) { + uint field_name_length; + Field **field; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_oracle_handler::append_update_where"); + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + for (field = table->field; *field; field++) + { + if ( + table->s->primary_key == MAX_KEY || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { + field_name_length = + oracle_share->column_name_str[(*field)->field_index].length(); + if ((*field)->is_null(ptr_diff)) + { + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_IS_NULL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN); + } else { + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); + (*field)->move_field_offset(ptr_diff); + if ( + spider_db_oracle_utility. + append_column_value(spider, str, *field, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_AND_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + (*field)->move_field_offset(-ptr_diff); + } + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + } +/* + str->length(str->length() - SPIDER_SQL_AND_LEN); +*/ + if (str->reserve(SPIDER_SQL_LIMIT1_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LIMIT1_STR, SPIDER_SQL_LIMIT1_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_condition_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg +) { + int error_num; + spider_string *str; + bool start_where = FALSE; + DBUG_ENTER("spider_oracle_handler::append_condition_part"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + DBUG_PRINT("info",("spider case1 sql_type=%lu", sql_type)); + if (test_flg) + { + str = NULL; + } else { + str = &sql; + start_where = ((int) str->length() == where_pos); + } + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + DBUG_PRINT("info",("spider case2 sql_type=%lu", sql_type)); + if (test_flg) + { + str = NULL; + } else { + str = &update_sql; + start_where = ((int) str->length() == where_pos); + } + break; + case SPIDER_SQL_TYPE_HANDLER: + DBUG_PRINT("info",("spider case3 sql_type=%lu", sql_type)); + if (test_flg) + { + str = NULL; + } else { + str = &ha_sql; + start_where = TRUE; + if (spider->active_index == MAX_KEY) + { + set_where_pos(SPIDER_SQL_TYPE_HANDLER); + if (str->reserve(SPIDER_SQL_READ_LEN + SPIDER_SQL_FIRST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_READ_STR, SPIDER_SQL_READ_LEN); + ha_next_pos = str->length(); + str->q_append(SPIDER_SQL_FIRST_STR, SPIDER_SQL_FIRST_LEN); + sql_part2.length(0); + } + ha_where_pos = str->length(); + + if (sql_part2.length()) + { + str->append(sql_part2); + start_where = FALSE; + } + } + break; + default: + DBUG_PRINT("info",("spider default sql_type=%lu", sql_type)); + DBUG_RETURN(0); + } + error_num = append_condition(str, alias, alias_length, start_where, + sql_type); + DBUG_PRINT("info",("spider str=%s", str ? str->c_ptr_safe() : "NULL")); + DBUG_PRINT("info",("spider length=%u", str ? str->length() : 0)); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_condition( + spider_string *str, + const char *alias, + uint alias_length, + bool start_where, + ulong sql_type +) { + int error_num, restart_pos = 0, start_where_pos; + SPIDER_CONDITION *tmp_cond = spider->condition; + DBUG_ENTER("spider_oracle_handler::append_condition"); + DBUG_PRINT("info",("spider str=%p", str)); + DBUG_PRINT("info",("spider alias=%p", alias)); + DBUG_PRINT("info",("spider alias_length=%u", alias_length)); + DBUG_PRINT("info",("spider start_where=%s", start_where ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); + if (str && start_where) + { + start_where_pos = str->length(); + } else { + start_where_pos = 0; + } + + if (spider->is_clone && !tmp_cond) + { + tmp_cond = spider->pt_clone_source_handler->condition; + } + + while (tmp_cond) + { + if (str) + { + restart_pos = str->length(); + if (start_where) + { + if (str->reserve(SPIDER_SQL_WHERE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + start_where = FALSE; + } else { + if (str->reserve(SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + } + if ((error_num = spider_db_print_item_type( + (Item *) tmp_cond->cond, spider, str, alias, alias_length, + spider_dbton_oracle.dbton_id))) + { + if (str && error_num == ER_SPIDER_COND_SKIP_NUM) + { + DBUG_PRINT("info",("spider COND skip")); + str->length(restart_pos); + start_where = (restart_pos == start_where_pos); + } else + DBUG_RETURN(error_num); + } + tmp_cond = tmp_cond->next; + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_match_against_part( + ulong sql_type, + st_spider_ft_info *ft_info, + const char *alias, + uint alias_length +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_match_against_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_match_against(str, ft_info, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_match_against( + spider_string *str, + st_spider_ft_info *ft_info, + const char *alias, + uint alias_length +) { + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + String *ft_init_key; + KEY *key_info; + uint key_name_length; + int key_count; + KEY_PART_INFO *key_part; + Field *field; + DBUG_ENTER("spider_oracle_handler::append_match_against"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_MATCH_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); + + ft_init_key = ft_info->key; + key_info = &table->key_info[ft_info->inx]; + DBUG_PRINT("info", ("spider key_info->key_parts=%u", + key_info->key_parts)); + + for ( + key_part = key_info->key_part, + key_count = 0; + key_count < (int) key_info->key_parts; + key_part++, + key_count++ + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (alias_length) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + } else { + if (str->reserve(key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_AGAINST_LEN + SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + + char buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, share->access_charset); + tmp_str.init_calc_mem(211); + tmp_str.length(0); + if ( + tmp_str.append(ft_init_key->ptr(), ft_init_key->length(), + ft_init_key->charset()) || + str->reserve(tmp_str.length() * 2) || + spider_db_oracle_utility.append_escaped_util(str, tmp_str.get_str()) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (str->reserve( + SPIDER_SQL_VALUE_QUOTE_LEN + SPIDER_SQL_CLOSE_PAREN_LEN + + ((ft_info->flags & FT_BOOL) ? SPIDER_SQL_IN_BOOLEAN_MODE_LEN : 0) + + ((ft_info->flags & FT_EXPAND) ? + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN : 0) + )) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if (ft_info->flags & FT_BOOL) + str->q_append(SPIDER_SQL_IN_BOOLEAN_MODE_STR, + SPIDER_SQL_IN_BOOLEAN_MODE_LEN); + if (ft_info->flags & FT_EXPAND) + str->q_append(SPIDER_SQL_WITH_QUERY_EXPANSION_STR, + SPIDER_SQL_WITH_QUERY_EXPANSION_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_match_select_part( + ulong sql_type, + const char *alias, + uint alias_length +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_match_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_match_select(str, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_match_select( + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_match_select"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider->ft_current) + { + st_spider_ft_info *ft_info = spider->ft_first; + while (TRUE) + { + if ((error_num = append_match_against(str, ft_info, + alias, alias_length))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + if (ft_info == spider->ft_current) + break; + ft_info = ft_info->next; + } + } + DBUG_RETURN(0); +} + +void spider_oracle_handler::set_order_pos( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::set_order_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + order_pos = sql.length(); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + order_pos = update_sql.length(); + break; + case SPIDER_SQL_TYPE_HANDLER: + ha_next_pos = ha_sql.length(); + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_VOID_RETURN; +} + +void spider_oracle_handler::set_order_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::set_order_to_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + sql.length(order_pos); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + update_sql.length(order_pos); + break; + case SPIDER_SQL_TYPE_HANDLER: + ha_sql.length(ha_next_pos); + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_handler::append_key_order_for_merge_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_key_order_for_merge_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + ha_limit_pos = ha_sql.length(); + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_order_for_merge_with_alias(str, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_key_order_for_merge_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + /* sort for index merge */ + TABLE *table = spider->get_table(); + int length; + Field *field; + uint key_name_length; + DBUG_ENTER("spider_oracle_handler::append_key_order_for_merge_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + spider->result_list.direct_order_limit || + spider->result_list.internal_limit < 9223372036854775807LL || + spider->result_list.split_read < 9223372036854775807LL || + spider->result_list.internal_offset + ) { + if (update_rownum_appended || select_rownum_appended) + { + if (str->reserve(SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + order_pos = str->length(); + limit_pos = str->length(); + DBUG_RETURN(0); + } + sql_part.length(0); + if (str == &update_sql) + { + if (sql_part.reserve(str->length() + SPIDER_SQL_UPDATE_WRAPPER_HEAD_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(str->ptr(), where_pos); + sql_part.q_append(SPIDER_SQL_UPDATE_WRAPPER_HEAD_STR, + SPIDER_SQL_UPDATE_WRAPPER_HEAD_LEN); + } else { + if (sql_part.reserve(str->length() + SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN + + SPIDER_SQL_ROW_NUMBER_HEAD_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_HEAD_STR, + SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN); + sql_part.q_append(str->ptr(), table_name_pos - SPIDER_SQL_FROM_LEN); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_HEAD_STR, + SPIDER_SQL_ROW_NUMBER_HEAD_LEN); + } + if (table->s->primary_key < MAX_KEY) + { + /* sort by primary key */ + KEY *key_info = &table->key_info[table->s->primary_key]; + KEY_PART_INFO *key_part; + for ( + key_part = key_info->key_part, + length = 1; + length <= (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (sql_part.reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(alias, alias_length); + oracle_share->append_column_name(&sql_part, field->field_index); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } else { + /* sort by all columns */ + Field **fieldp; + for ( + fieldp = table->field, length = 1; + *fieldp; + fieldp++, length++ + ) { + key_name_length = + oracle_share->column_name_str[(*fieldp)->field_index].length(); + if (sql_part.reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(alias, alias_length); + oracle_share->append_column_name(&sql_part, (*fieldp)->field_index); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + uint pos_diff; + if (str == &update_sql) + { + uint table_name_size = (update_set_pos ? update_set_pos : where_pos) - + table_name_pos; + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - where_pos + + SPIDER_SQL_FROM_LEN + table_name_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_TAIL_LEN); + sql_part.q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + sql_part.q_append(str->ptr() + table_name_pos, table_name_size); + pos_diff = sql_part.length() - where_pos; + sql_part.q_append(str->ptr() + where_pos, str->length() - where_pos); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + update_rownum_appended = TRUE; + } else { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - table_name_pos + + SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_TAIL_LEN); + pos_diff = sql_part.length() + SPIDER_SQL_FROM_LEN - table_name_pos; + sql_part.q_append(str->ptr() + table_name_pos - SPIDER_SQL_FROM_LEN, + str->length() - table_name_pos + SPIDER_SQL_FROM_LEN); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + select_rownum_appended = TRUE; + table_name_pos = table_name_pos + pos_diff; + } + if (str->copy(sql_part)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + where_pos = where_pos + pos_diff; + order_pos = str->length(); + limit_pos = str->length(); + DBUG_RETURN(0); + } + if (table->s->primary_key < MAX_KEY) + { + /* sort by primary key */ + KEY *key_info = &table->key_info[table->s->primary_key]; + KEY_PART_INFO *key_part; + for ( + key_part = key_info->key_part, + length = 1; + length <= (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + if (length > 1) + { + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + } else { + /* sort by all columns */ + Field **fieldp; + for ( + fieldp = table->field, length = 1; + *fieldp; + fieldp++, length++ + ) { + key_name_length = + oracle_share->column_name_str[(*fieldp)->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, (*fieldp)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + if (length > 1) + { + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + } + limit_pos = str->length(); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_key_order_for_direct_order_limit_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_key_order_for_direct_order_limit_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_key_order_for_direct_order_limit_with_alias( + str, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_key_order_for_direct_order_limit_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + int error_num; + ORDER *order; + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + DBUG_ENTER("spider_oracle_handler::append_key_order_for_direct_order_limit_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_get_select_limit(spider, &select_lex, &select_limit, + &offset_limit); + if ( + spider->result_list.direct_order_limit || + spider->result_list.internal_limit < 9223372036854775807LL || + spider->result_list.split_read < 9223372036854775807LL || + spider->result_list.internal_offset + ) { + if (update_rownum_appended || select_rownum_appended) + { + if (str->reserve(SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + order_pos = str->length(); + limit_pos = str->length(); + DBUG_RETURN(0); + } + sql_part.length(0); + if (str == &update_sql) + { + if (sql_part.reserve(str->length() + SPIDER_SQL_UPDATE_WRAPPER_HEAD_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(str->ptr(), where_pos); + sql_part.q_append(SPIDER_SQL_UPDATE_WRAPPER_HEAD_STR, + SPIDER_SQL_UPDATE_WRAPPER_HEAD_LEN); + } else { + if (sql_part.reserve(str->length() + SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN + + SPIDER_SQL_ROW_NUMBER_HEAD_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_HEAD_STR, + SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN); + sql_part.q_append(str->ptr(), table_name_pos - SPIDER_SQL_FROM_LEN); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_HEAD_STR, + SPIDER_SQL_ROW_NUMBER_HEAD_LEN); + } + bool all_desc = TRUE; + if (select_lex->order_list.first) + { + for (order = (ORDER *) select_lex->order_list.first; order; + order = order->next) + { + if ((error_num = + spider_db_print_item_type((*order->item), spider, &sql_part, alias, + alias_length, spider_dbton_oracle.dbton_id))) + { + DBUG_PRINT("info",("spider error=%d", error_num)); + DBUG_RETURN(error_num); + } + if (order->asc) + { + if (sql_part.reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + all_desc = FALSE; + } else { + if (sql_part.reserve(SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } else { + all_desc = FALSE; + } + uint pos_diff; + if (str == &update_sql) + { + uint table_name_size = (update_set_pos ? update_set_pos : where_pos) - + table_name_pos; + if (all_desc) + { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - where_pos + + SPIDER_SQL_FROM_LEN + table_name_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN); + } else { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - where_pos + + SPIDER_SQL_FROM_LEN + table_name_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_TAIL_LEN); + } + sql_part.q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + sql_part.q_append(str->ptr() + table_name_pos, table_name_size); + pos_diff = sql_part.length() - where_pos; + sql_part.q_append(str->ptr() + where_pos, str->length() - where_pos); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + update_rownum_appended = TRUE; + } else { + if (all_desc) + { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - table_name_pos + + SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN); + } else { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - table_name_pos + + SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_TAIL_LEN); + } + pos_diff = sql_part.length() + SPIDER_SQL_FROM_LEN - table_name_pos; + sql_part.q_append(str->ptr() + table_name_pos - SPIDER_SQL_FROM_LEN, + str->length() - table_name_pos + SPIDER_SQL_FROM_LEN); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + select_rownum_appended = TRUE; + table_name_pos = table_name_pos + pos_diff; + } + if (str->copy(sql_part)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + where_pos = where_pos + pos_diff; + order_pos = str->length(); + limit_pos = str->length(); + DBUG_RETURN(0); + } + if (select_lex->order_list.first) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + for (order = (ORDER *) select_lex->order_list.first; order; + order = order->next) + { + if ((error_num = + spider_db_print_item_type((*order->item), spider, str, alias, + alias_length, spider_dbton_oracle.dbton_id))) + { + DBUG_PRINT("info",("spider error=%d", error_num)); + DBUG_RETURN(error_num); + } + if (order->asc) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (str->reserve(SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + limit_pos = str->length(); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_key_order_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_key_order_with_alias_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + case SPIDER_SQL_TYPE_TMP_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + error_num = append_key_order_for_handler(str, alias, alias_length); + DBUG_RETURN(error_num); + default: + DBUG_RETURN(0); + } + error_num = append_key_order_with_alias(str, alias, alias_length); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_key_order_for_handler( + spider_string *str, + const char *alias, + uint alias_length +) { + DBUG_ENTER("spider_oracle_handler::append_key_order_for_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider ha_next_pos=%d", ha_next_pos)); + DBUG_PRINT("info",("spider ha_where_pos=%d", ha_where_pos)); + str->q_append(alias, alias_length); + memset((char *) str->ptr() + str->length(), ' ', + ha_where_pos - ha_next_pos - alias_length); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_key_order_with_alias( + spider_string *str, + const char *alias, + uint alias_length +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + KEY *key_info = result_list->key_info; + int length; + KEY_PART_INFO *key_part; + Field *field; + uint key_name_length; + DBUG_ENTER("spider_oracle_handler::append_key_order_with_alias"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + spider->result_list.direct_order_limit || + spider->result_list.internal_limit < 9223372036854775807LL || + spider->result_list.split_read < 9223372036854775807LL || + spider->result_list.internal_offset + ) { + if (update_rownum_appended || select_rownum_appended) + { + if (str->reserve(SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + order_pos = str->length(); + limit_pos = str->length(); + DBUG_RETURN(0); + } + sql_part.length(0); + if (str == &update_sql) + { + if (sql_part.reserve(str->length() + SPIDER_SQL_UPDATE_WRAPPER_HEAD_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(str->ptr(), where_pos); + sql_part.q_append(SPIDER_SQL_UPDATE_WRAPPER_HEAD_STR, + SPIDER_SQL_UPDATE_WRAPPER_HEAD_LEN); + } else { + if (sql_part.reserve(str->length() + SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN + + SPIDER_SQL_ROW_NUMBER_HEAD_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_HEAD_STR, + SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN); + sql_part.q_append(str->ptr(), table_name_pos - SPIDER_SQL_FROM_LEN); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_HEAD_STR, + SPIDER_SQL_ROW_NUMBER_HEAD_LEN); + } + if (result_list->sorted == TRUE) + { + if (result_list->desc_flg == TRUE) + { + for ( + key_part = key_info->key_part + result_list->key_order, + length = 1; + length + result_list->key_order <= (int) key_info->key_parts && + length <= result_list->max_order; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (sql_part.reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(alias, alias_length); + oracle_share->append_column_name(&sql_part, field->field_index); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (sql_part.reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(alias, alias_length); + oracle_share->append_column_name(&sql_part, field->field_index); + sql_part.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } else { + for ( + key_part = key_info->key_part + result_list->key_order, + length = 1; + length + result_list->key_order <= (int) key_info->key_parts && + length <= result_list->max_order; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (sql_part.reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(alias, alias_length); + oracle_share->append_column_name(&sql_part, field->field_index); + sql_part.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (sql_part.reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(alias, alias_length); + oracle_share->append_column_name(&sql_part, field->field_index); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } + } + uint pos_diff; + if (str == &update_sql) + { + uint table_name_size = (update_set_pos ? update_set_pos : where_pos) - + table_name_pos; + if (result_list->sorted == TRUE && result_list->desc_flg == TRUE) + { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - where_pos + + SPIDER_SQL_FROM_LEN + table_name_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN); + } else { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - where_pos + + SPIDER_SQL_FROM_LEN + table_name_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_TAIL_LEN); + } + sql_part.q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + sql_part.q_append(str->ptr() + table_name_pos, + table_name_size); + pos_diff = sql_part.length() - where_pos; + sql_part.q_append(str->ptr() + where_pos, str->length() - where_pos); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + update_rownum_appended = TRUE; + } else { + if (result_list->sorted == TRUE && result_list->desc_flg == TRUE) + { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - table_name_pos + + SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN); + } else { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + str->length() - table_name_pos + + SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_TAIL_LEN); + } + pos_diff = sql_part.length() + SPIDER_SQL_FROM_LEN - table_name_pos; + sql_part.q_append(str->ptr() + table_name_pos - SPIDER_SQL_FROM_LEN, + str->length() - table_name_pos + SPIDER_SQL_FROM_LEN); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + select_rownum_appended = TRUE; + table_name_pos = table_name_pos + pos_diff; + } + if (str->copy(sql_part)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + where_pos = where_pos + pos_diff; + order_pos = str->length(); + limit_pos = str->length(); + DBUG_RETURN(0); + } + if (result_list->sorted == TRUE) + { + if (result_list->desc_flg == TRUE) + { + for ( + key_part = key_info->key_part + result_list->key_order, + length = 1; + length + result_list->key_order < (int) key_info->key_parts && + length < result_list->max_order; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if ( + length + result_list->key_order <= (int) key_info->key_parts && + length <= result_list->max_order + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + } else { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_DESC_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + } + } + } else { + for ( + key_part = key_info->key_part + result_list->key_order, + length = 1; + length + result_list->key_order < (int) key_info->key_parts && + length < result_list->max_order; + key_part++, + length++ + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if ( + length + result_list->key_order <= (int) key_info->key_parts && + length <= result_list->max_order + ) { + field = key_part->field; + key_name_length = + oracle_share->column_name_str[field->field_index].length(); + if (length == 1) + { + if (str->reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + } + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_DESC_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + str->q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + } else { + if (str->reserve(alias_length + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(alias, alias_length); + oracle_share->append_column_name(str, field->field_index); + } + } + } + } + limit_pos = str->length(); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_limit_part( + longlong offset, + longlong limit, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_limit_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + limit_pos = str->length(); + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + limit_pos = str->length(); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + limit_pos = str->length(); + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + ha_limit_pos = str->length(); + break; + default: + DBUG_RETURN(0); + } + error_num = append_limit(str, offset, limit); + DBUG_PRINT("info",("spider str=%s", str->c_ptr_safe())); + DBUG_PRINT("info",("spider length=%u", str->length())); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::reappend_limit_part( + longlong offset, + longlong limit, + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::reappend_limit_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + str->length(limit_pos); + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + str->length(limit_pos); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + str->length(limit_pos); + break; + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + str->length(ha_limit_pos); + break; + default: + DBUG_RETURN(0); + } + error_num = append_limit(str, offset, limit); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_limit( + spider_string *str, + longlong offset, + longlong limit +) { + char buf[SPIDER_LONGLONG_LEN + 1]; + uint32 length; + DBUG_ENTER("spider_oracle_handler::append_limit"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info", ("spider offset=%lld", offset)); + DBUG_PRINT("info", ("spider limit=%lld", limit)); + if (offset || limit < 9223372036854775807LL) + { + if ((int) str->length() == where_pos) + { + if (offset) + { + int error_num; + if ((error_num = append_key_order_for_direct_order_limit_with_alias( + str, NULL, 0))) + DBUG_RETURN(error_num); + } else { + if (str->reserve(SPIDER_SQL_WHERE_LEN + SPIDER_SQL_ROWNUM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + str->q_append(SPIDER_SQL_ROWNUM_STR, SPIDER_SQL_ROWNUM_LEN); + } + } + if (offset) + { + if (str->reserve(SPIDER_SQL_BETWEEN_LEN + SPIDER_SQL_AND_LEN + + ((SPIDER_LONGLONG_LEN) * 2))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_BETWEEN_STR, SPIDER_SQL_BETWEEN_LEN); + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, offset + 1); + str->q_append(buf, length); + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit + offset); + str->q_append(buf, length); + } else { + if (str->reserve(SPIDER_SQL_HS_LTEQUAL_LEN + + (SPIDER_LONGLONG_LEN))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HS_LTEQUAL_STR, SPIDER_SQL_HS_LTEQUAL_LEN); + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + str->q_append(buf, length); + } + if (update_rownum_appended) + { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_select_lock_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_select_lock_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_select_lock(str); + DBUG_PRINT("info",("spider str=%s", str->c_ptr_safe())); + DBUG_PRINT("info",("spider length=%u", str->length())); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_select_lock( + spider_string *str +) { + int lock_mode = spider_conn_lock_mode(spider); + DBUG_ENTER("spider_oracle_handler::append_select_lock"); + DBUG_PRINT("info",("spider this=%p", this)); + if (select_rownum_appended) + { + table_lock_mode = lock_mode; + } else { + if (lock_mode == SPIDER_LOCK_MODE_EXCLUSIVE) + { + if (str->reserve(SPIDER_SQL_FOR_UPDATE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FOR_UPDATE_STR, SPIDER_SQL_FOR_UPDATE_LEN); + } else if (lock_mode == SPIDER_LOCK_MODE_SHARED) + { + if (str->reserve(SPIDER_SQL_FOR_UPDATE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FOR_UPDATE_STR, SPIDER_SQL_FOR_UPDATE_LEN); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_union_all_start_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_union_all_start_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_union_all_start(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_union_all_start( + spider_string *str +) { + DBUG_ENTER("spider_oracle_handler::append_union_all_start"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_union_all_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_union_all_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_union_all(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_union_all( + spider_string *str +) { + DBUG_ENTER("spider_oracle_handler::append_union_all"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_UNION_ALL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_UNION_ALL_STR, SPIDER_SQL_UNION_ALL_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_union_all_end_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_union_all_end_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_union_all_end(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_union_all_end( + spider_string *str +) { + DBUG_ENTER("spider_oracle_handler::append_union_all_end"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(str->length() - + SPIDER_SQL_UNION_ALL_LEN + SPIDER_SQL_CLOSE_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_multi_range_cnt_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_multi_range_cnt_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + str = &sql; + break; + case SPIDER_SQL_TYPE_TMP_SQL: + str = &tmp_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_multi_range_cnt(str, multi_range_cnt, with_comma); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_multi_range_cnt( + spider_string *str, + uint multi_range_cnt, + bool with_comma +) { + int range_cnt_length; + char range_cnt_str[SPIDER_SQL_INT_LEN]; + DBUG_ENTER("spider_oracle_handler::append_multi_range_cnt"); + DBUG_PRINT("info",("spider this=%p", this)); + range_cnt_length = my_sprintf(range_cnt_str, (range_cnt_str, "%u", + multi_range_cnt)); + if (with_comma) + { + if (str->reserve(range_cnt_length + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(range_cnt_str, range_cnt_length); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (str->reserve(range_cnt_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(range_cnt_str, range_cnt_length); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_open_handler_part( + ulong sql_type, + uint handler_id, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_open_handler_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_open_handler(str, handler_id, conn, link_idx); + exec_ha_sql = str; + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_open_handler( + spider_string *str, + uint handler_id, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_open_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); + DBUG_PRINT("info",("spider m_handler_cid=%s", + spider->m_handler_cid[link_idx])); + if (str->reserve(SPIDER_SQL_HANDLER_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_HANDLER_STR, SPIDER_SQL_HANDLER_LEN); + if ((error_num = oracle_share->append_table_name(str, + spider->conn_link_idx[link_idx]))) + DBUG_RETURN(error_num); + if (str->reserve(SPIDER_SQL_OPEN_LEN + SPIDER_SQL_AS_LEN + + SPIDER_SQL_HANDLER_CID_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_OPEN_STR, SPIDER_SQL_OPEN_LEN); + str->q_append(SPIDER_SQL_AS_STR, SPIDER_SQL_AS_LEN); + str->q_append(spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_close_handler_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_close_handler_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_close_handler(str, link_idx); + exec_ha_sql = str; + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_close_handler( + spider_string *str, + int link_idx +) { + DBUG_ENTER("spider_oracle_handler::append_close_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_HANDLER_LEN + SPIDER_SQL_CLOSE_LEN + + SPIDER_SQL_HANDLER_CID_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_HANDLER_STR, SPIDER_SQL_HANDLER_LEN); + str->q_append(spider->m_handler_cid[link_idx], + SPIDER_SQL_HANDLER_CID_LEN); + str->q_append(SPIDER_SQL_CLOSE_STR, SPIDER_SQL_CLOSE_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_insert_terminator_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_insert_terminator_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + str = &insert_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_insert_terminator(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_insert_terminator( + spider_string *str +) { + DBUG_ENTER("spider_oracle_handler::append_insert_terminator"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider->result_list.insert_dup_update_pushdown) + { + DBUG_PRINT("info",("spider add duplicate key update")); + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_DUPLICATE_KEY_UPDATE_LEN + + dup_update_sql.length())) + { + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_DUPLICATE_KEY_UPDATE_STR, + SPIDER_SQL_DUPLICATE_KEY_UPDATE_LEN); + if (str->append(dup_update_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } else { + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_insert_values_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_insert_values_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + str = &insert_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_insert_values(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_insert_values( + spider_string *str +) { + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + Field **field; + bool add_value = FALSE; + DBUG_ENTER("spider_oracle_handler::append_insert_values"); + DBUG_PRINT("info",("spider this=%p", this)); + nextval_pos = 0; + if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + { + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + for (field = table->field; *field; field++) + { + DBUG_PRINT("info",("spider field_index=%u", (*field)->field_index)); + if ( + bitmap_is_set(table->write_set, (*field)->field_index) || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { +#ifndef DBUG_OFF + my_bitmap_map *tmp_map = + dbug_tmp_use_all_columns(table, table->read_set); +#endif + add_value = TRUE; + DBUG_PRINT("info",("spider is_null()=%s", + (*field)->is_null() ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider table->next_number_field=%p", + table->next_number_field)); + DBUG_PRINT("info",("spider *field=%p", *field)); + DBUG_PRINT("info",("spider force_auto_increment=%s", + (table->next_number_field && spider->force_auto_increment) ? + "TRUE" : "FALSE")); + if ( + table->next_number_field == *field && + !table->auto_increment_field_not_null && + !spider->force_auto_increment + ) { + nextval_pos = str->length(); + if (str->reserve(oracle_share->nextval_max_length + + SPIDER_SQL_COMMA_LEN)) + { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->length(str->length() + oracle_share->nextval_max_length); + } else if ((*field)->is_null()) + { + if (str->reserve(SPIDER_SQL_NULL_LEN + SPIDER_SQL_COMMA_LEN)) + { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else { + if ( + spider_db_oracle_utility. + append_column_value(spider, str, *field, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN) + ) { +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); +#ifndef DBUG_OFF + dbug_tmp_restore_column_map(table->read_set, tmp_map); +#endif + } + } + if (add_value) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_COMMA_LEN)) + { + str->length(0); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_into_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_into_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + str = &insert_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_into(str); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_into( + spider_string *str +) { + const TABLE *table = spider->get_table(); + Field **field; + uint field_name_length = 0; + DBUG_ENTER("spider_oracle_handler::append_into"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_INTO_LEN + oracle_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + oracle_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_INTO_STR, SPIDER_SQL_INTO_LEN); + insert_table_name_pos = str->length(); + append_table_name_with_adjusting(str, first_link_idx, + SPIDER_SQL_TYPE_INSERT_SQL); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + for (field = table->field; *field; field++) + { + if ( + bitmap_is_set(table->write_set, (*field)->field_index) || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { + field_name_length = + oracle_share->column_name_str[(*field)->field_index].length(); + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + if (field_name_length) + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_VALUES_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN); + insert_pos = str->length(); + DBUG_RETURN(0); +} + +void spider_oracle_handler::set_insert_to_pos( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::set_insert_to_pos"); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + insert_sql.length(insert_pos); + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_handler::append_from_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_from_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_HANDLER: + str = &ha_sql; + break; + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + str = &update_sql; + break; + default: + str = &sql; + break; + } + error_num = append_from(str, sql_type, link_idx); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_from( + spider_string *str, + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_oracle_handler::append_from"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider link_idx=%d", link_idx)); + if (sql_type == SPIDER_SQL_TYPE_HANDLER) + { + ha_table_name_pos = str->length(); + DBUG_PRINT("info",("spider ha_table_name_pos=%u", ha_table_name_pos)); + ha_sql_handler_id = spider->m_handler_id[link_idx]; + DBUG_PRINT("info",("spider ha_sql_handler_id=%u", ha_sql_handler_id)); + if (str->reserve(SPIDER_SQL_HANDLER_CID_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_LEN); + DBUG_PRINT("info",("spider m_handler_cid=%s", + spider->m_handler_cid[link_idx])); + } else { + if (str->reserve(SPIDER_SQL_FROM_LEN + oracle_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + oracle_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + table_name_pos = str->length(); + append_table_name_with_adjusting(str, link_idx, sql_type); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_flush_tables_part( + ulong sql_type, + int link_idx, + bool lock +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_flush_tables_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_flush_tables(str, link_idx, lock); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_flush_tables( + spider_string *str, + int link_idx, + bool lock +) { + DBUG_ENTER("spider_oracle_handler::append_flush_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + if (lock) + { + if (str->reserve(SPIDER_SQL_FLUSH_TABLES_LEN + + SPIDER_SQL_WITH_READ_LOCK_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FLUSH_TABLES_STR, SPIDER_SQL_FLUSH_TABLES_LEN); + str->q_append(SPIDER_SQL_WITH_READ_LOCK_STR, + SPIDER_SQL_WITH_READ_LOCK_LEN); + } else { + if (str->reserve(SPIDER_SQL_FLUSH_TABLES_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_FLUSH_TABLES_STR, SPIDER_SQL_FLUSH_TABLES_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_optimize_table_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_optimize_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_optimize_table(str, link_idx); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_optimize_table( + spider_string *str, + int link_idx +) { + SPIDER_SHARE *share = spider->share; + int conn_link_idx = spider->conn_link_idx[link_idx]; + int local_length = spider_param_internal_optimize_local(spider->trx->thd, + share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; + DBUG_ENTER("spider_oracle_handler::append_optimize_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_OPTIMIZE_LEN + SPIDER_SQL_SQL_TABLE_LEN + + local_length + + oracle_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + oracle_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_OPTIMIZE_STR, SPIDER_SQL_SQL_OPTIMIZE_LEN); + if (local_length) + str->q_append(SPIDER_SQL_SQL_LOCAL_STR, SPIDER_SQL_SQL_LOCAL_LEN); + str->q_append(SPIDER_SQL_SQL_TABLE_STR, SPIDER_SQL_SQL_TABLE_LEN); + oracle_share->append_table_name(str, conn_link_idx); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_analyze_table_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_analyze_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_analyze_table(str, link_idx); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_analyze_table( + spider_string *str, + int link_idx +) { + SPIDER_SHARE *share = spider->share; + int conn_link_idx = spider->conn_link_idx[link_idx]; + int local_length = spider_param_internal_optimize_local(spider->trx->thd, + share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; + DBUG_ENTER("spider_oracle_handler::append_analyze_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_ANALYZE_LEN + SPIDER_SQL_SQL_TABLE_LEN + + local_length + + oracle_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + oracle_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_ANALYZE_STR, SPIDER_SQL_SQL_ANALYZE_LEN); + if (local_length) + str->q_append(SPIDER_SQL_SQL_LOCAL_STR, SPIDER_SQL_SQL_LOCAL_LEN); + str->q_append(SPIDER_SQL_SQL_TABLE_STR, SPIDER_SQL_SQL_TABLE_LEN); + oracle_share->append_table_name(str, conn_link_idx); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_repair_table_part( + ulong sql_type, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_repair_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_repair_table(str, link_idx, check_opt); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_repair_table( + spider_string *str, + int link_idx, + HA_CHECK_OPT* check_opt +) { + SPIDER_SHARE *share = spider->share; + int conn_link_idx = spider->conn_link_idx[link_idx]; + int local_length = spider_param_internal_optimize_local(spider->trx->thd, + share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; + DBUG_ENTER("spider_oracle_handler::append_repair_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_REPAIR_LEN + SPIDER_SQL_SQL_TABLE_LEN + + local_length + + oracle_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + oracle_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_REPAIR_STR, SPIDER_SQL_SQL_REPAIR_LEN); + if (local_length) + str->q_append(SPIDER_SQL_SQL_LOCAL_STR, SPIDER_SQL_SQL_LOCAL_LEN); + str->q_append(SPIDER_SQL_SQL_TABLE_STR, SPIDER_SQL_SQL_TABLE_LEN); + oracle_share->append_table_name(str, conn_link_idx); + if (check_opt->flags & T_QUICK) + { + if (str->reserve(SPIDER_SQL_SQL_QUICK_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_QUICK_STR, SPIDER_SQL_SQL_QUICK_LEN); + } + if (check_opt->flags & T_EXTEND) + { + if (str->reserve(SPIDER_SQL_SQL_EXTENDED_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_EXTENDED_STR, SPIDER_SQL_SQL_EXTENDED_LEN); + } + if (check_opt->sql_flags & TT_USEFRM) + { + if (str->reserve(SPIDER_SQL_SQL_USE_FRM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_USE_FRM_STR, SPIDER_SQL_SQL_USE_FRM_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_check_table_part( + ulong sql_type, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_check_table_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_check_table(str, link_idx, check_opt); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_check_table( + spider_string *str, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int conn_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_oracle_handler::append_check_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_CHECK_TABLE_LEN + + oracle_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + oracle_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_CHECK_TABLE_STR, + SPIDER_SQL_SQL_CHECK_TABLE_LEN); + oracle_share->append_table_name(str, conn_link_idx); + if (check_opt->flags & T_QUICK) + { + if (str->reserve(SPIDER_SQL_SQL_QUICK_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_QUICK_STR, SPIDER_SQL_SQL_QUICK_LEN); + } + if (check_opt->flags & T_FAST) + { + if (str->reserve(SPIDER_SQL_SQL_FAST_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_FAST_STR, SPIDER_SQL_SQL_FAST_LEN); + } + if (check_opt->flags & T_MEDIUM) + { + if (str->reserve(SPIDER_SQL_SQL_MEDIUM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_MEDIUM_STR, SPIDER_SQL_SQL_MEDIUM_LEN); + } + if (check_opt->flags & T_EXTEND) + { + if (str->reserve(SPIDER_SQL_SQL_EXTENDED_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_EXTENDED_STR, SPIDER_SQL_SQL_EXTENDED_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_enable_keys_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_enable_keys_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_enable_keys(str, link_idx); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_enable_keys( + spider_string *str, + int link_idx +) { + int conn_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_oracle_handler::append_enable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_ALTER_TABLE_LEN + + oracle_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + oracle_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_SQL_ENABLE_KEYS_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_ALTER_TABLE_STR, + SPIDER_SQL_SQL_ALTER_TABLE_LEN); + oracle_share->append_table_name(str, conn_link_idx); + str->q_append(SPIDER_SQL_SQL_ENABLE_KEYS_STR, + SPIDER_SQL_SQL_ENABLE_KEYS_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_disable_keys_part( + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_disable_keys_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = append_disable_keys(str, link_idx); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_disable_keys( + spider_string *str, + int link_idx +) { + int conn_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_oracle_handler::append_disable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_SQL_ALTER_TABLE_LEN + + oracle_share->db_names_str[conn_link_idx].length() + + SPIDER_SQL_DOT_LEN + + oracle_share->table_names_str[conn_link_idx].length() + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_SQL_DISABLE_KEYS_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_SQL_ALTER_TABLE_STR, + SPIDER_SQL_SQL_ALTER_TABLE_LEN); + oracle_share->append_table_name(str, conn_link_idx); + str->q_append(SPIDER_SQL_SQL_DISABLE_KEYS_STR, + SPIDER_SQL_SQL_DISABLE_KEYS_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_delete_all_rows_part( + ulong sql_type +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_delete_all_rows_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_DELETE_SQL: + str = &update_sql; + break; + default: + DBUG_RETURN(0); + } + error_num = append_delete_all_rows(str, sql_type); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_delete_all_rows( + spider_string *str, + ulong sql_type +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_delete_all_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + if (spider->sql_command == SQLCOM_TRUNCATE) + { + if ((error_num = append_truncate(str, sql_type, first_link_idx))) + DBUG_RETURN(error_num); + } else { + if ( + (error_num = append_delete(str)) || + (error_num = append_from(str, sql_type, first_link_idx)) + ) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_truncate( + spider_string *str, + ulong sql_type, + int link_idx +) { + DBUG_ENTER("spider_oracle_handler::append_truncate"); + if (str->reserve(SPIDER_SQL_TRUNCATE_TABLE_LEN + + oracle_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + oracle_share->table_nm_max_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_TRUNCATE_TABLE_STR, SPIDER_SQL_TRUNCATE_TABLE_LEN); + table_name_pos = str->length(); + append_table_name_with_adjusting(str, link_idx, sql_type); + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_explain_select_part( + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx +) { + int error_num; + spider_string *str; + DBUG_ENTER("spider_oracle_handler::append_explain_select_part"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_OTHER_SQL: + str = &spider->result_list.sqls[link_idx]; + break; + default: + DBUG_RETURN(0); + } + error_num = + append_explain_select(str, start_key, end_key, sql_type, link_idx); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::append_explain_select( + spider_string *str, + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::append_explain_select"); + DBUG_PRINT("info",("spider this=%p", this)); + if (str->reserve(SPIDER_SQL_EXPLAIN_SELECT_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_EXPLAIN_SELECT_STR, SPIDER_SQL_EXPLAIN_SELECT_LEN); + if ( + (error_num = append_from(str, sql_type, link_idx)) || + (error_num = append_key_where(str, NULL, NULL, start_key, end_key, + sql_type, FALSE)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + DBUG_RETURN(0); +} + +bool spider_oracle_handler::is_bulk_insert_exec_period( + bool bulk_end +) { + DBUG_ENTER("spider_oracle_handler::is_bulk_insert_exec_period"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_PRINT("info",("spider insert_sql.length=%u", insert_sql.length())); + DBUG_PRINT("info",("spider insert_pos=%d", insert_pos)); + DBUG_PRINT("info",("spider insert_sql=%s", insert_sql.c_ptr_safe())); + if ( +/* + (bulk_end || (int) insert_sql.length() >= spider->bulk_size) && +*/ + (int) insert_sql.length() > insert_pos + ) { + DBUG_RETURN(TRUE); + } + DBUG_RETURN(FALSE); +} + +bool spider_oracle_handler::sql_is_filled_up( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::sql_is_filled_up"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(filled_up); +} + +bool spider_oracle_handler::sql_is_empty( + ulong sql_type +) { + bool is_empty; + DBUG_ENTER("spider_oracle_handler::sql_is_empty"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + is_empty = (sql.length() == 0); + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + is_empty = (insert_sql.length() == 0); + break; + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + is_empty = (update_sql.length() == 0); + break; + case SPIDER_SQL_TYPE_TMP_SQL: + is_empty = (tmp_sql.length() == 0); + break; + case SPIDER_SQL_TYPE_HANDLER: + is_empty = (ha_sql.length() == 0); + break; + default: + is_empty = TRUE; + break; + } + DBUG_RETURN(is_empty); +} + +bool spider_oracle_handler::support_multi_split_read() +{ + DBUG_ENTER("spider_oracle_handler::support_multi_split_read"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +bool spider_oracle_handler::support_bulk_update() +{ + DBUG_ENTER("spider_oracle_handler::support_bulk_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_oracle_handler::bulk_tmp_table_insert() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::bulk_tmp_table_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = store_sql_to_bulk_tmp_table(&update_sql, upd_tmp_tbl); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::bulk_tmp_table_insert( + int link_idx +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::bulk_tmp_table_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = store_sql_to_bulk_tmp_table( + &spider->result_list.update_sqls[link_idx], + spider->result_list.upd_tmp_tbls[link_idx]); + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::bulk_tmp_table_end_bulk_insert() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::bulk_tmp_table_end_bulk_insert"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((error_num = upd_tmp_tbl->file->ha_end_bulk_insert())) + { + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::bulk_tmp_table_rnd_init() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::bulk_tmp_table_rnd_init"); + DBUG_PRINT("info",("spider this=%p", this)); + upd_tmp_tbl->file->extra(HA_EXTRA_CACHE); + if ((error_num = upd_tmp_tbl->file->ha_rnd_init(TRUE))) + { + DBUG_RETURN(error_num); + } + reading_from_bulk_tmp_table = TRUE; + DBUG_RETURN(0); +} + +int spider_oracle_handler::bulk_tmp_table_rnd_next() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::bulk_tmp_table_rnd_next"); + DBUG_PRINT("info",("spider this=%p", this)); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + error_num = upd_tmp_tbl->file->ha_rnd_next(upd_tmp_tbl->record[0]); +#else + error_num = upd_tmp_tbl->file->rnd_next(upd_tmp_tbl->record[0]); +#endif + if (!error_num) + { + error_num = restore_sql_from_bulk_tmp_table(&insert_sql, upd_tmp_tbl); + } + DBUG_RETURN(error_num); +} + +int spider_oracle_handler::bulk_tmp_table_rnd_end() +{ + int error_num; + DBUG_ENTER("spider_oracle_handler::bulk_tmp_table_rnd_end"); + DBUG_PRINT("info",("spider this=%p", this)); + reading_from_bulk_tmp_table = FALSE; + if ((error_num = upd_tmp_tbl->file->ha_rnd_end())) + { + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +bool spider_oracle_handler::need_copy_for_update( + int link_idx +) { + int all_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_oracle_handler::need_copy_for_update"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(!oracle_share->same_db_table_name || + spider->share->link_statuses[all_link_idx] == SPIDER_LINK_STATUS_RECOVERY); +} + +bool spider_oracle_handler::bulk_tmp_table_created() +{ + DBUG_ENTER("spider_oracle_handler::bulk_tmp_table_created"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(upd_tmp_tbl); +} + +int spider_oracle_handler::mk_bulk_tmp_table_and_bulk_start() +{ + THD *thd = spider->trx->thd; + TABLE *table = spider->get_table(); + DBUG_ENTER("spider_oracle_handler::mk_bulk_tmp_table_and_bulk_start"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!upd_tmp_tbl) + { + if (!(upd_tmp_tbl = spider_mk_sys_tmp_table( + thd, table, &upd_tmp_tbl_prm, "a", update_sql.charset()))) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + upd_tmp_tbl->file->extra(HA_EXTRA_WRITE_CACHE); + upd_tmp_tbl->file->ha_start_bulk_insert((ha_rows) 0); + } + DBUG_RETURN(0); +} + +void spider_oracle_handler::rm_bulk_tmp_table() +{ + DBUG_ENTER("spider_oracle_handler::rm_bulk_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + if (upd_tmp_tbl) + { + spider_rm_sys_tmp_table(spider->trx->thd, upd_tmp_tbl, &upd_tmp_tbl_prm); + upd_tmp_tbl = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_handler::store_sql_to_bulk_tmp_table( + spider_string *str, + TABLE *tmp_table +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::store_sql_to_bulk_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_table->field[0]->set_notnull(); + tmp_table->field[0]->store(str->ptr(), str->length(), str->charset()); + if ((error_num = tmp_table->file->ha_write_row(tmp_table->record[0]))) + DBUG_RETURN(error_num); + DBUG_RETURN(0); +} + +int spider_oracle_handler::restore_sql_from_bulk_tmp_table( + spider_string *str, + TABLE *tmp_table +) { + DBUG_ENTER("spider_oracle_handler::restore_sql_from_bulk_tmp_table"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_table->field[0]->val_str(str->get_str()); + str->mem_calc(); + DBUG_RETURN(0); +} + +int spider_oracle_handler::insert_lock_tables_list( + SPIDER_CONN *conn, + int link_idx +) { + spider_db_oracle *db_conn = (spider_db_oracle *) conn->db_conn; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash2 = &link_for_hash[link_idx]; + DBUG_ENTER("spider_oracle_handler::insert_lock_tables_list"); + DBUG_PRINT("info",("spider this=%p", this)); + uint old_elements = + db_conn->lock_table_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value( + &db_conn->lock_table_hash, + tmp_link_for_hash2->db_table_str_hash_value, + (uchar*) tmp_link_for_hash2)) +#else + if (my_hash_insert(&db_conn->lock_table_hash, + (uchar*) tmp_link_for_hash2)) +#endif + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (db_conn->lock_table_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + db_conn->lock_table_hash, + (db_conn->lock_table_hash.array.max_element - old_elements) * + db_conn->lock_table_hash.array.size_of_element); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::append_lock_tables_list( + SPIDER_CONN *conn, + int link_idx, + int *appended +) { + int error_num; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash, *tmp_link_for_hash2; + int conn_link_idx = spider->conn_link_idx[link_idx]; + spider_db_oracle *db_conn = (spider_db_oracle *) conn->db_conn; + DBUG_ENTER("spider_oracle_handler::append_lock_tables_list"); + DBUG_PRINT("info",("spider this=%p", this)); + tmp_link_for_hash2 = &link_for_hash[link_idx]; + tmp_link_for_hash2->db_table_str = + &oracle_share->db_table_str[conn_link_idx]; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + tmp_link_for_hash2->db_table_str_hash_value = + oracle_share->db_table_str_hash_value[conn_link_idx]; + if (!(tmp_link_for_hash = (SPIDER_LINK_FOR_HASH *) + my_hash_search_using_hash_value( + &db_conn->lock_table_hash, + tmp_link_for_hash2->db_table_str_hash_value, + (uchar*) tmp_link_for_hash2->db_table_str->ptr(), + tmp_link_for_hash2->db_table_str->length()))) +#else + if (!(tmp_link_for_hash = (SPIDER_LINK_FOR_HASH *) my_hash_search( + &db_conn->lock_table_hash, + (uchar*) tmp_link_for_hash2->db_table_str->ptr(), + tmp_link_for_hash2->db_table_str->length()))) +#endif + { + if ((error_num = insert_lock_tables_list(conn, link_idx))) + DBUG_RETURN(error_num); + *appended = 1; + } else { + if (tmp_link_for_hash->spider->lock_type < spider->lock_type) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value( + &db_conn->lock_table_hash, + tmp_link_for_hash->db_table_str_hash_value, + (uchar*) tmp_link_for_hash); +#else + my_hash_delete(&db_conn->lock_table_hash, + (uchar*) tmp_link_for_hash); +#endif + uint old_elements = + db_conn->lock_table_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value( + &db_conn->lock_table_hash, + tmp_link_for_hash2->db_table_str_hash_value, + (uchar*) tmp_link_for_hash2)) +#else + if (my_hash_insert(&db_conn->lock_table_hash, + (uchar*) tmp_link_for_hash2)) +#endif + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (db_conn->lock_table_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + db_conn->lock_table_hash, + (db_conn->lock_table_hash.array.max_element - old_elements) * + db_conn->lock_table_hash.array.size_of_element); + } + } + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::realloc_sql( + ulong *realloced +) { + THD *thd = spider->trx->thd; + st_spider_share *share = spider->share; + int init_sql_alloc_size = + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); + DBUG_ENTER("spider_oracle_handler::realloc_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + if ((int) sql.alloced_length() > init_sql_alloc_size * 2) + { + sql.free(); + if (sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_SELECT_SQL; + } + if ((int) ha_sql.alloced_length() > init_sql_alloc_size * 2) + { + ha_sql.free(); + if (ha_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_SELECT_SQL; + } + if ((int) dup_update_sql.alloced_length() > init_sql_alloc_size * 2) + { + dup_update_sql.free(); + if (dup_update_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if ((int) insert_sql.alloced_length() > init_sql_alloc_size * 2) + { + insert_sql.free(); + if (insert_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_INSERT_SQL; + } + if ((int) update_sql.alloced_length() > init_sql_alloc_size * 2) + { + update_sql.free(); + if (update_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= (SPIDER_SQL_TYPE_UPDATE_SQL | SPIDER_SQL_TYPE_DELETE_SQL); + } + update_sql.length(0); + if ((int) tmp_sql.alloced_length() > init_sql_alloc_size * 2) + { + tmp_sql.free(); + if (tmp_sql.real_alloc(init_sql_alloc_size)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + *realloced |= SPIDER_SQL_TYPE_TMP_SQL; + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::reset_sql( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::reset_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & SPIDER_SQL_TYPE_SELECT_SQL) + { + table_lock_mode = 0; + select_rownum_appended = FALSE; + sql.length(0); + } + if (sql_type & SPIDER_SQL_TYPE_INSERT_SQL) + { + insert_sql.length(0); + } + if (sql_type & (SPIDER_SQL_TYPE_UPDATE_SQL | SPIDER_SQL_TYPE_DELETE_SQL | + SPIDER_SQL_TYPE_BULK_UPDATE_SQL)) + { + update_rownum_appended = FALSE; + update_set_pos = 0; + update_sql.length(0); + } + if (sql_type & SPIDER_SQL_TYPE_TMP_SQL) + { + tmp_sql.length(0); + } + if (sql_type & SPIDER_SQL_TYPE_HANDLER) + { + ha_sql.length(0); + } + DBUG_RETURN(0); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +int spider_oracle_handler::reset_keys( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::reset_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_oracle_handler::reset_upds( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::reset_upds"); + DBUG_PRINT("info",("spider this=%p", this)); + hs_upds.clear(); + DBUG_RETURN(0); +} + +int spider_oracle_handler::reset_strs( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::reset_strs"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_oracle_handler::reset_strs_pos( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::reset_strs_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + +int spider_oracle_handler::push_back_upds( + SPIDER_HS_STRING_REF &info +) { + int error_num; + DBUG_ENTER("spider_oracle_handler::push_back_upds"); + DBUG_PRINT("info",("spider this=%p", this)); + error_num = hs_upds.push_back(info); + DBUG_RETURN(error_num); +} +#endif + +bool spider_oracle_handler::need_lock_before_set_sql_for_exec( + ulong sql_type +) { + DBUG_ENTER("spider_oracle_handler::need_lock_before_set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +int spider_oracle_handler::set_sql_for_exec( + ulong sql_type, + int link_idx +) { + int error_num; + uint tmp_pos; + SPIDER_SHARE *share = spider->share; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + int all_link_idx = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_oracle_handler::set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql_type & (SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL)) + { + if (table_lock_mode) + { + spider_string *str = &result_list->insert_sqls[link_idx]; + str->length(0); + if (str->reserve(SPIDER_SQL_LOCK_TABLE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LOCK_TABLE_STR, SPIDER_SQL_LOCK_TABLE_LEN); + if ((error_num = oracle_share->append_table_name(str, all_link_idx))) + DBUG_RETURN(error_num); + if (table_lock_mode == SPIDER_LOCK_MODE_EXCLUSIVE) + { + if (str->reserve(SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_STR, + SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_LEN); + } else if (table_lock_mode == SPIDER_LOCK_MODE_SHARED) + { + if (str->reserve(SPIDER_SQL_LOCK_TABLE_SHARE_MODE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_LOCK_TABLE_SHARE_MODE_STR, + SPIDER_SQL_LOCK_TABLE_SHARE_MODE_LEN); + } + exec_lock_sql = str; + } + + if (oracle_share->same_db_table_name || link_idx == first_link_idx) + { + if (sql_type & SPIDER_SQL_TYPE_SELECT_SQL) + exec_sql = &sql; + if (sql_type & SPIDER_SQL_TYPE_TMP_SQL) + exec_tmp_sql = &tmp_sql; + } else { + char tmp_table_name[MAX_FIELD_WIDTH * 2], + tgt_table_name[MAX_FIELD_WIDTH * 2]; + int tmp_table_name_length; + spider_string tgt_table_name_str(tgt_table_name, + MAX_FIELD_WIDTH * 2, + oracle_share->db_names_str[link_idx].charset()); + const char *table_names[2], *table_aliases[2]; + uint table_name_lengths[2], table_alias_lengths[2]; + tgt_table_name_str.init_calc_mem(212); + tgt_table_name_str.length(0); + if (result_list->tmp_table_join) + { + create_tmp_bka_table_name(tmp_table_name, &tmp_table_name_length, + link_idx); + append_table_name_with_adjusting(&tgt_table_name_str, link_idx, + SPIDER_SQL_TYPE_TMP_SQL); + table_names[0] = tmp_table_name; + table_names[1] = tgt_table_name_str.c_ptr(); + table_name_lengths[0] = tmp_table_name_length; + table_name_lengths[1] = tgt_table_name_str.length(); + table_aliases[0] = SPIDER_SQL_A_STR; + table_aliases[1] = SPIDER_SQL_B_STR; + table_alias_lengths[0] = SPIDER_SQL_A_LEN; + table_alias_lengths[1] = SPIDER_SQL_B_LEN; + } + if (sql_type & SPIDER_SQL_TYPE_SELECT_SQL) + { + exec_sql = &result_list->sqls[link_idx]; + if (exec_sql->copy(sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + else { + tmp_pos = exec_sql->length(); + exec_sql->length(table_name_pos); + if (result_list->tmp_table_join) + { + if ((error_num = spider_db_oracle_utility.append_from_with_alias( + exec_sql, table_names, table_name_lengths, + table_aliases, table_alias_lengths, 2, + &table_name_pos, TRUE)) + ) + DBUG_RETURN(error_num); + } else { + append_table_name_with_adjusting(exec_sql, link_idx, + SPIDER_SQL_TYPE_SELECT_SQL); + } + exec_sql->length(tmp_pos); + } + } + if (sql_type & SPIDER_SQL_TYPE_TMP_SQL) + { + exec_tmp_sql = &result_list->tmp_sqls[link_idx]; + if (result_list->tmp_table_join) + { + if (exec_tmp_sql->copy(tmp_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + else { + tmp_pos = exec_tmp_sql->length(); + exec_tmp_sql->length(tmp_sql_pos1); + exec_tmp_sql->q_append(tmp_table_name, tmp_table_name_length); + exec_tmp_sql->length(tmp_sql_pos2); + exec_tmp_sql->q_append(tmp_table_name, tmp_table_name_length); + exec_tmp_sql->length(tmp_sql_pos3); + exec_tmp_sql->q_append(tmp_table_name, tmp_table_name_length); + exec_tmp_sql->length(tmp_pos); + } + } + } + } + } + if (sql_type & SPIDER_SQL_TYPE_INSERT_SQL) + { + if (oracle_share->same_db_table_name || link_idx == first_link_idx) + exec_insert_sql = &insert_sql; + else { + exec_insert_sql = &result_list->insert_sqls[link_idx]; + if (exec_insert_sql->copy(insert_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_PRINT("info",("spider exec_insert_sql=%s", + exec_insert_sql->c_ptr_safe())); + tmp_pos = exec_insert_sql->length(); + exec_insert_sql->length(insert_table_name_pos); + append_table_name_with_adjusting(exec_insert_sql, link_idx, + sql_type); + exec_insert_sql->length(tmp_pos); + DBUG_PRINT("info",("spider exec_insert_sql->length=%u", + exec_insert_sql->length())); + DBUG_PRINT("info",("spider exec_insert_sql=%s", + exec_insert_sql->c_ptr_safe())); + } + if (nextval_pos) + { + memcpy((uchar *) exec_insert_sql->ptr() + nextval_pos, + oracle_share->nextval_str[all_link_idx].ptr(), + oracle_share->nextval_max_length); + } + } + if (sql_type & SPIDER_SQL_TYPE_BULK_UPDATE_SQL) + { + if (reading_from_bulk_tmp_table) + { + if ( + oracle_share->same_db_table_name && + share->link_statuses[all_link_idx] != SPIDER_LINK_STATUS_RECOVERY + ) { + exec_update_sql = &insert_sql; + } else if (!spider->result_list.upd_tmp_tbls[link_idx]) + { + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + } else { + exec_update_sql = &spider->result_list.insert_sqls[link_idx]; + if ((error_num = restore_sql_from_bulk_tmp_table(exec_update_sql, + spider->result_list.upd_tmp_tbls[link_idx]))) + { + DBUG_RETURN(error_num); + } + } + } else { + if ( + oracle_share->same_db_table_name && + share->link_statuses[all_link_idx] != SPIDER_LINK_STATUS_RECOVERY + ) { + exec_update_sql = &update_sql; + } else { + exec_update_sql = &spider->result_list.update_sqls[link_idx]; + } + } + DBUG_PRINT("info",("spider exec_update_sql=%s", + exec_update_sql->c_ptr_safe())); + } else if (sql_type & + (SPIDER_SQL_TYPE_UPDATE_SQL | SPIDER_SQL_TYPE_DELETE_SQL)) + { + if (oracle_share->same_db_table_name || link_idx == first_link_idx) + exec_update_sql = &update_sql; + else { + exec_update_sql = &spider->result_list.update_sqls[link_idx]; + if (exec_update_sql->copy(update_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + tmp_pos = exec_update_sql->length(); + exec_update_sql->length(table_name_pos); + append_table_name_with_adjusting(exec_update_sql, link_idx, + sql_type); + exec_update_sql->length(tmp_pos); + } + DBUG_PRINT("info",("spider exec_update_sql=%s", + exec_update_sql->c_ptr_safe())); + } + if (sql_type & SPIDER_SQL_TYPE_HANDLER) + { + if (spider->m_handler_id[link_idx] == ha_sql_handler_id) + exec_ha_sql = &ha_sql; + else { + exec_ha_sql = &result_list->sqls[link_idx]; + if (exec_ha_sql->copy(ha_sql)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + else { + tmp_pos = exec_ha_sql->length(); + exec_ha_sql->length(ha_table_name_pos); + append_table_name_with_adjusting(exec_ha_sql, link_idx, + SPIDER_SQL_TYPE_HANDLER); + exec_ha_sql->length(tmp_pos); + } + } + DBUG_PRINT("info",("spider exec_ha_sql=%s", + exec_ha_sql->c_ptr_safe())); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::set_sql_for_exec( + spider_db_copy_table *tgt_ct, + ulong sql_type +) { + spider_oracle_copy_table *oracle_ct = (spider_oracle_copy_table *) tgt_ct; + DBUG_ENTER("spider_oracle_handler::set_sql_for_exec"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_INSERT_SQL: + exec_insert_sql = &oracle_ct->sql; + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::execute_sql( + ulong sql_type, + SPIDER_CONN *conn, + int quick_mode, + int *need_mon +) { + spider_string *tgt_sql; + uint tgt_length; + DBUG_ENTER("spider_oracle_handler::execute_sql"); + DBUG_PRINT("info",("spider this=%p", this)); + switch (sql_type) + { + case SPIDER_SQL_TYPE_SELECT_SQL: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_SELECT_SQL")); + tgt_sql = exec_sql; + tgt_length = tgt_sql->length(); + if (table_lock_mode) + { + DBUG_PRINT("info",("spider table_lock_mode=%d", table_lock_mode)); + spider_db_oracle *db_conn = (spider_db_oracle *) conn->db_conn; + db_conn->table_lock_mode = table_lock_mode; + db_conn->exec_lock_sql = exec_lock_sql; + table_lock_mode = 0; + } + break; + case SPIDER_SQL_TYPE_INSERT_SQL: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_SELECT_SQL")); + tgt_sql = exec_insert_sql; + tgt_length = tgt_sql->length(); + break; + case SPIDER_SQL_TYPE_UPDATE_SQL: + case SPIDER_SQL_TYPE_DELETE_SQL: + case SPIDER_SQL_TYPE_BULK_UPDATE_SQL: + DBUG_PRINT("info",("spider %s", + sql_type == SPIDER_SQL_TYPE_UPDATE_SQL ? "SPIDER_SQL_TYPE_UPDATE_SQL" : + sql_type == SPIDER_SQL_TYPE_DELETE_SQL ? "SPIDER_SQL_TYPE_DELETE_SQL" : + "SPIDER_SQL_TYPE_BULK_UPDATE_SQL" + )); + tgt_sql = exec_update_sql; + tgt_length = tgt_sql->length(); + break; + case SPIDER_SQL_TYPE_TMP_SQL: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_TMP_SQL")); + tgt_sql = exec_tmp_sql; + tgt_length = tgt_sql->length(); + break; + case SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL")); + tgt_sql = exec_tmp_sql; + tgt_length = tmp_sql_pos5; + break; + case SPIDER_SQL_TYPE_HANDLER: + DBUG_PRINT("info",("spider SPIDER_SQL_TYPE_HANDLER")); + tgt_sql = exec_ha_sql; + tgt_length = tgt_sql->length(); + break; + default: + /* nothing to do */ + DBUG_PRINT("info",("spider default")); + DBUG_RETURN(0); + } + DBUG_RETURN(spider_db_query( + conn, + tgt_sql->ptr(), + tgt_length, + quick_mode, + need_mon + )); +} + +int spider_oracle_handler::reset() +{ + DBUG_ENTER("spider_oracle_handler::reset"); + DBUG_PRINT("info",("spider this=%p", this)); + update_sql.length(0); + DBUG_RETURN(0); +} + +int spider_oracle_handler::sts_mode_exchange( + int sts_mode +) { + DBUG_ENTER("spider_oracle_handler::sts_mode_exchange"); + DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); + DBUG_RETURN(1); +} + +int spider_oracle_handler::show_table_status( + int link_idx, + int sts_mode, + uint flag +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_DB_RESULT *res; + SPIDER_SHARE *share = spider->share; + uint pos = (2 * spider->conn_link_idx[link_idx]); + DBUG_ENTER("spider_oracle_handler::show_table_status"); + DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); + if ( + (flag & HA_STATUS_AUTO) && + (error_num = show_autoinc(link_idx)) + ) { + DBUG_RETURN(error_num); + } + + if (sts_mode == 1) + { +/* + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + oracle_share->show_table_status[0 + pos].ptr(), + oracle_share->show_table_status[0 + pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { +*/ + /* retry */ +/* + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + oracle_share->show_table_status[0 + pos].ptr(), + oracle_share->show_table_status[0 + pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (error_num || (error_num = spider_db_errorno(conn))) + DBUG_RETURN(error_num); + else { + my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, + ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), + oracle_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), + oracle_share->table_names_str[spider->conn_link_idx[ + link_idx]].ptr()); + DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_status( + sts_mode, + share->records, + share->mean_rec_length, + share->data_file_length, + share->max_data_file_length, + share->index_file_length, + share->auto_increment_value, + share->create_time, + share->update_time, + share->check_time + ); + res->free_result(); + delete res; + if (error_num) + DBUG_RETURN(error_num); +*/ + if (!share->records) + share->records = 10000; + share->mean_rec_length = 65535; + share->data_file_length = 65535; + share->max_data_file_length = 65535; + share->index_file_length = 65535; +/* + share->auto_increment_value = 0; +*/ + share->create_time = (time_t) 0; + share->update_time = (time_t) 0; + share->check_time = (time_t) 0; + } else { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + oracle_share->show_table_status[1 + pos].ptr(), + oracle_share->show_table_status[1 + pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + oracle_share->show_table_status[1 + pos].ptr(), + oracle_share->show_table_status[1 + pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (error_num || (error_num = spider_db_errorno(conn))) + DBUG_RETURN(error_num); + else + DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_status( + sts_mode, + share->records, + share->mean_rec_length, + share->data_file_length, + share->max_data_file_length, + share->index_file_length, + share->auto_increment_value, + share->create_time, + share->update_time, + share->check_time + ); + res->free_result(); + delete res; + if (error_num) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::crd_mode_exchange( + int crd_mode +) { + DBUG_ENTER("spider_oracle_handler::crd_mode_exchange"); + DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); + DBUG_RETURN(1); +} + +int spider_oracle_handler::show_index( + int link_idx, + int crd_mode +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_SHARE *share = spider->share; + TABLE *table = spider->get_table(); + SPIDER_DB_RESULT *res; + int roop_count; + longlong *tmp_cardinality; + uint pos = (2 * spider->conn_link_idx[link_idx]); + DBUG_ENTER("spider_oracle_handler::show_index"); + DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); + if (crd_mode == 1) + { +/* + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + oracle_share->show_index[0 + pos].ptr(), + oracle_share->show_index[0 + pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { +*/ + /* retry */ +/* + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + oracle_share->show_index[0 + pos].ptr(), + oracle_share->show_index[0 + pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } +*/ + /* no record is ok */ +/* + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if (res) + { + error_num = res->fetch_table_cardinality( + crd_mode, + table, + share->cardinality, + share->cardinality_upd, + share->bitmap_size + ); + } +*/ + for (roop_count = 0, tmp_cardinality = share->cardinality; + roop_count < (int) table->s->fields; + roop_count++, tmp_cardinality++) + { + if (!spider_bit_is_set(share->cardinality_upd, roop_count)) + { + DBUG_PRINT("info", + ("spider init column cardinality id=%d", roop_count)); + *tmp_cardinality = 1; + } + } +/* + if (res) + { + res->free_result(); + delete res; + } + if (error_num) + DBUG_RETURN(error_num); +*/ + } else { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + oracle_share->show_index[1 + pos].ptr(), + oracle_share->show_index[1 + pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + oracle_share->show_index[1 + pos].ptr(), + oracle_share->show_index[1 + pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + /* no record is ok */ + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + if (res) + { + error_num = res->fetch_table_cardinality( + crd_mode, + table, + share->cardinality, + share->cardinality_upd, + share->bitmap_size + ); + } + for (roop_count = 0, tmp_cardinality = share->cardinality; + roop_count < (int) table->s->fields; + roop_count++, tmp_cardinality++) + { + if (!spider_bit_is_set(share->cardinality_upd, roop_count)) + { + DBUG_PRINT("info", + ("spider init column cardinality id=%d", roop_count)); + *tmp_cardinality = 1; + } + } + if (res) + { + res->free_result(); + delete res; + } + if (error_num) + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::show_records( + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_DB_RESULT *res; + SPIDER_SHARE *share = spider->share; + uint pos = spider->conn_link_idx[link_idx]; + DBUG_ENTER("spider_oracle_handler::show_records"); + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + oracle_share->show_records[pos].ptr(), + oracle_share->show_records[pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + oracle_share->show_records[pos].ptr(), + oracle_share->show_records[pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_PRINT("info", ("spider error_num=%d 3", error_num)); + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (error_num || (error_num = spider_db_errorno(conn))) + { + DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); + DBUG_RETURN(error_num); + } else { + DBUG_PRINT("info", ("spider error_num=%d 6", + ER_QUERY_ON_FOREIGN_DATA_SOURCE)); + DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_records( + 1, + share->records + ); + res->free_result(); + delete res; + if (error_num) + { + DBUG_PRINT("info", ("spider error_num=%d 7", error_num)); + DBUG_RETURN(error_num); + } + spider->trx->direct_aggregate_count++; + DBUG_RETURN(0); +} + +int spider_oracle_handler::show_autoinc( + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_DB_RESULT *res; + SPIDER_SHARE *share = spider->share; + uint pos = spider->conn_link_idx[link_idx]; + ulonglong auto_increment_value; + DBUG_ENTER("spider_oracle_handler::show_autoinc"); + if (!oracle_share->show_autoinc) + DBUG_RETURN(0); + + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + oracle_share->show_autoinc[pos].ptr(), + oracle_share->show_autoinc[pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); + DBUG_RETURN(error_num); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + oracle_share->show_records[pos].ptr(), + oracle_share->show_records[pos].length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_PRINT("info", ("spider error_num=%d 3", error_num)); + DBUG_RETURN(spider_db_errorno(conn)); + } + } else { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); + DBUG_RETURN(error_num); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + if (error_num || (error_num = spider_db_errorno(conn))) + { + DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); + DBUG_RETURN(error_num); + } else { + DBUG_PRINT("info", ("spider error_num=%d 6", + ER_QUERY_ON_FOREIGN_DATA_SOURCE)); + DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_records( + 1, + auto_increment_value + ); + res->free_result(); + delete res; + if (error_num) + { + DBUG_PRINT("info", ("spider error_num=%d 7", error_num)); + DBUG_RETURN(error_num); + } + if (auto_increment_value >= share->auto_increment_value) + { + share->auto_increment_value = auto_increment_value + 1; + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::show_last_insert_id( + int link_idx, + ulonglong &last_insert_id +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_DB_RESULT *res; + uint pos = spider->conn_link_idx[link_idx]; + spider_db_oracle *db_oracle = (spider_db_oracle *) conn->db_conn; + DBUG_ENTER("spider_oracle_handler::show_last_insert_id"); + if (!oracle_share->show_last_insert_id) + { + DBUG_ASSERT(0); + last_insert_id = 0; + db_oracle->stored_last_insert_id = 0; + DBUG_RETURN(0); + } + + if ( + spider_db_query( + conn, + oracle_share->show_last_insert_id[pos].ptr(), + oracle_share->show_last_insert_id[pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) { + DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); + DBUG_RETURN(error_num); + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); + DBUG_RETURN(error_num); + } else { + DBUG_PRINT("info", ("spider error_num=%d 6", + ER_QUERY_ON_FOREIGN_DATA_SOURCE)); + DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + } + } + error_num = res->fetch_table_records( + 1, + last_insert_id + ); + res->free_result(); + delete res; + if (error_num) + { + DBUG_PRINT("info", ("spider error_num=%d 7", error_num)); + DBUG_RETURN(error_num); + } + db_oracle->stored_last_insert_id = last_insert_id; + DBUG_RETURN(0); +} + +ha_rows spider_oracle_handler::explain_select( + key_range *start_key, + key_range *end_key, + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + spider_string *str = &result_list->sqls[link_idx]; + SPIDER_DB_RESULT *res; + ha_rows rows; + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + DBUG_ENTER("spider_oracle_handler::explain_select"); + if ((error_num = dbton_hdl->append_explain_select_part( + start_key, end_key, SPIDER_SQL_TYPE_OTHER_SQL, link_idx))) + { + my_errno = error_num; + DBUG_RETURN(HA_POS_ERROR); + } + + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + spider_conn_queue_connect_rewrite(spider->share, conn, link_idx); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider->share); + if ( + (error_num = spider_db_set_names(spider, conn, link_idx)) || + ( + spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(conn)) + ) + ) { + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect + ) { + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + { + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider->share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + } else { + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + } + st_spider_db_request_key request_key; + request_key.spider_thread_id = spider->trx->spider_thread_id; + request_key.query_id = spider->trx->thd->query_id; + request_key.handler = spider; + request_key.request_id = 1; + request_key.next = NULL; + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (error_num || (error_num = spider_db_errorno(conn))) + { + if (spider->check_error_mode(error_num)) + my_errno = error_num; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } else { + my_errno = ER_QUERY_ON_FOREIGN_DATA_SOURCE; + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(HA_POS_ERROR); + } + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + error_num = res->fetch_table_records( + 2, + rows + ); + res->free_result(); + delete res; + if (error_num) + { + my_errno = error_num; + DBUG_RETURN(HA_POS_ERROR); + } + DBUG_RETURN(rows); +} + +int spider_oracle_handler::lock_tables( + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + spider_string *str = &sql; + DBUG_ENTER("spider_oracle_handler::lock_tables"); + do { + str->length(0); + if ((error_num = conn->db_conn->append_lock_tables(str))) + { + DBUG_RETURN(error_num); + } + if (str->length()) + { + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + spider->share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + DBUG_RETURN(spider_db_errorno(conn)); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + if (!conn->table_locked) + { + conn->table_locked = TRUE; + spider->trx->locked_connections++; + } + } while (str->length()); + DBUG_RETURN(0); +} + +int spider_oracle_handler::unlock_tables( + int link_idx +) { + int error_num; + SPIDER_CONN *conn = spider->conns[link_idx]; + DBUG_ENTER("spider_oracle_handler::unlock_tables"); + if (conn->table_locked) + { + if ((error_num = conn->db_conn->commit(&spider->need_mons[link_idx]))) + { + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::disable_keys( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::disable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_disable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_oracle_handler::enable_keys( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::enable_keys"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_enable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_oracle_handler::check_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::check_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_check_table_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx, check_opt))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_oracle_handler::repair_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::repair_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_repair_table_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx, check_opt))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_oracle_handler::analyze_table( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::analyze_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_analyze_table_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_oracle_handler::optimize_table( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::optimize_table"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_optimize_table_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx))) + { + DBUG_RETURN(error_num); + } + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &spider->need_mons[link_idx]; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_oracle_handler::flush_tables( + SPIDER_CONN *conn, + int link_idx, + bool lock +) { + int error_num; + SPIDER_SHARE *share = spider->share; + spider_string *str = &spider->result_list.sqls[link_idx]; + DBUG_ENTER("spider_oracle_handler::flush_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + str->length(0); + if ((error_num = append_flush_tables_part(SPIDER_SQL_TYPE_OTHER_HS, + link_idx, lock))) + { + DBUG_RETURN(error_num); + } + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + str->ptr(), + str->length(), + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_oracle_handler::flush_logs( + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_oracle_handler::flush_logs"); + DBUG_PRINT("info",("spider this=%p", this)); + spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, + share); + if (spider_db_query( + conn, + SPIDER_SQL_FLUSH_LOGS_STR, + SPIDER_SQL_FLUSH_LOGS_LEN, + -1, + &spider->need_mons[link_idx]) + ) { + error_num = spider_db_errorno(conn); + DBUG_RETURN(error_num); + } + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(0); +} + +int spider_oracle_handler::insert_opened_handler( + SPIDER_CONN *conn, + int link_idx +) { + spider_db_oracle *db_conn = (spider_db_oracle *) conn->db_conn; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash = &link_for_hash[link_idx]; + DBUG_ASSERT(tmp_link_for_hash->spider == spider); + DBUG_ASSERT(tmp_link_for_hash->link_idx == link_idx); + uint old_elements = db_conn->handler_open_array.max_element; + DBUG_ENTER("spider_oracle_handler::insert_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + if (insert_dynamic(&db_conn->handler_open_array, + (uchar*) &tmp_link_for_hash)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (db_conn->handler_open_array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + db_conn->handler_open_array, + (db_conn->handler_open_array.max_element - old_elements) * + db_conn->handler_open_array.size_of_element); + } + DBUG_RETURN(0); +} + +int spider_oracle_handler::delete_opened_handler( + SPIDER_CONN *conn, + int link_idx +) { + spider_db_oracle *db_conn = (spider_db_oracle *) conn->db_conn; + uint roop_count, elements = db_conn->handler_open_array.elements; + SPIDER_LINK_FOR_HASH *tmp_link_for_hash; + DBUG_ENTER("spider_oracle_handler::delete_opened_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + for (roop_count = 0; roop_count < elements; roop_count++) + { + get_dynamic(&db_conn->handler_open_array, (uchar *) &tmp_link_for_hash, + roop_count); + if (tmp_link_for_hash == &link_for_hash[link_idx]) + { + delete_dynamic_element(&db_conn->handler_open_array, roop_count); + break; + } + } + DBUG_ASSERT(roop_count < elements); + DBUG_RETURN(0); +} + +int spider_oracle_handler::sync_from_clone_source( + spider_db_handler *dbton_hdl +) { + DBUG_ENTER("spider_oracle_handler::sync_from_clone_source"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +bool spider_oracle_handler::support_use_handler( + int use_handler +) { + DBUG_ENTER("spider_oracle_handler::support_use_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(FALSE); +} + +spider_oracle_copy_table::spider_oracle_copy_table( + spider_oracle_share *db_share +) : spider_db_copy_table( + db_share +), + oracle_share(db_share), + pos(0), + table_name_pos(0), + pos_diff(0), + table_lock_mode(0), + select_rownum_appended(FALSE), + first_str(NULL), + current_str(NULL) +{ + DBUG_ENTER("spider_oracle_copy_table::spider_oracle_copy_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_oracle_copy_table::~spider_oracle_copy_table() +{ + DBUG_ENTER("spider_oracle_copy_table::~spider_oracle_copy_table"); + DBUG_PRINT("info",("spider this=%p", this)); + while (first_str) + { + current_str = first_str; + first_str = first_str->next; + delete [] current_str; + } + DBUG_VOID_RETURN; +} + +int spider_oracle_copy_table::init() +{ + DBUG_ENTER("spider_oracle_copy_table::init"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.init_calc_mem(213); + sql_part.init_calc_mem(215); + DBUG_RETURN(0); +} + +void spider_oracle_copy_table::set_sql_charset( + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_oracle_copy_table::set_sql_charset"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.set_charset(cs); + DBUG_VOID_RETURN; +} + +int spider_oracle_copy_table::append_select_str() +{ + DBUG_ENTER("spider_oracle_copy_table::append_select_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_SELECT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_insert_str( + int insert_flg +) { + DBUG_ENTER("spider_oracle_copy_table::append_insert_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_INSERT_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_INSERT_STR, SPIDER_SQL_INSERT_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_table_columns( + TABLE_SHARE *table_share +) { + int error_num; + Field **field; + DBUG_ENTER("spider_oracle_copy_table::append_table_columns"); + DBUG_PRINT("info",("spider this=%p", this)); + for (field = table_share->field; *field; field++) + { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql, + (char *) (*field)->field_name, spider_dbton_oracle.dbton_id))) + DBUG_RETURN(error_num); + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + sql.length(sql.length() - SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_from_str() +{ + DBUG_ENTER("spider_oracle_copy_table::append_from_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_table_name( + int link_idx +) { + int error_num; + DBUG_ENTER("spider_oracle_copy_table::append_table_name"); + DBUG_PRINT("info",("spider this=%p", this)); + table_name_pos = sql.length(); + error_num = oracle_share->append_table_name(&sql, link_idx); + store_link_idx = link_idx; + DBUG_RETURN(error_num); +} + +void spider_oracle_copy_table::set_sql_pos() +{ + DBUG_ENTER("spider_oracle_copy_table::set_sql_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + pos = sql.length(); + DBUG_VOID_RETURN; +} + +void spider_oracle_copy_table::set_sql_to_pos() +{ + DBUG_ENTER("spider_oracle_copy_table::set_sql_to_pos"); + DBUG_PRINT("info",("spider this=%p", this)); + sql.length(pos); + DBUG_VOID_RETURN; +} + +int spider_oracle_copy_table::append_copy_where( + spider_db_copy_table *source_ct, + KEY *key_info, + ulong *last_row_pos, + ulong *last_lengths +) { + int error_num, roop_count, roop_count2; + DBUG_ENTER("spider_oracle_copy_table::append_copy_where"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_WHERE_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + Field *field; + KEY_PART_INFO *key_part = key_info->key_part; + for (roop_count = key_info->key_parts - 1; roop_count >= 0; roop_count--) + { + for (roop_count2 = 0; roop_count2 < roop_count; roop_count2++) + { + field = key_part[roop_count2].field; + if ((error_num = copy_key_row(source_ct, + field, &last_row_pos[field->field_index], + &last_lengths[field->field_index], + SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN))) + { + DBUG_RETURN(error_num); + } + } + field = key_part[roop_count2].field; + if ((error_num = copy_key_row(source_ct, + field, &last_row_pos[field->field_index], + &last_lengths[field->field_index], + SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN))) + { + DBUG_RETURN(error_num); + } + sql.length(sql.length() - SPIDER_SQL_AND_LEN); + if (sql.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + + SPIDER_SQL_OR_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + sql.q_append(SPIDER_SQL_OR_STR, SPIDER_SQL_OR_LEN); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + sql.length(sql.length() - SPIDER_SQL_OR_LEN - SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_key_order_str( + KEY *key_info, + int start_pos, + bool desc_flg +) { + int length, error_num; + KEY_PART_INFO *key_part; + Field *field; + DBUG_ENTER("spider_oracle_copy_table::append_key_order_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (select_rownum_appended) + { + if (sql.reserve(SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + DBUG_RETURN(0); + } + sql_part.length(0); + if (sql_part.reserve(sql.length() + SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN + + SPIDER_SQL_ROW_NUMBER_HEAD_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_HEAD_STR, + SPIDER_SQL_SELECT_WRAPPER_HEAD_LEN); + sql_part.q_append(sql.ptr(), table_name_pos - SPIDER_SQL_FROM_LEN); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_HEAD_STR, + SPIDER_SQL_ROW_NUMBER_HEAD_LEN); + if ((int) key_info->key_parts > start_pos) + { + if (desc_flg == TRUE) + { + for ( + key_part = key_info->key_part + start_pos, + length = 0; + length + start_pos < (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + if (sql_part.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql_part, + (char *) field->field_name, spider_dbton_oracle.dbton_id))) + DBUG_RETURN(error_num); + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (sql_part.reserve(SPIDER_SQL_NAME_QUOTE_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (sql_part.reserve(SPIDER_SQL_NAME_QUOTE_LEN + + SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + sql_part.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } else { + for ( + key_part = key_info->key_part + start_pos, + length = 0; + length + start_pos < (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + if (sql_part.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql_part, + (char *) field->field_name, spider_dbton_oracle.dbton_id))) + DBUG_RETURN(error_num); + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (sql_part.reserve(SPIDER_SQL_NAME_QUOTE_LEN + + SPIDER_SQL_DESC_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + sql_part.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (sql_part.reserve(SPIDER_SQL_NAME_QUOTE_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + sql_part.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } + } + if (desc_flg == TRUE) + { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + sql.length() - table_name_pos + + SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_DESC_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_DESC_TAIL_LEN); + } else { + if (sql_part.reserve(SPIDER_SQL_ROW_NUMBER_TAIL_LEN + + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN + sql.length() - table_name_pos + + SPIDER_SQL_FROM_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_ROW_NUMBER_TAIL_STR, + SPIDER_SQL_ROW_NUMBER_TAIL_LEN); + } + pos_diff = sql_part.length() + SPIDER_SQL_FROM_LEN - table_name_pos; + sql_part.q_append(sql.ptr() + table_name_pos - SPIDER_SQL_FROM_LEN, + sql.length() - table_name_pos + SPIDER_SQL_FROM_LEN); + sql_part.q_append(SPIDER_SQL_SELECT_WRAPPER_TAIL_STR, + SPIDER_SQL_SELECT_WRAPPER_TAIL_LEN); + + if ((int) key_info->key_parts > start_pos) + { + if (sql.reserve(SPIDER_SQL_ORDER_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); + if (desc_flg == TRUE) + { + for ( + key_part = key_info->key_part + start_pos, + length = 0; + length + start_pos < (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql, + (char *) field->field_name, spider_dbton_oracle.dbton_id))) + DBUG_RETURN(error_num); + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_DESC_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } else { + for ( + key_part = key_info->key_part + start_pos, + length = 0; + length + start_pos < (int) key_info->key_parts; + key_part++, + length++ + ) { + field = key_part->field; + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql, + (char *) field->field_name, spider_dbton_oracle.dbton_id))) + DBUG_RETURN(error_num); + if (key_part->key_part_flag & HA_REVERSE_SORT) + { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_DESC_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_DESC_STR, SPIDER_SQL_DESC_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } else { + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, + SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } + sql.length(sql.length() - SPIDER_SQL_COMMA_LEN); + } + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_limit( + longlong offset, + longlong limit +) { + char buf[SPIDER_LONGLONG_LEN + 1]; + uint32 length; + DBUG_ENTER("spider_oracle_copy_table::append_limit"); + DBUG_PRINT("info",("spider this=%p", this)); + if (offset || limit < 9223372036854775807LL) + { + if (!select_rownum_appended) + { + select_rownum_appended = TRUE; + table_name_pos = table_name_pos + pos_diff; + if (sql.copy(sql_part)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + pos = pos + pos_diff; + } + if (offset) + { + if (sql.reserve(SPIDER_SQL_BETWEEN_LEN + SPIDER_SQL_AND_LEN + + ((SPIDER_LONGLONG_LEN) * 2))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_BETWEEN_STR, SPIDER_SQL_BETWEEN_LEN); + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, offset); + sql.q_append(buf, length); + sql.q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + sql.q_append(buf, length); + } else { + if (sql.reserve(SPIDER_SQL_HS_LTEQUAL_LEN + + (SPIDER_LONGLONG_LEN))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_HS_LTEQUAL_STR, SPIDER_SQL_HS_LTEQUAL_LEN); + length = (uint32) (my_charset_bin.cset->longlong10_to_str)( + &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + sql.q_append(buf, length); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_into_str() +{ + DBUG_ENTER("spider_oracle_copy_table::append_into_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_INTO_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_INTO_STR, SPIDER_SQL_INTO_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_open_paren_str() +{ + DBUG_ENTER("spider_oracle_copy_table::append_open_paren_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_values_str() +{ + DBUG_ENTER("spider_oracle_copy_table::append_values_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN); + sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_select_lock_str( + int lock_mode +) { + DBUG_ENTER("spider_oracle_copy_table::append_select_lock_str"); + DBUG_PRINT("info",("spider this=%p", this)); + if (select_rownum_appended) + { + int error_num; + table_lock_mode = lock_mode; + sql_part.length(0); + if (sql_part.reserve(SPIDER_SQL_LOCK_TABLE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_LOCK_TABLE_STR, SPIDER_SQL_LOCK_TABLE_LEN); + if ((error_num = oracle_share->append_table_name(&sql_part, + store_link_idx))) + DBUG_RETURN(error_num); + if (lock_mode == SPIDER_LOCK_MODE_EXCLUSIVE) + { + if (sql_part.reserve(SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_STR, + SPIDER_SQL_LOCK_TABLE_EXCLUSIVE_MODE_LEN); + } else if (lock_mode == SPIDER_LOCK_MODE_SHARED) + { + if (sql_part.reserve(SPIDER_SQL_LOCK_TABLE_SHARE_MODE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql_part.q_append(SPIDER_SQL_LOCK_TABLE_SHARE_MODE_STR, + SPIDER_SQL_LOCK_TABLE_SHARE_MODE_LEN); + } + } else { + if (lock_mode == SPIDER_LOCK_MODE_EXCLUSIVE) + { + if (sql.reserve(SPIDER_SQL_FOR_UPDATE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_FOR_UPDATE_STR, SPIDER_SQL_FOR_UPDATE_LEN); + } else if (lock_mode == SPIDER_LOCK_MODE_SHARED) + { + if (sql.reserve(SPIDER_SQL_FOR_UPDATE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_FOR_UPDATE_STR, SPIDER_SQL_FOR_UPDATE_LEN); + } + } + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::exec_query( + SPIDER_CONN *conn, + int quick_mode, + int *need_mon +) { + int error_num = 0; + DBUG_ENTER("spider_oracle_copy_table::exec_query"); + DBUG_PRINT("info",("spider this=%p", this)); + if (current_str) + { + spider_string *tmp_str = first_str; + while (tmp_str && tmp_str != current_str) + { + if ( + (error_num = spider_db_query(conn, tmp_str->ptr(), tmp_str->length(), + quick_mode, need_mon)) && + error_num != HA_ERR_FOUND_DUPP_KEY + ) { + break; + } + tmp_str = tmp_str->next; + } + if (tmp_str == current_str) + { + error_num = spider_db_query(conn, tmp_str->ptr(), tmp_str->length(), + quick_mode, need_mon); + } + if (error_num == HA_ERR_FOUND_DUPP_KEY) + error_num = 0; + current_str = NULL; + } else { + if (table_lock_mode) + { + DBUG_PRINT("info",("spider table_lock_mode=%d", table_lock_mode)); + spider_db_oracle *db_conn = (spider_db_oracle *) conn->db_conn; + db_conn->table_lock_mode = table_lock_mode; + db_conn->exec_lock_sql = &sql_part; + table_lock_mode = 0; + } + error_num = spider_db_query(conn, sql.ptr(), sql.length(), quick_mode, + need_mon); + } + DBUG_RETURN(error_num); +} + +int spider_oracle_copy_table::copy_key_row( + spider_db_copy_table *source_ct, + Field *field, + ulong *row_pos, + ulong *length, + const char *joint_str, + const int joint_length +) { + int error_num; + spider_string *source_str = &((spider_oracle_copy_table *) source_ct)->sql; + DBUG_ENTER("spider_oracle_copy_table::copy_key_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + if ((error_num = spider_db_append_name_with_quote_str(&sql, + (char *) field->field_name, spider_dbton_oracle.dbton_id))) + DBUG_RETURN(error_num); + if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + joint_length + *length + + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); + sql.q_append(joint_str, joint_length); + sql.q_append(source_str->ptr() + *row_pos, *length); + sql.q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::copy_row( + Field *field, + SPIDER_DB_ROW *row +) { + int error_num; + DBUG_ENTER("spider_oracle_copy_table::copy_row"); + DBUG_PRINT("info",("spider this=%p", this)); + if (row->is_null()) + { + DBUG_PRINT("info",("spider column is null")); + if (current_str->reserve(SPIDER_SQL_NULL_LEN + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + current_str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); + } else if (field->str_needs_quotes()) + { + DBUG_PRINT("info",("spider str_needs_quotes")); + if (current_str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + current_str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, + SPIDER_SQL_VALUE_QUOTE_LEN); + if ((error_num = row->append_escaped_to_str(current_str, + spider_dbton_oracle.dbton_id))) + DBUG_RETURN(error_num); + if (current_str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN + + SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + current_str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, + SPIDER_SQL_VALUE_QUOTE_LEN); + } else { + DBUG_PRINT("info",("spider without_quotes")); + if ((error_num = row->append_to_str(current_str))) + DBUG_RETURN(error_num); + if (current_str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + current_str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::copy_rows( + TABLE *table, + SPIDER_DB_ROW *row, + ulong **last_row_pos, + ulong **last_lengths +) { + int error_num; + Field **field; + ulong *lengths2, *row_pos2; + DBUG_ENTER("spider_oracle_copy_table::copy_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!current_str) + { + if (!first_str) + { + if (!(first_str = new spider_string[1])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + first_str->init_calc_mem(216); + first_str->set_charset(sql.charset()); + if (first_str->reserve(sql.length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + first_str->q_append(sql.ptr(), sql.length()); + } else { + first_str->length(sql.length()); + } + current_str = first_str; + } else { + if (!current_str->next) + { + if (!(current_str->next = new spider_string[1])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + current_str->next->init_calc_mem(217); + current_str->next->set_charset(sql.charset()); + if (current_str->next->reserve(sql.length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + current_str->next->q_append(sql.ptr(), sql.length()); + } else { + current_str->next->length(sql.length()); + } + current_str = current_str->next; + } + row_pos2 = *last_row_pos; + lengths2 = *last_lengths; + + for ( + field = table->field; + *field; + field++, + lengths2++ + ) { + *row_pos2 = current_str->length(); + if ((error_num = + copy_row(*field, row))) + DBUG_RETURN(error_num); + *lengths2 = current_str->length() - *row_pos2 - SPIDER_SQL_COMMA_LEN; + row->next(); + row_pos2++; + } + current_str->length(current_str->length() - SPIDER_SQL_COMMA_LEN); + if (current_str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + current_str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + DBUG_PRINT("info",("spider current_str=%s", current_str->c_ptr_safe())); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::copy_rows( + TABLE *table, + SPIDER_DB_ROW *row +) { + int error_num; + Field **field; + DBUG_ENTER("spider_oracle_copy_table::copy_rows"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!current_str) + { + if (!first_str) + { + if (!(first_str = new spider_string[1])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + first_str->init_calc_mem(218); + first_str->set_charset(sql.charset()); + if (first_str->reserve(sql.length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + first_str->q_append(sql.ptr(), sql.length()); + } else { + first_str->length(sql.length()); + } + current_str = first_str; + } else { + if (!current_str->next) + { + if (!(current_str->next = new spider_string[1])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + current_str->next->init_calc_mem(219); + current_str->next->set_charset(sql.charset()); + if (current_str->next->reserve(sql.length())) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + current_str->next->q_append(sql.ptr(), sql.length()); + } else { + current_str->next->length(sql.length()); + } + current_str = current_str->next; + } + + for ( + field = table->field; + *field; + field++ + ) { + if ((error_num = + copy_row(*field, row))) + DBUG_RETURN(error_num); + row->next(); + } + current_str->length(current_str->length() - SPIDER_SQL_COMMA_LEN); + if (current_str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + current_str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + DBUG_PRINT("info",("spider current_str=%s", current_str->c_ptr_safe())); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::append_insert_terminator() +{ + DBUG_ENTER("spider_oracle_copy_table::append_insert_terminator"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(0); +} + +int spider_oracle_copy_table::copy_insert_values( + spider_db_copy_table *source_ct +) { + spider_oracle_copy_table *tmp_ct = (spider_oracle_copy_table *) source_ct; + spider_string *source_str = &tmp_ct->sql; + int values_length = source_str->length() - tmp_ct->pos; + const char *values_ptr = source_str->ptr() + tmp_ct->pos; + DBUG_ENTER("spider_oracle_copy_table::copy_insert_values"); + DBUG_PRINT("info",("spider this=%p", this)); + if (sql.reserve(values_length)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + sql.q_append(values_ptr, values_length); + DBUG_RETURN(0); +} +#endif diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h new file mode 100644 index 00000000000..e6ebb90f601 --- /dev/null +++ b/storage/spider/spd_db_oracle.h @@ -0,0 +1,1389 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +class spider_db_oracle; +class spider_db_oracle_result; + +class spider_db_oracle_util: public spider_db_util +{ +public: + spider_db_oracle_util(); + ~spider_db_oracle_util(); + int append_name( + spider_string *str, + const char *name, + uint name_length + ); + int append_name_with_charset( + spider_string *str, + const char *name, + uint name_length, + CHARSET_INFO *name_charset + ); + bool is_name_quote( + const char head_code + ); + int append_escaped_name_quote( + spider_string *str + ); + int append_column_value( + ha_spider *spider, + spider_string *str, + Field *field, + const uchar *new_ptr, + CHARSET_INFO *access_charset + ); + int append_from_with_alias( + spider_string *str, + const char **table_names, + uint *table_name_lengths, + const char **table_aliases, + uint *table_alias_lengths, + uint table_count, + int *table_name_pos, + bool over_write + ); + int append_trx_isolation( + spider_string *str, + int trx_isolation + ); + int append_autocommit( + spider_string *str, + bool autocommit + ); + int append_sql_log_off( + spider_string *str, + bool sql_log_off + ); + int append_time_zone( + spider_string *str, + Time_zone *time_zone + ); + int append_start_transaction( + spider_string *str + ); + int append_xa_start( + spider_string *str, + XID *xid + ); + int append_lock_table_head( + spider_string *str + ); + int append_lock_table_body( + spider_string *str, + const char *db_name, + uint db_name_length, + CHARSET_INFO *db_name_charset, + const char *table_name, + uint table_name_length, + CHARSET_INFO *table_name_charset, + int lock_type + ); + int append_lock_table_tail( + spider_string *str + ); + int append_unlock_table( + spider_string *str + ); + int open_item_func( + Item_func *item_func, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length + ); + size_t escape_string( + char *to, + const char *from, + size_t from_length, + CHARSET_INFO *access_charset + ); + int append_escaped_util( + spider_string *to, + String *from + ); +}; + +class spider_db_oracle_row: public spider_db_row +{ +public: + spider_db_oracle *db_conn; + spider_db_oracle_result *result; + sb2 *ind; + char **val; + ub2 *rlen; + sb2 *ind_first; + char **val_first; + ub2 *rlen_first; + spider_string *val_str; + spider_string *val_str_first; + OCIDefine **defnp; + OCILobLocator **lobhp; + OCIParam **colhp; + ub2 *coltp; + ub2 *colsz; + uint field_count; + ulong *row_size; + ulong *row_size_first; + CHARSET_INFO *access_charset; + bool cloned; + spider_db_oracle_util util; + + spider_db_oracle_row(); + ~spider_db_oracle_row(); + int store_to_field( + Field *field, + CHARSET_INFO *access_charset + ); + int append_to_str( + spider_string *str + ); + int append_escaped_to_str( + spider_string *str, + uint dbton_id + ); + void first(); + void next(); + bool is_null(); + int val_int(); + double val_real(); + SPIDER_DB_ROW *clone(); + int store_to_tmp_table( + TABLE *tmp_table, + spider_string *str + ); + /* for oracle */ + int init(); + void deinit(); + int define(); + int fetch(); +}; + +class spider_db_oracle_result: public spider_db_result +{ +public: + spider_db_oracle *db_conn; + OCIStmt *stmtp; + uint field_count; + CHARSET_INFO *access_charset; + bool fetched; + spider_db_oracle_row row; + int store_error_num; + + spider_db_oracle_result(); + ~spider_db_oracle_result(); + bool has_result(); + void free_result(); + SPIDER_DB_ROW *current_row(); + SPIDER_DB_ROW *fetch_row(); + SPIDER_DB_ROW *fetch_row_from_result_buffer( + spider_db_result_buffer *spider_res_buf + ); + SPIDER_DB_ROW *fetch_row_from_tmp_table( + TABLE *tmp_table + ); + int fetch_table_status( + int mode, + ha_rows &records, + ulong &mean_rec_length, + ulonglong &data_file_length, + ulonglong &max_data_file_length, + ulonglong &index_file_length, + ulonglong &auto_increment_value, + time_t &create_time, + time_t &update_time, + time_t &check_time + ); + int fetch_table_records( + int mode, + ha_rows &records + ); + int fetch_table_cardinality( + int mode, + TABLE *table, + longlong *cardinality, + uchar *cardinality_upd, + int bitmap_size + ); + int fetch_table_mon_status( + int &status + ); + longlong num_rows(); + uint num_fields(); + void move_to_pos( + longlong pos + ); + int get_errno(); +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + int fetch_columns_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset + ); + int fetch_index_for_discover_table_structure( + spider_string *str, + CHARSET_INFO *access_charset + ); +#endif + /* for oracle */ + int set_column_info(); +}; + +class spider_db_oracle: public spider_db_conn +{ +public: + OCIEnv *envhp; + OCIError *errhp; + OCIServer *srvhp; + OCISvcCtx *svchp; + OCISession *usrhp; + OCIStmt *stmtp; + OCITrans *txnhp; + spider_db_oracle_result *result; + int stored_error_num; + const char *stored_error; + uint update_rows; + int table_lock_mode; + spider_string *exec_lock_sql; + spider_db_oracle_util util; + ulonglong stored_last_insert_id; + HASH lock_table_hash; + bool lock_table_hash_inited; + uint lock_table_hash_id; + const char *lock_table_hash_func_name; + const char *lock_table_hash_file_name; + ulong lock_table_hash_line_no; + DYNAMIC_ARRAY handler_open_array; + bool handler_open_array_inited; + uint handler_open_array_id; + const char *handler_open_array_func_name; + const char *handler_open_array_file_name; + ulong handler_open_array_line_no; + + /* for bg_connect */ + char stored_error_msg[MYSQL_ERRMSG_SIZE]; + char *tgt_host; + char *tgt_username; + char *tgt_password; + long tgt_port; + char *tgt_socket; + char *server_name; + int connect_retry_count; + longlong connect_retry_interval; + + spider_db_oracle( + SPIDER_CONN *conn + ); + ~spider_db_oracle(); + int init(); + bool is_connected(); + void bg_connect(); + int connect( + char *tgt_host, + char *tgt_username, + char *tgt_password, + long tgt_port, + char *tgt_socket, + char *server_name, + int connect_retry_count, + longlong connect_retry_interval + ); + int ping(); + void bg_disconnect(); + void disconnect(); + int set_net_timeout(); + int exec_query( + const char *query, + uint length, + int quick_mode + ); + int get_errno(); + const char *get_error(); + bool is_server_gone_error( + int error_num + ); + bool is_dup_entry_error( + int error_num + ); + bool is_xa_nota_error( + int error_num + ); + spider_db_result *store_result( + spider_db_result_buffer **spider_res_buf, + st_spider_db_request_key *request_key, + int *error_num + ); + spider_db_result *use_result( + st_spider_db_request_key *request_key, + int *error_num + ); + int next_result(); + uint affected_rows(); + ulonglong last_insert_id(); + int set_character_set( + const char *csname + ); + int select_db( + const char *dbname + ); + int consistent_snapshot( + int *need_mon + ); + bool trx_start_in_bulk_sql(); + int start_transaction( + int *need_mon + ); + int commit( + int *need_mon + ); + int rollback( + int *need_mon + ); + bool xa_start_in_bulk_sql(); + int xa_start( + XID *xid, + int *need_mon + ); + int xa_end( + XID *xid, + int *need_mon + ); + int xa_prepare( + XID *xid, + int *need_mon + ); + int xa_commit( + XID *xid, + int *need_mon + ); + int xa_rollback( + XID *xid, + int *need_mon + ); + bool set_trx_isolation_in_bulk_sql(); + int set_trx_isolation( + int trx_isolation, + int *need_mon + ); + bool set_autocommit_in_bulk_sql(); + int set_autocommit( + bool autocommit, + int *need_mon + ); + bool set_sql_log_off_in_bulk_sql(); + int set_sql_log_off( + bool sql_log_off, + int *need_mon + ); + bool set_time_zone_in_bulk_sql(); + int set_time_zone( + Time_zone *time_zone, + int *need_mon + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int append_sql( + char *sql, + ulong sql_length, + st_spider_db_request_key *request_key + ); + int append_open_handler( + uint handler_id, + const char *db_name, + const char *table_name, + const char *index_name, + const char *sql, + st_spider_db_request_key *request_key + ); + int append_select( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key + ); + int append_insert( + uint handler_id, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + st_spider_db_request_key *request_key + ); + int append_update( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + SPIDER_DB_HS_STRING_REF_BUFFER *upds, + int limit, + int skip, + bool increment, + bool decrement, + st_spider_db_request_key *request_key + ); + int append_delete( + uint handler_id, + spider_string *sql, + SPIDER_DB_HS_STRING_REF_BUFFER *keys, + int limit, + int skip, + st_spider_db_request_key *request_key + ); + void reset_request_queue(); +#endif + size_t escape_string( + char *to, + const char *from, + size_t from_length + ); + bool have_lock_table_list(); + int append_lock_tables( + spider_string *str + ); + int append_unlock_tables( + spider_string *str + ); + uint get_lock_table_hash_count(); + void reset_lock_table_hash(); + uint get_opened_handler_count(); + void reset_opened_handler(); + void set_dup_key_idx( + ha_spider *spider, + int link_idx + ); + bool cmp_request_key_to_snd( + st_spider_db_request_key *request_key + ); +private: + int set_error( + sword res, + dvoid *hndlp, + int error_num, + const char *error1, + const char *error2 + ); +}; + +class spider_oracle_share: public spider_db_share +{ +public: + spider_string *table_select; + int table_select_pos; + spider_string *key_select; + int *key_select_pos; + spider_string *key_hint; + spider_string *show_table_status; + spider_string *show_records; + spider_string *show_autoinc; + spider_string *show_last_insert_id; + spider_string *show_index; + spider_string *table_names_str; + spider_string *db_names_str; + spider_string *db_table_str; + spider_string *nextval_str; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type *db_table_str_hash_value; +#endif + uint table_nm_max_length; + uint db_nm_max_length; + uint nextval_max_length; + spider_string *column_name_str; + bool same_db_table_name; + int first_all_link_idx; + + spider_oracle_share( + st_spider_share *share + ); + ~spider_oracle_share(); + int init(); + uint get_column_name_length( + uint field_index + ); + int append_column_name( + spider_string *str, + uint field_index + ); + int append_column_name_with_alias( + spider_string *str, + uint field_index, + const char *alias, + uint alias_length + ); + int append_table_name( + spider_string *str, + int all_link_idx + ); + int append_table_name_with_adjusting( + spider_string *str, + int all_link_idx + ); + int append_from_with_adjusted_table_name( + spider_string *str, + int *table_name_pos + ); + bool need_change_db_table_name(); +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + int discover_table_structure( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str + ); +#endif +private: + int create_table_names_str(); + void free_table_names_str(); + int create_column_name_str(); + void free_column_name_str(); + int convert_key_hint_str(); + int append_show_table_status(); + void free_show_table_status(); + int append_show_records(); + void free_show_records(); + int append_show_autoinc(); + void free_show_autoinc(); + int append_show_last_insert_id(); + void free_show_last_insert_id(); + int append_show_index(); + void free_show_index(); + int append_table_select(); + int append_key_select( + uint idx + ); +}; + +class spider_oracle_handler: public spider_db_handler +{ + spider_string sql; + spider_string sql_part; + spider_string sql_part2; + spider_string ha_sql; + int where_pos; + int order_pos; + int limit_pos; + int table_name_pos; + int update_set_pos; + int ha_read_pos; + int ha_next_pos; + int ha_where_pos; + int ha_limit_pos; + int ha_table_name_pos; + uint ha_sql_handler_id; + spider_string insert_sql; + int insert_pos; + int insert_table_name_pos; + int nextval_pos; + spider_string update_sql; + TABLE *upd_tmp_tbl; + TMP_TABLE_PARAM upd_tmp_tbl_prm; + spider_string tmp_sql; + int tmp_sql_pos1; /* drop db nm pos at tmp_table_join */ + int tmp_sql_pos2; /* create db nm pos at tmp_table_join */ + int tmp_sql_pos3; /* insert db nm pos at tmp_table_join */ + int tmp_sql_pos4; /* insert val pos at tmp_table_join */ + int tmp_sql_pos5; /* end of drop tbl at tmp_table_join */ + spider_string dup_update_sql; + spider_string *exec_sql; + spider_string *exec_insert_sql; + spider_string *exec_update_sql; + spider_string *exec_tmp_sql; + spider_string *exec_ha_sql; + spider_string *exec_lock_sql; + int table_lock_mode; + bool reading_from_bulk_tmp_table; + bool filled_up; + bool select_rownum_appended; + bool update_rownum_appended; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; +#endif +public: + spider_oracle_share *oracle_share; + SPIDER_LINK_FOR_HASH *link_for_hash; + spider_oracle_handler( + ha_spider *spider, + spider_oracle_share *share + ); + ~spider_oracle_handler(); + int init(); + int append_table_name_with_adjusting( + spider_string *str, + int link_idx, + ulong sql_type + ); + int append_key_column_types( + const key_range *start_key, + spider_string *str + ); + int append_key_join_columns_for_bka( + const key_range *start_key, + spider_string *str, + const char **table_aliases, + uint *table_alias_lengths + ); + int append_tmp_table_and_sql_for_bka( + const key_range *start_key + ); + int reuse_tmp_table_and_sql_for_bka(); + void create_tmp_bka_table_name( + char *tmp_table_name, + int *tmp_table_name_length, + int link_idx + ); + int append_create_tmp_bka_table( + const key_range *start_key, + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos, + CHARSET_INFO *table_charset + ); + int append_drop_tmp_bka_table( + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos, + int *drop_table_end_pos, + bool with_semicolon + ); + int append_insert_tmp_bka_table( + const key_range *start_key, + spider_string *str, + char *tmp_table_name, + int tmp_table_name_length, + int *db_name_pos + ); + int append_insert_for_recovery( + ulong sql_type, + int link_idx + ); + int append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff + ); + int append_update( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx + ); + int append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff + ); + int append_delete( + const TABLE *table, + my_ptrdiff_t ptr_diff, + int link_idx + ); + int append_insert_part(); + int append_insert( + spider_string *str, + int link_idx + ); + int append_update_part(); + int append_update( + spider_string *str, + int link_idx + ); + int append_delete_part(); + int append_delete( + spider_string *str + ); + #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_increment_update_set_part(); + int append_increment_update_set( + spider_string *str + ); + #endif + #endif + int append_update_set_part(); + int append_update_set( + spider_string *str + ); + #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + int append_direct_update_set_part(); + int append_direct_update_set( + spider_string *str + ); + int append_dup_update_pushdown_part( + const char *alias, + uint alias_length + ); + int append_update_columns_part( + const char *alias, + uint alias_length + ); + int check_update_columns_part(); + int append_update_columns( + spider_string *str, + const char *alias, + uint alias_length + ); + #endif + int append_select_part( + ulong sql_type + ); + int append_select( + spider_string *str, + ulong sql_type + ); + int append_table_select_part( + ulong sql_type + ); + int append_table_select( + spider_string *str + ); + int append_key_select_part( + ulong sql_type, + uint idx + ); + int append_key_select( + spider_string *str, + uint idx + ); + int append_minimum_select_part( + ulong sql_type + ); + int append_minimum_select( + spider_string *str, + ulong sql_type + ); + int append_table_select_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_key_select_with_alias( + spider_string *str, + const KEY *key_info, + const char *alias, + uint alias_length + ); + int append_minimum_select_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_select_columns_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_hint_after_table_part( + ulong sql_type + ); + int append_hint_after_table( + spider_string *str + ); + void set_where_pos( + ulong sql_type + ); + void set_where_to_pos( + ulong sql_type + ); + int check_item_type( + Item *item + ); + int append_values_connector_part( + ulong sql_type + ); + int append_values_connector( + spider_string *str + ); + int append_values_terminator_part( + ulong sql_type + ); + int append_values_terminator( + spider_string *str + ); + int append_key_column_values_part( + const key_range *start_key, + ulong sql_type + ); + int append_key_column_values( + spider_string *str, + const key_range *start_key + ); + int append_key_where_part( + const key_range *start_key, + const key_range *end_key, + ulong sql_type + ); + int append_key_where( + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + const key_range *start_key, + const key_range *end_key, + ulong sql_type, + bool set_order + ); + int append_is_null_part( + ulong sql_type, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq + ); + int append_is_null( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + KEY_PART_INFO *key_part, + const key_range *key, + const uchar **ptr, + bool key_eq + ); + int append_where_terminator_part( + ulong sql_type, + bool set_order, + int key_count + ); + int append_where_terminator( + ulong sql_type, + spider_string *str, + spider_string *str_part, + spider_string *str_part2, + bool set_order, + int key_count + ); + int append_match_where_part( + ulong sql_type + ); + int append_match_where( + spider_string *str + ); + int append_update_where( + spider_string *str, + const TABLE *table, + my_ptrdiff_t ptr_diff + ); + int append_condition_part( + const char *alias, + uint alias_length, + ulong sql_type, + bool test_flg + ); + int append_condition( + spider_string *str, + const char *alias, + uint alias_length, + bool start_where, + ulong sql_type + ); + int append_match_against_part( + ulong sql_type, + st_spider_ft_info *ft_info, + const char *alias, + uint alias_length + ); + int append_match_against( + spider_string *str, + st_spider_ft_info *ft_info, + const char *alias, + uint alias_length + ); + int append_match_select_part( + ulong sql_type, + const char *alias, + uint alias_length + ); + int append_match_select( + spider_string *str, + const char *alias, + uint alias_length + ); + void set_order_pos( + ulong sql_type + ); + void set_order_to_pos( + ulong sql_type + ); + int append_key_order_for_merge_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_for_merge_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_key_order_for_direct_order_limit_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_for_direct_order_limit_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_key_order_with_alias_part( + const char *alias, + uint alias_length, + ulong sql_type + ); + int append_key_order_for_handler( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_key_order_with_alias( + spider_string *str, + const char *alias, + uint alias_length + ); + int append_limit_part( + longlong offset, + longlong limit, + ulong sql_type + ); + int reappend_limit_part( + longlong offset, + longlong limit, + ulong sql_type + ); + int append_limit( + spider_string *str, + longlong offset, + longlong limit + ); + int append_select_lock_part( + ulong sql_type + ); + int append_select_lock( + spider_string *str + ); + int append_union_all_start_part( + ulong sql_type + ); + int append_union_all_start( + spider_string *str + ); + int append_union_all_part( + ulong sql_type + ); + int append_union_all( + spider_string *str + ); + int append_union_all_end_part( + ulong sql_type + ); + int append_union_all_end( + spider_string *str + ); + int append_multi_range_cnt_part( + ulong sql_type, + uint multi_range_cnt, + bool with_comma + ); + int append_multi_range_cnt( + spider_string *str, + uint multi_range_cnt, + bool with_comma + ); + int append_open_handler_part( + ulong sql_type, + uint handler_id, + SPIDER_CONN *conn, + int link_idx + ); + int append_open_handler( + spider_string *str, + uint handler_id, + SPIDER_CONN *conn, + int link_idx + ); + int append_close_handler_part( + ulong sql_type, + int link_idx + ); + int append_close_handler( + spider_string *str, + int link_idx + ); + int append_insert_terminator_part( + ulong sql_type + ); + int append_insert_terminator( + spider_string *str + ); + int append_insert_values_part( + ulong sql_type + ); + int append_insert_values( + spider_string *str + ); + int append_into_part( + ulong sql_type + ); + int append_into( + spider_string *str + ); + void set_insert_to_pos( + ulong sql_type + ); + int append_from_part( + ulong sql_type, + int link_idx + ); + int append_from( + spider_string *str, + ulong sql_type, + int link_idx + ); + int append_flush_tables_part( + ulong sql_type, + int link_idx, + bool lock + ); + int append_flush_tables( + spider_string *str, + int link_idx, + bool lock + ); + int append_optimize_table_part( + ulong sql_type, + int link_idx + ); + int append_optimize_table( + spider_string *str, + int link_idx + ); + int append_analyze_table_part( + ulong sql_type, + int link_idx + ); + int append_analyze_table( + spider_string *str, + int link_idx + ); + int append_repair_table_part( + ulong sql_type, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int append_repair_table( + spider_string *str, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int append_check_table_part( + ulong sql_type, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int append_check_table( + spider_string *str, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int append_enable_keys_part( + ulong sql_type, + int link_idx + ); + int append_enable_keys( + spider_string *str, + int link_idx + ); + int append_disable_keys_part( + ulong sql_type, + int link_idx + ); + int append_disable_keys( + spider_string *str, + int link_idx + ); + int append_delete_all_rows_part( + ulong sql_type + ); + int append_delete_all_rows( + spider_string *str, + ulong sql_type + ); + int append_truncate( + spider_string *str, + ulong sql_type, + int link_idx + ); + int append_explain_select_part( + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx + ); + int append_explain_select( + spider_string *str, + key_range *start_key, + key_range *end_key, + ulong sql_type, + int link_idx + ); + bool is_bulk_insert_exec_period( + bool bulk_end + ); + bool sql_is_filled_up( + ulong sql_type + ); + bool sql_is_empty( + ulong sql_type + ); + bool support_multi_split_read(); + bool support_bulk_update(); + int bulk_tmp_table_insert(); + int bulk_tmp_table_insert( + int link_idx + ); + int bulk_tmp_table_end_bulk_insert(); + int bulk_tmp_table_rnd_init(); + int bulk_tmp_table_rnd_next(); + int bulk_tmp_table_rnd_end(); + bool need_copy_for_update( + int link_idx + ); + bool bulk_tmp_table_created(); + int mk_bulk_tmp_table_and_bulk_start(); + void rm_bulk_tmp_table(); + int store_sql_to_bulk_tmp_table( + spider_string *str, + TABLE *tmp_table + ); + int restore_sql_from_bulk_tmp_table( + spider_string *str, + TABLE *tmp_table + ); + int insert_lock_tables_list( + SPIDER_CONN *conn, + int link_idx + ); + int append_lock_tables_list( + SPIDER_CONN *conn, + int link_idx, + int *appended + ); + int realloc_sql( + ulong *realloced + ); + int reset_sql( + ulong sql_type + ); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int reset_keys( + ulong sql_type + ); + int reset_upds( + ulong sql_type + ); + int reset_strs( + ulong sql_type + ); + int reset_strs_pos( + ulong sql_type + ); + int push_back_upds( + SPIDER_HS_STRING_REF &info + ); +#endif + bool need_lock_before_set_sql_for_exec( + ulong sql_type + ); + int set_sql_for_exec( + ulong sql_type, + int link_idx + ); + int set_sql_for_exec( + spider_db_copy_table *tgt_ct, + ulong sql_type + ); + int execute_sql( + ulong sql_type, + SPIDER_CONN *conn, + int quick_mode, + int *need_mon + ); + int reset(); + int sts_mode_exchange( + int sts_mode + ); + int show_table_status( + int link_idx, + int sts_mode, + uint flag + ); + int crd_mode_exchange( + int crd_mode + ); + int show_index( + int link_idx, + int crd_mode + ); + int show_records( + int link_idx + ); + int show_autoinc( + int link_idx + ); + int show_last_insert_id( + int link_idx, + ulonglong &last_insert_id + ); + ha_rows explain_select( + key_range *start_key, + key_range *end_key, + int link_idx + ); + int lock_tables( + int link_idx + ); + int unlock_tables( + int link_idx + ); + int disable_keys( + SPIDER_CONN *conn, + int link_idx + ); + int enable_keys( + SPIDER_CONN *conn, + int link_idx + ); + int check_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int repair_table( + SPIDER_CONN *conn, + int link_idx, + HA_CHECK_OPT* check_opt + ); + int analyze_table( + SPIDER_CONN *conn, + int link_idx + ); + int optimize_table( + SPIDER_CONN *conn, + int link_idx + ); + int flush_tables( + SPIDER_CONN *conn, + int link_idx, + bool lock + ); + int flush_logs( + SPIDER_CONN *conn, + int link_idx + ); + int insert_opened_handler( + SPIDER_CONN *conn, + int link_idx + ); + int delete_opened_handler( + SPIDER_CONN *conn, + int link_idx + ); + int sync_from_clone_source( + spider_db_handler *dbton_hdl + ); + bool support_use_handler( + int use_handler + ); +}; + +class spider_oracle_copy_table: public spider_db_copy_table +{ +public: + spider_oracle_share *oracle_share; + spider_string sql; + spider_string sql_part; + uint pos; + uint table_name_pos; + uint pos_diff; + int table_lock_mode; + int store_link_idx; + bool select_rownum_appended; + spider_string *first_str; + spider_string *current_str; + spider_oracle_copy_table( + spider_oracle_share *db_share + ); + ~spider_oracle_copy_table(); + int init(); + void set_sql_charset( + CHARSET_INFO *cs + ); + int append_select_str(); + int append_insert_str( + int insert_flg + ); + int append_table_columns( + TABLE_SHARE *table_share + ); + int append_from_str(); + int append_table_name( + int link_idx + ); + void set_sql_pos(); + void set_sql_to_pos(); + int append_copy_where( + spider_db_copy_table *source_ct, + KEY *key_info, + ulong *last_row_pos, + ulong *last_lengths + ); + int append_key_order_str( + KEY *key_info, + int start_pos, + bool desc_flg + ); + int append_limit( + longlong offset, + longlong limit + ); + int append_into_str(); + int append_open_paren_str(); + int append_values_str(); + int append_select_lock_str( + int lock_mode + ); + int exec_query( + SPIDER_CONN *conn, + int quick_mode, + int *need_mon + ); + int copy_key_row( + spider_db_copy_table *source_ct, + Field *field, + ulong *row_pos, + ulong *length, + const char *joint_str, + const int joint_length + ); + int copy_row( + Field *field, + SPIDER_DB_ROW *row + ); + int copy_rows( + TABLE *table, + SPIDER_DB_ROW *row, + ulong **last_row_pos, + ulong **last_lengths + ); + int copy_rows( + TABLE *table, + SPIDER_DB_ROW *row + ); + int append_insert_terminator(); + int copy_insert_values( + spider_db_copy_table *source_ct + ); +}; diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc new file mode 100644 index 00000000000..2c844eb2da3 --- /dev/null +++ b/storage/spider/spd_direct_sql.cc @@ -0,0 +1,1877 @@ +/* Copyright (C) 2009-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#include "sql_base.h" +#include "sql_servers.h" +#endif +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_sys_table.h" +#include "ha_spider.h" +#include "spd_db_conn.h" +#include "spd_trx.h" +#include "spd_conn.h" +#include "spd_table.h" +#include "spd_direct_sql.h" +#include "spd_udf.h" +#include "spd_malloc.h" + +extern const char **spd_defaults_extra_file; +extern const char **spd_defaults_file; + +extern handlerton *spider_hton_ptr; +extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; + +#ifdef HAVE_PSI_INTERFACE +extern PSI_mutex_key spd_key_mutex_mta_conn; +extern PSI_mutex_key spd_key_mutex_bg_direct_sql; +extern PSI_cond_key spd_key_cond_bg_direct_sql; +#endif + +extern HASH spider_open_connections; +extern pthread_mutex_t spider_conn_mutex; + +uint spider_udf_calc_hash( + char *key, + uint mod +) { + uint sum = 0; + DBUG_ENTER("spider_udf_calc_hash"); + while (*key != '\0') + { + sum += *key; + key++; + } + DBUG_PRINT("info",("spider calc hash = %u", sum % mod)); + DBUG_RETURN(sum % mod); +} + +int spider_udf_direct_sql_create_table_list( + SPIDER_DIRECT_SQL *direct_sql, + char *table_name_list, + uint table_name_list_length +) { + int table_count, roop_count, length; + char *tmp_ptr, *tmp_ptr2, *tmp_ptr3, *tmp_name_ptr; + THD *thd = direct_sql->trx->thd; + DBUG_ENTER("spider_udf_direct_sql_create_table_list"); + tmp_ptr = table_name_list; + while (*tmp_ptr == ' ') + tmp_ptr++; + if (*tmp_ptr) + table_count = 1; + else { + direct_sql->table_count = 0; + DBUG_RETURN(0); + } + + while (TRUE) + { + if ((tmp_ptr2 = strchr(tmp_ptr, ' '))) + { + table_count++; + tmp_ptr = tmp_ptr2 + 1; + while (*tmp_ptr == ' ') + tmp_ptr++; + } else + break; + } +#if MYSQL_VERSION_ID < 50500 + if (!(direct_sql->db_names = (char**) + spider_bulk_malloc(spider_current_trx, 31, MYF(MY_WME | MY_ZEROFILL), + &direct_sql->db_names, sizeof(char*) * table_count, + &direct_sql->table_names, sizeof(char*) * table_count, + &direct_sql->tables, sizeof(TABLE*) * table_count, + &tmp_name_ptr, sizeof(char) * ( + table_name_list_length + + thd->db_length * table_count + + 2 * table_count + ), + &direct_sql->iop, sizeof(int) * table_count, + NullS)) + ) +#else + if (!(direct_sql->db_names = (char**) + spider_bulk_malloc(spider_current_trx, 31, MYF(MY_WME | MY_ZEROFILL), + &direct_sql->db_names, sizeof(char*) * table_count, + &direct_sql->table_names, sizeof(char*) * table_count, + &direct_sql->tables, sizeof(TABLE*) * table_count, + &tmp_name_ptr, sizeof(char) * ( + table_name_list_length + + thd->db_length * table_count + + 2 * table_count + ), + &direct_sql->iop, sizeof(int) * table_count, + &direct_sql->table_list, sizeof(TABLE_LIST) * table_count, + &direct_sql->real_table_bitmap, sizeof(uchar) * ((table_count + 7) / 8), + NullS)) + ) +#endif + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + tmp_ptr = table_name_list; + while (*tmp_ptr == ' ') + tmp_ptr++; + roop_count = 0; + while (TRUE) + { + if ((tmp_ptr2 = strchr(tmp_ptr, ' '))) + *tmp_ptr2 = '\0'; + + direct_sql->db_names[roop_count] = tmp_name_ptr; + + if ((tmp_ptr3 = strchr(tmp_ptr, '.'))) + { + /* exist database name */ + *tmp_ptr3 = '\0'; + length = strlen(tmp_ptr); + memcpy(tmp_name_ptr, tmp_ptr, length + 1); + tmp_name_ptr += length + 1; + tmp_ptr = tmp_ptr3 + 1; + } else { + if (thd->db) + { + memcpy(tmp_name_ptr, thd->db, + thd->db_length + 1); + tmp_name_ptr += thd->db_length + 1; + } else { + direct_sql->db_names[roop_count] = (char *) ""; + } + } + + direct_sql->table_names[roop_count] = tmp_name_ptr; + length = strlen(tmp_ptr); + memcpy(tmp_name_ptr, tmp_ptr, length + 1); + tmp_name_ptr += length + 1; + + DBUG_PRINT("info",("spider db=%s", + direct_sql->db_names[roop_count])); + DBUG_PRINT("info",("spider table_name=%s", + direct_sql->table_names[roop_count])); + + if (!tmp_ptr2) + break; + tmp_ptr = tmp_ptr2 + 1; + while (*tmp_ptr == ' ') + tmp_ptr++; + roop_count++; + } + direct_sql->table_count = table_count; + DBUG_RETURN(0); +} + +int spider_udf_direct_sql_create_conn_key( + SPIDER_DIRECT_SQL *direct_sql +) { + char *tmp_name, port_str[6]; + DBUG_ENTER("spider_udf_direct_sql_create_conn_key"); + + /* tgt_db not use */ +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + direct_sql->conn_key_length + = 1 + + direct_sql->tgt_wrapper_length + 1 + + direct_sql->tgt_host_length + 1 + + 5 + 1 + + direct_sql->tgt_socket_length + 1 + + direct_sql->tgt_username_length + 1 + + direct_sql->tgt_password_length + 1 + + direct_sql->tgt_ssl_ca_length + 1 + + direct_sql->tgt_ssl_capath_length + 1 + + direct_sql->tgt_ssl_cert_length + 1 + + direct_sql->tgt_ssl_cipher_length + 1 + + direct_sql->tgt_ssl_key_length + 1 + + 1 + 1 + + direct_sql->tgt_default_file_length + 1 + + direct_sql->tgt_default_group_length; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + direct_sql->conn_key_length + = 1 + + direct_sql->tgt_wrapper_length + 1 + + direct_sql->tgt_host_length + 1 + + 5 + 1 + + direct_sql->tgt_socket_length; + } +#endif + if (!(direct_sql->conn_key = (char *) + spider_malloc(spider_current_trx, 9, direct_sql->conn_key_length + 1, + MYF(MY_WME | MY_ZEROFILL))) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (direct_sql->connection_channel > 48) + *direct_sql->conn_key = '0' + 48 - direct_sql->connection_channel; + else + *direct_sql->conn_key = '0' + direct_sql->connection_channel; + DBUG_PRINT("info",("spider tgt_wrapper=%s", direct_sql->tgt_wrapper)); + tmp_name = strmov(direct_sql->conn_key + 1, direct_sql->tgt_wrapper); + DBUG_PRINT("info",("spider tgt_host=%s", direct_sql->tgt_host)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_host); + my_sprintf(port_str, (port_str, "%05ld", direct_sql->tgt_port)); + DBUG_PRINT("info",("spider port_str=%s", port_str)); + tmp_name = strmov(tmp_name + 1, port_str); + if (direct_sql->tgt_socket) + { + DBUG_PRINT("info",("spider tgt_socket=%s", direct_sql->tgt_socket)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_socket); + } else + tmp_name++; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + if (direct_sql->tgt_username) + { + DBUG_PRINT("info",("spider tgt_username=%s", direct_sql->tgt_username)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_username); + } else + tmp_name++; + if (direct_sql->tgt_password) + { + DBUG_PRINT("info",("spider tgt_password=%s", direct_sql->tgt_password)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_password); + } else + tmp_name++; + if (direct_sql->tgt_ssl_ca) + { + DBUG_PRINT("info",("spider tgt_ssl_ca=%s", direct_sql->tgt_ssl_ca)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_ca); + } else + tmp_name++; + if (direct_sql->tgt_ssl_capath) + { + DBUG_PRINT("info",("spider tgt_ssl_capath=%s", + direct_sql->tgt_ssl_capath)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_capath); + } else + tmp_name++; + if (direct_sql->tgt_ssl_cert) + { + DBUG_PRINT("info",("spider tgt_ssl_cert=%s", direct_sql->tgt_ssl_cert)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_cert); + } else + tmp_name++; + if (direct_sql->tgt_ssl_cipher) + { + DBUG_PRINT("info",("spider tgt_ssl_cipher=%s", + direct_sql->tgt_ssl_cipher)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_cipher); + } else + tmp_name++; + if (direct_sql->tgt_ssl_key) + { + DBUG_PRINT("info",("spider tgt_ssl_key=%s", direct_sql->tgt_ssl_key)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_key); + } else + tmp_name++; + tmp_name++; + *tmp_name = '0' + ((char) direct_sql->tgt_ssl_vsc); + if (direct_sql->tgt_default_file) + { + DBUG_PRINT("info",("spider tgt_default_file=%s", + direct_sql->tgt_default_file)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_file); + } else + tmp_name++; + if (direct_sql->tgt_default_group) + { + DBUG_PRINT("info",("spider tgt_default_group=%s", + direct_sql->tgt_default_group)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_group); + } else + tmp_name++; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + uint roop_count2; + direct_sql->dbton_id = SPIDER_DBTON_SIZE; + DBUG_PRINT("info",("spider direct_sql->tgt_wrapper=%s", + direct_sql->tgt_wrapper)); + for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) + { + DBUG_PRINT("info",("spider spider_dbton[%d].wrapper=%s", roop_count2, + spider_dbton[roop_count2].wrapper ? + spider_dbton[roop_count2].wrapper : "NULL")); + if ( + spider_dbton[roop_count2].wrapper && + !strcmp(direct_sql->tgt_wrapper, spider_dbton[roop_count2].wrapper) + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + if (spider_dbton[roop_count2].db_access_type == + SPIDER_DB_ACCESS_TYPE_SQL) + { + direct_sql->dbton_id = roop_count2; + break; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (spider_dbton[roop_count2].db_access_type == + SPIDER_DB_ACCESS_TYPE_NOSQL) + { + direct_sql->dbton_id = roop_count2; + break; + } + } +#endif + } + } +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + direct_sql->conn_key_hash_value = my_calc_hash(&spider_open_connections, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length); +#endif + DBUG_RETURN(0); +} + +SPIDER_CONN *spider_udf_direct_sql_create_conn( + const SPIDER_DIRECT_SQL *direct_sql, + int *error_num +) { + SPIDER_CONN *conn; + char *tmp_name, *tmp_host, *tmp_username, *tmp_password, *tmp_socket; + char *tmp_wrapper, *tmp_ssl_ca, *tmp_ssl_capath, *tmp_ssl_cert; + char *tmp_ssl_cipher, *tmp_ssl_key, *tmp_default_file, *tmp_default_group; + int *need_mon; + DBUG_ENTER("spider_udf_direct_sql_create_conn"); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + if (!(conn = (SPIDER_CONN *) + spider_bulk_malloc(spider_current_trx, 32, MYF(MY_WME | MY_ZEROFILL), + &conn, sizeof(*conn), + &tmp_name, direct_sql->conn_key_length + 1, + &tmp_host, direct_sql->tgt_host_length + 1, + &tmp_username, direct_sql->tgt_username_length + 1, + &tmp_password, direct_sql->tgt_password_length + 1, + &tmp_socket, direct_sql->tgt_socket_length + 1, + &tmp_wrapper, direct_sql->tgt_wrapper_length + 1, + &tmp_ssl_ca, direct_sql->tgt_ssl_ca_length + 1, + &tmp_ssl_capath, direct_sql->tgt_ssl_capath_length + 1, + &tmp_ssl_cert, direct_sql->tgt_ssl_cert_length + 1, + &tmp_ssl_cipher, direct_sql->tgt_ssl_cipher_length + 1, + &tmp_ssl_key, direct_sql->tgt_ssl_key_length + 1, + &tmp_default_file, + direct_sql->tgt_default_file_length + 1, + &tmp_default_group, + direct_sql->tgt_default_group_length + 1, + &need_mon, sizeof(int), + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn; + } + conn->default_database.init_calc_mem(138); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + if (!(conn = (SPIDER_CONN *) + spider_bulk_malloc(spider_current_trx, 33, MYF(MY_WME | MY_ZEROFILL), + &conn, sizeof(*conn), + &tmp_name, direct_sql->conn_key_length + 1, + &tmp_host, direct_sql->tgt_host_length + 1, + &tmp_socket, direct_sql->tgt_socket_length + 1, + &tmp_wrapper, direct_sql->tgt_wrapper_length + 1, + &need_mon, sizeof(int), + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn; + } + conn->default_database.init_calc_mem(103); + } +#endif + + conn->conn_key_length = direct_sql->conn_key_length; + conn->conn_key = tmp_name; + memcpy(conn->conn_key, direct_sql->conn_key, direct_sql->conn_key_length); + conn->tgt_wrapper_length = direct_sql->tgt_wrapper_length; + conn->tgt_wrapper = tmp_wrapper; + memcpy(conn->tgt_wrapper, direct_sql->tgt_wrapper, + direct_sql->tgt_wrapper_length); + conn->tgt_host_length = direct_sql->tgt_host_length; + conn->tgt_host = tmp_host; + memcpy(conn->tgt_host, direct_sql->tgt_host, direct_sql->tgt_host_length); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + conn->tgt_port = direct_sql->tgt_port; + conn->tgt_socket_length = direct_sql->tgt_socket_length; + conn->tgt_socket = tmp_socket; + memcpy(conn->tgt_socket, direct_sql->tgt_socket, + direct_sql->tgt_socket_length); + conn->tgt_username_length = direct_sql->tgt_username_length; + conn->tgt_username = tmp_username; + memcpy(conn->tgt_username, direct_sql->tgt_username, + direct_sql->tgt_username_length); + conn->tgt_password_length = direct_sql->tgt_password_length; + conn->tgt_password = tmp_password; + memcpy(conn->tgt_password, direct_sql->tgt_password, + direct_sql->tgt_password_length); + conn->tgt_ssl_ca_length = direct_sql->tgt_ssl_ca_length; + if (conn->tgt_ssl_ca_length) + { + conn->tgt_ssl_ca = tmp_ssl_ca; + memcpy(conn->tgt_ssl_ca, direct_sql->tgt_ssl_ca, + direct_sql->tgt_ssl_ca_length); + } else + conn->tgt_ssl_ca = NULL; + conn->tgt_ssl_capath_length = direct_sql->tgt_ssl_capath_length; + if (conn->tgt_ssl_capath_length) + { + conn->tgt_ssl_capath = tmp_ssl_capath; + memcpy(conn->tgt_ssl_capath, direct_sql->tgt_ssl_capath, + direct_sql->tgt_ssl_capath_length); + } else + conn->tgt_ssl_capath = NULL; + conn->tgt_ssl_cert_length = direct_sql->tgt_ssl_cert_length; + if (conn->tgt_ssl_cert_length) + { + conn->tgt_ssl_cert = tmp_ssl_cert; + memcpy(conn->tgt_ssl_cert, direct_sql->tgt_ssl_cert, + direct_sql->tgt_ssl_cert_length); + } else + conn->tgt_ssl_cert = NULL; + conn->tgt_ssl_cipher_length = direct_sql->tgt_ssl_cipher_length; + if (conn->tgt_ssl_cipher_length) + { + conn->tgt_ssl_cipher = tmp_ssl_cipher; + memcpy(conn->tgt_ssl_cipher, direct_sql->tgt_ssl_cipher, + direct_sql->tgt_ssl_cipher_length); + } else + conn->tgt_ssl_cipher = NULL; + conn->tgt_ssl_key_length = direct_sql->tgt_ssl_key_length; + if (conn->tgt_ssl_key_length) + { + conn->tgt_ssl_key = tmp_ssl_key; + memcpy(conn->tgt_ssl_key, direct_sql->tgt_ssl_key, + direct_sql->tgt_ssl_key_length); + } else + conn->tgt_ssl_key = NULL; + conn->tgt_default_file_length = direct_sql->tgt_default_file_length; + if (conn->tgt_default_file_length) + { + conn->tgt_default_file = tmp_default_file; + memcpy(conn->tgt_default_file, direct_sql->tgt_default_file, + direct_sql->tgt_default_file_length); + } else + conn->tgt_default_file = NULL; + conn->tgt_default_group_length = direct_sql->tgt_default_group_length; + if (conn->tgt_default_group_length) + { + conn->tgt_default_group = tmp_default_group; + memcpy(conn->tgt_default_group, direct_sql->tgt_default_group, + direct_sql->tgt_default_group_length); + } else + conn->tgt_default_group = NULL; + conn->tgt_ssl_vsc = direct_sql->tgt_ssl_vsc; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + conn->hs_port = direct_sql->tgt_port; + if (direct_sql->tgt_socket) + { + conn->hs_sock_length = direct_sql->tgt_socket_length; + conn->hs_sock = tmp_socket; + memcpy(conn->hs_sock, direct_sql->tgt_socket, + direct_sql->tgt_socket_length); + } + } +#endif + conn->dbton_id = direct_sql->dbton_id; + conn->conn_need_mon = need_mon; + conn->need_mon = need_mon; + if (!(conn->db_conn = spider_dbton[conn->dbton_id].create_db_conn(conn))) + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_db_conn_create; + } + if ((*error_num = conn->db_conn->init())) + { + goto error_db_conn_init; + } + conn->join_trx = 0; + conn->thd = NULL; + conn->table_lock = 0; + conn->semi_trx_isolation = -2; + conn->semi_trx_isolation_chk = FALSE; + conn->semi_trx_chk = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + conn->conn_kind = SPIDER_CONN_KIND_MYSQL; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (direct_sql->access_mode == 1) + { + conn->conn_kind = SPIDER_CONN_KIND_HS_READ; + } else { + conn->conn_kind = SPIDER_CONN_KIND_HS_WRITE; + } +#endif + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex, + MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_mta_conn_mutex_init; + } + + if ((*error_num = spider_db_udf_direct_sql_connect(direct_sql, conn))) + goto error; + conn->ping_time = (time_t) time((time_t*) 0); + + DBUG_RETURN(conn); + +error: + DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name); + pthread_mutex_destroy(&conn->mta_conn_mutex); +error_mta_conn_mutex_init: +error_db_conn_init: + delete conn->db_conn; +error_db_conn_create: + spider_free(spider_current_trx, conn, MYF(0)); +error_alloc_conn: + DBUG_RETURN(NULL); +} + +SPIDER_CONN *spider_udf_direct_sql_get_conn( + const SPIDER_DIRECT_SQL *direct_sql, + SPIDER_TRX *trx, + int *error_num +) { + SPIDER_CONN *conn = NULL; + DBUG_ENTER("spider_udf_direct_sql_get_conn"); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + DBUG_PRINT("info",("spider direct_sql->access_mode=%d", + direct_sql->access_mode)); +#endif + +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (direct_sql->access_mode == 0 && +#endif + !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &trx->trx_conn_hash, direct_sql->conn_key_hash_value, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) || + (direct_sql->access_mode == 1 && + !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &trx->trx_direct_hs_r_conn_hash, direct_sql->conn_key_hash_value, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) + ) || + (direct_sql->access_mode == 2 && + !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &trx->trx_direct_hs_w_conn_hash, direct_sql->conn_key_hash_value, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) + ) +#endif + ) +#else + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (direct_sql->access_mode == 0 && +#endif + !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) || + (direct_sql->access_mode == 1 && + !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_direct_hs_r_conn_hash, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) + ) || + (direct_sql->access_mode == 2 && + !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_direct_hs_w_conn_hash, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) + ) +#endif + ) +#endif + { + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (direct_sql->access_mode == 0 && +#endif + ( + (spider_param_conn_recycle_mode(trx->thd) & 1) || + spider_param_conn_recycle_strict(trx->thd) + ) +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) || + (direct_sql->access_mode == 1 && + ( + (spider_param_hs_r_conn_recycle_mode(trx->thd) & 1) || + spider_param_hs_r_conn_recycle_strict(trx->thd) + ) + ) || + (direct_sql->access_mode == 2 && + ( + (spider_param_hs_w_conn_recycle_mode(trx->thd) & 1) || + spider_param_hs_w_conn_recycle_strict(trx->thd) + ) + ) +#endif + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + pthread_mutex_lock(&spider_conn_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( + &spider_open_connections, direct_sql->conn_key_hash_value, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length))) +#else + if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_open_connections, + (uchar*) direct_sql->conn_key, direct_sql->conn_key_length))) +#endif + { + pthread_mutex_unlock(&spider_conn_mutex); + DBUG_PRINT("info",("spider create new conn")); + if(!(conn = spider_udf_direct_sql_create_conn(direct_sql, + error_num))) + goto error; + } else { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_open_connections, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&spider_open_connections, (uchar*) conn); +#endif + pthread_mutex_unlock(&spider_conn_mutex); + DBUG_PRINT("info",("spider get global conn")); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } +#endif + } else { + DBUG_PRINT("info",("spider create new conn")); + /* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */ + if(!(conn = spider_udf_direct_sql_create_conn(direct_sql, error_num))) + goto error; + } + conn->thd = trx->thd; + conn->priority = direct_sql->priority; + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 0) + { +#endif + uint old_elements = trx->trx_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_conn_hash, + direct_sql->conn_key_hash_value, (uchar*) conn)) +#else + if (my_hash_insert(&trx->trx_conn_hash, (uchar*) conn)) +#endif + { + spider_free_conn(conn); + *error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (trx->trx_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_conn_hash, + (trx->trx_conn_hash.array.max_element - old_elements) * + trx->trx_conn_hash.array.size_of_element); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (direct_sql->access_mode == 1) + { + uint old_elements = trx->trx_direct_hs_r_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_direct_hs_r_conn_hash, + direct_sql->conn_key_hash_value, (uchar*) conn)) +#else + if (my_hash_insert(&trx->trx_direct_hs_r_conn_hash, (uchar*) conn)) +#endif + { + spider_free_conn(conn); + *error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (trx->trx_direct_hs_r_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_direct_hs_r_conn_hash, + (trx->trx_direct_hs_r_conn_hash.array.max_element - old_elements) * + trx->trx_direct_hs_r_conn_hash.array.size_of_element); + } + } else { + uint old_elements = trx->trx_direct_hs_w_conn_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_direct_hs_w_conn_hash, + direct_sql->conn_key_hash_value, (uchar*) conn)) +#else + if (my_hash_insert(&trx->trx_direct_hs_w_conn_hash, (uchar*) conn)) +#endif + { + spider_free_conn(conn); + *error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (trx->trx_direct_hs_w_conn_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_direct_hs_w_conn_hash, + (trx->trx_direct_hs_w_conn_hash.array.max_element - old_elements) * + trx->trx_direct_hs_w_conn_hash.array.size_of_element); + } + } +#endif + } + + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider conn->conn_kind=%u", conn->conn_kind)); + DBUG_RETURN(conn); + +error: + DBUG_RETURN(NULL); +} + +int spider_udf_direct_sql_get_server( + SPIDER_DIRECT_SQL *direct_sql +) { + MEM_ROOT mem_root; + int error_num, length; + FOREIGN_SERVER *server, server_buf; + DBUG_ENTER("spider_udf_direct_sql_get_server"); + SPD_INIT_ALLOC_ROOT(&mem_root, 65, 0, MYF(MY_WME)); + + if (!(server + = get_server_by_name(&mem_root, direct_sql->server_name, &server_buf))) + { + error_num = ER_FOREIGN_SERVER_DOESNT_EXIST; + goto error_get_server; + } + + if (!direct_sql->tgt_wrapper && server->scheme) + { + direct_sql->tgt_wrapper_length = strlen(server->scheme); + if (!(direct_sql->tgt_wrapper = + spider_create_string(server->scheme, direct_sql->tgt_wrapper_length))) + { + error_num = HA_ERR_OUT_OF_MEM; + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + DBUG_PRINT("info",("spider tgt_wrapper=%s", direct_sql->tgt_wrapper)); + } + + if (!direct_sql->tgt_host && server->host) + { + direct_sql->tgt_host_length = strlen(server->host); + if (!(direct_sql->tgt_host = + spider_create_string(server->host, direct_sql->tgt_host_length))) + { + error_num = HA_ERR_OUT_OF_MEM; + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + DBUG_PRINT("info",("spider tgt_host=%s", direct_sql->tgt_host)); + } + + if (direct_sql->tgt_port == -1) + { + direct_sql->tgt_port = server->port; + DBUG_PRINT("info",("spider tgt_port=%ld", direct_sql->tgt_port)); + } + + if (!direct_sql->tgt_socket && server->socket) + { + direct_sql->tgt_socket_length = strlen(server->socket); + if (!(direct_sql->tgt_socket = + spider_create_string(server->socket, direct_sql->tgt_socket_length))) + { + error_num = HA_ERR_OUT_OF_MEM; + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + DBUG_PRINT("info",("spider tgt_socket=%s", direct_sql->tgt_socket)); + } + + if (!direct_sql->tgt_default_db_name && server->db && + (length = strlen(server->db))) + { + direct_sql->tgt_default_db_name_length = length; + if (!(direct_sql->tgt_default_db_name = + spider_create_string(server->db, length))) + { + error_num = HA_ERR_OUT_OF_MEM; + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + DBUG_PRINT("info",("spider tgt_default_db_name=%s", + direct_sql->tgt_default_db_name)); + } + + if (!direct_sql->tgt_username && server->username) + { + direct_sql->tgt_username_length = strlen(server->username); + if (!(direct_sql->tgt_username = + spider_create_string(server->username, direct_sql->tgt_username_length))) + { + error_num = HA_ERR_OUT_OF_MEM; + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + DBUG_PRINT("info",("spider tgt_username=%s", direct_sql->tgt_username)); + } + + if (!direct_sql->tgt_password && server->password) + { + direct_sql->tgt_password_length = strlen(server->password); + if (!(direct_sql->tgt_password = + spider_create_string(server->password, direct_sql->tgt_password_length))) + { + error_num = HA_ERR_OUT_OF_MEM; + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + DBUG_PRINT("info",("spider tgt_password=%s", direct_sql->tgt_password)); + } + + free_root(&mem_root, MYF(0)); + DBUG_RETURN(0); + +error_get_server: + my_error(error_num, MYF(0), direct_sql->server_name); +error: + free_root(&mem_root, MYF(0)); + DBUG_RETURN(error_num); +} + +#define SPIDER_PARAM_STR_LEN(name) name ## _length +#define SPIDER_PARAM_STR(title_name, param_name) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (!direct_sql->param_name) \ + { \ + if ((direct_sql->param_name = spider_get_string_between_quote( \ + start_ptr, TRUE))) \ + direct_sql->SPIDER_PARAM_STR_LEN(param_name) = \ + strlen(direct_sql->param_name); \ + else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%s", direct_sql->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_HINT_WITH_MAX(title_name, param_name, check_length, max_size, min_val, max_val) \ + if (!strncasecmp(tmp_ptr, title_name, check_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider max_size=%d", max_size)); \ + int hint_num = atoi(tmp_ptr + check_length) - 1; \ + DBUG_PRINT("info",("spider hint_num=%d", hint_num)); \ + DBUG_PRINT("info",("spider direct_sql->param_name=%p", \ + direct_sql->param_name)); \ + if (direct_sql->param_name) \ + { \ + if (hint_num < 0 || hint_num >= max_size) \ + { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } else if (direct_sql->param_name[hint_num] != -1) \ + break; \ + char *hint_str = spider_get_string_between_quote(start_ptr, FALSE); \ + if (hint_str) \ + { \ + direct_sql->param_name[hint_num] = atoi(hint_str); \ + if (direct_sql->param_name[hint_num] < min_val) \ + direct_sql->param_name[hint_num] = min_val; \ + else if (direct_sql->param_name[hint_num] > max_val) \ + direct_sql->param_name[hint_num] = max_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"[%d]=%d", hint_num, \ + direct_sql->param_name[hint_num])); \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + break; \ + } +#define SPIDER_PARAM_INT_WITH_MAX(title_name, param_name, min_val, max_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (direct_sql->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + direct_sql->param_name = atoi(tmp_ptr2); \ + if (direct_sql->param_name < min_val) \ + direct_sql->param_name = min_val; \ + else if (direct_sql->param_name > max_val) \ + direct_sql->param_name = max_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%d", \ + (int) direct_sql->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_INT(title_name, param_name, min_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (direct_sql->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + direct_sql->param_name = atoi(tmp_ptr2); \ + if (direct_sql->param_name < min_val) \ + direct_sql->param_name = min_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%d", direct_sql->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_LONGLONG(title_name, param_name, min_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (direct_sql->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + direct_sql->param_name = \ + my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \ + if (direct_sql->param_name < min_val) \ + direct_sql->param_name = min_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%lld", \ + direct_sql->param_name)); \ + } \ + break; \ + } + +int spider_udf_parse_direct_sql_param( + SPIDER_TRX *trx, + SPIDER_DIRECT_SQL *direct_sql, + const char *param, + int param_length +) { + int error_num = 0, roop_count; + char *param_string = NULL; + char *sprit_ptr[2]; + char *tmp_ptr, *tmp_ptr2, *start_ptr; + int title_length; + DBUG_ENTER("spider_udf_parse_direct_sql_param"); + direct_sql->tgt_port = -1; + direct_sql->tgt_ssl_vsc = -1; + direct_sql->table_loop_mode = -1; + direct_sql->priority = -1; + direct_sql->connect_timeout = -1; + direct_sql->net_read_timeout = -1; + direct_sql->net_write_timeout = -1; + direct_sql->bulk_insert_rows = -1; + direct_sql->connection_channel = -1; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + direct_sql->access_mode = -1; +#endif +#if MYSQL_VERSION_ID < 50500 +#else + direct_sql->use_real_table = -1; +#endif + for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) + direct_sql->iop[roop_count] = -1; + + if (param_length == 0) + goto set_default; + DBUG_PRINT("info",("spider create param_string string")); + if ( + !(param_string = spider_create_string( + param, + param_length)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error_alloc_param_string; + } + DBUG_PRINT("info",("spider param_string=%s", param_string)); + + sprit_ptr[0] = param_string; + while (sprit_ptr[0]) + { + if ((sprit_ptr[1] = strchr(sprit_ptr[0], ','))) + { + *sprit_ptr[1] = '\0'; + sprit_ptr[1]++; + } + tmp_ptr = sprit_ptr[0]; + sprit_ptr[0] = sprit_ptr[1]; + while (*tmp_ptr == ' ' || *tmp_ptr == '\r' || + *tmp_ptr == '\n' || *tmp_ptr == '\t') + tmp_ptr++; + + if (*tmp_ptr == '\0') + continue; + + title_length = 0; + start_ptr = tmp_ptr; + while (*start_ptr != ' ' && *start_ptr != '\'' && + *start_ptr != '"' && *start_ptr != '\0' && + *start_ptr != '\r' && *start_ptr != '\n' && + *start_ptr != '\t') + { + title_length++; + start_ptr++; + } + + switch (title_length) + { + case 0: + continue; + case 3: +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_INT_WITH_MAX("acm", access_mode, 0, 2); +#endif + SPIDER_PARAM_LONGLONG("bir", bulk_insert_rows, 0); + SPIDER_PARAM_INT_WITH_MAX("cch", connection_channel, 0, 63); + SPIDER_PARAM_INT("cto", connect_timeout, 0); + SPIDER_PARAM_STR("dff", tgt_default_file); + SPIDER_PARAM_STR("dfg", tgt_default_group); + SPIDER_PARAM_LONGLONG("prt", priority, 0); + SPIDER_PARAM_INT("rto", net_read_timeout, 0); + SPIDER_PARAM_STR("sca", tgt_ssl_ca); + SPIDER_PARAM_STR("sch", tgt_ssl_cipher); + SPIDER_PARAM_STR("scp", tgt_ssl_capath); + SPIDER_PARAM_STR("scr", tgt_ssl_cert); + SPIDER_PARAM_STR("sky", tgt_ssl_key); + SPIDER_PARAM_STR("srv", server_name); + SPIDER_PARAM_INT_WITH_MAX("svc", tgt_ssl_vsc, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("tlm", table_loop_mode, 0, 2); +#if MYSQL_VERSION_ID < 50500 +#else + SPIDER_PARAM_INT_WITH_MAX("urt", use_real_table, 0, 1); +#endif + SPIDER_PARAM_INT("wto", net_write_timeout, 0); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 4: + SPIDER_PARAM_STR("host", tgt_host); + SPIDER_PARAM_STR("user", tgt_username); + SPIDER_PARAM_INT_WITH_MAX("port", tgt_port, 0, 65535); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 6: + SPIDER_PARAM_STR("server", server_name); + SPIDER_PARAM_STR("socket", tgt_socket); + SPIDER_PARAM_HINT_WITH_MAX("iop", iop, 3, direct_sql->table_count, 0, 2); + SPIDER_PARAM_STR("ssl_ca", tgt_ssl_ca); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 7: + SPIDER_PARAM_STR("wrapper", tgt_wrapper); + SPIDER_PARAM_STR("ssl_key", tgt_ssl_key); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 8: + SPIDER_PARAM_STR("database", tgt_default_db_name); + SPIDER_PARAM_STR("password", tgt_password); + SPIDER_PARAM_LONGLONG("priority", priority, 0); + SPIDER_PARAM_STR("ssl_cert", tgt_ssl_cert); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 10: + SPIDER_PARAM_STR("ssl_cipher", tgt_ssl_cipher); + SPIDER_PARAM_STR("ssl_capath", tgt_ssl_capath); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 11: +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_INT_WITH_MAX("access_mode", access_mode, 0, 2); +#endif + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 12: + SPIDER_PARAM_STR("default_file", tgt_default_file); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 13: + SPIDER_PARAM_STR("default_group", tgt_default_group); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 14: +#if MYSQL_VERSION_ID < 50500 +#else + SPIDER_PARAM_INT_WITH_MAX("use_real_table", use_real_table, 0, 1); +#endif + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 15: + SPIDER_PARAM_INT_WITH_MAX("table_loop_mode", table_loop_mode, 0, 2); + SPIDER_PARAM_INT("connect_timeout", connect_timeout, 0); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 16: + SPIDER_PARAM_LONGLONG("bulk_insert_rows", bulk_insert_rows, 1); + SPIDER_PARAM_INT("net_read_timeout", net_read_timeout, 0); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 17: + SPIDER_PARAM_INT("net_write_timeout", net_write_timeout, 0); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 18: + SPIDER_PARAM_INT_WITH_MAX( + "connection_channel", connection_channel, 0, 63); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + case 22: + SPIDER_PARAM_INT_WITH_MAX("ssl_verify_server_cert", tgt_ssl_vsc, 0, 1); + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + default: + error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, + MYF(0), tmp_ptr); + goto error; + } + } + +set_default: + if ((error_num = spider_udf_set_direct_sql_param_default( + trx, + direct_sql + ))) + goto error; + + if (param_string) + { + spider_free(spider_current_trx, param_string, MYF(0)); + } + DBUG_RETURN(0); + +error: + if (param_string) + { + spider_free(spider_current_trx, param_string, MYF(0)); + } +error_alloc_param_string: + DBUG_RETURN(error_num); +} + +int spider_udf_set_direct_sql_param_default( + SPIDER_TRX *trx, + SPIDER_DIRECT_SQL *direct_sql +) { + int error_num, roop_count; + DBUG_ENTER("spider_udf_set_direct_sql_param_default"); + if (direct_sql->server_name) + { + if ((error_num = spider_udf_direct_sql_get_server(direct_sql))) + DBUG_RETURN(error_num); + } + + if (!direct_sql->tgt_default_db_name) + { + DBUG_PRINT("info",("spider create default tgt_default_db_name")); + direct_sql->tgt_default_db_name_length = trx->thd->db_length; + if ( + !(direct_sql->tgt_default_db_name = spider_create_string( + trx->thd->db, + direct_sql->tgt_default_db_name_length)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (!direct_sql->tgt_wrapper) + { + DBUG_PRINT("info",("spider create default tgt_wrapper")); + direct_sql->tgt_wrapper_length = SPIDER_DB_WRAPPER_LEN; + if ( + !(direct_sql->tgt_wrapper = spider_create_string( + SPIDER_DB_WRAPPER_STR, + direct_sql->tgt_wrapper_length)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (!direct_sql->tgt_host) + { + DBUG_PRINT("info",("spider create default tgt_host")); + direct_sql->tgt_host_length = strlen(my_localhost); + if ( + !(direct_sql->tgt_host = spider_create_string( + my_localhost, + direct_sql->tgt_host_length)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if ( + !direct_sql->tgt_default_file && + direct_sql->tgt_default_group && + (*spd_defaults_file || *spd_defaults_extra_file) + ) { + DBUG_PRINT("info",("spider create default tgt_default_file")); + if (*spd_defaults_extra_file) + { + direct_sql->tgt_default_file_length = strlen(*spd_defaults_extra_file); + if ( + !(direct_sql->tgt_default_file = spider_create_string( + *spd_defaults_extra_file, + direct_sql->tgt_default_file_length)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } else { + direct_sql->tgt_default_file_length = strlen(*spd_defaults_file); + if ( + !(direct_sql->tgt_default_file = spider_create_string( + *spd_defaults_file, + direct_sql->tgt_default_file_length)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + } + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == -1) + direct_sql->access_mode = 0; +#endif + + if (direct_sql->tgt_port == -1) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (direct_sql->access_mode == 1) + direct_sql->tgt_port = 9998; + else if (direct_sql->access_mode == 2) + direct_sql->tgt_port = 9999; + else +#endif + direct_sql->tgt_port = MYSQL_PORT; + } + else if (direct_sql->tgt_port < 0) + direct_sql->tgt_port = 0; + else if (direct_sql->tgt_port > 65535) + direct_sql->tgt_port = 65535; + + if (direct_sql->tgt_ssl_vsc == -1) + direct_sql->tgt_ssl_vsc = 0; + + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + direct_sql->access_mode == 0 && +#endif + !direct_sql->tgt_socket && + !strcmp(direct_sql->tgt_host, my_localhost) + ) { + DBUG_PRINT("info",("spider create default tgt_socket")); + direct_sql->tgt_socket_length = strlen((char *) MYSQL_UNIX_ADDR); + if ( + !(direct_sql->tgt_socket = spider_create_string( + (char *) MYSQL_UNIX_ADDR, + direct_sql->tgt_socket_length)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (direct_sql->table_loop_mode == -1) + direct_sql->table_loop_mode = 0; + if (direct_sql->priority == -1) + direct_sql->priority = 1000000; + if (direct_sql->connect_timeout == -1) + direct_sql->connect_timeout = 6; + if (direct_sql->net_read_timeout == -1) + direct_sql->net_read_timeout = 600; + if (direct_sql->net_write_timeout == -1) + direct_sql->net_write_timeout = 600; + if (direct_sql->bulk_insert_rows == -1) + direct_sql->bulk_insert_rows = 3000; + if (direct_sql->connection_channel == -1) + direct_sql->connection_channel = 0; +#if MYSQL_VERSION_ID < 50500 +#else + if (direct_sql->use_real_table == -1) + direct_sql->use_real_table = 0; +#endif + for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) + { + if (direct_sql->iop[roop_count] == -1) + direct_sql->iop[roop_count] = 0; + } + DBUG_RETURN(0); +} + +void spider_udf_free_direct_sql_alloc( + SPIDER_DIRECT_SQL *direct_sql, + my_bool bg +) { + SPIDER_BG_DIRECT_SQL *bg_direct_sql; + DBUG_ENTER("spider_udf_free_direct_sql_alloc"); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (bg) + { + pthread_mutex_lock(direct_sql->bg_mutex); + bg_direct_sql = (SPIDER_BG_DIRECT_SQL *) direct_sql->parent; + if (bg_direct_sql->direct_sql == direct_sql) + bg_direct_sql->direct_sql = direct_sql->next; + if (direct_sql->next) + direct_sql->next->prev = direct_sql->prev; + if (direct_sql->prev) + direct_sql->prev->next = direct_sql->next; + pthread_cond_signal(direct_sql->bg_cond); + pthread_mutex_unlock(direct_sql->bg_mutex); + } +#endif +#if MYSQL_VERSION_ID < 50500 +#else + if (direct_sql->real_table_used && direct_sql->open_tables_thd) + { + spider_sys_close_table(direct_sql->open_tables_thd, + &direct_sql->open_tables_backup); + } +#endif + if (direct_sql->server_name) + { + spider_free(spider_current_trx, direct_sql->server_name, MYF(0)); + } + if (direct_sql->tgt_default_db_name) + { + spider_free(spider_current_trx, direct_sql->tgt_default_db_name, MYF(0)); + } + if (direct_sql->tgt_host) + { + spider_free(spider_current_trx, direct_sql->tgt_host, MYF(0)); + } + if (direct_sql->tgt_username) + { + spider_free(spider_current_trx, direct_sql->tgt_username, MYF(0)); + } + if (direct_sql->tgt_password) + { + spider_free(spider_current_trx, direct_sql->tgt_password, MYF(0)); + } + if (direct_sql->tgt_socket) + { + spider_free(spider_current_trx, direct_sql->tgt_socket, MYF(0)); + } + if (direct_sql->tgt_wrapper) + { + spider_free(spider_current_trx, direct_sql->tgt_wrapper, MYF(0)); + } + if (direct_sql->tgt_ssl_ca) + { + spider_free(spider_current_trx, direct_sql->tgt_ssl_ca, MYF(0)); + } + if (direct_sql->tgt_ssl_capath) + { + spider_free(spider_current_trx, direct_sql->tgt_ssl_capath, MYF(0)); + } + if (direct_sql->tgt_ssl_cert) + { + spider_free(spider_current_trx, direct_sql->tgt_ssl_cert, MYF(0)); + } + if (direct_sql->tgt_ssl_cipher) + { + spider_free(spider_current_trx, direct_sql->tgt_ssl_cipher, MYF(0)); + } + if (direct_sql->tgt_ssl_key) + { + spider_free(spider_current_trx, direct_sql->tgt_ssl_key, MYF(0)); + } + if (direct_sql->tgt_default_file) + { + spider_free(spider_current_trx, direct_sql->tgt_default_file, MYF(0)); + } + if (direct_sql->tgt_default_group) + { + spider_free(spider_current_trx, direct_sql->tgt_default_group, MYF(0)); + } + if (direct_sql->conn_key) + { + spider_free(spider_current_trx, direct_sql->conn_key, MYF(0)); + } + if (direct_sql->db_names) + { + spider_free(spider_current_trx, direct_sql->db_names, MYF(0)); + } + spider_free(spider_current_trx, direct_sql, MYF(0)); + DBUG_VOID_RETURN; +} + +long long spider_direct_sql_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error, + my_bool bg +) { + int error_num, roop_count; + SPIDER_DIRECT_SQL *direct_sql = NULL, *tmp_direct_sql; + THD *thd = current_thd; + SPIDER_TRX *trx; + SPIDER_CONN *conn; + char *sql; + TABLE_LIST table_list; + SPIDER_BG_DIRECT_SQL *bg_direct_sql; +#if MYSQL_VERSION_ID < 50500 +#else + TABLE_LIST *real_table_list_last = NULL; + uint use_real_table = 0; +#endif + DBUG_ENTER("spider_direct_sql_body"); + if (!(direct_sql = (SPIDER_DIRECT_SQL *) + spider_bulk_malloc(spider_current_trx, 34, MYF(MY_WME | MY_ZEROFILL), + &direct_sql, sizeof(SPIDER_DIRECT_SQL), + &sql, sizeof(char) * args->lengths[0], + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (bg) + { + bg_direct_sql = (SPIDER_BG_DIRECT_SQL *) initid->ptr; + pthread_mutex_lock(&bg_direct_sql->bg_mutex); + tmp_direct_sql = (SPIDER_DIRECT_SQL *) bg_direct_sql->direct_sql; + bg_direct_sql->direct_sql = direct_sql; + if (tmp_direct_sql) + { + tmp_direct_sql->prev = direct_sql; + direct_sql->next = tmp_direct_sql; + } + pthread_mutex_unlock(&bg_direct_sql->bg_mutex); + direct_sql->bg_mutex = &bg_direct_sql->bg_mutex; + direct_sql->bg_cond = &bg_direct_sql->bg_cond; + direct_sql->parent = bg_direct_sql; + bg_direct_sql->called_cnt++; + } +#endif + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + direct_sql->trx = trx; + + if (args->args[1]) + { + if (spider_udf_direct_sql_create_table_list( + direct_sql, + args->args[1], + args->lengths[1] + )) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + } else { + if (spider_udf_direct_sql_create_table_list( + direct_sql, + (char *) "", + 0 + )) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + } + if (args->args[2]) + { + if (spider_udf_parse_direct_sql_param( + trx, + direct_sql, + args->args[2], + args->lengths[2] + )) { + goto error; + } + } else { + if (spider_udf_parse_direct_sql_param( + trx, + direct_sql, + "", + 0 + )) { + goto error; + } + } +#if MYSQL_VERSION_ID < 50500 +#else + use_real_table = spider_param_udf_ds_use_real_table(thd, + direct_sql->use_real_table); +#endif + for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) + { + table_list.db = direct_sql->db_names[roop_count]; + table_list.table_name = direct_sql->table_names[roop_count]; + if (!(direct_sql->tables[roop_count] = + find_temporary_table(thd, &table_list))) + { +#if MYSQL_VERSION_ID < 50500 +#else + if (!use_real_table) + { +#endif + my_printf_error(ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM, + ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_STR, + MYF(0), table_list.db, table_list.table_name); + goto error; +#if MYSQL_VERSION_ID < 50500 +#else + } + TABLE_LIST *tables = &direct_sql->table_list[roop_count]; + tables->init_one_table(table_list.db, strlen(table_list.db), + table_list.table_name, strlen(table_list.table_name), + table_list.table_name, TL_WRITE); + tables->mdl_request.init(MDL_key::TABLE, table_list.db, + table_list.table_name, MDL_SHARED_WRITE, MDL_TRANSACTION); + if (!direct_sql->table_list_first) + { + direct_sql->table_list_first = tables; + } else { + real_table_list_last->next_global = tables; + } + real_table_list_last = tables; + spider_set_bit(direct_sql->real_table_bitmap, roop_count); + direct_sql->real_table_used = TRUE; +#endif + } + } + if (spider_udf_direct_sql_create_conn_key(direct_sql)) + { + goto error; + } + if (!(conn = spider_udf_direct_sql_get_conn(direct_sql, trx, &error_num))) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + conn->error_mode = 0; + direct_sql->conn = conn; + if (spider_db_udf_check_and_set_set_names(trx)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + if (args->args[0]) + { + direct_sql->sql_length = args->lengths[0]; + memcpy(sql, args->args[0], direct_sql->sql_length); + } else + direct_sql->sql_length = 0; + direct_sql->sql = sql; + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (bg) + { + if (spider_udf_bg_direct_sql(direct_sql)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + } else { +#endif + if (conn->bg_init) + pthread_mutex_lock(&conn->bg_conn_mutex); + if (spider_db_udf_direct_sql(direct_sql)) + { + if (conn->bg_init) + pthread_mutex_unlock(&conn->bg_conn_mutex); + if (direct_sql->modified_non_trans_table) + thd->transaction.stmt.modified_non_trans_table = TRUE; + goto error; + } + if (conn->bg_init) + pthread_mutex_unlock(&conn->bg_conn_mutex); + if (direct_sql->modified_non_trans_table) + thd->transaction.stmt.modified_non_trans_table = TRUE; +#ifndef WITHOUT_SPIDER_BG_SEARCH + } + if (!bg) + { +#endif + spider_udf_free_direct_sql_alloc(direct_sql, FALSE); +#ifndef WITHOUT_SPIDER_BG_SEARCH + } +#endif + DBUG_RETURN(1); + +error: + if (direct_sql) + spider_udf_free_direct_sql_alloc(direct_sql, bg); + *error = 1; + DBUG_RETURN(0); +} + +my_bool spider_direct_sql_init_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *message, + my_bool bg +) { + SPIDER_BG_DIRECT_SQL *bg_direct_sql; + DBUG_ENTER("spider_direct_sql_init_body"); + if (args->arg_count != 3) + { + strcpy(message, "spider_(bg)_direct_sql() requires 3 arguments"); + goto error; + } + if ( + args->arg_type[0] != STRING_RESULT || + args->arg_type[1] != STRING_RESULT || + args->arg_type[2] != STRING_RESULT + ) { + strcpy(message, "spider_(bg)_direct_sql() requires string arguments"); + goto error; + } +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (bg) + { + if (!(bg_direct_sql = (SPIDER_BG_DIRECT_SQL *) + spider_malloc(spider_current_trx, 10, sizeof(SPIDER_BG_DIRECT_SQL), + MYF(MY_WME | MY_ZEROFILL))) + ) { + strcpy(message, "spider_bg_direct_sql() out of memory"); + goto error; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&bg_direct_sql->bg_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_bg_direct_sql, + &bg_direct_sql->bg_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + strcpy(message, "spider_bg_direct_sql() out of memory"); + goto error_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_cond_init(&bg_direct_sql->bg_cond, NULL)) +#else + if (mysql_cond_init(spd_key_cond_bg_direct_sql, + &bg_direct_sql->bg_cond, NULL)) +#endif + { + strcpy(message, "spider_bg_direct_sql() out of memory"); + goto error_cond_init; + } + initid->ptr = (char *) bg_direct_sql; + } +#endif + DBUG_RETURN(FALSE); + +#ifndef WITHOUT_SPIDER_BG_SEARCH +error_cond_init: + pthread_mutex_destroy(&bg_direct_sql->bg_mutex); +error_mutex_init: + spider_free(spider_current_trx, bg_direct_sql, MYF(0)); +#endif +error: + DBUG_RETURN(TRUE); +} + +void spider_direct_sql_deinit_body( + UDF_INIT *initid +) { + SPIDER_BG_DIRECT_SQL *bg_direct_sql = (SPIDER_BG_DIRECT_SQL *) initid->ptr; + DBUG_ENTER("spider_direct_sql_deinit_body"); + if (bg_direct_sql) + { + pthread_cond_destroy(&bg_direct_sql->bg_cond); + pthread_mutex_destroy(&bg_direct_sql->bg_mutex); + spider_free(spider_current_trx, bg_direct_sql, MYF(0)); + } + DBUG_VOID_RETURN; +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +void spider_direct_sql_bg_start( + UDF_INIT *initid +) { + SPIDER_BG_DIRECT_SQL *bg_direct_sql = (SPIDER_BG_DIRECT_SQL *) initid->ptr; + DBUG_ENTER("spider_direct_sql_bg_start"); + bg_direct_sql->called_cnt = 0; + bg_direct_sql->bg_error = 0; + DBUG_VOID_RETURN; +} + +long long spider_direct_sql_bg_end( + UDF_INIT *initid +) { + THD *thd = current_thd; + SPIDER_BG_DIRECT_SQL *bg_direct_sql = (SPIDER_BG_DIRECT_SQL *) initid->ptr; + DBUG_ENTER("spider_direct_sql_bg_end"); + pthread_mutex_lock(&bg_direct_sql->bg_mutex); + while (bg_direct_sql->direct_sql) + pthread_cond_wait(&bg_direct_sql->bg_cond, &bg_direct_sql->bg_mutex); + pthread_mutex_unlock(&bg_direct_sql->bg_mutex); + if (bg_direct_sql->modified_non_trans_table) + thd->transaction.stmt.modified_non_trans_table = TRUE; + if (bg_direct_sql->bg_error) + { + my_message(bg_direct_sql->bg_error, bg_direct_sql->bg_error_msg, MYF(0)); + DBUG_RETURN(0); + } + DBUG_RETURN(bg_direct_sql->called_cnt); +} + +int spider_udf_bg_direct_sql( + SPIDER_DIRECT_SQL *direct_sql +) { + int error_num; + SPIDER_CONN *conn = direct_sql->conn; + DBUG_ENTER("spider_udf_bg_direct_sql"); + if ((error_num = spider_create_conn_thread(conn))) + DBUG_RETURN(error_num); + if (!pthread_mutex_trylock(&conn->bg_conn_mutex)) + { + DBUG_PRINT("info",("spider get bg_conn_mutex")); + conn->bg_target = direct_sql; + conn->bg_direct_sql = TRUE; + conn->bg_caller_sync_wait = TRUE; + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + conn->bg_caller_sync_wait = FALSE; + } else { + DBUG_PRINT("info",("spider get put job stack")); + bool bg_get_job_stack = FALSE; + pthread_mutex_lock(&conn->bg_job_stack_mutex); + uint old_elements = conn->bg_job_stack.max_element; + if (insert_dynamic(&conn->bg_job_stack, (uchar *) &direct_sql)) + { + pthread_mutex_unlock(&conn->bg_job_stack_mutex); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (conn->bg_job_stack.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + conn->bg_job_stack, + (conn->bg_job_stack.max_element - old_elements) * + conn->bg_job_stack.size_of_element); + } + if (!conn->bg_get_job_stack_off) + bg_get_job_stack = TRUE; + pthread_mutex_unlock(&conn->bg_job_stack_mutex); + if (bg_get_job_stack) + { + DBUG_PRINT("info",("spider get bg_conn_mutex")); + pthread_mutex_lock(&conn->bg_conn_mutex); + conn->bg_target = NULL; + conn->bg_get_job_stack = TRUE; + conn->bg_direct_sql = TRUE; + conn->bg_caller_sync_wait = TRUE; + pthread_mutex_lock(&conn->bg_conn_sync_mutex); + pthread_cond_signal(&conn->bg_conn_cond); + pthread_mutex_unlock(&conn->bg_conn_mutex); + pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex); + pthread_mutex_unlock(&conn->bg_conn_sync_mutex); + conn->bg_caller_sync_wait = FALSE; + } + } + DBUG_RETURN(0); +} +#endif diff --git a/storage/spider/spd_direct_sql.h b/storage/spider/spd_direct_sql.h new file mode 100644 index 00000000000..f20e9de6373 --- /dev/null +++ b/storage/spider/spd_direct_sql.h @@ -0,0 +1,67 @@ +/* Copyright (C) 2009-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +uint spider_udf_calc_hash( + char *key, + uint mod +); + +int spider_udf_direct_sql_create_table_list( + SPIDER_DIRECT_SQL *direct_sql, + char *table_name_list, + uint table_name_list_length +); + +int spider_udf_direct_sql_create_conn_key( + SPIDER_DIRECT_SQL *direct_sql +); + +SPIDER_CONN *spider_udf_direct_sql_create_conn( + const SPIDER_DIRECT_SQL *direct_sql, + int *error_num +); + +SPIDER_CONN *spider_udf_direct_sql_get_conn( + const SPIDER_DIRECT_SQL *direct_sql, + SPIDER_TRX *trx, + int *error_num +); + +int spider_udf_direct_sql_get_server( + SPIDER_DIRECT_SQL *direct_sql +); + +int spider_udf_parse_direct_sql_param( + SPIDER_TRX *trx, + SPIDER_DIRECT_SQL *direct_sql, + const char *param, + int param_length +); + +int spider_udf_set_direct_sql_param_default( + SPIDER_TRX *trx, + SPIDER_DIRECT_SQL *direct_sql +); + +void spider_udf_free_direct_sql_alloc( + SPIDER_DIRECT_SQL *direct_sql, + my_bool bg +); + +#ifndef WITHOUT_SPIDER_BG_SEARCH +int spider_udf_bg_direct_sql( + SPIDER_DIRECT_SQL *direct_sql +); +#endif diff --git a/storage/spider/spd_err.h b/storage/spider/spd_err.h new file mode 100644 index 00000000000..c644d6ebca5 --- /dev/null +++ b/storage/spider/spd_err.h @@ -0,0 +1,119 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define ER_SPIDER_INVALID_CONNECT_INFO_NUM 12501 +#define ER_SPIDER_INVALID_CONNECT_INFO_STR "The connect info '%-.64s' is invalid" +#define ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM 12502 +#define ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR "The connect info '%-.64s' for %s is too long" +#define ER_SPIDER_INVALID_UDF_PARAM_NUM 12503 +#define ER_SPIDER_INVALID_UDF_PARAM_STR "The UDF parameter '%-.64s' is invalid" +#define ER_SPIDER_DIFFERENT_LINK_COUNT_NUM 12504 +#define ER_SPIDER_DIFFERENT_LINK_COUNT_STR "Different multiple table link parameter's count" +#define ER_SPIDER_UDF_PING_TABLE_PARAM_TOO_LONG_NUM 12505 +#define ER_SPIDER_UDF_PING_TABLE_PARAM_TOO_LONG_STR "Server name or table name are too long" +#define ER_SPIDER_UDF_PING_TABLE_PARAM_REQIRED_NUM 12506 +#define ER_SPIDER_UDF_PING_TABLE_PARAM_REQIRED_STR "Server name or table name are required" +#define ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM 12507 +#define ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR "This UDF can't execute if other tables are opened" +#define ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM "This UDF can't execute if other tables are opened '%s'=%lld" +#define ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR "This UDF can't execute if other tables are opened '%s'=%p" +#define ER_SPIDER_UDF_PING_TABLE_NO_SERVER_ID_NUM 12508 +#define ER_SPIDER_UDF_PING_TABLE_NO_SERVER_ID_STR "Current server_id is not exist" +#define ER_SPIDER_UDF_PING_TABLE_DIFFERENT_MON_NUM 12509 +#define ER_SPIDER_UDF_PING_TABLE_DIFFERENT_MON_STR "Monitor count is different" +#define ER_SPIDER_LINK_MON_OK_NUM 12510 +#define ER_SPIDER_LINK_MON_OK_STR "Table '%s.%s' get a problem, but mon is OK" +#define ER_SPIDER_LINK_MON_NG_NUM 12511 +#define ER_SPIDER_LINK_MON_NG_STR "Table '%s.%s' get a problem" +#define ER_SPIDER_LINK_MON_DRAW_FEW_MON_NUM 12512 +#define ER_SPIDER_LINK_MON_DRAW_FEW_MON_STR "Can not judge by enough monitor for table '%s.%s'" +#define ER_SPIDER_LINK_MON_DRAW_NUM 12513 +#define ER_SPIDER_LINK_MON_DRAW_STR "Can not judge status for table '%s.%s'" +#define ER_SPIDER_ALL_LINKS_FAILED_NUM 12514 +#define ER_SPIDER_ALL_LINKS_FAILED_STR "All links of '%s.%s' are failed" +#define ER_SPIDER_TMP_TABLE_MON_NUM 12515 +#define ER_SPIDER_TMP_TABLE_MON_STR "Can't use monitor by temporary table" +#define ER_SPIDER_MON_AT_ALTER_TABLE_NUM 12516 +#define ER_SPIDER_MON_AT_ALTER_TABLE_STR "Got an error in alter or drop table" +#define ER_SPIDER_BLANK_UDF_ARGUMENT_NUM 12517 +#define ER_SPIDER_BLANK_UDF_ARGUMENT_STR "The UDF no.%d argument can't be blank" +#define ER_SPIDER_READ_ONLY_NUM 12518 +#define ER_SPIDER_READ_ONLY_STR "Table '%s.%s' is read only" +#define ER_SPIDER_LINK_IS_FAILOVER_NUM 12519 +#define ER_SPIDER_LINK_IS_FAILOVER_STR "A link is fail-overed" +#define ER_SPIDER_AUTOINC_VAL_IS_DIFFERENT_NUM 12520 +#define ER_SPIDER_AUTOINC_VAL_IS_DIFFERENT_STR "Binlog's auto-inc value is probably different from linked table's auto-inc value" +#define ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM 12521 +#define ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR "Can't use wrapper '%s' for SQL connection" +#define ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM 12522 +#define ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR "Can't use wrapper '%s' for NOSQL connection" +#define ER_SPIDER_REQUEST_KEY_NUM 12523 +#define ER_SPIDER_REQUEST_KEY_STR "Request key not found" + +#define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_NUM 12601 +#define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_STR "Can't use both spider_use_consistent_snapshot = 1 and spider_internal_xa = 1" +#define ER_SPIDER_XA_LOCKED_NUM 12602 +#define ER_SPIDER_XA_LOCKED_STR "This xid is now locked" +#define ER_SPIDER_XA_NOT_PREPARED_NUM 12603 +#define ER_SPIDER_XA_NOT_PREPARED_STR "This xid is not prepared" +#define ER_SPIDER_XA_PREPARED_NUM 12604 +#define ER_SPIDER_XA_PREPARED_STR "This xid is prepared" +#define ER_SPIDER_XA_EXISTS_NUM 12605 +#define ER_SPIDER_XA_EXISTS_STR "This xid is already exist" +#define ER_SPIDER_XA_MEMBER_EXISTS_NUM 12606 +#define ER_SPIDER_XA_MEMBER_EXISTS_STR "This xid member is already exist" +#define ER_SPIDER_XA_NOT_EXISTS_NUM 12607 +#define ER_SPIDER_XA_NOT_EXISTS_STR "This xid is not exist" +#define ER_SPIDER_XA_MEMBER_NOT_EXISTS_NUM 12608 +#define ER_SPIDER_XA_MEMBER_NOT_EXISTS_STR "This xid member is not exist" +#define ER_SPIDER_SYS_TABLE_VERSION_NUM 12609 +#define ER_SPIDER_SYS_TABLE_VERSION_STR "System table %s is different version" +#define ER_SPIDER_WRONG_CHARACTER_IN_NAME_NUM 12611 +#define ER_SPIDER_WRONG_CHARACTER_IN_NAME_STR "Wrong character in name string" +#define ER_SPIDER_LOW_MEM_READ_PREV_NUM 12621 +#define ER_SPIDER_LOW_MEM_READ_PREV_STR "Can't use this operation at low mem read mode" +#define ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM 12622 +#define ER_SPIDER_ALTER_BEFORE_UNLOCK_STR "Can't use this operation before executing 'unlock tables'" +#define ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM 12701 +#define ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR "Remote MySQL server has gone away" +#define ER_SPIDER_REMOTE_SERVER_GONE_AWAY_LEN (sizeof(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR) - 1) +#define ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM 12702 +#define ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR "Remote table '%s.%s' is not found" +#define ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM 12703 +#define ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_STR "Temporary table '%s.%s' is not found" +#define ER_SPIDER_UDF_COPY_TABLE_SRC_NOT_FOUND_NUM 12704 +#define ER_SPIDER_UDF_COPY_TABLE_SRC_NOT_FOUND_STR "Source table is not found" +#define ER_SPIDER_UDF_COPY_TABLE_DST_NOT_FOUND_NUM 12705 +#define ER_SPIDER_UDF_COPY_TABLE_DST_NOT_FOUND_STR "Destination table is not found" +#define ER_SPIDER_UDF_COPY_TABLE_SRC_NG_STATUS_NUM 12706 +#define ER_SPIDER_UDF_COPY_TABLE_SRC_NG_STATUS_STR "Source table is NG status" +#define ER_SPIDER_UDF_COPY_TABLE_DST_NG_STATUS_NUM 12707 +#define ER_SPIDER_UDF_COPY_TABLE_DST_NG_STATUS_STR "Destination table is NG status" +#define ER_SPIDER_UDF_CANT_OPEN_TABLE_NUM 12708 +#define ER_SPIDER_UDF_CANT_OPEN_TABLE_STR "Can't open table %s.%s" +#define ER_SPIDER_UDF_COPY_TABLE_NEED_PK_NUM 12709 +#define ER_SPIDER_UDF_COPY_TABLE_NEED_PK_STR "Table %s.%s needs PK for copying" +#define ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM 12710 +#define ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR "Invalid information from remote table '%s.%s'" +#define ER_SPIDER_HS_STR "Error from HS %d %s" +#define ER_SPIDER_HS_NUM 12711 +#define ER_SPIDER_ORACLE_STR "Error from Oracle %d %d %s" +#define ER_SPIDER_ORACLE_NUM 12712 +#define ER_SPIDER_ORACLE_ERR "Oracle error" +#define ER_SPIDER_COND_SKIP_NUM 12801 + +#define ER_SPIDER_UNKNOWN_NUM 12500 +#define ER_SPIDER_UNKNOWN_STR "unknown" +#define ER_SPIDER_UNKNOWN_LEN (sizeof(ER_SPIDER_UNKNOWN_STR) - 1) diff --git a/storage/spider/spd_i_s.cc b/storage/spider/spd_i_s.cc new file mode 100644 index 00000000000..c32745dae98 --- /dev/null +++ b/storage/spider/spd_i_s.cc @@ -0,0 +1,148 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#include "sql_show.h" +#endif +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_table.h" + +extern pthread_mutex_t spider_mem_calc_mutex; + +extern const char *spider_alloc_func_name[SPIDER_MEM_CALC_LIST_NUM]; +extern const char *spider_alloc_file_name[SPIDER_MEM_CALC_LIST_NUM]; +extern ulong spider_alloc_line_no[SPIDER_MEM_CALC_LIST_NUM]; +extern ulonglong spider_total_alloc_mem[SPIDER_MEM_CALC_LIST_NUM]; +extern longlong spider_current_alloc_mem[SPIDER_MEM_CALC_LIST_NUM]; +extern ulonglong spider_alloc_mem_count[SPIDER_MEM_CALC_LIST_NUM]; +extern ulonglong spider_free_mem_count[SPIDER_MEM_CALC_LIST_NUM]; + +static struct st_mysql_storage_engine spider_i_s_info = +{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; + +static ST_FIELD_INFO spider_i_s_alloc_mem_fields_info[] = +{ + {"ID", 10, MYSQL_TYPE_LONG, 0, MY_I_S_UNSIGNED, "id", SKIP_OPEN_TABLE}, + {"FUNC_NAME", 64, MYSQL_TYPE_STRING, 0, + MY_I_S_MAYBE_NULL, "func_name", SKIP_OPEN_TABLE}, + {"FILE_NAME", 64, MYSQL_TYPE_STRING, 0, + MY_I_S_MAYBE_NULL, "file_name", SKIP_OPEN_TABLE}, + {"LINE_NO", 10, MYSQL_TYPE_LONG, 0, + MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "line_no", SKIP_OPEN_TABLE}, + {"TOTAL_ALLOC_MEM", 20, MYSQL_TYPE_LONGLONG, 0, + MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "total_alloc_mem", SKIP_OPEN_TABLE}, + {"CURRENT_ALLOC_MEM", 20, MYSQL_TYPE_LONGLONG, 0, + MY_I_S_MAYBE_NULL, "current_alloc_mem", SKIP_OPEN_TABLE}, + {"ALLOC_MEM_COUNT", 20, MYSQL_TYPE_LONGLONG, 0, + MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "alloc_mem_count", SKIP_OPEN_TABLE}, + {"FREE_MEM_COUNT", 20, MYSQL_TYPE_LONGLONG, 0, + MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "free_mem_count", SKIP_OPEN_TABLE}, + {NULL, 0, MYSQL_TYPE_STRING, 0, 0, NULL, 0} +}; + +static int spider_i_s_alloc_mem_fill_table( + THD *thd, + TABLE_LIST *tables, + COND *cond +) { + uint roop_count; + TABLE *table = tables->table; + DBUG_ENTER("spider_i_s_alloc_mem_fill_table"); + for (roop_count = 0; roop_count < SPIDER_MEM_CALC_LIST_NUM; roop_count++) + { + table->field[0]->store(roop_count, TRUE); + if (spider_alloc_func_name[roop_count]) + { + table->field[1]->set_notnull(); + table->field[2]->set_notnull(); + table->field[3]->set_notnull(); + table->field[4]->set_notnull(); + table->field[5]->set_notnull(); + table->field[6]->set_notnull(); + table->field[7]->set_notnull(); + table->field[1]->store(spider_alloc_func_name[roop_count], + strlen(spider_alloc_func_name[roop_count]), system_charset_info); + table->field[2]->store(spider_alloc_file_name[roop_count], + strlen(spider_alloc_file_name[roop_count]), system_charset_info); + table->field[3]->store(spider_alloc_line_no[roop_count], TRUE); + pthread_mutex_lock(&spider_mem_calc_mutex); + table->field[4]->store(spider_total_alloc_mem[roop_count], TRUE); + table->field[5]->store(spider_current_alloc_mem[roop_count], FALSE); + table->field[6]->store(spider_alloc_mem_count[roop_count], TRUE); + table->field[7]->store(spider_free_mem_count[roop_count], TRUE); + pthread_mutex_unlock(&spider_mem_calc_mutex); + } else { + table->field[1]->set_null(); + table->field[2]->set_null(); + table->field[3]->set_null(); + table->field[4]->set_null(); + table->field[5]->set_null(); + table->field[6]->set_null(); + table->field[7]->set_null(); + } + if (schema_table_store_record(thd, table)) + { + DBUG_RETURN(1); + } + } + DBUG_RETURN(0); +} + +static int spider_i_s_alloc_mem_init( + void *p +) { + ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; + DBUG_ENTER("spider_i_s_alloc_mem_init"); + schema->fields_info = spider_i_s_alloc_mem_fields_info; + schema->fill_table = spider_i_s_alloc_mem_fill_table; + schema->idx_field1 = 0; + DBUG_RETURN(0); +} + +static int spider_i_s_alloc_mem_deinit( + void *p +) { + DBUG_ENTER("spider_i_s_alloc_mem_deinit"); + DBUG_RETURN(0); +} + +struct st_mysql_plugin spider_i_s_alloc_mem = +{ + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &spider_i_s_info, + "SPIDER_ALLOC_MEM", + "Kentoku Shiba", + "Spider memory allocating viewer", + PLUGIN_LICENSE_GPL, + spider_i_s_alloc_mem_init, + spider_i_s_alloc_mem_deinit, + 0x0001, + NULL, + NULL, + NULL, +#if MYSQL_VERSION_ID >= 50600 + 0, +#endif +}; diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h new file mode 100644 index 00000000000..4340339ac57 --- /dev/null +++ b/storage/spider/spd_include.h @@ -0,0 +1,1123 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#if MYSQL_VERSION_ID < 50500 +#else +#define my_free(A,B) my_free(A) +#ifdef pthread_mutex_t +#undef pthread_mutex_t +#endif +#define pthread_mutex_t mysql_mutex_t +#ifdef pthread_mutex_lock +#undef pthread_mutex_lock +#endif +#define pthread_mutex_lock mysql_mutex_lock +#ifdef pthread_mutex_trylock +#undef pthread_mutex_trylock +#endif +#define pthread_mutex_trylock mysql_mutex_trylock +#ifdef pthread_mutex_unlock +#undef pthread_mutex_unlock +#endif +#define pthread_mutex_unlock mysql_mutex_unlock +#ifdef pthread_mutex_destroy +#undef pthread_mutex_destroy +#endif +#define pthread_mutex_destroy mysql_mutex_destroy +#ifdef pthread_cond_t +#undef pthread_cond_t +#endif +#define pthread_cond_t mysql_cond_t +#ifdef pthread_cond_wait +#undef pthread_cond_wait +#endif +#define pthread_cond_wait mysql_cond_wait +#ifdef pthread_cond_signal +#undef pthread_cond_signal +#endif +#define pthread_cond_signal mysql_cond_signal +#ifdef pthread_cond_broadcast +#undef pthread_cond_broadcast +#endif +#define pthread_cond_broadcast mysql_cond_broadcast +#ifdef pthread_cond_destroy +#undef pthread_cond_destroy +#endif +#define pthread_cond_destroy mysql_cond_destroy +#define my_sprintf(A,B) sprintf B +#endif + +#if MYSQL_VERSION_ID >= 50500 +#define SPIDER_HAS_HASH_VALUE_TYPE +#endif + +#define spider_bitmap_size(A) ((A + 7) / 8) +#define spider_set_bit(BITMAP, BIT) \ + ((BITMAP)[(BIT) / 8] |= (1 << ((BIT) & 7))) +#define spider_clear_bit(BITMAP, BIT) \ + ((BITMAP)[(BIT) / 8] &= ~(1 << ((BIT) & 7))) +#define spider_bit_is_set(BITMAP, BIT) \ + (uint) ((BITMAP)[(BIT) / 8] & (1 << ((BIT) & 7))) + +#define SPIDER_LINK_STATUS_NO_CHANGE 0 +#define SPIDER_LINK_STATUS_OK 1 +#define SPIDER_LINK_STATUS_RECOVERY 2 +#define SPIDER_LINK_STATUS_NG 3 + +#define SPIDER_LINK_MON_OK 0 +#define SPIDER_LINK_MON_NG -1 +#define SPIDER_LINK_MON_DRAW_FEW_MON 1 +#define SPIDER_LINK_MON_DRAW 2 + +#define SPIDER_TMP_SHARE_CHAR_PTR_COUNT 19 +#define SPIDER_TMP_SHARE_UINT_COUNT 17 +#define SPIDER_TMP_SHARE_LONG_COUNT 15 +#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3 + +#define SPIDER_MEM_CALC_LIST_NUM 230 + +#define SPIDER_BACKUP_DASTATUS \ + bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE; +#define SPIDER_RESTORE_DASTATUS \ + if (!da_status && thd->is_error()) thd->clear_error(); +#define SPIDER_CONN_RESTORE_DASTATUS \ + if (thd && conn->error_mode) {SPIDER_RESTORE_DASTATUS;} +#define SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM \ + if (thd && conn->error_mode) {SPIDER_RESTORE_DASTATUS; error_num = 0;} +#define SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM \ + if (thd && conn->error_mode) {SPIDER_RESTORE_DASTATUS; tmp_error_num = 0;} + +#define SPIDER_SET_FILE_POS(A) \ + {(A)->thd = current_thd; (A)->func_name = __func__; (A)->file_name = __FILE__; (A)->line_no = __LINE__;} +#define SPIDER_CLEAR_FILE_POS(A) \ + {(A)->thd = NULL; (A)->func_name = NULL; (A)->file_name = NULL; (A)->line_no = 0;} + +class ha_spider; +typedef struct st_spider_share SPIDER_SHARE; + +typedef struct st_spider_file_pos +{ + THD *thd; + const char *func_name; + const char *file_name; + ulong line_no; +} SPIDER_FILE_POS; + +typedef struct st_spider_link_for_hash +{ + ha_spider *spider; + int link_idx; + spider_string *db_table_str; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type db_table_str_hash_value; +#endif +} SPIDER_LINK_FOR_HASH; + +/* alter table */ +typedef struct st_spider_alter_table +{ + bool now_create; + char *table_name; + uint table_name_length; + char *tmp_char; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type table_name_hash_value; +#endif + longlong tmp_priority; + uint link_count; + uint all_link_count; + + char **tmp_server_names; + char **tmp_tgt_table_names; + char **tmp_tgt_dbs; + char **tmp_tgt_hosts; + char **tmp_tgt_usernames; + char **tmp_tgt_passwords; + char **tmp_tgt_sockets; + char **tmp_tgt_wrappers; + char **tmp_tgt_ssl_cas; + char **tmp_tgt_ssl_capaths; + char **tmp_tgt_ssl_certs; + char **tmp_tgt_ssl_ciphers; + char **tmp_tgt_ssl_keys; + char **tmp_tgt_default_files; + char **tmp_tgt_default_groups; + long *tmp_tgt_ports; + long *tmp_tgt_ssl_vscs; + long *tmp_link_statuses; + + uint *tmp_server_names_lengths; + uint *tmp_tgt_table_names_lengths; + uint *tmp_tgt_dbs_lengths; + uint *tmp_tgt_hosts_lengths; + uint *tmp_tgt_usernames_lengths; + uint *tmp_tgt_passwords_lengths; + uint *tmp_tgt_sockets_lengths; + uint *tmp_tgt_wrappers_lengths; + uint *tmp_tgt_ssl_cas_lengths; + uint *tmp_tgt_ssl_capaths_lengths; + uint *tmp_tgt_ssl_certs_lengths; + uint *tmp_tgt_ssl_ciphers_lengths; + uint *tmp_tgt_ssl_keys_lengths; + uint *tmp_tgt_default_files_lengths; + uint *tmp_tgt_default_groups_lengths; + + uint tmp_server_names_charlen; + uint tmp_tgt_table_names_charlen; + uint tmp_tgt_dbs_charlen; + uint tmp_tgt_hosts_charlen; + uint tmp_tgt_usernames_charlen; + uint tmp_tgt_passwords_charlen; + uint tmp_tgt_sockets_charlen; + uint tmp_tgt_wrappers_charlen; + uint tmp_tgt_ssl_cas_charlen; + uint tmp_tgt_ssl_capaths_charlen; + uint tmp_tgt_ssl_certs_charlen; + uint tmp_tgt_ssl_ciphers_charlen; + uint tmp_tgt_ssl_keys_charlen; + uint tmp_tgt_default_files_charlen; + uint tmp_tgt_default_groups_charlen; + + uint tmp_server_names_length; + uint tmp_tgt_table_names_length; + uint tmp_tgt_dbs_length; + uint tmp_tgt_hosts_length; + uint tmp_tgt_usernames_length; + uint tmp_tgt_passwords_length; + uint tmp_tgt_sockets_length; + uint tmp_tgt_wrappers_length; + uint tmp_tgt_ssl_cas_length; + uint tmp_tgt_ssl_capaths_length; + uint tmp_tgt_ssl_certs_length; + uint tmp_tgt_ssl_ciphers_length; + uint tmp_tgt_ssl_keys_length; + uint tmp_tgt_default_files_length; + uint tmp_tgt_default_groups_length; + uint tmp_tgt_ports_length; + uint tmp_tgt_ssl_vscs_length; + uint tmp_link_statuses_length; +} SPIDER_ALTER_TABLE; + +/* database connection */ +typedef struct st_spider_conn +{ + uint conn_kind; + char *conn_key; + uint conn_key_length; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type conn_key_hash_value; +#endif + int link_idx; + spider_db_conn *db_conn; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + query_id_t hsc_query_id; + ulonglong hs_pre_age; + ulonglong hs_age; +#endif + uint opened_handlers; + ulonglong conn_id; + ulonglong connection_id; + pthread_mutex_t mta_conn_mutex; + volatile bool mta_conn_mutex_lock_already; + volatile bool mta_conn_mutex_unlock_later; + SPIDER_FILE_POS mta_conn_mutex_file_pos; + uint join_trx; + int trx_isolation; + bool semi_trx_isolation_chk; + int semi_trx_isolation; + bool semi_trx_chk; + bool semi_trx; + bool trx_start; + bool table_locked; + int table_lock; + bool disable_xa; + bool disable_reconnect; + int autocommit; + int sql_log_off; + THD *thd; + void *another_ha_first; + void *another_ha_last; + st_spider_conn *p_small; + st_spider_conn *p_big; + st_spider_conn *c_small; + st_spider_conn *c_big; + longlong priority; + bool server_lost; + bool ignore_dup_key; + char *error_str; + int error_length; + time_t ping_time; + CHARSET_INFO *access_charset; + Time_zone *time_zone; + uint connect_timeout; + uint net_read_timeout; + uint net_write_timeout; + int error_mode; + spider_string default_database; + + char *tgt_host; + char *tgt_username; + char *tgt_password; + char *tgt_socket; + char *tgt_wrapper; + char *tgt_ssl_ca; + char *tgt_ssl_capath; + char *tgt_ssl_cert; + char *tgt_ssl_cipher; + char *tgt_ssl_key; + char *tgt_default_file; + char *tgt_default_group; + long tgt_port; + long tgt_ssl_vsc; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char *hs_sock; + long hs_port; +#endif + + uint tgt_host_length; + uint tgt_username_length; + uint tgt_password_length; + uint tgt_socket_length; + uint tgt_wrapper_length; + uint tgt_ssl_ca_length; + uint tgt_ssl_capath_length; + uint tgt_ssl_cert_length; + uint tgt_ssl_cipher_length; + uint tgt_ssl_key_length; + uint tgt_default_file_length; + uint tgt_default_group_length; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint hs_sock_length; +#endif + uint dbton_id; + +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile +#endif + void *quick_target; +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile bool bg_init; + volatile bool bg_break; + volatile bool bg_kill; + volatile bool bg_caller_wait; + volatile bool bg_caller_sync_wait; + volatile bool bg_search; + volatile bool bg_discard_result; + volatile bool bg_direct_sql; + volatile bool bg_exec_sql; + volatile bool bg_get_job_stack; + volatile bool bg_get_job_stack_off; + volatile uint bg_simple_action; + THD *bg_thd; + pthread_t bg_thread; + pthread_cond_t bg_conn_cond; + pthread_mutex_t bg_conn_mutex; + pthread_cond_t bg_conn_sync_cond; + pthread_mutex_t bg_conn_sync_mutex; + pthread_mutex_t bg_conn_chain_mutex; + pthread_mutex_t *bg_conn_chain_mutex_ptr; + volatile void *bg_target; + volatile int *bg_error_num; + volatile ulong bg_sql_type; + pthread_mutex_t bg_job_stack_mutex; + DYNAMIC_ARRAY bg_job_stack; + uint bg_job_stack_id; + const char *bg_job_stack_func_name; + const char *bg_job_stack_file_name; + ulong bg_job_stack_line_no; + uint bg_job_stack_cur_pos; +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile +#endif + int *need_mon; + int *conn_need_mon; + + bool use_for_active_standby; + bool in_before_query; + + bool queued_connect; + bool queued_ping; + bool queued_trx_isolation; + bool queued_semi_trx_isolation; + bool queued_autocommit; + bool queued_sql_log_off; + bool queued_time_zone; + bool queued_trx_start; + bool queued_xa_start; + bool queued_net_timeout; + SPIDER_SHARE *queued_connect_share; + int queued_connect_link_idx; + ha_spider *queued_ping_spider; + int queued_ping_link_idx; + int queued_trx_isolation_val; + int queued_semi_trx_isolation_val; + bool queued_autocommit_val; + bool queued_sql_log_off_val; + Time_zone *queued_time_zone_val; + XID *queued_xa_start_xid; + +#ifdef HA_CAN_BULK_ACCESS + uint bulk_access_requests; + uint bulk_access_sended; + int bulk_access_error_num; + st_spider_conn *bulk_access_next; +#endif +} SPIDER_CONN; + +#ifdef WITH_PARTITION_STORAGE_ENGINE +typedef struct st_spider_patition_handler_share +{ + uint use_count; + TABLE *table; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type table_hash_value; +#endif + void *creator; + void **handlers; + uchar *searched_bitmap; + uchar *idx_read_bitmap; + uchar *idx_write_bitmap; + uchar *rnd_read_bitmap; + uchar *rnd_write_bitmap; + bool between_flg; + bool idx_bitmap_is_set; + bool rnd_bitmap_is_set; +} SPIDER_PARTITION_HANDLER_SHARE; + +typedef struct st_spider_patition_share +{ + char *table_name; + uint table_name_length; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type table_path_hash_value; +#endif + uint use_count; + pthread_mutex_t sts_mutex; + pthread_mutex_t crd_mutex; + pthread_mutex_t pt_handler_mutex; + HASH pt_handler_hash; + uint pt_handler_hash_id; + const char *pt_handler_hash_func_name; + const char *pt_handler_hash_file_name; + ulong pt_handler_hash_line_no; + + volatile bool sts_init; + volatile bool crd_init; + volatile time_t sts_get_time; + volatile time_t crd_get_time; + ulonglong data_file_length; + ulonglong max_data_file_length; + ulonglong index_file_length; + ulonglong auto_increment_value; + ha_rows records; + ulong mean_rec_length; + time_t check_time; + time_t create_time; + time_t update_time; + + longlong *cardinality; +/* + volatile SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share; +*/ +} SPIDER_PARTITION_SHARE; +#endif + +typedef struct st_spider_transaction +{ + bool trx_start; + bool trx_xa; + bool trx_consistent_snapshot; + + bool use_consistent_snapshot; + bool internal_xa; + uint internal_xa_snapshot; + + query_id_t query_id; + bool tmp_flg; + bool registed_allocated_thds; + + THD *thd; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type thd_hash_value; +#endif + XID xid; + HASH trx_conn_hash; + uint trx_conn_hash_id; + const char *trx_conn_hash_func_name; + const char *trx_conn_hash_file_name; + ulong trx_conn_hash_line_no; + HASH trx_another_conn_hash; + uint trx_another_conn_hash_id; + const char *trx_another_conn_hash_func_name; + const char *trx_another_conn_hash_file_name; + ulong trx_another_conn_hash_line_no; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + HASH trx_hs_r_conn_hash; + uint trx_hs_r_conn_hash_id; + const char *trx_hs_r_conn_hash_func_name; + const char *trx_hs_r_conn_hash_file_name; + ulong trx_hs_r_conn_hash_line_no; + HASH trx_hs_w_conn_hash; + uint trx_hs_w_conn_hash_id; + const char *trx_hs_w_conn_hash_func_name; + const char *trx_hs_w_conn_hash_file_name; + ulong trx_hs_w_conn_hash_line_no; +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + HASH trx_direct_hs_r_conn_hash; + uint trx_direct_hs_r_conn_hash_id; + const char *trx_direct_hs_r_conn_hash_func_name; + const char *trx_direct_hs_r_conn_hash_file_name; + ulong trx_direct_hs_r_conn_hash_line_no; + HASH trx_direct_hs_w_conn_hash; + uint trx_direct_hs_w_conn_hash_id; + const char *trx_direct_hs_w_conn_hash_func_name; + const char *trx_direct_hs_w_conn_hash_file_name; + ulong trx_direct_hs_w_conn_hash_line_no; +#endif + HASH trx_alter_table_hash; + uint trx_alter_table_hash_id; + const char *trx_alter_table_hash_func_name; + const char *trx_alter_table_hash_file_name; + ulong trx_alter_table_hash_line_no; + HASH trx_ha_hash; + uint trx_ha_hash_id; + const char *trx_ha_hash_func_name; + const char *trx_ha_hash_file_name; + ulong trx_ha_hash_line_no; + uint trx_ha_reuse_count; + XID_STATE internal_xid_state; + SPIDER_CONN *join_trx_top; + ulonglong spider_thread_id; + ulonglong trx_conn_adjustment; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ulonglong trx_hs_r_conn_adjustment; + ulonglong trx_hs_w_conn_adjustment; +#endif + uint locked_connections; + + ulonglong direct_update_count; + ulonglong direct_delete_count; + ulonglong direct_order_limit_count; + ulonglong direct_aggregate_count; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ulonglong hs_result_free_count; +#endif + +#ifdef HA_CAN_BULK_ACCESS + SPIDER_CONN *bulk_access_conn_first; + SPIDER_CONN *bulk_access_conn_last; +#endif + + pthread_mutex_t *udf_table_mutexes; + CHARSET_INFO *udf_access_charset; + spider_string *udf_set_names; + + time_t mem_calc_merge_time; + const char *alloc_func_name[SPIDER_MEM_CALC_LIST_NUM]; + const char *alloc_file_name[SPIDER_MEM_CALC_LIST_NUM]; + ulong alloc_line_no[SPIDER_MEM_CALC_LIST_NUM]; + ulonglong total_alloc_mem[SPIDER_MEM_CALC_LIST_NUM]; + longlong current_alloc_mem[SPIDER_MEM_CALC_LIST_NUM]; + ulonglong alloc_mem_count[SPIDER_MEM_CALC_LIST_NUM]; + ulonglong free_mem_count[SPIDER_MEM_CALC_LIST_NUM]; + ulonglong total_alloc_mem_buffer[SPIDER_MEM_CALC_LIST_NUM]; + longlong current_alloc_mem_buffer[SPIDER_MEM_CALC_LIST_NUM]; + ulonglong alloc_mem_count_buffer[SPIDER_MEM_CALC_LIST_NUM]; + ulonglong free_mem_count_buffer[SPIDER_MEM_CALC_LIST_NUM]; +} SPIDER_TRX; + +typedef struct st_spider_share +{ + char *table_name; + uint table_name_length; + uint use_count; + uint link_count; + uint all_link_count; + uint link_bitmap_size; + pthread_mutex_t mutex; + pthread_mutex_t sts_mutex; + pthread_mutex_t crd_mutex; + pthread_mutex_t auto_increment_mutex; + THR_LOCK lock; + TABLE_SHARE *table_share; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type table_name_hash_value; +#ifdef WITH_PARTITION_STORAGE_ENGINE + my_hash_value_type table_path_hash_value; +#endif +#endif + + volatile bool init; + volatile bool init_error; + volatile time_t init_error_time; + volatile bool link_status_init; + volatile bool sts_init; + volatile time_t sts_get_time; +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile time_t bg_sts_try_time; + volatile double bg_sts_interval; + volatile int bg_sts_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + volatile int bg_sts_sync; +#endif + volatile bool bg_sts_init; + volatile bool bg_sts_kill; + volatile bool bg_sts_thd_wait; + THD *bg_sts_thd; + pthread_t bg_sts_thread; + pthread_cond_t bg_sts_cond; + pthread_cond_t bg_sts_sync_cond; + volatile bool crd_init; +#endif + volatile time_t crd_get_time; +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile time_t bg_crd_try_time; + volatile double bg_crd_interval; + volatile int bg_crd_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + volatile int bg_crd_sync; +#endif + volatile bool bg_crd_init; + volatile bool bg_crd_kill; + volatile bool bg_crd_thd_wait; + THD *bg_crd_thd; + pthread_t bg_crd_thread; + pthread_cond_t bg_crd_cond; + pthread_cond_t bg_crd_sync_cond; +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + volatile bool bg_mon_init; + volatile bool bg_mon_kill; + THD **bg_mon_thds; + pthread_t *bg_mon_threads; + pthread_mutex_t *bg_mon_mutexes; + pthread_cond_t *bg_mon_conds; +#endif + volatile bool auto_increment_init; + volatile ulonglong auto_increment_lclval; + ulonglong data_file_length; + ulonglong max_data_file_length; + ulonglong index_file_length; + ulonglong auto_increment_value; + ha_rows records; + ulong mean_rec_length; + time_t check_time; + time_t create_time; + time_t update_time; + + int bitmap_size; + spider_string *key_hint; + CHARSET_INFO *access_charset; + longlong *cardinality; + uchar *cardinality_upd; + longlong additional_table_flags; + bool have_recovery_link; + +#ifndef WITHOUT_SPIDER_BG_SEARCH + int sts_bg_mode; +#endif + double sts_interval; + int sts_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + int sts_sync; +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + int crd_bg_mode; +#endif + double crd_interval; + int crd_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + int crd_sync; +#endif + int crd_type; + double crd_weight; + longlong internal_offset; + longlong internal_limit; + longlong split_read; + double semi_split_read; + longlong semi_split_read_limit; + int init_sql_alloc_size; + int reset_sql_alloc; + int multi_split_read; + int max_order; + int semi_table_lock; + int semi_table_lock_conn; + int selupd_lock_mode; + int query_cache; + int internal_delayed; + int bulk_size; + int bulk_update_mode; + int bulk_update_size; + int internal_optimize; + int internal_optimize_local; + double scan_rate; + double read_rate; + longlong priority; + int quick_mode; + longlong quick_page_size; + int low_mem_read; + int table_count_mode; + int select_column_mode; +#ifndef WITHOUT_SPIDER_BG_SEARCH + int bgs_mode; + longlong bgs_first_read; + longlong bgs_second_read; +#endif + longlong first_read; + longlong second_read; + int auto_increment_mode; + int use_table_charset; + int use_pushdown_udf; + int skip_default_condition; + int direct_dup_insert; + longlong direct_order_limit; + int read_only_mode; + int error_read_mode; + int error_write_mode; + int active_link_count; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + longlong hs_result_free_size; +#endif +#ifdef HA_CAN_BULK_ACCESS + int bulk_access_free; +#endif + + int bka_mode; + char *bka_engine; + int bka_engine_length; + +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type *conn_keys_hash_value; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + my_hash_value_type *hs_read_conn_keys_hash_value; + my_hash_value_type *hs_write_conn_keys_hash_value; +#endif +#endif + char **server_names; + char **tgt_table_names; + char **tgt_dbs; + char **tgt_hosts; + char **tgt_usernames; + char **tgt_passwords; + char **tgt_sockets; + char **tgt_wrappers; + char **tgt_ssl_cas; + char **tgt_ssl_capaths; + char **tgt_ssl_certs; + char **tgt_ssl_ciphers; + char **tgt_ssl_keys; + char **tgt_default_files; + char **tgt_default_groups; + char **tgt_pk_names; + char **tgt_sequence_names; + char **conn_keys; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char **hs_read_socks; + char **hs_write_socks; + char **hs_read_conn_keys; + char **hs_write_conn_keys; +#endif + long *tgt_ports; + long *tgt_ssl_vscs; + long *link_statuses; +#ifndef WITHOUT_SPIDER_BG_SEARCH + long *monitoring_bg_kind; +#endif + long *monitoring_kind; +#ifndef WITHOUT_SPIDER_BG_SEARCH + longlong *monitoring_bg_interval; +#endif + longlong *monitoring_limit; + longlong *monitoring_sid; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + long *use_hs_reads; + long *use_hs_writes; + long *hs_read_ports; + long *hs_write_ports; + long *hs_write_to_reads; +#endif + long *use_handlers; + long *connect_timeouts; + long *net_read_timeouts; + long *net_write_timeouts; + long *access_balances; + + uint *server_names_lengths; + uint *tgt_table_names_lengths; + uint *tgt_dbs_lengths; + uint *tgt_hosts_lengths; + uint *tgt_usernames_lengths; + uint *tgt_passwords_lengths; + uint *tgt_sockets_lengths; + uint *tgt_wrappers_lengths; + uint *tgt_ssl_cas_lengths; + uint *tgt_ssl_capaths_lengths; + uint *tgt_ssl_certs_lengths; + uint *tgt_ssl_ciphers_lengths; + uint *tgt_ssl_keys_lengths; + uint *tgt_default_files_lengths; + uint *tgt_default_groups_lengths; + uint *tgt_pk_names_lengths; + uint *tgt_sequence_names_lengths; + uint *conn_keys_lengths; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint *hs_read_socks_lengths; + uint *hs_write_socks_lengths; + uint *hs_read_conn_keys_lengths; + uint *hs_write_conn_keys_lengths; +#endif + uint *sql_dbton_ids; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint *hs_dbton_ids; +#endif + + uint server_names_charlen; + uint tgt_table_names_charlen; + uint tgt_dbs_charlen; + uint tgt_hosts_charlen; + uint tgt_usernames_charlen; + uint tgt_passwords_charlen; + uint tgt_sockets_charlen; + uint tgt_wrappers_charlen; + uint tgt_ssl_cas_charlen; + uint tgt_ssl_capaths_charlen; + uint tgt_ssl_certs_charlen; + uint tgt_ssl_ciphers_charlen; + uint tgt_ssl_keys_charlen; + uint tgt_default_files_charlen; + uint tgt_default_groups_charlen; + uint tgt_pk_names_charlen; + uint tgt_sequence_names_charlen; + uint conn_keys_charlen; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint hs_read_socks_charlen; + uint hs_write_socks_charlen; + uint hs_read_conn_keys_charlen; + uint hs_write_conn_keys_charlen; +#endif + + uint server_names_length; + uint tgt_table_names_length; + uint tgt_dbs_length; + uint tgt_hosts_length; + uint tgt_usernames_length; + uint tgt_passwords_length; + uint tgt_sockets_length; + uint tgt_wrappers_length; + uint tgt_ssl_cas_length; + uint tgt_ssl_capaths_length; + uint tgt_ssl_certs_length; + uint tgt_ssl_ciphers_length; + uint tgt_ssl_keys_length; + uint tgt_default_files_length; + uint tgt_default_groups_length; + uint tgt_pk_names_length; + uint tgt_sequence_names_length; + uint conn_keys_length; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint hs_read_socks_length; + uint hs_write_socks_length; + uint hs_read_conn_keys_length; + uint hs_write_conn_keys_length; +#endif + uint tgt_ports_length; + uint tgt_ssl_vscs_length; + uint link_statuses_length; +#ifndef WITHOUT_SPIDER_BG_SEARCH + uint monitoring_bg_kind_length; +#endif + uint monitoring_kind_length; +#ifndef WITHOUT_SPIDER_BG_SEARCH + uint monitoring_bg_interval_length; +#endif + uint monitoring_limit_length; + uint monitoring_sid_length; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint use_hs_reads_length; + uint use_hs_writes_length; + uint hs_read_ports_length; + uint hs_write_ports_length; + uint hs_write_to_reads_length; +#endif + uint use_handlers_length; + uint connect_timeouts_length; + uint net_read_timeouts_length; + uint net_write_timeouts_length; + uint access_balances_length; + + /* for dbton */ + uchar dbton_bitmap[spider_bitmap_size(SPIDER_DBTON_SIZE)]; + spider_db_share *dbton_share[SPIDER_DBTON_SIZE]; + uint use_dbton_count; + uint use_dbton_ids[SPIDER_DBTON_SIZE]; + uint dbton_id_to_seq[SPIDER_DBTON_SIZE]; + uint use_sql_dbton_count; + uint use_sql_dbton_ids[SPIDER_DBTON_SIZE]; + uint sql_dbton_id_to_seq[SPIDER_DBTON_SIZE]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint use_hs_dbton_count; + uint use_hs_dbton_ids[SPIDER_DBTON_SIZE]; + uint hs_dbton_id_to_seq[SPIDER_DBTON_SIZE]; +#endif + + SPIDER_ALTER_TABLE alter_table; +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARTITION_SHARE *partition_share; +#endif +} SPIDER_SHARE; + +typedef struct st_spider_link_pack +{ + SPIDER_SHARE *share; + int link_idx; +} SPIDER_LINK_PACK; + +typedef struct st_spider_init_error_table +{ + char *table_name; + uint table_name_length; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type table_name_hash_value; +#endif + bool init_error_with_message; + char init_error_msg[MYSQL_ERRMSG_SIZE]; + volatile int init_error; + volatile time_t init_error_time; +} SPIDER_INIT_ERROR_TABLE; + +typedef struct st_spider_direct_sql +{ + int table_count; + char **db_names; + char **table_names; + TABLE **tables; + int *iop; + +#if MYSQL_VERSION_ID < 50500 +#else + /* for using real table */ + bool real_table_used; + TABLE_LIST *table_list_first; + TABLE_LIST *table_list; + uchar *real_table_bitmap; + Open_tables_backup open_tables_backup; + THD *open_tables_thd; +#endif + + char *sql; + ulong sql_length; + + SPIDER_TRX *trx; + SPIDER_CONN *conn; + + bool modified_non_trans_table; + + int table_loop_mode; + longlong priority; + int connect_timeout; + int net_read_timeout; + int net_write_timeout; + longlong bulk_insert_rows; + int connection_channel; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + int access_mode; +#endif +#if MYSQL_VERSION_ID < 50500 +#else + int use_real_table; +#endif + + char *server_name; + char *tgt_default_db_name; + char *tgt_host; + char *tgt_username; + char *tgt_password; + char *tgt_socket; + char *tgt_wrapper; + char *tgt_ssl_ca; + char *tgt_ssl_capath; + char *tgt_ssl_cert; + char *tgt_ssl_cipher; + char *tgt_ssl_key; + char *tgt_default_file; + char *tgt_default_group; + char *conn_key; + long tgt_port; + long tgt_ssl_vsc; + + uint server_name_length; + uint tgt_default_db_name_length; + uint tgt_host_length; + uint tgt_username_length; + uint tgt_password_length; + uint tgt_socket_length; + uint tgt_wrapper_length; + uint tgt_ssl_ca_length; + uint tgt_ssl_capath_length; + uint tgt_ssl_cert_length; + uint tgt_ssl_cipher_length; + uint tgt_ssl_key_length; + uint tgt_default_file_length; + uint tgt_default_group_length; + uint conn_key_length; + uint dbton_id; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type conn_key_hash_value; +#endif + + pthread_mutex_t *bg_mutex; + pthread_cond_t *bg_cond; + volatile st_spider_direct_sql *prev; + volatile st_spider_direct_sql *next; + void *parent; +} SPIDER_DIRECT_SQL; + +typedef struct st_spider_bg_direct_sql +{ + longlong called_cnt; + char bg_error_msg[MYSQL_ERRMSG_SIZE]; + volatile int bg_error; + volatile bool modified_non_trans_table; + pthread_mutex_t bg_mutex; + pthread_cond_t bg_cond; + volatile SPIDER_DIRECT_SQL *direct_sql; +} SPIDER_BG_DIRECT_SQL; + +typedef struct st_spider_mon_table_result +{ + int result_status; + SPIDER_TRX *trx; +} SPIDER_MON_TABLE_RESULT; + +typedef struct st_spider_table_mon +{ + SPIDER_SHARE *share; + uint32 server_id; + st_spider_table_mon *next; +} SPIDER_TABLE_MON; + +typedef struct st_spider_table_mon_list +{ + char *key; + uint key_length; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type key_hash_value; +#endif + + uint use_count; + uint mutex_hash; + ulonglong mon_table_cache_version; + + char *table_name; + int link_id; + uint table_name_length; + + int list_size; + SPIDER_TABLE_MON *first; + SPIDER_TABLE_MON *current; + volatile int mon_status; + + SPIDER_SHARE *share; + + pthread_mutex_t caller_mutex; + pthread_mutex_t receptor_mutex; + pthread_mutex_t monitor_mutex; + pthread_mutex_t update_status_mutex; + volatile int last_caller_result; + volatile int last_receptor_result; + volatile int last_mon_result; +} SPIDER_TABLE_MON_LIST; + +typedef struct st_spider_copy_table_conn +{ + SPIDER_SHARE *share; + int link_idx; + SPIDER_CONN *conn; + spider_db_copy_table *copy_table; + ha_spider *spider; + int need_mon; +#ifndef WITHOUT_SPIDER_BG_SEARCH + int bg_error_num; +#endif + st_spider_copy_table_conn *next; +} SPIDER_COPY_TABLE_CONN; + +typedef struct st_spider_copy_tables +{ + SPIDER_TRX *trx; + char *spider_db_name; + int spider_db_name_length; + char *spider_table_name; + int spider_table_name_length; + char *spider_real_table_name; + int spider_real_table_name_length; + TABLE_LIST spider_table_list; + CHARSET_INFO *access_charset; + + SPIDER_COPY_TABLE_CONN *table_conn[2]; + bool use_auto_mode[2]; + int link_idx_count[2]; + int *link_idxs[2]; + + int bulk_insert_interval; + longlong bulk_insert_rows; + int use_table_charset; + int use_transaction; +#ifndef WITHOUT_SPIDER_BG_SEARCH + int bg_mode; +#endif + + char *database; + + int database_length; +} SPIDER_COPY_TABLES; + +class SPIDER_SORT +{ +public: + ulong sort; +}; + +typedef struct st_spider_trx_ha +{ + char *table_name; + uint table_name_length; + SPIDER_TRX *trx; + SPIDER_SHARE *share; + uint link_count; + uint link_bitmap_size; + uint *conn_link_idx; + uchar *conn_can_fo; + bool wait_for_reusing; +} SPIDER_TRX_HA; + +#ifdef HA_CAN_BULK_ACCESS +typedef struct st_spider_bulk_access_link +{ + ha_spider *spider; + uint sequence_num; + bool used; + bool called; + MEM_ROOT mem_root; + st_spider_bulk_access_link *next; +} SPIDER_BULK_ACCESS_LINK; +#endif + +char *spider_create_string( + const char *str, + uint length +); diff --git a/storage/spider/spd_malloc.cc b/storage/spider/spd_malloc.cc new file mode 100644 index 00000000000..8cfa7e86357 --- /dev/null +++ b/storage/spider/spd_malloc.cc @@ -0,0 +1,1267 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#endif +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_malloc.h" + +extern handlerton *spider_hton_ptr; + +pthread_mutex_t spider_mem_calc_mutex; + +const char *spider_alloc_func_name[SPIDER_MEM_CALC_LIST_NUM]; +const char *spider_alloc_file_name[SPIDER_MEM_CALC_LIST_NUM]; +ulong spider_alloc_line_no[SPIDER_MEM_CALC_LIST_NUM]; +ulonglong spider_total_alloc_mem[SPIDER_MEM_CALC_LIST_NUM]; +longlong spider_current_alloc_mem[SPIDER_MEM_CALC_LIST_NUM]; +ulonglong spider_alloc_mem_count[SPIDER_MEM_CALC_LIST_NUM]; +ulonglong spider_free_mem_count[SPIDER_MEM_CALC_LIST_NUM]; + +void spider_merge_mem_calc( + SPIDER_TRX *trx, + bool force +) { + uint roop_count; + time_t tmp_time; + DBUG_ENTER("spider_merge_mem_calc"); + if (force) + { + pthread_mutex_lock(&spider_mem_calc_mutex); + tmp_time = (time_t) time((time_t*) 0); + } else { + tmp_time = (time_t) time((time_t*) 0); + if ( + difftime(tmp_time, trx->mem_calc_merge_time) < 2 || + pthread_mutex_trylock(&spider_mem_calc_mutex) + ) + DBUG_VOID_RETURN; + } + for (roop_count = 0; roop_count < SPIDER_MEM_CALC_LIST_NUM; roop_count++) + { + DBUG_ASSERT(!spider_alloc_func_name[roop_count] || + !trx->alloc_func_name[roop_count] || + spider_alloc_func_name[roop_count] == trx->alloc_func_name[roop_count]); + DBUG_ASSERT(!spider_alloc_file_name[roop_count] || + !trx->alloc_file_name[roop_count] || + spider_alloc_file_name[roop_count] == trx->alloc_file_name[roop_count]); + DBUG_ASSERT(!spider_alloc_line_no[roop_count] || + !trx->alloc_line_no[roop_count] || + spider_alloc_line_no[roop_count] == trx->alloc_line_no[roop_count]); + if (trx->alloc_func_name[roop_count]) + { + spider_alloc_func_name[roop_count] = trx->alloc_func_name[roop_count]; + spider_alloc_file_name[roop_count] = trx->alloc_file_name[roop_count]; + spider_alloc_line_no[roop_count] = trx->alloc_line_no[roop_count]; + spider_total_alloc_mem[roop_count] += + trx->total_alloc_mem_buffer[roop_count]; + trx->total_alloc_mem_buffer[roop_count] = 0; + spider_alloc_mem_count[roop_count] += + trx->alloc_mem_count_buffer[roop_count]; + trx->alloc_mem_count_buffer[roop_count] = 0; + } + spider_current_alloc_mem[roop_count] += + trx->current_alloc_mem_buffer[roop_count]; + trx->current_alloc_mem_buffer[roop_count] = 0; + spider_free_mem_count[roop_count] += + trx->free_mem_count_buffer[roop_count]; + trx->free_mem_count_buffer[roop_count] = 0; + } + pthread_mutex_unlock(&spider_mem_calc_mutex); + trx->mem_calc_merge_time = tmp_time; + DBUG_VOID_RETURN; +} + +void spider_free_mem_calc( + SPIDER_TRX *trx, + uint id, + size_t size +) { + DBUG_ENTER("spider_free_mem_calc"); + DBUG_ASSERT(id < SPIDER_MEM_CALC_LIST_NUM); + DBUG_PRINT("info",("spider trx=%p id=%u size=%llu", + trx, id, (ulonglong) size)); + if (trx) + { + DBUG_PRINT("info",("spider calc into trx")); + trx->current_alloc_mem[id] -= size; + trx->current_alloc_mem_buffer[id] -= size; + trx->free_mem_count[id] += 1; + trx->free_mem_count_buffer[id] += 1; + } else { + DBUG_PRINT("info",("spider calc into global")); + pthread_mutex_lock(&spider_mem_calc_mutex); + spider_current_alloc_mem[id] -= size; + spider_free_mem_count[id] += 1; + pthread_mutex_unlock(&spider_mem_calc_mutex); + } + DBUG_VOID_RETURN; +} + +void spider_alloc_mem_calc( + SPIDER_TRX *trx, + uint id, + const char *func_name, + const char *file_name, + ulong line_no, + size_t size +) { + DBUG_ENTER("spider_alloc_mem_calc"); + DBUG_ASSERT(id < SPIDER_MEM_CALC_LIST_NUM); + DBUG_PRINT("info",("spider trx=%p id=%u size=%llu", + trx, id, (ulonglong) size)); + if (trx) + { + DBUG_PRINT("info",("spider calc into trx")); + DBUG_ASSERT(!trx->alloc_func_name[id] || + trx->alloc_func_name[id] == func_name); + DBUG_ASSERT(!trx->alloc_file_name[id] || + trx->alloc_file_name[id] == file_name); + DBUG_ASSERT(!trx->alloc_line_no[id] || + trx->alloc_line_no[id] == line_no); + trx->alloc_func_name[id] = func_name; + trx->alloc_file_name[id] = file_name; + trx->alloc_line_no[id] = line_no; + trx->total_alloc_mem[id] += size; + trx->total_alloc_mem_buffer[id] += size; + trx->current_alloc_mem[id] += size; + trx->current_alloc_mem_buffer[id] += size; + trx->alloc_mem_count[id] += 1; + trx->alloc_mem_count_buffer[id] += 1; + } else { + DBUG_PRINT("info",("spider calc into global")); + pthread_mutex_lock(&spider_mem_calc_mutex); + DBUG_ASSERT(!spider_alloc_func_name[id] || + spider_alloc_func_name[id] == func_name); + DBUG_ASSERT(!spider_alloc_file_name[id] || + spider_alloc_file_name[id] == file_name); + DBUG_ASSERT(!spider_alloc_line_no[id] || + spider_alloc_line_no[id] == line_no); + spider_alloc_func_name[id] = func_name; + spider_alloc_file_name[id] = file_name; + spider_alloc_line_no[id] = line_no; + spider_total_alloc_mem[id] += size; + spider_current_alloc_mem[id] += size; + spider_alloc_mem_count[id] += 1; + pthread_mutex_unlock(&spider_mem_calc_mutex); + } + DBUG_VOID_RETURN; +} + +void spider_free_mem( + SPIDER_TRX *trx, + void *ptr, + myf my_flags +) { + uint id, size; + uchar *tmp_ptr = (uchar *) ptr; + DBUG_ENTER("spider_free_mem"); + tmp_ptr -= ALIGN_SIZE(sizeof(uint)); + size = *((uint *) tmp_ptr); + tmp_ptr -= ALIGN_SIZE(sizeof(uint)); + id = *((uint *) tmp_ptr); + my_free(tmp_ptr, my_flags); + + spider_free_mem_calc(trx, id, size); + DBUG_VOID_RETURN; +} + +void *spider_alloc_mem( + SPIDER_TRX *trx, + uint id, + const char *func_name, + const char *file_name, + ulong line_no, + size_t size, + myf my_flags +) { + uchar *ptr; + DBUG_ENTER("spider_alloc_mem"); + size += ALIGN_SIZE(sizeof(uint)) + ALIGN_SIZE(sizeof(uint)); + if (!(ptr = (uchar *) my_malloc(size, my_flags))) + DBUG_RETURN(NULL); + + spider_alloc_mem_calc(trx, id, func_name, file_name, line_no, size); + *((uint *) ptr) = id; + ptr += ALIGN_SIZE(sizeof(uint)); + *((uint *) ptr) = size; + ptr += ALIGN_SIZE(sizeof(uint)); + DBUG_RETURN(ptr); +} + +void *spider_bulk_alloc_mem( + SPIDER_TRX *trx, + uint id, + const char *func_name, + const char *file_name, + ulong line_no, + myf my_flags, + ... +) { + uchar **tmp_ptr, *top_ptr, *current_ptr; + uint total_size; + va_list args; + DBUG_ENTER("spider_bulk_alloc_mem"); + total_size = ALIGN_SIZE(sizeof(uint)) + ALIGN_SIZE(sizeof(uint)); + va_start(args, my_flags); + while (va_arg(args, char **)) + total_size += ALIGN_SIZE(va_arg(args, uint)); + va_end(args); + + if (!(top_ptr = (uchar *) my_malloc(total_size, my_flags))) + DBUG_RETURN(NULL); + + spider_alloc_mem_calc(trx, id, func_name, file_name, line_no, total_size); + *((uint *) top_ptr) = id; + top_ptr += ALIGN_SIZE(sizeof(uint)); + *((uint *) top_ptr) = total_size; + top_ptr += ALIGN_SIZE(sizeof(uint)); + + current_ptr = top_ptr; + va_start(args, my_flags); + while ((tmp_ptr = (uchar **) va_arg(args, char **))) + { + *tmp_ptr = current_ptr; + current_ptr += ALIGN_SIZE(va_arg(args, uint)); + } + va_end(args); + DBUG_RETURN((void *) top_ptr); +} + +#define SPIDER_STRING_CALC_MEM \ + if (mem_calc_inited) \ + { \ + uint32 new_alloc_mem = \ + (this->str.is_alloced() ? this->str.alloced_length() : 0); \ + if (new_alloc_mem != current_alloc_mem) \ + { \ + if (new_alloc_mem > current_alloc_mem) \ + spider_alloc_mem_calc(spider_current_trx, id, func_name, file_name, \ + line_no, new_alloc_mem - current_alloc_mem); \ + else \ + spider_free_mem_calc(spider_current_trx, id, \ + current_alloc_mem - new_alloc_mem); \ + current_alloc_mem = new_alloc_mem; \ + } \ + } + +spider_string::spider_string( +) : str(), next(NULL) +{ + DBUG_ENTER("spider_string::spider_string"); + DBUG_PRINT("info",("spider this=%p", this)); + mem_calc_inited = FALSE; + DBUG_VOID_RETURN; +} + +spider_string::spider_string( + uint32 length_arg +) : str(length_arg), next(NULL) +{ + DBUG_ENTER("spider_string::spider_string"); + DBUG_PRINT("info",("spider this=%p", this)); + mem_calc_inited = FALSE; + DBUG_VOID_RETURN; +} + +spider_string::spider_string( + const char *str, + CHARSET_INFO *cs +) : str(str, cs), next(NULL) +{ + DBUG_ENTER("spider_string::spider_string"); + DBUG_PRINT("info",("spider this=%p", this)); + mem_calc_inited = FALSE; + DBUG_VOID_RETURN; +} + +spider_string::spider_string( + const char *str, + uint32 len, + CHARSET_INFO *cs +) : str(str, len, cs), next(NULL) +{ + DBUG_ENTER("spider_string::spider_string"); + DBUG_PRINT("info",("spider this=%p", this)); + mem_calc_inited = FALSE; + DBUG_VOID_RETURN; +} + +spider_string::spider_string( + char *str, + uint32 len, + CHARSET_INFO *cs +) : str(str, len, cs), next(NULL) +{ + DBUG_ENTER("spider_string::spider_string"); + DBUG_PRINT("info",("spider this=%p", this)); + mem_calc_inited = FALSE; + DBUG_VOID_RETURN; +} + +spider_string::spider_string( + const String &str +) : str(str), next(NULL) +{ + DBUG_ENTER("spider_string::spider_string"); + DBUG_PRINT("info",("spider this=%p", this)); + mem_calc_inited = FALSE; + DBUG_VOID_RETURN; +} + +spider_string::~spider_string() +{ + DBUG_ENTER("spider_string::~spider_string"); + DBUG_PRINT("info",("spider this=%p", this)); + if (mem_calc_inited) + free(); + DBUG_VOID_RETURN; +} + +void spider_string::init_mem_calc( + uint id, + const char *func_name, + const char *file_name, + ulong line_no +) { + DBUG_ENTER("spider_string::init_mem_calc"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(!mem_calc_inited); + this->id = id; + this->func_name = func_name; + this->file_name = file_name; + this->line_no = line_no; + if (str.is_alloced()) + { + current_alloc_mem = str.alloced_length(); + spider_alloc_mem_calc(spider_current_trx, id, func_name, file_name, + line_no, current_alloc_mem); + } else + current_alloc_mem = 0; + mem_calc_inited = TRUE; + DBUG_VOID_RETURN; +} + +void spider_string::mem_calc() +{ + DBUG_ENTER("spider_string::mem_calc"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + SPIDER_STRING_CALC_MEM; + DBUG_VOID_RETURN; +} + +String *spider_string::get_str() +{ + DBUG_ENTER("spider_string::get_str"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(&str); +} + +void spider_string::set_charset( + CHARSET_INFO *charset_arg +) { + DBUG_ENTER("spider_string::set_charset"); + DBUG_PRINT("info",("spider this=%p", this)); + str.set_charset(charset_arg); + DBUG_VOID_RETURN; +} + +CHARSET_INFO *spider_string::charset() const +{ + DBUG_ENTER("spider_string::charset"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.charset()); +} + +uint32 spider_string::length() const +{ + DBUG_ENTER("spider_string::length"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.length()); +} + +uint32 spider_string::alloced_length() const +{ + DBUG_ENTER("spider_string::alloced_length"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.alloced_length()); +} + +char &spider_string::operator [] (uint32 i) const +{ + DBUG_ENTER("spider_string::operator []"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str[i]); +} + +void spider_string::length( + uint32 len +) { + DBUG_ENTER("spider_string::length"); + DBUG_PRINT("info",("spider this=%p", this)); + str.length(len); + DBUG_VOID_RETURN; +} + +bool spider_string::is_empty() const +{ + DBUG_ENTER("spider_string::is_empty"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.is_empty()); +} + +const char *spider_string::ptr() const +{ + DBUG_ENTER("spider_string::ptr"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.ptr()); +} + +char *spider_string::c_ptr() +{ + DBUG_ENTER("spider_string::c_ptr"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + char *res = str.c_ptr(); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +char *spider_string::c_ptr_quick() +{ + DBUG_ENTER("spider_string::c_ptr_quick"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.c_ptr_quick()); +} + +char *spider_string::c_ptr_safe() +{ + DBUG_ENTER("spider_string::c_ptr_safe"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + char *res = str.c_ptr_safe(); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +LEX_STRING spider_string::lex_string() const +{ + DBUG_ENTER("spider_string::lex_string"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.lex_string()); +} + +void spider_string::set( + String &str, + uint32 offset, + uint32 arg_length +) { + DBUG_ENTER("spider_string::set"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + str.set(str, offset, arg_length); + SPIDER_STRING_CALC_MEM; + DBUG_VOID_RETURN; +} + +void spider_string::set( + char *str, + uint32 arg_length, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::set"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !this->str.is_alloced()) || + current_alloc_mem == this->str.alloced_length()); + this->str.set(str, arg_length, cs); + SPIDER_STRING_CALC_MEM; + DBUG_VOID_RETURN; +} + +void spider_string::set( + const char *str, + uint32 arg_length, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::set"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !this->str.is_alloced()) || + current_alloc_mem == this->str.alloced_length()); + this->str.set(str, arg_length, cs); + SPIDER_STRING_CALC_MEM; + DBUG_VOID_RETURN; +} + +bool spider_string::set_ascii( + const char *str, + uint32 arg_length +) { + DBUG_ENTER("spider_string::set_ascii"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !this->str.is_alloced()) || + current_alloc_mem == this->str.alloced_length()); + bool res = this->str.set_ascii(str, arg_length); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +void spider_string::set_quick( + char *str, + uint32 arg_length, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::set_quick"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !this->str.is_alloced()) || + current_alloc_mem == this->str.alloced_length()); + this->str.set_quick(str, arg_length, cs); + SPIDER_STRING_CALC_MEM; + DBUG_VOID_RETURN; +} + +bool spider_string::set_int( + longlong num, + bool unsigned_flag, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::set_int"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.set_int(num, unsigned_flag, cs); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::set( + longlong num, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::set"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.set(num, cs); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::set( + ulonglong num, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::set"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.set(num, cs); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::set_real( + double num, + uint decimals, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::set_real"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.set_real(num, decimals, cs); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +void spider_string::chop() +{ + DBUG_ENTER("spider_string::chop"); + DBUG_PRINT("info",("spider this=%p", this)); + str.chop(); + DBUG_VOID_RETURN; +} + +void spider_string::free() +{ + DBUG_ENTER("spider_string::free"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + str.free(); + if (mem_calc_inited && current_alloc_mem) + { + spider_free_mem_calc(spider_current_trx, id, current_alloc_mem); + current_alloc_mem = 0; + } + DBUG_VOID_RETURN; +} + +bool spider_string::alloc(uint32 arg_length) +{ + bool res; + DBUG_ENTER("spider_string::alloc"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + res = str.alloc(arg_length); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::real_alloc(uint32 arg_length) +{ + bool res; + DBUG_ENTER("spider_string::real_alloc"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + res = str.real_alloc(arg_length); +/* + if (mem_calc_inited && !res && arg_length) +*/ + if (mem_calc_inited && !res) + { + DBUG_ASSERT(!current_alloc_mem); + spider_alloc_mem_calc(spider_current_trx, id, func_name, file_name, + line_no, str.alloced_length()); + current_alloc_mem = str.alloced_length(); + } + DBUG_RETURN(res); +} + +bool spider_string::realloc(uint32 arg_length) +{ + bool res; + DBUG_ENTER("spider_string::realloc"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + res = str.realloc(arg_length); + if (mem_calc_inited && !res && current_alloc_mem < str.alloced_length()) + { + spider_alloc_mem_calc(spider_current_trx, id, func_name, file_name, + line_no, str.alloced_length() - current_alloc_mem); + current_alloc_mem = str.alloced_length(); + } + DBUG_RETURN(res); +} + +void spider_string::shrink( + uint32 arg_length +) { + DBUG_ENTER("spider_string::shrink"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + str.shrink(arg_length); + SPIDER_STRING_CALC_MEM; + DBUG_VOID_RETURN; +} + +bool spider_string::is_alloced() +{ + DBUG_ENTER("spider_string::is_alloced"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.is_alloced()); +} + +spider_string &spider_string::operator = ( + const String &s +) { + DBUG_ENTER("spider_string::operator ="); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + str = s; + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(*this); +} + +bool spider_string::copy() +{ + DBUG_ENTER("spider_string::copy"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.copy(); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::copy( + const spider_string &s +) { + DBUG_ENTER("spider_string::copy"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.copy(s.str); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::copy( + const String &s +) { + DBUG_ENTER("spider_string::copy"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.copy(s); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::copy( + const char *s, + uint32 arg_length, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::copy"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.copy(s, arg_length, cs); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::needs_conversion( + uint32 arg_length, + CHARSET_INFO *cs_from, + CHARSET_INFO *cs_to, + uint32 *offset +) { + DBUG_ENTER("spider_string::needs_conversion"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.needs_conversion(arg_length, cs_from, cs_to, offset)); +} + +bool spider_string::copy_aligned( + const char *s, + uint32 arg_length, + uint32 offset, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::copy_aligned"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.copy_aligned(s, arg_length, offset, cs); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::set_or_copy_aligned( + const char *s, + uint32 arg_length, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::set_or_copy_aligned"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.set_or_copy_aligned(s, arg_length, cs); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::copy( + const char *s, + uint32 arg_length, + CHARSET_INFO *csfrom, + CHARSET_INFO *csto, + uint *errors +) { + DBUG_ENTER("spider_string::copy"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.copy(s, arg_length, csfrom, csto, errors); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + const spider_string &s +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(s.str); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + const String &s +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(s); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + const char *s +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(s); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + LEX_STRING *ls +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(ls); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + const char *s, + uint32 arg_length +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(s, arg_length); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + const char *s, + uint32 arg_length, + CHARSET_INFO *cs +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(s, arg_length, cs); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append_ulonglong( + ulonglong val +) { + DBUG_ENTER("spider_string::append_ulonglong"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append_ulonglong(val); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + IO_CACHE *file, + uint32 arg_length +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(file, arg_length); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append_with_prefill( + const char *s, + uint32 arg_length, + uint32 full_length, + char fill_char +) { + DBUG_ENTER("spider_string::append_with_prefill"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append_with_prefill(s, arg_length, full_length, + fill_char); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +int spider_string::strstr( + const String &search, + uint32 offset +) { + DBUG_ENTER("spider_string::strstr"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.strstr(search, offset)); +} + +int spider_string::strrstr( + const String &search, + uint32 offset +) { + DBUG_ENTER("spider_string::strrstr"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.strrstr(search, offset)); +} + +bool spider_string::replace( + uint32 offset, + uint32 arg_length, + const char *to, + uint32 length +) { + DBUG_ENTER("spider_string::replace"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.replace(offset, arg_length, to, length); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::replace( + uint32 offset, + uint32 arg_length, + const String &to +) { + DBUG_ENTER("spider_string::replace"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.replace(offset, arg_length, to); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + char chr +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(chr); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::fill( + uint32 max_length, + char fill +) { + DBUG_ENTER("spider_string::fill"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.fill(max_length, fill); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +void spider_string::strip_sp() +{ + DBUG_ENTER("spider_string::strip_sp"); + DBUG_PRINT("info",("spider this=%p", this)); + str.strip_sp(); + DBUG_VOID_RETURN; +} + +uint32 spider_string::numchars() +{ + DBUG_ENTER("spider_string::numchars"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.numchars()); +} + +int spider_string::charpos( + int i, + uint32 offset +) { + DBUG_ENTER("spider_string::charpos"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.charpos(i, offset)); +} + +int spider_string::reserve( + uint32 space_needed +) { + DBUG_ENTER("spider_string::reserve"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + int res = str.reserve(space_needed); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +int spider_string::reserve( + uint32 space_needed, + uint32 grow_by +) { + DBUG_ENTER("spider_string::reserve"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + int res = str.reserve(space_needed, grow_by); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +void spider_string::q_append( + const char c +) { + DBUG_ENTER("spider_string::q_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.q_append(c); + DBUG_VOID_RETURN; +} + +void spider_string::q_append( + const uint32 n +) { + DBUG_ENTER("spider_string::q_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.q_append(n); + DBUG_VOID_RETURN; +} + +void spider_string::q_append( + double d +) { + DBUG_ENTER("spider_string::q_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.q_append(d); + DBUG_VOID_RETURN; +} + +void spider_string::q_append( + double *d +) { + DBUG_ENTER("spider_string::q_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.q_append(d); + DBUG_VOID_RETURN; +} + +void spider_string::q_append( + const char *data, + uint32 data_len +) { + DBUG_ENTER("spider_string::q_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.q_append(data, data_len); + DBUG_VOID_RETURN; +} + +void spider_string::write_at_position( + int position, + uint32 value +) { + DBUG_ENTER("spider_string::write_at_position"); + DBUG_PRINT("info",("spider this=%p", this)); + str.write_at_position(position, value); + DBUG_VOID_RETURN; +} + +void spider_string::qs_append( + const char *str, + uint32 len +) { + DBUG_ENTER("spider_string::qs_append"); + DBUG_PRINT("info",("spider this=%p", this)); + this->str.qs_append(str, len); + DBUG_VOID_RETURN; +} + +void spider_string::qs_append( + double d +) { + DBUG_ENTER("spider_string::qs_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.qs_append(d); + DBUG_VOID_RETURN; +} + +void spider_string::qs_append( + double *d +) { + DBUG_ENTER("spider_string::qs_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.qs_append(d); + DBUG_VOID_RETURN; +} + +void spider_string::qs_append( + const char c +) { + DBUG_ENTER("spider_string::qs_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.qs_append(c); + DBUG_VOID_RETURN; +} + +void spider_string::qs_append( + int i +) { + DBUG_ENTER("spider_string::qs_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.qs_append(i); + DBUG_VOID_RETURN; +} + +void spider_string::qs_append( + uint i +) { + DBUG_ENTER("spider_string::qs_append"); + DBUG_PRINT("info",("spider this=%p", this)); + str.qs_append(i); + DBUG_VOID_RETURN; +} + +char *spider_string::prep_append( + uint32 arg_length, + uint32 step_alloc +) { + DBUG_ENTER("spider_string::prep_append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + char *res = str.prep_append(arg_length, step_alloc); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +bool spider_string::append( + const char *s, + uint32 arg_length, + uint32 step_alloc +) { + DBUG_ENTER("spider_string::append"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append(s, arg_length, step_alloc); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} + +#ifdef SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE +bool spider_string::append_for_single_quote( + const char *st, + uint len +) { + DBUG_ENTER("spider_string::append_for_single_quote"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + bool res = str.append_for_single_quote(st, len); + SPIDER_STRING_CALC_MEM; + DBUG_RETURN(res); +} +#endif + +void spider_string::swap( + spider_string &s +) { + DBUG_ENTER("spider_string::swap"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_ASSERT(mem_calc_inited); + DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || + current_alloc_mem == str.alloced_length()); + str.swap(s.str); + SPIDER_STRING_CALC_MEM; + DBUG_VOID_RETURN; +} + +bool spider_string::uses_buffer_owned_by( + const String *s +) const +{ + DBUG_ENTER("spider_string::uses_buffer_owned_by"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.uses_buffer_owned_by(s)); +} + +bool spider_string::is_ascii() const +{ + DBUG_ENTER("spider_string::is_ascii"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(str.is_ascii()); +} diff --git a/storage/spider/spd_malloc.h b/storage/spider/spd_malloc.h new file mode 100644 index 00000000000..e981eb3cae4 --- /dev/null +++ b/storage/spider/spd_malloc.h @@ -0,0 +1,79 @@ +/* Copyright (C) 2012-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define spider_free(A,B,C) spider_free_mem(A,B,C) +#define spider_malloc(A,B,C,D) \ + spider_alloc_mem(A,B,__func__,__FILE__,__LINE__,C,D) +#define spider_bulk_malloc(A,B,C,...) \ + spider_bulk_alloc_mem(A,B,__func__,__FILE__,__LINE__,C,__VA_ARGS__) +#define spider_current_trx \ + (current_thd ? ((SPIDER_TRX *) *thd_ha_data(current_thd, spider_hton_ptr)) : NULL) + +#define init_calc_mem(A) init_mem_calc(A,__func__,__FILE__,__LINE__) + +#define SPIDER_CALC_MEM_ID(name) name ## _id +#define SPIDER_CALC_MEM_FUNC(name) name ## _func_name +#define SPIDER_CALC_MEM_FILE(name) name ## _file_name +#define SPIDER_CALC_MEM_LINE(name) name ## _line_no +#define spider_alloc_calc_mem_init(A,B) \ + {SPIDER_CALC_MEM_ID(A) = B; SPIDER_CALC_MEM_FUNC(A) = __func__; SPIDER_CALC_MEM_FILE(A) = __FILE__; SPIDER_CALC_MEM_LINE(A) = __LINE__;} +#define spider_alloc_calc_mem(A,B,C) \ + spider_alloc_mem_calc(A,SPIDER_CALC_MEM_ID(B),SPIDER_CALC_MEM_FUNC(B),SPIDER_CALC_MEM_FILE(B),SPIDER_CALC_MEM_LINE(B),C) + +void spider_merge_mem_calc( + SPIDER_TRX *trx, + bool force +); + +void spider_free_mem_calc( + SPIDER_TRX *trx, + uint id, + size_t size +); + +void spider_alloc_mem_calc( + SPIDER_TRX *trx, + uint id, + const char *func_name, + const char *file_name, + ulong line_no, + size_t size +); + +void spider_free_mem( + SPIDER_TRX *trx, + void *ptr, + myf my_flags +); + +void *spider_alloc_mem( + SPIDER_TRX *trx, + uint id, + const char *func_name, + const char *file_name, + ulong line_no, + size_t size, + myf my_flags +); + +void *spider_bulk_alloc_mem( + SPIDER_TRX *trx, + uint id, + const char *func_name, + const char *file_name, + ulong line_no, + myf my_flags, + ... +); diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc new file mode 100644 index 00000000000..22b15d41b95 --- /dev/null +++ b/storage/spider/spd_param.cc @@ -0,0 +1,2933 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#endif +#include +#include "spd_err.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "ha_spider.h" +#include "spd_table.h" +#include "spd_trx.h" + +extern struct st_mysql_plugin spider_i_s_alloc_mem; + +extern volatile ulonglong spider_mon_table_cache_version; +extern volatile ulonglong spider_mon_table_cache_version_req; + +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +static int spider_direct_update(THD *thd, SHOW_VAR *var, char *buff) +{ + int error_num = 0; + SPIDER_TRX *trx; + DBUG_ENTER("spider_direct_update"); + var->type = SHOW_LONGLONG; + if ((trx = spider_get_trx(thd, TRUE, &error_num))) + var->value = (char *) &trx->direct_update_count; + DBUG_RETURN(error_num); +} + +static int spider_direct_delete(THD *thd, SHOW_VAR *var, char *buff) +{ + int error_num = 0; + SPIDER_TRX *trx; + DBUG_ENTER("spider_direct_delete"); + var->type = SHOW_LONGLONG; + if ((trx = spider_get_trx(thd, TRUE, &error_num))) + var->value = (char *) &trx->direct_delete_count; + DBUG_RETURN(error_num); +} +#endif + +static int spider_direct_order_limit(THD *thd, SHOW_VAR *var, char *buff) +{ + int error_num = 0; + SPIDER_TRX *trx; + DBUG_ENTER("spider_direct_order_limit"); + var->type = SHOW_LONGLONG; + if ((trx = spider_get_trx(thd, TRUE, &error_num))) + var->value = (char *) &trx->direct_order_limit_count; + DBUG_RETURN(error_num); +} + +static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, char *buff) +{ + int error_num = 0; + SPIDER_TRX *trx; + DBUG_ENTER("spider_direct_aggregate"); + var->type = SHOW_LONGLONG; + if ((trx = spider_get_trx(thd, TRUE, &error_num))) + var->value = (char *) &trx->direct_aggregate_count; + DBUG_RETURN(error_num); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +static int spider_hs_result_free(THD *thd, SHOW_VAR *var, char *buff) +{ + int error_num = 0; + SPIDER_TRX *trx; + DBUG_ENTER("spider_hs_result_free"); + var->type = SHOW_LONGLONG; + if ((trx = spider_get_trx(thd, TRUE, &error_num))) + var->value = (char *) &trx->hs_result_free_count; + DBUG_RETURN(error_num); +} +#endif + +struct st_mysql_show_var spider_status_variables[] = +{ + {"Spider_mon_table_cache_version", + (char *) &spider_mon_table_cache_version, SHOW_LONGLONG}, + {"Spider_mon_table_cache_version_req", + (char *) &spider_mon_table_cache_version_req, SHOW_LONGLONG}, +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC + {"Spider_direct_update", (char *) &spider_direct_update, SHOW_SIMPLE_FUNC}, + {"Spider_direct_delete", (char *) &spider_direct_delete, SHOW_SIMPLE_FUNC}, +#else + {"Spider_direct_update", (char *) &spider_direct_update, SHOW_FUNC}, + {"Spider_direct_delete", (char *) &spider_direct_delete, SHOW_FUNC}, +#endif +#endif +#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC + {"Spider_direct_order_limit", + (char *) &spider_direct_order_limit, SHOW_SIMPLE_FUNC}, + {"Spider_direct_aggregate", + (char *) &spider_direct_aggregate, SHOW_SIMPLE_FUNC}, +#else + {"Spider_direct_order_limit", + (char *) &spider_direct_order_limit, SHOW_FUNC}, + {"Spider_direct_aggregate", + (char *) &spider_direct_aggregate, SHOW_FUNC}, +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC + {"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_SIMPLE_FUNC}, +#else + {"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_FUNC}, +#endif +#endif + {NullS, NullS, SHOW_LONG} +}; + +typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_int_t, int); +#if MYSQL_VERSION_ID < 50500 +extern bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd, + const char *name, long long val); +#else +extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed, + bool is_unsignd, longlong v); +#endif + +static my_bool spider_support_xa; +static MYSQL_SYSVAR_BOOL( + support_xa, + spider_support_xa, + PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY, + "XA support", + NULL, + NULL, + TRUE +); + +my_bool spider_param_support_xa() +{ + DBUG_ENTER("spider_param_support_xa"); + DBUG_RETURN(spider_support_xa); +} + +static my_bool spider_connect_mutex; +static MYSQL_SYSVAR_BOOL( + connect_mutex, + spider_connect_mutex, + PLUGIN_VAR_OPCMDARG, + "Use mutex at connecting", + NULL, + NULL, + FALSE +); + +my_bool spider_param_connect_mutex() +{ + DBUG_ENTER("spider_param_connect_mutex"); + DBUG_RETURN(spider_connect_mutex); +} + +static uint spider_table_init_error_interval; +/* + 0-: interval + */ +static MYSQL_SYSVAR_UINT( + table_init_error_interval, + spider_table_init_error_interval, + PLUGIN_VAR_RQCMDARG, + "Return same error code until interval passes if table init is failed", + NULL, + NULL, + 1, + 0, + 4294967295U, + 0 +); + +uint spider_param_table_init_error_interval() +{ + DBUG_ENTER("spider_param_table_init_error_interval"); + DBUG_RETURN(spider_table_init_error_interval); +} + +static int spider_use_table_charset; +/* + -1 :use table parameter + 0 :use utf8 + 1 :use table charset + */ +static MYSQL_SYSVAR_INT( + use_table_charset, + spider_use_table_charset, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Use table charset for remote access", + NULL, + NULL, + -1, + -1, + 1, + 0 +); + +int spider_param_use_table_charset( + int use_table_charset +) { + DBUG_ENTER("spider_param_use_table_charset"); + DBUG_RETURN(spider_use_table_charset == -1 ? + use_table_charset : spider_use_table_charset); +} + +/* + 0: no recycle + 1: recycle in instance + 2: recycle in thread + */ +static MYSQL_THDVAR_UINT( + conn_recycle_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Connection recycle mode", /* comment */ + NULL, /* check */ + NULL, /* update */ + 0, /* def */ + 0, /* min */ + 2, /* max */ + 0 /* blk */ +); + +uint spider_param_conn_recycle_mode( + THD *thd +) { + DBUG_ENTER("spider_param_conn_recycle_mode"); + DBUG_RETURN(THDVAR(thd, conn_recycle_mode)); +} + +/* + 0: weak + 1: strict + */ +static MYSQL_THDVAR_UINT( + conn_recycle_strict, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Strict connection recycle", /* comment */ + NULL, /* check */ + NULL, /* update */ + 0, /* def */ + 0, /* min */ + 1, /* max */ + 0 /* blk */ +); + +uint spider_param_conn_recycle_strict( + THD *thd +) { + DBUG_ENTER("spider_param_conn_recycle_strict"); + DBUG_RETURN(THDVAR(thd, conn_recycle_strict)); +} + +/* + FALSE: no sync + TRUE: sync + */ +static MYSQL_THDVAR_BOOL( + sync_trx_isolation, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Sync transaction isolation level", /* comment */ + NULL, /* check */ + NULL, /* update */ + TRUE /* def */ +); + +bool spider_param_sync_trx_isolation( + THD *thd +) { + DBUG_ENTER("spider_param_sync_trx_isolation"); + DBUG_RETURN(THDVAR(thd, sync_trx_isolation)); +} + +/* + FALSE: no use + TRUE: use + */ +static MYSQL_THDVAR_BOOL( + use_consistent_snapshot, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Use start transaction with consistent snapshot", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_use_consistent_snapshot( + THD *thd +) { + DBUG_ENTER("spider_param_use_consistent_snapshot"); + DBUG_RETURN(THDVAR(thd, use_consistent_snapshot)); +} + +/* + FALSE: off + TRUE: on + */ +static MYSQL_THDVAR_BOOL( + internal_xa, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Use inner xa transaction", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_internal_xa( + THD *thd +) { + DBUG_ENTER("spider_param_internal_xa"); + DBUG_RETURN(THDVAR(thd, internal_xa)); +} + +/* + 0 :err when use a spider table + 1 :err when start trx + 2 :start trx with snapshot on remote server(not use xa) + 3 :start xa on remote server(not use trx with snapshot) + */ +static MYSQL_THDVAR_UINT( + internal_xa_snapshot, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Action of inner xa and snapshot both using", /* comment */ + NULL, /* check */ + NULL, /* update */ + 0, /* def */ + 0, /* min */ + 3, /* max */ + 0 /* blk */ +); + +uint spider_param_internal_xa_snapshot( + THD *thd +) { + DBUG_ENTER("spider_param_internal_xa_snapshot"); + DBUG_RETURN(THDVAR(thd, internal_xa_snapshot)); +} + +/* + 0 :off + 1 :continue prepare, commit, rollback if xid not found return + 2 :continue prepare, commit, rollback if all error return + */ +static MYSQL_THDVAR_UINT( + force_commit, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Force prepare, commit, rollback mode", /* comment */ + NULL, /* check */ + NULL, /* update */ + 1, /* def */ + 0, /* min */ + 2, /* max */ + 0 /* blk */ +); + +uint spider_param_force_commit( + THD *thd +) { + DBUG_ENTER("spider_param_force_commit"); + DBUG_RETURN(THDVAR(thd, force_commit)); +} + +/* + -1 :use table parameter + 0-:offset + */ +static MYSQL_THDVAR_LONGLONG( + internal_offset, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Internal offset", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_internal_offset( + THD *thd, + longlong internal_offset +) { + DBUG_ENTER("spider_param_internal_offset"); + DBUG_RETURN(THDVAR(thd, internal_offset) < 0 ? + internal_offset : THDVAR(thd, internal_offset)); +} + +/* + -1 :use table parameter + 0-:limit + */ +static MYSQL_THDVAR_LONGLONG( + internal_limit, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Internal limit", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_internal_limit( + THD *thd, + longlong internal_limit +) { + DBUG_ENTER("spider_param_internal_limit"); + DBUG_RETURN(THDVAR(thd, internal_limit) < 0 ? + internal_limit : THDVAR(thd, internal_limit)); +} + +/* + -1 :use table parameter + 0-:number of rows at a select + */ +static MYSQL_THDVAR_LONGLONG( + split_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Number of rows at a select", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_split_read( + THD *thd, + longlong split_read +) { + DBUG_ENTER("spider_param_split_read"); + DBUG_RETURN(THDVAR(thd, split_read) < 0 ? + split_read : THDVAR(thd, split_read)); +} + +/* + -1 :use table parameter + 0 :doesn't use "offset" and "limit" for "split_read" + 1-:magnification + */ +static MYSQL_THDVAR_INT( + semi_split_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Use offset and limit parameter in SQL for split_read parameter.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +double spider_param_semi_split_read( + THD *thd, + double semi_split_read +) { + DBUG_ENTER("spider_param_semi_split_read"); + DBUG_RETURN(THDVAR(thd, semi_split_read) < 0 ? + semi_split_read : THDVAR(thd, semi_split_read)); +} + +/* + -1 :use table parameter + 0-:the limit value + */ +static MYSQL_THDVAR_LONGLONG( + semi_split_read_limit, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "The limit value for semi_split_read", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_semi_split_read_limit( + THD *thd, + longlong semi_split_read_limit +) { + DBUG_ENTER("spider_param_semi_split_read_limit"); + DBUG_RETURN(THDVAR(thd, semi_split_read_limit) < 0 ? + semi_split_read_limit : THDVAR(thd, semi_split_read_limit)); +} + +/* + -1 :use table parameter + 0 :no alloc + 1-:alloc size + */ +static MYSQL_THDVAR_INT( + init_sql_alloc_size, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Initial sql string alloc size", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +int spider_param_init_sql_alloc_size( + THD *thd, + int init_sql_alloc_size +) { + DBUG_ENTER("spider_param_init_sql_alloc_size"); + DBUG_RETURN(THDVAR(thd, init_sql_alloc_size) < 0 ? + init_sql_alloc_size : THDVAR(thd, init_sql_alloc_size)); +} + +/* + -1 :use table parameter + 0 :off + 1 :on + */ +static MYSQL_THDVAR_INT( + reset_sql_alloc, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Reset sql string alloc after execute", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_reset_sql_alloc( + THD *thd, + int reset_sql_alloc +) { + DBUG_ENTER("spider_param_reset_sql_alloc"); + DBUG_RETURN(THDVAR(thd, reset_sql_alloc) < 0 ? + reset_sql_alloc : THDVAR(thd, reset_sql_alloc)); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +/* + -1 :use table parameter + 0-:result free size for handlersocket + */ +static MYSQL_THDVAR_LONGLONG( + hs_result_free_size, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Result free size for handlersocket", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_hs_result_free_size( + THD *thd, + longlong hs_result_free_size +) { + DBUG_ENTER("spider_param_hs_result_free_size"); + DBUG_RETURN(THDVAR(thd, hs_result_free_size) < 0 ? + hs_result_free_size : THDVAR(thd, hs_result_free_size)); +} +#endif + +/* + -1 :use table parameter + 0 :off + 1 :on + */ +static MYSQL_THDVAR_INT( + multi_split_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Sprit read mode for multi range", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +int spider_param_multi_split_read( + THD *thd, + int multi_split_read +) { + DBUG_ENTER("spider_param_multi_split_read"); + DBUG_RETURN(THDVAR(thd, multi_split_read) < 0 ? + multi_split_read : THDVAR(thd, multi_split_read)); +} + +/* + -1 :use table parameter + 0-:max order columns + */ +static MYSQL_THDVAR_INT( + max_order, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Max columns for order by", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 32767, /* max */ + 0 /* blk */ +); + +int spider_param_max_order( + THD *thd, + int max_order +) { + DBUG_ENTER("spider_param_max_order"); + DBUG_RETURN(THDVAR(thd, max_order) < 0 ? + max_order : THDVAR(thd, max_order)); +} + +/* + -1 :off + 0 :read uncommitted + 1 :read committed + 2 :repeatable read + 3 :serializable + */ +static MYSQL_THDVAR_INT( + semi_trx_isolation, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Transaction isolation level during execute a sql", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 3, /* max */ + 0 /* blk */ +); + +int spider_param_semi_trx_isolation( + THD *thd +) { + DBUG_ENTER("spider_param_semi_trx_isolation"); + DBUG_RETURN(THDVAR(thd, semi_trx_isolation)); +} + +static int spider_param_semi_table_lock_check( + MYSQL_THD thd, + struct st_mysql_sys_var *var, + void *save, + struct st_mysql_value *value +) { + int error_num; + SPIDER_TRX *trx; + my_bool fixed; + long long tmp; + struct my_option options; + DBUG_ENTER("spider_param_semi_table_lock_check"); + if (!(trx = spider_get_trx((THD *) thd, TRUE, &error_num))) + DBUG_RETURN(error_num); + if (trx->locked_connections) + { + my_message(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM, + ER_SPIDER_ALTER_BEFORE_UNLOCK_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM); + } + value->val_int(value, &tmp); + options.sub_size = 0; + options.var_type = GET_INT; + options.def_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->def_val; + options.min_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->min_val; + options.max_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->max_val; + options.block_size = + (long) ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->blk_sz; + options.arg_type = REQUIRED_ARG; + *((int *) save) = (int) getopt_ll_limit_value(tmp, &options, &fixed); +#if MYSQL_VERSION_ID < 50500 + DBUG_RETURN(throw_bounds_warning(thd, fixed, FALSE, + ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, (long long) tmp)); +#else + DBUG_RETURN(throw_bounds_warning(thd, + ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, fixed, FALSE, + (longlong) tmp)); +#endif +} + +/* + 0 :off + 1 :on + */ +static MYSQL_THDVAR_INT( + semi_table_lock, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Table lock during execute a sql", /* comment */ + &spider_param_semi_table_lock_check, /* check */ + NULL, /* update */ + 1, /* def */ + 0, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_semi_table_lock( + THD *thd, + int semi_table_lock +) { + DBUG_ENTER("spider_param_semi_table_lock"); + DBUG_RETURN((semi_table_lock & THDVAR(thd, semi_table_lock))); +} + +static int spider_param_semi_table_lock_connection_check( + MYSQL_THD thd, + struct st_mysql_sys_var *var, + void *save, + struct st_mysql_value *value +) { + int error_num; + SPIDER_TRX *trx; + my_bool fixed; + long long tmp; + struct my_option options; + DBUG_ENTER("spider_param_semi_table_lock_connection_check"); + if (!(trx = spider_get_trx((THD *) thd, TRUE, &error_num))) + DBUG_RETURN(error_num); + if (trx->locked_connections) + { + my_message(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM, + ER_SPIDER_ALTER_BEFORE_UNLOCK_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM); + } + value->val_int(value, &tmp); + options.sub_size = 0; + options.var_type = GET_INT; + options.def_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->def_val; + options.min_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->min_val; + options.max_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->max_val; + options.block_size = + (long) ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->blk_sz; + options.arg_type = REQUIRED_ARG; + *((int *) save) = (int) getopt_ll_limit_value(tmp, &options, &fixed); +#if MYSQL_VERSION_ID < 50500 + DBUG_RETURN(throw_bounds_warning(thd, fixed, FALSE, + ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, (long long) tmp)); +#else + DBUG_RETURN(throw_bounds_warning(thd, + ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, fixed, FALSE, + (longlong) tmp)); +#endif +} + +/* + -1 :off + 0 :use same connection + 1 :use different connection + */ +static MYSQL_THDVAR_INT( + semi_table_lock_connection, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Use different connection if semi_table_lock is enabled", /* comment */ + &spider_param_semi_table_lock_connection_check, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_semi_table_lock_connection( + THD *thd, + int semi_table_lock_connection +) { + DBUG_ENTER("spider_param_semi_table_lock_connection"); + DBUG_RETURN(THDVAR(thd, semi_table_lock_connection) == -1 ? + semi_table_lock_connection : THDVAR(thd, semi_table_lock_connection)); +} + +/* + 0-:block_size + */ +static MYSQL_THDVAR_UINT( + block_size, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Index block size", /* comment */ + NULL, /* check */ + NULL, /* update */ + 16384, /* def */ + 0, /* min */ + 4294967295U, /* max */ + 0 /* blk */ +); + +uint spider_param_block_size( + THD *thd +) { + DBUG_ENTER("spider_param_block_size"); + DBUG_RETURN(THDVAR(thd, block_size)); +} + +/* + -1 :use table parameter + 0 :off + 1 :lock in share mode + 2 :for update + */ +static MYSQL_THDVAR_INT( + selupd_lock_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Lock for select with update", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2, /* max */ + 0 /* blk */ +); + +int spider_param_selupd_lock_mode( + THD *thd, + int selupd_lock_mode +) { + DBUG_ENTER("spider_param_selupd_lock_mode"); + DBUG_RETURN(THDVAR(thd, selupd_lock_mode) == -1 ? + selupd_lock_mode : THDVAR(thd, selupd_lock_mode)); +} + +/* + FALSE: no sync + TRUE: sync + */ +static MYSQL_THDVAR_BOOL( + sync_autocommit, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Sync autocommit", /* comment */ + NULL, /* check */ + NULL, /* update */ + TRUE /* def */ +); + +bool spider_param_sync_autocommit( + THD *thd +) { + DBUG_ENTER("spider_param_sync_autocommit"); + DBUG_RETURN(THDVAR(thd, sync_autocommit)); +} + +/* + FALSE: no sync + TRUE: sync + */ +static MYSQL_THDVAR_BOOL( + sync_time_zone, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Sync time_zone", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_sync_time_zone( + THD *thd +) { + DBUG_ENTER("spider_param_sync_time_zone"); + DBUG_RETURN(THDVAR(thd, sync_time_zone)); +} + +/* + FALSE: not use + TRUE: use + */ +static MYSQL_THDVAR_BOOL( + use_default_database, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Use default database", /* comment */ + NULL, /* check */ + NULL, /* update */ + TRUE /* def */ +); + +bool spider_param_use_default_database( + THD *thd +) { + DBUG_ENTER("spider_param_use_default_database"); + DBUG_RETURN(THDVAR(thd, use_default_database)); +} + +/* + FALSE: sql_log_off = 0 + TRUE: sql_log_off = 1 + */ +static MYSQL_THDVAR_BOOL( + internal_sql_log_off, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Sync sql_log_off", /* comment */ + NULL, /* check */ + NULL, /* update */ + TRUE /* def */ +); + +bool spider_param_internal_sql_log_off( + THD *thd +) { + DBUG_ENTER("spider_param_internal_sql_log_off"); + DBUG_RETURN(THDVAR(thd, internal_sql_log_off)); +} + +/* + -1 :use table parameter + 0-:bulk insert size + */ +static MYSQL_THDVAR_INT( + bulk_size, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Bulk insert size", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +int spider_param_bulk_size( + THD *thd, + int bulk_size +) { + DBUG_ENTER("spider_param_bulk_size"); + DBUG_RETURN(THDVAR(thd, bulk_size) < 0 ? + bulk_size : THDVAR(thd, bulk_size)); +} + +/* + -1 :use table parameter + 0 : Send "update" and "delete" statements one by one. + 1 : Send collected multiple "update" and "delete" statements. + (Collected statements are sent one by one) + 2 : Send collected multiple "update" and "delete" statements. + (Collected statements are sent together) + */ +static MYSQL_THDVAR_INT( + bulk_update_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "The mode of bulk updating and deleting", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2, /* max */ + 0 /* blk */ +); + +int spider_param_bulk_update_mode( + THD *thd, + int bulk_update_mode +) { + DBUG_ENTER("spider_param_bulk_update_mode"); + DBUG_RETURN(THDVAR(thd, bulk_update_mode) == -1 ? + bulk_update_mode : THDVAR(thd, bulk_update_mode)); +} + +/* + -1 :use table parameter + 0-:bulk update size + */ +static MYSQL_THDVAR_INT( + bulk_update_size, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Bulk update size", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +int spider_param_bulk_update_size( + THD *thd, + int bulk_update_size +) { + DBUG_ENTER("spider_param_bulk_update_size"); + DBUG_RETURN(THDVAR(thd, bulk_update_size) == -1 ? + bulk_update_size : THDVAR(thd, bulk_update_size)); +} + +/* + -1 :use table parameter + 0 :off + 1 :on + */ +static MYSQL_THDVAR_INT( + internal_optimize, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Execute optimize to remote server", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_internal_optimize( + THD *thd, + int internal_optimize +) { + DBUG_ENTER("spider_param_internal_optimize"); + DBUG_RETURN(THDVAR(thd, internal_optimize) == -1 ? + internal_optimize : THDVAR(thd, internal_optimize)); +} + +/* + -1 :use table parameter + 0 :off + 1 :on + */ +static MYSQL_THDVAR_INT( + internal_optimize_local, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Execute optimize to remote server with local", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_internal_optimize_local( + THD *thd, + int internal_optimize_local +) { + DBUG_ENTER("spider_param_internal_optimize_local"); + DBUG_RETURN(THDVAR(thd, internal_optimize_local) == -1 ? + internal_optimize_local : THDVAR(thd, internal_optimize_local)); +} + +/* + FALSE: off + TRUE: on + */ +static MYSQL_THDVAR_BOOL( + use_flash_logs, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Execute flush logs to remote server", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_use_flash_logs( + THD *thd +) { + DBUG_ENTER("spider_param_use_flash_logs"); + DBUG_RETURN(THDVAR(thd, use_flash_logs)); +} + +/* + 0 :off + 1 :flush tables with read lock + 2 :flush tables another connection + */ +static MYSQL_THDVAR_INT( + use_snapshot_with_flush_tables, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Execute optimize to remote server with local", /* comment */ + NULL, /* check */ + NULL, /* update */ + 0, /* def */ + 0, /* min */ + 2, /* max */ + 0 /* blk */ +); + +int spider_param_use_snapshot_with_flush_tables( + THD *thd +) { + DBUG_ENTER("spider_param_use_snapshot_with_flush_tables"); + DBUG_RETURN(THDVAR(thd, use_snapshot_with_flush_tables)); +} + +/* + FALSE: off + TRUE: on + */ +static MYSQL_THDVAR_BOOL( + use_all_conns_snapshot, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "When start trx with snapshot, it send to all connections", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_use_all_conns_snapshot( + THD *thd +) { + DBUG_ENTER("spider_param_use_all_conns_snapshot"); + DBUG_RETURN(THDVAR(thd, use_all_conns_snapshot)); +} + +/* + FALSE: off + TRUE: on + */ +static MYSQL_THDVAR_BOOL( + lock_exchange, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Exchange select lock to lock tables", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_lock_exchange( + THD *thd +) { + DBUG_ENTER("spider_param_lock_exchange"); + DBUG_RETURN(THDVAR(thd, lock_exchange)); +} + +/* + FALSE: off + TRUE: on + */ +static MYSQL_THDVAR_BOOL( + internal_unlock, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Unlock tables for using connections in sql", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_internal_unlock( + THD *thd +) { + DBUG_ENTER("spider_param_internal_unlock"); + DBUG_RETURN(THDVAR(thd, internal_unlock)); +} + +/* + FALSE: off + TRUE: on + */ +static MYSQL_THDVAR_BOOL( + semi_trx, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Take a transaction during execute a sql", /* comment */ + NULL, /* check */ + NULL, /* update */ + TRUE /* def */ +); + +bool spider_param_semi_trx( + THD *thd +) { + DBUG_ENTER("spider_param_semi_trx"); + DBUG_RETURN(THDVAR(thd, semi_trx)); +} + +/* + -1 :use table parameter + 0-:seconds of timeout + */ +static MYSQL_THDVAR_INT( + connect_timeout, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Wait timeout of connecting to remote server", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +int spider_param_connect_timeout( + THD *thd, + int connect_timeout +) { + DBUG_ENTER("spider_param_connect_timeout"); + if (thd) + DBUG_RETURN(THDVAR(thd, connect_timeout) == -1 ? + connect_timeout : THDVAR(thd, connect_timeout)); + DBUG_RETURN(connect_timeout); +} + +/* + -1 :use table parameter + 0-:seconds of timeout + */ +static MYSQL_THDVAR_INT( + net_read_timeout, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Wait timeout of receiving data from remote server", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +int spider_param_net_read_timeout( + THD *thd, + int net_read_timeout +) { + DBUG_ENTER("spider_param_net_read_timeout"); + if (thd) + DBUG_RETURN(THDVAR(thd, net_read_timeout) == -1 ? + net_read_timeout : THDVAR(thd, net_read_timeout)); + DBUG_RETURN(net_read_timeout); +} + +/* + -1 :use table parameter + 0-:seconds of timeout + */ +static MYSQL_THDVAR_INT( + net_write_timeout, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Wait timeout of sending data to remote server", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +int spider_param_net_write_timeout( + THD *thd, + int net_write_timeout +) { + DBUG_ENTER("spider_param_net_write_timeout"); + if (thd) + DBUG_RETURN(THDVAR(thd, net_write_timeout) == -1 ? + net_write_timeout : THDVAR(thd, net_write_timeout)); + DBUG_RETURN(net_write_timeout); +} + +/* + -1 :use table parameter + 0 :It acquires it collectively. + 1 :Acquisition one by one.If it discontinues once, and it will need + it later, it retrieves it again when there is interrupt on the way. + 2 :Acquisition one by one.Interrupt is waited for until end of getting + result when there is interrupt on the way. + */ +static MYSQL_THDVAR_INT( + quick_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "The retrieval result from a remote server is acquired by acquisition one by one", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 3, /* max */ + 0 /* blk */ +); + +int spider_param_quick_mode( + THD *thd, + int quick_mode +) { + DBUG_ENTER("spider_param_quick_mode"); + DBUG_RETURN(THDVAR(thd, quick_mode) < 0 ? + quick_mode : THDVAR(thd, quick_mode)); +} + +/* + -1 :use table parameter + 0-:number of records + */ +static MYSQL_THDVAR_LONGLONG( + quick_page_size, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Number of records in a page when acquisition one by one", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_quick_page_size( + THD *thd, + longlong quick_page_size +) { + DBUG_ENTER("spider_param_quick_page_size"); + DBUG_RETURN(THDVAR(thd, quick_page_size) < 0 ? + quick_page_size : THDVAR(thd, quick_page_size)); +} + +/* + -1 :use table parameter + 0 :It doesn't use low memory mode. + 1 :It uses low memory mode. + */ +static MYSQL_THDVAR_INT( + low_mem_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Use low memory mode when SQL(SELECT) internally issued to a remote server is executed and get a result list", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_low_mem_read( + THD *thd, + int low_mem_read +) { + DBUG_ENTER("spider_param_low_mem_read"); + DBUG_RETURN(THDVAR(thd, low_mem_read) < 0 ? + low_mem_read : THDVAR(thd, low_mem_read)); +} + +/* + -1 :use table parameter + 0 :Use index columns if select statement can solve by using index, + otherwise use all columns. + 1 :Use columns that are judged necessary. + */ +static MYSQL_THDVAR_INT( + select_column_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "The mode of using columns at select clause", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_select_column_mode( + THD *thd, + int select_column_mode +) { + DBUG_ENTER("spider_param_select_column_mode"); + DBUG_RETURN(THDVAR(thd, select_column_mode) == -1 ? + select_column_mode : THDVAR(thd, select_column_mode)); +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +/* + -1 :use table parameter + 0 :background search is disabled + 1 :background search is used if search with no lock + 2 :background search is used if search with no lock or shared lock + 3 :background search is used regardless of the lock + */ +static MYSQL_THDVAR_INT( + bgs_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Mode of background search", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 3, /* max */ + 0 /* blk */ +); + +int spider_param_bgs_mode( + THD *thd, + int bgs_mode +) { + DBUG_ENTER("spider_param_bgs_mode"); + DBUG_RETURN(THDVAR(thd, bgs_mode) < 0 ? + bgs_mode : THDVAR(thd, bgs_mode)); +} + +/* + -1 :use table parameter + 0 :records is gotten usually + 1-:number of records + */ +static MYSQL_THDVAR_LONGLONG( + bgs_first_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Number of first read records when background search is used", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_bgs_first_read( + THD *thd, + longlong bgs_first_read +) { + DBUG_ENTER("spider_param_bgs_first_read"); + DBUG_RETURN(THDVAR(thd, bgs_first_read) < 0 ? + bgs_first_read : THDVAR(thd, bgs_first_read)); +} + +/* + -1 :use table parameter + 0 :records is gotten usually + 1-:number of records + */ +static MYSQL_THDVAR_LONGLONG( + bgs_second_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Number of second read records when background search is used", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_bgs_second_read( + THD *thd, + longlong bgs_second_read +) { + DBUG_ENTER("spider_param_bgs_second_read"); + DBUG_RETURN(THDVAR(thd, bgs_second_read) < 0 ? + bgs_second_read : THDVAR(thd, bgs_second_read)); +} +#endif + +/* + -1 :use table parameter + 0 :records is gotten usually + 1-:number of records + */ +static MYSQL_THDVAR_LONGLONG( + first_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Number of first read records", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_first_read( + THD *thd, + longlong first_read +) { + DBUG_ENTER("spider_param_first_read"); + DBUG_RETURN(THDVAR(thd, first_read) < 0 ? + first_read : THDVAR(thd, first_read)); +} + +/* + -1 :use table parameter + 0 :records is gotten usually + 1-:number of records + */ +static MYSQL_THDVAR_LONGLONG( + second_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Number of second read records", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_second_read( + THD *thd, + longlong second_read +) { + DBUG_ENTER("spider_param_second_read"); + DBUG_RETURN(THDVAR(thd, second_read) < 0 ? + second_read : THDVAR(thd, second_read)); +} + +/* + -1 :use table parameter + 0 :always get the newest information + 1-:interval + */ +static MYSQL_THDVAR_INT( + crd_interval, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Interval of cardinality confirmation.(second)", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +double spider_param_crd_interval( + THD *thd, + double crd_interval +) { + DBUG_ENTER("spider_param_crd_interval"); + DBUG_RETURN(THDVAR(thd, crd_interval) == -1 ? + crd_interval : THDVAR(thd, crd_interval)); +} + +/* + -1 :use table parameter + 0 :use table parameter + 1 :use show command + 2 :use information schema + 3 :use explain + */ +static MYSQL_THDVAR_INT( + crd_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Mode of cardinality confirmation.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 3, /* max */ + 0 /* blk */ +); + +int spider_param_crd_mode( + THD *thd, + int crd_mode +) { + DBUG_ENTER("spider_param_crd_mode"); + DBUG_RETURN(THDVAR(thd, crd_mode) <= 0 ? + crd_mode : THDVAR(thd, crd_mode)); +} + +#ifdef WITH_PARTITION_STORAGE_ENGINE +/* + -1 :use table parameter + 0 :No synchronization. + 1 :Cardinality is synchronized when opening a table. + Then no synchronization. + 2 :Synchronization. + */ +static MYSQL_THDVAR_INT( + crd_sync, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Cardinality synchronization in partitioned table.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2, /* max */ + 0 /* blk */ +); + +int spider_param_crd_sync( + THD *thd, + int crd_sync +) { + DBUG_ENTER("spider_param_crd_sync"); + DBUG_RETURN(THDVAR(thd, crd_sync) == -1 ? + crd_sync : THDVAR(thd, crd_sync)); +} +#endif + +/* + -1 :use table parameter + 0 :The crd_weight is used as a fixed value. + 1 :The crd_weight is used as an addition value. + 2 :The crd_weight is used as a multiplication value. + */ +static MYSQL_THDVAR_INT( + crd_type, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Type of cardinality calculation.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2, /* max */ + 0 /* blk */ +); + +int spider_param_crd_type( + THD *thd, + int crd_type +) { + DBUG_ENTER("spider_param_crd_type"); + DBUG_RETURN(THDVAR(thd, crd_type) == -1 ? + crd_type : THDVAR(thd, crd_type)); +} + +/* + -1 :use table parameter + 0-:weight + */ +static MYSQL_THDVAR_INT( + crd_weight, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Weight coefficient to calculate effectiveness of index from cardinality of column.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +double spider_param_crd_weight( + THD *thd, + double crd_weight +) { + DBUG_ENTER("spider_param_crd_weight"); + DBUG_RETURN(THDVAR(thd, crd_weight) == -1 ? + crd_weight : THDVAR(thd, crd_weight)); +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +/* + -1 :use table parameter + 0 :Background confirmation is disabled + 1 :Background confirmation is enabled + */ +static MYSQL_THDVAR_INT( + crd_bg_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Mode of cardinality confirmation at background.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_crd_bg_mode( + THD *thd, + int crd_bg_mode +) { + DBUG_ENTER("spider_param_crd_bg_mode"); + DBUG_RETURN(THDVAR(thd, crd_bg_mode) == -1 ? + crd_bg_mode : THDVAR(thd, crd_bg_mode)); +} +#endif + +/* + -1 :use table parameter + 0 :always get the newest information + 1-:interval + */ +static MYSQL_THDVAR_INT( + sts_interval, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Interval of table state confirmation.(second)", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +double spider_param_sts_interval( + THD *thd, + double sts_interval +) { + DBUG_ENTER("spider_param_sts_interval"); + DBUG_RETURN(THDVAR(thd, sts_interval) == -1 ? + sts_interval : THDVAR(thd, sts_interval)); +} + +/* + -1 :use table parameter + 0 :use table parameter + 1 :use show command + 2 :use information schema + */ +static MYSQL_THDVAR_INT( + sts_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Mode of table state confirmation.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2, /* max */ + 0 /* blk */ +); + +int spider_param_sts_mode( + THD *thd, + int sts_mode +) { + DBUG_ENTER("spider_param_sts_mode"); + DBUG_RETURN(THDVAR(thd, sts_mode) <= 0 ? + sts_mode : THDVAR(thd, sts_mode)); +} + +#ifdef WITH_PARTITION_STORAGE_ENGINE +/* + -1 :use table parameter + 0 :No synchronization. + 1 :Table state is synchronized when opening a table. + Then no synchronization. + 2 :Synchronization. + */ +static MYSQL_THDVAR_INT( + sts_sync, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Table state synchronization in partitioned table.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2, /* max */ + 0 /* blk */ +); + +int spider_param_sts_sync( + THD *thd, + int sts_sync +) { + DBUG_ENTER("spider_param_sts_sync"); + DBUG_RETURN(THDVAR(thd, sts_sync) == -1 ? + sts_sync : THDVAR(thd, sts_sync)); +} +#endif + +#ifndef WITHOUT_SPIDER_BG_SEARCH +/* + -1 :use table parameter + 0 :Background confirmation is disabled + 1 :Background confirmation is enabled + */ +static MYSQL_THDVAR_INT( + sts_bg_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Mode of table state confirmation at background.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_sts_bg_mode( + THD *thd, + int sts_bg_mode +) { + DBUG_ENTER("spider_param_sts_bg_mode"); + DBUG_RETURN(THDVAR(thd, sts_bg_mode) == -1 ? + sts_bg_mode : THDVAR(thd, sts_bg_mode)); +} +#endif + +/* + 0 :always ping + 1-:interval + */ +static MYSQL_THDVAR_INT( + ping_interval_at_trx_start, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Ping interval at transaction start", /* comment */ + NULL, /* check */ + NULL, /* update */ + 3600, /* def */ + 0, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +double spider_param_ping_interval_at_trx_start( + THD *thd +) { + DBUG_ENTER("spider_param_ping_interval_at_trx_start"); + DBUG_RETURN(THDVAR(thd, ping_interval_at_trx_start)); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +/* + 0 :always ping + 1-:interval + */ +static MYSQL_THDVAR_INT( + hs_ping_interval, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Ping interval for handlersocket", /* comment */ + NULL, /* check */ + NULL, /* update */ + 30, /* def */ + 0, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +double spider_param_hs_ping_interval( + THD *thd +) { + DBUG_ENTER("spider_param_hs_ping_interval"); + DBUG_RETURN(THDVAR(thd, hs_ping_interval)); +} +#endif + +/* + -1 :use table parameter + 0 :normal mode + 1 :quick mode + 2 :set 0 value + */ +static MYSQL_THDVAR_INT( + auto_increment_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Mode of auto increment.", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 3, /* max */ + 0 /* blk */ +); + +int spider_param_auto_increment_mode( + THD *thd, + int auto_increment_mode +) { + DBUG_ENTER("spider_param_auto_increment_mode"); + DBUG_RETURN(THDVAR(thd, auto_increment_mode) == -1 ? + auto_increment_mode : THDVAR(thd, auto_increment_mode)); +} + +/* + FALSE: off + TRUE: on + */ +static MYSQL_THDVAR_BOOL( + same_server_link, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Permit to link same server's table", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_same_server_link( + THD *thd +) { + DBUG_ENTER("spider_param_same_server_link"); + DBUG_RETURN(THDVAR(thd, same_server_link)); +} + +/* + FALSE: transmits + TRUE: don't transmit + */ +static MYSQL_THDVAR_BOOL( + local_lock_table, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "Remote server transmission when lock tables is executed at local", + /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +bool spider_param_local_lock_table( + THD *thd +) { + DBUG_ENTER("spider_param_local_lock_table"); + DBUG_RETURN(THDVAR(thd, local_lock_table)); +} + +/* + -1 :use table parameter + 0 :don't transmit + 1 :transmits + */ +static MYSQL_THDVAR_INT( + use_pushdown_udf, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Remote server transmission existence when UDF is used at condition and \"engine_condition_pushdown=1\"", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_use_pushdown_udf( + THD *thd, + int use_pushdown_udf +) { + DBUG_ENTER("spider_param_use_pushdown_udf"); + DBUG_RETURN(THDVAR(thd, use_pushdown_udf) == -1 ? + use_pushdown_udf : THDVAR(thd, use_pushdown_udf)); +} + +/* + -1 :use table parameter + 0 :duplicate check on local server + 1 :avoid duplicate check on local server + */ +static MYSQL_THDVAR_INT( + direct_dup_insert, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Execute \"REPLACE\" and \"INSERT IGNORE\" on remote server and avoid duplicate check on local server", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_direct_dup_insert( + THD *thd, + int direct_dup_insert +) { + DBUG_ENTER("spider_param_direct_dup_insert"); + DBUG_RETURN(THDVAR(thd, direct_dup_insert) < 0 ? + direct_dup_insert : THDVAR(thd, direct_dup_insert)); +} + +static uint spider_udf_table_lock_mutex_count; +/* + 1-: mutex count + */ +static MYSQL_SYSVAR_UINT( + udf_table_lock_mutex_count, + spider_udf_table_lock_mutex_count, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Mutex count of table lock for Spider UDFs", + NULL, + NULL, + 20, + 1, + 4294967295U, + 0 +); + +uint spider_param_udf_table_lock_mutex_count() +{ + DBUG_ENTER("spider_param_udf_table_lock_mutex_count"); + DBUG_RETURN(spider_udf_table_lock_mutex_count); +} + +static uint spider_udf_table_mon_mutex_count; +/* + 1-: mutex count + */ +static MYSQL_SYSVAR_UINT( + udf_table_mon_mutex_count, + spider_udf_table_mon_mutex_count, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Mutex count of table mon for Spider UDFs", + NULL, + NULL, + 20, + 1, + 4294967295U, + 0 +); + +uint spider_param_udf_table_mon_mutex_count() +{ + DBUG_ENTER("spider_param_udf_table_mon_mutex_count"); + DBUG_RETURN(spider_udf_table_mon_mutex_count); +} + +/* + 1-:number of rows + */ +static MYSQL_THDVAR_LONGLONG( + udf_ds_bulk_insert_rows, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Number of rows for bulk inserting", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_udf_ds_bulk_insert_rows( + THD *thd, + longlong udf_ds_bulk_insert_rows +) { + DBUG_ENTER("spider_param_udf_ds_bulk_insert_rows"); + DBUG_RETURN(THDVAR(thd, udf_ds_bulk_insert_rows) <= 0 ? + udf_ds_bulk_insert_rows : THDVAR(thd, udf_ds_bulk_insert_rows)); +} + +/* + -1 :use table parameter + 0 :drop records + 1 :insert last table + 2 :insert first table and loop again + */ +static MYSQL_THDVAR_INT( + udf_ds_table_loop_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Table loop mode if the number of tables in table list are less than the number of result sets", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 2, /* max */ + 0 /* blk */ +); + +int spider_param_udf_ds_table_loop_mode( + THD *thd, + int udf_ds_table_loop_mode +) { + DBUG_ENTER("spider_param_udf_ds_table_loop_mode"); + DBUG_RETURN(THDVAR(thd, udf_ds_table_loop_mode) == -1 ? + udf_ds_table_loop_mode : THDVAR(thd, udf_ds_table_loop_mode)); +} + +static char *spider_remote_access_charset; +/* + */ +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +static MYSQL_SYSVAR_STR( + remote_access_charset, + spider_remote_access_charset, + PLUGIN_VAR_MEMALLOC | + PLUGIN_VAR_RQCMDARG, + "Set remote access charset at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#else +#ifdef PLUGIN_VAR_CAN_MEMALLOC +static MYSQL_SYSVAR_STR( + remote_access_charset, + spider_remote_access_charset, + PLUGIN_VAR_MEMALLOC | + PLUGIN_VAR_RQCMDARG, + "Set remote access charset at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#else +static MYSQL_SYSVAR_STR( + remote_access_charset, + spider_remote_access_charset, + PLUGIN_VAR_RQCMDARG, + "Set remote access charset at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#endif +#endif + +char *spider_param_remote_access_charset() +{ + DBUG_ENTER("spider_param_remote_access_charset"); + DBUG_RETURN(spider_remote_access_charset); +} + +static int spider_remote_autocommit; +/* + -1 :don't set + 0 :autocommit = 0 + 1 :autocommit = 1 + */ +static MYSQL_SYSVAR_INT( + remote_autocommit, + spider_remote_autocommit, + PLUGIN_VAR_RQCMDARG, + "Set autocommit mode at connecting for improvement performance of connection if you know", + NULL, + NULL, + -1, + -1, + 1, + 0 +); + +int spider_param_remote_autocommit() +{ + DBUG_ENTER("spider_param_remote_autocommit"); + DBUG_RETURN(spider_remote_autocommit); +} + +static char *spider_remote_time_zone; +/* + */ +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +static MYSQL_SYSVAR_STR( + remote_time_zone, + spider_remote_time_zone, + PLUGIN_VAR_MEMALLOC | + PLUGIN_VAR_RQCMDARG, + "Set remote time_zone at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#else +#ifdef PLUGIN_VAR_CAN_MEMALLOC +static MYSQL_SYSVAR_STR( + remote_time_zone, + spider_remote_time_zone, + PLUGIN_VAR_MEMALLOC | + PLUGIN_VAR_RQCMDARG, + "Set remote time_zone at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#else +static MYSQL_SYSVAR_STR( + remote_time_zone, + spider_remote_time_zone, + PLUGIN_VAR_RQCMDARG, + "Set remote time_zone at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#endif +#endif + +char *spider_param_remote_time_zone() +{ + DBUG_ENTER("spider_param_remote_time_zone"); + DBUG_RETURN(spider_remote_time_zone); +} + +static int spider_remote_sql_log_off; +/* + -1 :don't set + 0 :sql_log_off = 0 + 1 :sql_log_off = 1 + */ +static MYSQL_SYSVAR_INT( + remote_sql_log_off, + spider_remote_sql_log_off, + PLUGIN_VAR_RQCMDARG, + "Set sql_log_off mode at connecting for improvement performance of connection if you know", + NULL, + NULL, + -1, + -1, + 1, + 0 +); + +int spider_param_remote_sql_log_off() +{ + DBUG_ENTER("spider_param_remote_sql_log_off"); + DBUG_RETURN(spider_remote_sql_log_off); +} + +static int spider_remote_trx_isolation; +/* + -1 :don't set + 0 :READ UNCOMMITTED + 1 :READ COMMITTED + 2 :REPEATABLE READ + 3 :SERIALIZABLE + */ +static MYSQL_SYSVAR_INT( + remote_trx_isolation, + spider_remote_trx_isolation, + PLUGIN_VAR_RQCMDARG, + "Set transaction isolation level at connecting for improvement performance of connection if you know", + NULL, + NULL, + -1, + -1, + 3, + 0 +); + +int spider_param_remote_trx_isolation() +{ + DBUG_ENTER("spider_param_remote_trx_isolation"); + DBUG_RETURN(spider_remote_trx_isolation); +} + +static char *spider_remote_default_database; +/* + */ +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +static MYSQL_SYSVAR_STR( + remote_default_database, + spider_remote_default_database, + PLUGIN_VAR_MEMALLOC | + PLUGIN_VAR_RQCMDARG, + "Set remote database at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#else +#ifdef PLUGIN_VAR_CAN_MEMALLOC +static MYSQL_SYSVAR_STR( + remote_default_database, + spider_remote_default_database, + PLUGIN_VAR_MEMALLOC | + PLUGIN_VAR_RQCMDARG, + "Set remote database at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#else +static MYSQL_SYSVAR_STR( + remote_default_database, + spider_remote_default_database, + PLUGIN_VAR_RQCMDARG, + "Set remote database at connecting for improvement performance of connection if you know", + NULL, + NULL, + NULL +); +#endif +#endif + +char *spider_param_remote_default_database() +{ + DBUG_ENTER("spider_param_remote_default_database"); + DBUG_RETURN(spider_remote_default_database); +} + +/* + 0-:connect retry interval (micro second) + */ +static MYSQL_THDVAR_LONGLONG( + connect_retry_interval, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Connect retry interval", /* comment */ + NULL, /* check */ + NULL, /* update */ + 1000, /* def */ + 0, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_connect_retry_interval( + THD *thd +) { + DBUG_ENTER("spider_param_connect_retry_interval"); + if (thd) + DBUG_RETURN(THDVAR(thd, connect_retry_interval)); + DBUG_RETURN(0); +} + +/* + 0-:connect retry count + */ +static MYSQL_THDVAR_INT( + connect_retry_count, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Connect retry count", /* comment */ + NULL, /* check */ + NULL, /* update */ + 1000, /* def */ + 0, /* min */ + 2147483647, /* max */ + 0 /* blk */ +); + +int spider_param_connect_retry_count( + THD *thd +) { + DBUG_ENTER("spider_param_connect_retry_count"); + if (thd) + DBUG_RETURN(THDVAR(thd, connect_retry_count)); + DBUG_RETURN(0); +} + +/* + */ +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +static MYSQL_THDVAR_STR( + bka_engine, /* name */ + PLUGIN_VAR_MEMALLOC | + PLUGIN_VAR_RQCMDARG, + "Temporary table's engine for BKA", /* comment */ + NULL, /* check */ + NULL, /* update */ + NULL /* def */ +); +#else +#ifdef PLUGIN_VAR_CAN_MEMALLOC +static MYSQL_THDVAR_STR( + bka_engine, /* name */ + PLUGIN_VAR_MEMALLOC | + PLUGIN_VAR_RQCMDARG, + "Temporary table's engine for BKA", /* comment */ + NULL, /* check */ + NULL, /* update */ + NULL /* def */ +); +#else +static MYSQL_THDVAR_STR( + bka_engine, /* name */ + PLUGIN_VAR_RQCMDARG, + "Temporary table's engine for BKA", /* comment */ + NULL, /* check */ + NULL, /* update */ + NULL /* def */ +); +#endif +#endif + +char *spider_param_bka_engine( + THD *thd, + char *bka_engine +) { + DBUG_ENTER("spider_param_bka_engine"); + DBUG_RETURN(THDVAR(thd, bka_engine) ? + THDVAR(thd, bka_engine) : bka_engine); +} + +/* + -1 :use table parameter + 0 :use union all + 1 :use temporary table + */ +static MYSQL_THDVAR_INT( + bka_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Mode of BKA for Spider", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_bka_mode( + THD *thd, + int bka_mode +) { + DBUG_ENTER("spider_param_bka_mode"); + DBUG_RETURN(THDVAR(thd, bka_mode) == -1 ? + bka_mode : THDVAR(thd, bka_mode)); +} + +static int spider_udf_ct_bulk_insert_interval; +/* + -1 : The UDF parameter is adopted. + 0 or more : Milliseconds. + */ +static MYSQL_SYSVAR_INT( + udf_ct_bulk_insert_interval, + spider_udf_ct_bulk_insert_interval, + PLUGIN_VAR_RQCMDARG, + "The interval time between bulk insert and next bulk insert at coping", + NULL, + NULL, + -1, + -1, + 2147483647, + 0 +); + +int spider_param_udf_ct_bulk_insert_interval( + int udf_ct_bulk_insert_interval +) { + DBUG_ENTER("spider_param_udf_ct_bulk_insert_interval"); + DBUG_RETURN(spider_udf_ct_bulk_insert_interval < 0 ? + udf_ct_bulk_insert_interval : spider_udf_ct_bulk_insert_interval); +} + +static longlong spider_udf_ct_bulk_insert_rows; +/* + -1,0 : The UDF parameter is adopted. + 1 or more : Number of rows. + */ +static MYSQL_SYSVAR_LONGLONG( + udf_ct_bulk_insert_rows, + spider_udf_ct_bulk_insert_rows, + PLUGIN_VAR_RQCMDARG, + "The number of rows inserted with bulk insert of one time at coping", + NULL, + NULL, + -1, + -1, + 9223372036854775807LL, + 0 +); + +longlong spider_param_udf_ct_bulk_insert_rows( + longlong udf_ct_bulk_insert_rows +) { + DBUG_ENTER("spider_param_udf_ct_bulk_insert_rows"); + DBUG_RETURN(spider_udf_ct_bulk_insert_rows <= 0 ? + udf_ct_bulk_insert_rows : spider_udf_ct_bulk_insert_rows); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +/* + 0: no recycle + 1: recycle in instance + 2: recycle in thread + */ +static MYSQL_THDVAR_UINT( + hs_r_conn_recycle_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Handlersocket connection recycle mode", /* comment */ + NULL, /* check */ + NULL, /* update */ + 2, /* def */ + 0, /* min */ + 2, /* max */ + 0 /* blk */ +); + +uint spider_param_hs_r_conn_recycle_mode( + THD *thd +) { + DBUG_ENTER("spider_param_hs_r_conn_recycle_mode"); + DBUG_RETURN(THDVAR(thd, hs_r_conn_recycle_mode)); +} + +/* + 0: weak + 1: strict + */ +static MYSQL_THDVAR_UINT( + hs_r_conn_recycle_strict, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Strict handlersocket connection recycle", /* comment */ + NULL, /* check */ + NULL, /* update */ + 0, /* def */ + 0, /* min */ + 1, /* max */ + 0 /* blk */ +); + +uint spider_param_hs_r_conn_recycle_strict( + THD *thd +) { + DBUG_ENTER("spider_param_hs_r_conn_recycle_strict"); + DBUG_RETURN(THDVAR(thd, hs_r_conn_recycle_strict)); +} + +/* + 0: no recycle + 1: recycle in instance + 2: recycle in thread + */ +static MYSQL_THDVAR_UINT( + hs_w_conn_recycle_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Handlersocket connection recycle mode", /* comment */ + NULL, /* check */ + NULL, /* update */ + 2, /* def */ + 0, /* min */ + 2, /* max */ + 0 /* blk */ +); + +uint spider_param_hs_w_conn_recycle_mode( + THD *thd +) { + DBUG_ENTER("spider_param_hs_w_conn_recycle_mode"); + DBUG_RETURN(THDVAR(thd, hs_w_conn_recycle_mode)); +} + +/* + 0: weak + 1: strict + */ +static MYSQL_THDVAR_UINT( + hs_w_conn_recycle_strict, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Strict handlersocket connection recycle", /* comment */ + NULL, /* check */ + NULL, /* update */ + 0, /* def */ + 0, /* min */ + 1, /* max */ + 0 /* blk */ +); + +uint spider_param_hs_w_conn_recycle_strict( + THD *thd +) { + DBUG_ENTER("spider_param_hs_w_conn_recycle_strict"); + DBUG_RETURN(THDVAR(thd, hs_w_conn_recycle_strict)); +} + +/* + -1 :use table parameter + 0 :not use + 1 :use handlersocket + */ +static MYSQL_THDVAR_INT( + use_hs_read, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Use handlersocket for reading", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_use_hs_read( + THD *thd, + int use_hs_read +) { + DBUG_ENTER("spider_param_use_hs_read"); + DBUG_RETURN(THDVAR(thd, use_hs_read) == -1 ? + use_hs_read : THDVAR(thd, use_hs_read)); +} + +/* + -1 :use table parameter + 0 :not use + 1 :use handlersocket + */ +static MYSQL_THDVAR_INT( + use_hs_write, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Use handlersocket for writing", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_use_hs_write( + THD *thd, + int use_hs_write +) { + DBUG_ENTER("spider_param_use_hs_write"); + DBUG_RETURN(THDVAR(thd, use_hs_write) == -1 ? + use_hs_write : THDVAR(thd, use_hs_write)); +} +#endif + +/* + -1 :use table parameter + 0 :not use + 1 :use handler + */ +static MYSQL_THDVAR_INT( + use_handler, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Use handler for reading", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 3, /* max */ + 0 /* blk */ +); + +int spider_param_use_handler( + THD *thd, + int use_handler +) { + DBUG_ENTER("spider_param_use_handler"); + DBUG_RETURN(THDVAR(thd, use_handler) == -1 ? + use_handler : THDVAR(thd, use_handler)); +} + +/* + -1 :use table parameter + 0 :return error if error + 1 :return 0 record if error + */ +static MYSQL_THDVAR_INT( + error_read_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Read error mode if error", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_error_read_mode( + THD *thd, + int error_read_mode +) { + DBUG_ENTER("spider_param_error_read_mode"); + DBUG_RETURN(THDVAR(thd, error_read_mode) == -1 ? + error_read_mode : THDVAR(thd, error_read_mode)); +} + +/* + -1 :use table parameter + 0 :return error if error + 1 :return 0 record if error + */ +static MYSQL_THDVAR_INT( + error_write_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Write error mode if error", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_error_write_mode( + THD *thd, + int error_write_mode +) { + DBUG_ENTER("spider_param_error_write_mode"); + DBUG_RETURN(THDVAR(thd, error_write_mode) == -1 ? + error_write_mode : THDVAR(thd, error_write_mode)); +} + +/* + -1 :use table parameter + 0 :not skip + 1 :skip + */ +static MYSQL_THDVAR_INT( + skip_default_condition, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Skip generating internal default condition", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_skip_default_condition( + THD *thd, + int skip_default_condition +) { + DBUG_ENTER("spider_param_skip_default_condition"); + DBUG_RETURN(THDVAR(thd, skip_default_condition) == -1 ? + skip_default_condition : THDVAR(thd, skip_default_condition)); +} + +/* + -1 :use table parameter + 0 :not send directly + 1-:send directly + */ +static MYSQL_THDVAR_LONGLONG( + direct_order_limit, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Send 'ORDER BY' and 'LIMIT' to remote server directly", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_direct_order_limit( + THD *thd, + longlong direct_order_limit +) { + DBUG_ENTER("spider_param_direct_order_limit"); + DBUG_RETURN(THDVAR(thd, direct_order_limit) == -1 ? + direct_order_limit : THDVAR(thd, direct_order_limit)); +} + +/* + -1 :use table parameter + 0 :writable + 1 :read only + */ +static MYSQL_THDVAR_INT( + read_only_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Read only", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_read_only_mode( + THD *thd, + int read_only_mode +) { + DBUG_ENTER("spider_param_read_only_mode"); + DBUG_RETURN(THDVAR(thd, read_only_mode) == -1 ? + read_only_mode : THDVAR(thd, read_only_mode)); +} + +#ifdef HA_CAN_BULK_ACCESS +static int spider_bulk_access_free; +/* + -1 :use table parameter + 0 :in reset + 1 :in close + */ +static MYSQL_SYSVAR_INT( + bulk_access_free, + spider_bulk_access_free, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Free mode of bulk access resources", + NULL, + NULL, + -1, + -1, + 1, + 0 +); + +int spider_param_bulk_access_free( + int bulk_access_free +) { + DBUG_ENTER("spider_param_bulk_access_free"); + DBUG_RETURN(spider_bulk_access_free == -1 ? + bulk_access_free : spider_bulk_access_free); +} +#endif + +#if MYSQL_VERSION_ID < 50500 +#else +/* + -1 :use UDF parameter + 0 :can not use + 1 :can use + */ +static MYSQL_THDVAR_INT( + udf_ds_use_real_table, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Use real table for temporary table list", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_udf_ds_use_real_table( + THD *thd, + int udf_ds_use_real_table +) { + DBUG_ENTER("spider_param_udf_ds_use_real_table"); + DBUG_RETURN(THDVAR(thd, udf_ds_use_real_table) == -1 ? + udf_ds_use_real_table : THDVAR(thd, udf_ds_use_real_table)); +} +#endif + +static struct st_mysql_storage_engine spider_storage_engine = +{ MYSQL_HANDLERTON_INTERFACE_VERSION }; + +static struct st_mysql_sys_var* spider_system_variables[] = { + MYSQL_SYSVAR(support_xa), + MYSQL_SYSVAR(table_init_error_interval), + MYSQL_SYSVAR(use_table_charset), + MYSQL_SYSVAR(conn_recycle_mode), + MYSQL_SYSVAR(conn_recycle_strict), + MYSQL_SYSVAR(sync_trx_isolation), + MYSQL_SYSVAR(use_consistent_snapshot), + MYSQL_SYSVAR(internal_xa), + MYSQL_SYSVAR(internal_xa_snapshot), + MYSQL_SYSVAR(force_commit), + MYSQL_SYSVAR(internal_offset), + MYSQL_SYSVAR(internal_limit), + MYSQL_SYSVAR(split_read), + MYSQL_SYSVAR(semi_split_read), + MYSQL_SYSVAR(semi_split_read_limit), + MYSQL_SYSVAR(init_sql_alloc_size), + MYSQL_SYSVAR(reset_sql_alloc), +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + MYSQL_SYSVAR(hs_result_free_size), +#endif + MYSQL_SYSVAR(multi_split_read), + MYSQL_SYSVAR(max_order), + MYSQL_SYSVAR(semi_trx_isolation), + MYSQL_SYSVAR(semi_table_lock), + MYSQL_SYSVAR(semi_table_lock_connection), + MYSQL_SYSVAR(block_size), + MYSQL_SYSVAR(selupd_lock_mode), + MYSQL_SYSVAR(sync_autocommit), + MYSQL_SYSVAR(sync_time_zone), + MYSQL_SYSVAR(use_default_database), + MYSQL_SYSVAR(internal_sql_log_off), + MYSQL_SYSVAR(bulk_size), + MYSQL_SYSVAR(bulk_update_mode), + MYSQL_SYSVAR(bulk_update_size), + MYSQL_SYSVAR(internal_optimize), + MYSQL_SYSVAR(internal_optimize_local), + MYSQL_SYSVAR(use_flash_logs), + MYSQL_SYSVAR(use_snapshot_with_flush_tables), + MYSQL_SYSVAR(use_all_conns_snapshot), + MYSQL_SYSVAR(lock_exchange), + MYSQL_SYSVAR(internal_unlock), + MYSQL_SYSVAR(semi_trx), + MYSQL_SYSVAR(connect_timeout), + MYSQL_SYSVAR(net_read_timeout), + MYSQL_SYSVAR(net_write_timeout), + MYSQL_SYSVAR(quick_mode), + MYSQL_SYSVAR(quick_page_size), + MYSQL_SYSVAR(low_mem_read), + MYSQL_SYSVAR(select_column_mode), +#ifndef WITHOUT_SPIDER_BG_SEARCH + MYSQL_SYSVAR(bgs_mode), + MYSQL_SYSVAR(bgs_first_read), + MYSQL_SYSVAR(bgs_second_read), +#endif + MYSQL_SYSVAR(first_read), + MYSQL_SYSVAR(second_read), + MYSQL_SYSVAR(crd_interval), + MYSQL_SYSVAR(crd_mode), +#ifdef WITH_PARTITION_STORAGE_ENGINE + MYSQL_SYSVAR(crd_sync), +#endif + MYSQL_SYSVAR(crd_type), + MYSQL_SYSVAR(crd_weight), +#ifndef WITHOUT_SPIDER_BG_SEARCH + MYSQL_SYSVAR(crd_bg_mode), +#endif + MYSQL_SYSVAR(sts_interval), + MYSQL_SYSVAR(sts_mode), +#ifdef WITH_PARTITION_STORAGE_ENGINE + MYSQL_SYSVAR(sts_sync), +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + MYSQL_SYSVAR(sts_bg_mode), +#endif + MYSQL_SYSVAR(ping_interval_at_trx_start), +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + MYSQL_SYSVAR(hs_ping_interval), +#endif + MYSQL_SYSVAR(auto_increment_mode), + MYSQL_SYSVAR(same_server_link), + MYSQL_SYSVAR(local_lock_table), + MYSQL_SYSVAR(use_pushdown_udf), + MYSQL_SYSVAR(direct_dup_insert), + MYSQL_SYSVAR(udf_table_lock_mutex_count), + MYSQL_SYSVAR(udf_table_mon_mutex_count), + MYSQL_SYSVAR(udf_ds_bulk_insert_rows), + MYSQL_SYSVAR(udf_ds_table_loop_mode), + MYSQL_SYSVAR(remote_access_charset), + MYSQL_SYSVAR(remote_autocommit), + MYSQL_SYSVAR(remote_time_zone), + MYSQL_SYSVAR(remote_sql_log_off), + MYSQL_SYSVAR(remote_trx_isolation), + MYSQL_SYSVAR(remote_default_database), + MYSQL_SYSVAR(connect_retry_interval), + MYSQL_SYSVAR(connect_retry_count), + MYSQL_SYSVAR(connect_mutex), + MYSQL_SYSVAR(bka_engine), + MYSQL_SYSVAR(bka_mode), + MYSQL_SYSVAR(udf_ct_bulk_insert_interval), + MYSQL_SYSVAR(udf_ct_bulk_insert_rows), +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + MYSQL_SYSVAR(hs_r_conn_recycle_mode), + MYSQL_SYSVAR(hs_r_conn_recycle_strict), + MYSQL_SYSVAR(hs_w_conn_recycle_mode), + MYSQL_SYSVAR(hs_w_conn_recycle_strict), + MYSQL_SYSVAR(use_hs_read), + MYSQL_SYSVAR(use_hs_write), +#endif + MYSQL_SYSVAR(use_handler), + MYSQL_SYSVAR(error_read_mode), + MYSQL_SYSVAR(error_write_mode), + MYSQL_SYSVAR(skip_default_condition), + MYSQL_SYSVAR(direct_order_limit), + MYSQL_SYSVAR(read_only_mode), +#ifdef HA_CAN_BULK_ACCESS + MYSQL_SYSVAR(bulk_access_free), +#endif +#if MYSQL_VERSION_ID < 50500 +#else + MYSQL_SYSVAR(udf_ds_use_real_table), +#endif + NULL +}; + +mysql_declare_plugin(spider) +{ + MYSQL_STORAGE_ENGINE_PLUGIN, + &spider_storage_engine, + "SPIDER", + "Kentoku Shiba", + "Spider storage engine", + PLUGIN_LICENSE_GPL, + spider_db_init, + spider_db_done, + 0x0300, + spider_status_variables, + spider_system_variables, + NULL, +#if MYSQL_VERSION_ID >= 50600 + 0, +#endif +}, +spider_i_s_alloc_mem +mysql_declare_plugin_end; diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h new file mode 100644 index 00000000000..a3e1576cdf1 --- /dev/null +++ b/storage/spider/spd_param.h @@ -0,0 +1,370 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software); you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation); version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY); without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program); if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +my_bool spider_param_support_xa(); +my_bool spider_param_connect_mutex(); +uint spider_param_table_init_error_interval(); +int spider_param_use_table_charset( + int use_table_charset +); +uint spider_param_conn_recycle_mode( + THD *thd +); +uint spider_param_conn_recycle_strict( + THD *thd +); +bool spider_param_sync_trx_isolation( + THD *thd +); +bool spider_param_use_consistent_snapshot( + THD *thd +); +bool spider_param_internal_xa( + THD *thd +); +uint spider_param_internal_xa_snapshot( + THD *thd +); +uint spider_param_force_commit( + THD *thd +); +longlong spider_param_internal_offset( + THD *thd, + longlong internal_offset +); +longlong spider_param_internal_limit( + THD *thd, + longlong internal_limit +); +longlong spider_param_split_read( + THD *thd, + longlong split_read +); +double spider_param_semi_split_read( + THD *thd, + double semi_split_read +); +longlong spider_param_semi_split_read_limit( + THD *thd, + longlong semi_split_read_limit +); +int spider_param_init_sql_alloc_size( + THD *thd, + int init_sql_alloc_size +); +int spider_param_reset_sql_alloc( + THD *thd, + int reset_sql_alloc +); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +longlong spider_param_hs_result_free_size( + THD *thd, + longlong hs_result_free_size +); +#endif +int spider_param_multi_split_read( + THD *thd, + int multi_split_read +); +int spider_param_max_order( + THD *thd, + int max_order +); +int spider_param_semi_trx_isolation( + THD *thd +); +int spider_param_semi_table_lock( + THD *thd, + int semi_table_lock +); +int spider_param_semi_table_lock_connection( + THD *thd, + int semi_table_lock_connection +); +uint spider_param_block_size( + THD *thd +); +int spider_param_selupd_lock_mode( + THD *thd, + int selupd_lock_mode +); +bool spider_param_sync_autocommit( + THD *thd +); +bool spider_param_sync_time_zone( + THD *thd +); +bool spider_param_use_default_database( + THD *thd +); +bool spider_param_internal_sql_log_off( + THD *thd +); +int spider_param_bulk_size( + THD *thd, + int bulk_size +); +int spider_param_bulk_update_mode( + THD *thd, + int bulk_update_mode +); +int spider_param_bulk_update_size( + THD *thd, + int bulk_update_size +); +int spider_param_internal_optimize( + THD *thd, + int internal_optimize +); +int spider_param_internal_optimize_local( + THD *thd, + int internal_optimize_local +); +bool spider_param_use_flash_logs( + THD *thd +); +int spider_param_use_snapshot_with_flush_tables( + THD *thd +); +bool spider_param_use_all_conns_snapshot( + THD *thd +); +bool spider_param_lock_exchange( + THD *thd +); +bool spider_param_internal_unlock( + THD *thd +); +bool spider_param_semi_trx( + THD *thd +); +int spider_param_connect_timeout( + THD *thd, + int connect_timeout +); +int spider_param_net_read_timeout( + THD *thd, + int net_read_timeout +); +int spider_param_net_write_timeout( + THD *thd, + int net_write_timeout +); +int spider_param_quick_mode( + THD *thd, + int quick_mode +); +longlong spider_param_quick_page_size( + THD *thd, + longlong quick_page_size +); +int spider_param_low_mem_read( + THD *thd, + int low_mem_read +); +int spider_param_select_column_mode( + THD *thd, + int select_column_mode +); +#ifndef WITHOUT_SPIDER_BG_SEARCH +int spider_param_bgs_mode( + THD *thd, + int bgs_mode +); +longlong spider_param_bgs_first_read( + THD *thd, + longlong bgs_first_read +); +longlong spider_param_bgs_second_read( + THD *thd, + longlong bgs_second_read +); +#endif +longlong spider_param_first_read( + THD *thd, + longlong first_read +); +longlong spider_param_second_read( + THD *thd, + longlong second_read +); +double spider_param_crd_interval( + THD *thd, + double crd_interval +); +int spider_param_crd_mode( + THD *thd, + int crd_mode +); +#ifdef WITH_PARTITION_STORAGE_ENGINE +int spider_param_crd_sync( + THD *thd, + int crd_sync +); +#endif +int spider_param_crd_type( + THD *thd, + int crd_type +); +double spider_param_crd_weight( + THD *thd, + double crd_weight +); +#ifndef WITHOUT_SPIDER_BG_SEARCH +int spider_param_crd_bg_mode( + THD *thd, + int crd_bg_mode +); +#endif +double spider_param_sts_interval( + THD *thd, + double sts_interval +); +int spider_param_sts_mode( + THD *thd, + int sts_mode +); +#ifdef WITH_PARTITION_STORAGE_ENGINE +int spider_param_sts_sync( + THD *thd, + int sts_sync +); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH +int spider_param_sts_bg_mode( + THD *thd, + int sts_bg_mode +); +#endif +double spider_param_ping_interval_at_trx_start( + THD *thd +); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +double spider_param_hs_ping_interval( + THD *thd +); +#endif +int spider_param_auto_increment_mode( + THD *thd, + int auto_increment_mode +); +bool spider_param_same_server_link( + THD *thd +); +bool spider_param_local_lock_table( + THD *thd +); +int spider_param_use_pushdown_udf( + THD *thd, + int use_pushdown_udf +); +int spider_param_direct_dup_insert( + THD *thd, + int direct_dup_insert +); +uint spider_param_udf_table_lock_mutex_count(); +uint spider_param_udf_table_mon_mutex_count(); +longlong spider_param_udf_ds_bulk_insert_rows( + THD *thd, + longlong udf_ds_bulk_insert_rows +); +int spider_param_udf_ds_table_loop_mode( + THD *thd, + int udf_ds_table_loop_mode +); +char *spider_param_remote_access_charset(); +int spider_param_remote_autocommit(); +char *spider_param_remote_time_zone(); +int spider_param_remote_sql_log_off(); +int spider_param_remote_trx_isolation(); +char *spider_param_remote_default_database(); +longlong spider_param_connect_retry_interval( + THD *thd +); +int spider_param_connect_retry_count( + THD *thd +); +char *spider_param_bka_engine( + THD *thd, + char *bka_engine +); +int spider_param_bka_mode( + THD *thd, + int bka_mode +); +int spider_param_udf_ct_bulk_insert_interval( + int udf_ct_bulk_insert_interval +); +longlong spider_param_udf_ct_bulk_insert_rows( + longlong udf_ct_bulk_insert_rows +); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +uint spider_param_hs_r_conn_recycle_mode( + THD *thd +); +uint spider_param_hs_r_conn_recycle_strict( + THD *thd +); +uint spider_param_hs_w_conn_recycle_mode( + THD *thd +); +uint spider_param_hs_w_conn_recycle_strict( + THD *thd +); +int spider_param_use_hs_read( + THD *thd, + int use_hs_read +); +int spider_param_use_hs_write( + THD *thd, + int use_hs_write +); +#endif +int spider_param_use_handler( + THD *thd, + int use_handler +); +int spider_param_error_read_mode( + THD *thd, + int error_read_mode +); +int spider_param_error_write_mode( + THD *thd, + int error_write_mode +); +int spider_param_skip_default_condition( + THD *thd, + int skip_default_condition +); +longlong spider_param_direct_order_limit( + THD *thd, + longlong direct_order_limit +); +int spider_param_read_only_mode( + THD *thd, + int read_only_mode +); +#ifdef HA_CAN_BULK_ACCESS +int spider_param_bulk_access_free( + int bulk_access_free +); +#endif +#if MYSQL_VERSION_ID < 50500 +#else +int spider_param_udf_ds_use_real_table( + THD *thd, + int udf_ds_use_real_table +); +#endif diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc new file mode 100644 index 00000000000..34bd3fb3575 --- /dev/null +++ b/storage/spider/spd_ping_table.cc @@ -0,0 +1,1460 @@ +/* Copyright (C) 2009-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#include "sql_acl.h" +#endif +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "ha_spider.h" +#include "spd_db_conn.h" +#include "spd_trx.h" +#include "spd_conn.h" +#include "spd_sys_table.h" +#include "spd_table.h" +#include "spd_ping_table.h" +#include "spd_direct_sql.h" +#include "spd_udf.h" +#include "spd_malloc.h" + +extern handlerton *spider_hton_ptr; + +#ifdef HAVE_PSI_INTERFACE +extern PSI_mutex_key spd_key_mutex_mon_list_caller; +extern PSI_mutex_key spd_key_mutex_mon_list_receptor; +extern PSI_mutex_key spd_key_mutex_mon_list_monitor; +extern PSI_mutex_key spd_key_mutex_mon_list_update_status; +extern PSI_mutex_key spd_key_mutex_mon_table_cache; +#endif + +#ifndef WITHOUT_SPIDER_BG_SEARCH +extern pthread_mutex_t spider_global_trx_mutex; +extern SPIDER_TRX *spider_global_trx; +#endif + +HASH *spider_udf_table_mon_list_hash; +uint spider_udf_table_mon_list_hash_id; +const char *spider_udf_table_mon_list_hash_func_name; +const char *spider_udf_table_mon_list_hash_file_name; +ulong spider_udf_table_mon_list_hash_line_no; +pthread_mutex_t *spider_udf_table_mon_mutexes; +pthread_cond_t *spider_udf_table_mon_conds; + +pthread_mutex_t spider_mon_table_cache_mutex; +DYNAMIC_ARRAY spider_mon_table_cache; +uint spider_mon_table_cache_id; +const char *spider_mon_table_cache_func_name; +const char *spider_mon_table_cache_file_name; +ulong spider_mon_table_cache_line_no; +volatile ulonglong spider_mon_table_cache_version = 0; +volatile ulonglong spider_mon_table_cache_version_req = 1; + +SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( + SPIDER_TRX *trx, + THD *thd, + spider_string *str, + uint conv_name_length, + int link_idx, + uint32 server_id, + bool need_lock, + int *error_num +) { + uint mutex_hash; + SPIDER_TABLE_MON_LIST *table_mon_list; + MEM_ROOT mem_root; + ulonglong mon_table_cache_version; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value; +#endif + DBUG_ENTER("spider_get_ping_table_mon_list"); + if (spider_mon_table_cache_version != spider_mon_table_cache_version_req) + { + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + if ((*error_num = spider_init_ping_table_mon_cache(thd, &mem_root, + need_lock))) + { + free_root(&mem_root, MYF(0)); + goto error; + } + free_root(&mem_root, MYF(0)); + } + + mutex_hash = spider_udf_calc_hash(str->c_ptr(), + spider_param_udf_table_mon_mutex_count()); + DBUG_PRINT("info",("spider hash key=%s", str->c_ptr())); + DBUG_PRINT("info",("spider hash key length=%u", str->length())); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + hash_value = my_calc_hash( + &spider_udf_table_mon_list_hash[mutex_hash], + (uchar*) str->c_ptr(), str->length()); +#endif + pthread_mutex_lock(&spider_udf_table_mon_mutexes[mutex_hash]); + mon_table_cache_version = (ulonglong) spider_mon_table_cache_version; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(table_mon_list = (SPIDER_TABLE_MON_LIST *) + my_hash_search_using_hash_value( + &spider_udf_table_mon_list_hash[mutex_hash], hash_value, + (uchar*) str->c_ptr(), str->length())) || + table_mon_list->mon_table_cache_version != mon_table_cache_version + ) +#else + if (!(table_mon_list = (SPIDER_TABLE_MON_LIST *) my_hash_search( + &spider_udf_table_mon_list_hash[mutex_hash], + (uchar*) str->c_ptr(), str->length())) || + table_mon_list->mon_table_cache_version != mon_table_cache_version + ) +#endif + { + DBUG_ASSERT(trx != spider_global_trx); + if ( + table_mon_list && + table_mon_list->mon_table_cache_version != mon_table_cache_version + ) + spider_release_ping_table_mon_list_loop(mutex_hash, table_mon_list); + + if (!(table_mon_list = spider_get_ping_table_tgt(thd, str->c_ptr(), + conv_name_length, link_idx, server_id, str, need_lock, error_num))) + { + pthread_mutex_unlock(&spider_udf_table_mon_mutexes[mutex_hash]); + goto error; + } + table_mon_list->mutex_hash = mutex_hash; + table_mon_list->mon_table_cache_version = mon_table_cache_version; + uint old_elements = + spider_udf_table_mon_list_hash[mutex_hash].array.max_element; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + table_mon_list->key_hash_value = hash_value; +#endif +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value( + &spider_udf_table_mon_list_hash[mutex_hash], + hash_value, (uchar*) table_mon_list)) +#else + if (my_hash_insert(&spider_udf_table_mon_list_hash[mutex_hash], + (uchar*) table_mon_list)) +#endif + { + spider_ping_table_free_mon_list(table_mon_list); + *error_num = HA_ERR_OUT_OF_MEM; + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + pthread_mutex_unlock(&spider_udf_table_mon_mutexes[mutex_hash]); + goto error; + } + if (spider_udf_table_mon_list_hash[mutex_hash].array.max_element > + old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + spider_udf_table_mon_list_hash, + (spider_udf_table_mon_list_hash[mutex_hash].array.max_element - + old_elements) * + spider_udf_table_mon_list_hash[mutex_hash].array.size_of_element); + } + } + table_mon_list->use_count++; + DBUG_PRINT("info",("spider table_mon_list->use_count=%d", + table_mon_list->use_count)); + pthread_mutex_unlock(&spider_udf_table_mon_mutexes[mutex_hash]); + DBUG_RETURN(table_mon_list); + +error: + DBUG_RETURN(NULL); +} + +void spider_free_ping_table_mon_list( + SPIDER_TABLE_MON_LIST *table_mon_list +) { + DBUG_ENTER("spider_free_ping_table_mon_list"); + pthread_mutex_lock(&spider_udf_table_mon_mutexes[ + table_mon_list->mutex_hash]); + table_mon_list->use_count--; + DBUG_PRINT("info",("spider table_mon_list->use_count=%d", table_mon_list->use_count)); + if (!table_mon_list->use_count) + pthread_cond_broadcast(&spider_udf_table_mon_conds[ + table_mon_list->mutex_hash]); + pthread_mutex_unlock(&spider_udf_table_mon_mutexes[ + table_mon_list->mutex_hash]); + DBUG_VOID_RETURN; +} + +void spider_release_ping_table_mon_list_loop( + uint mutex_hash, + SPIDER_TABLE_MON_LIST *table_mon_list +) { + DBUG_ENTER("spider_release_ping_table_mon_list_loop"); +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_udf_table_mon_list_hash[mutex_hash], + table_mon_list->key_hash_value, (uchar*) table_mon_list); +#else + my_hash_delete(&spider_udf_table_mon_list_hash[mutex_hash], + (uchar*) table_mon_list); +#endif + while (TRUE) + { + if (table_mon_list->use_count) + pthread_cond_wait(&spider_udf_table_mon_conds[mutex_hash], + &spider_udf_table_mon_mutexes[mutex_hash]); + else { + spider_ping_table_free_mon_list(table_mon_list); + break; + } + } + DBUG_VOID_RETURN; +} + +void spider_release_ping_table_mon_list( + const char *conv_name, + uint conv_name_length, + int link_idx +) { + uint mutex_hash; + SPIDER_TABLE_MON_LIST *table_mon_list; + char link_idx_str[SPIDER_SQL_INT_LEN]; + int link_idx_str_length; + DBUG_ENTER("spider_release_ping_table_mon_list"); + DBUG_PRINT("info", ("spider conv_name=%s", conv_name)); + DBUG_PRINT("info", ("spider conv_name_length=%u", conv_name_length)); + DBUG_PRINT("info", ("spider link_idx=%d", link_idx)); + link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d", + link_idx)); +#ifdef _MSC_VER + spider_string conv_name_str(conv_name_length + link_idx_str_length + 1); + conv_name_str.set_charset(system_charset_info); +#else + char buf[conv_name_length + link_idx_str_length + 1]; + spider_string conv_name_str(buf, conv_name_length + link_idx_str_length + 1, + system_charset_info); +#endif + conv_name_str.init_calc_mem(134); + conv_name_str.length(0); + conv_name_str.q_append(conv_name, conv_name_length); + conv_name_str.q_append(link_idx_str, link_idx_str_length); + + mutex_hash = spider_udf_calc_hash(conv_name_str.c_ptr_safe(), + spider_param_udf_table_mon_mutex_count()); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value = my_calc_hash( + &spider_udf_table_mon_list_hash[mutex_hash], + (uchar*) conv_name_str.c_ptr(), conv_name_str.length()); +#endif + pthread_mutex_lock(&spider_udf_table_mon_mutexes[mutex_hash]); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if ((table_mon_list = (SPIDER_TABLE_MON_LIST *) + my_hash_search_using_hash_value( + &spider_udf_table_mon_list_hash[mutex_hash], hash_value, + (uchar*) conv_name_str.c_ptr(), conv_name_str.length()))) +#else + if ((table_mon_list = (SPIDER_TABLE_MON_LIST *) my_hash_search( + &spider_udf_table_mon_list_hash[mutex_hash], + (uchar*) conv_name_str.c_ptr(), conv_name_str.length()))) +#endif + spider_release_ping_table_mon_list_loop(mutex_hash, table_mon_list); + pthread_mutex_unlock(&spider_udf_table_mon_mutexes[mutex_hash]); + DBUG_VOID_RETURN; +} + +int spider_get_ping_table_mon( + THD *thd, + SPIDER_TABLE_MON_LIST *table_mon_list, + char *name, + uint name_length, + int link_idx, + uint32 server_id, + MEM_ROOT *mem_root, + bool need_lock +) { + int error_num; + TABLE *table_link_mon = NULL; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + char table_key[MAX_KEY_LENGTH]; + SPIDER_TABLE_MON *table_mon, *table_mon_prev = NULL; + SPIDER_SHARE *tmp_share; + char **tmp_connect_info, *tmp_ptr; + uint *tmp_connect_info_length; + long *tmp_long; + longlong *tmp_longlong; + int list_size = 0; + DBUG_ENTER("spider_get_ping_table_mon"); + + if ( + !(table_link_mon = spider_open_sys_table( + thd, SPIDER_SYS_LINK_MON_TABLE_NAME_STR, + SPIDER_SYS_LINK_MON_TABLE_NAME_LEN, FALSE, &open_tables_backup, + need_lock, &error_num)) + ) { + my_error(error_num, MYF(0)); + goto error; + } + spider_store_tables_name(table_link_mon, name, name_length); + spider_store_tables_link_idx(table_link_mon, link_idx); + if (!(error_num = spider_ping_table_cache_compare(table_link_mon, mem_root))) + goto create_table_mon; + if (error_num == HA_ERR_OUT_OF_MEM) + goto error; + if ((tmp_ptr = strstr(name, "#P#"))) + { + *tmp_ptr = '\0'; + spider_store_tables_name(table_link_mon, name, strlen(name)); + *tmp_ptr = '#'; + if (!(error_num = spider_ping_table_cache_compare(table_link_mon, + mem_root))) + goto create_table_mon; + if (error_num == HA_ERR_OUT_OF_MEM) + goto error; + } + error_num = HA_ERR_KEY_NOT_FOUND; + table_link_mon->file->print_error(error_num, MYF(0)); + goto error; + +create_table_mon: + if ((error_num = spider_get_sys_table_by_idx(table_link_mon, table_key, + table_link_mon->s->primary_key, 3))) + { + table_link_mon->file->print_error(error_num, MYF(0)); + goto error; + } + + do { + if (!(table_mon = (SPIDER_TABLE_MON *) + spider_bulk_malloc(spider_current_trx, 35, MYF(MY_WME | MY_ZEROFILL), + &table_mon, sizeof(SPIDER_TABLE_MON), + &tmp_share, sizeof(SPIDER_SHARE), + &tmp_connect_info, sizeof(char *) * SPIDER_TMP_SHARE_CHAR_PTR_COUNT, + &tmp_connect_info_length, sizeof(uint) * SPIDER_TMP_SHARE_UINT_COUNT, + &tmp_long, sizeof(long) * SPIDER_TMP_SHARE_LONG_COUNT, + &tmp_longlong, sizeof(longlong) * SPIDER_TMP_SHARE_LONGLONG_COUNT, + NullS)) + ) { + spider_sys_index_end(table_link_mon); + error_num = HA_ERR_OUT_OF_MEM; + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + goto error; + } + spider_set_tmp_share_pointer(tmp_share, tmp_connect_info, + tmp_connect_info_length, tmp_long, tmp_longlong); + tmp_share->link_statuses[0] = -1; + table_mon->share = tmp_share; + if (table_mon_prev) + table_mon_prev->next = table_mon; + else + table_mon_list->first = table_mon; + table_mon_prev = table_mon; + if ( + (error_num = spider_get_sys_link_mon_server_id( + table_link_mon, &table_mon->server_id, mem_root)) || + (error_num = spider_get_sys_link_mon_connect_info( + table_link_mon, tmp_share, 0, mem_root)) + ) { + table_link_mon->file->print_error(error_num, MYF(0)); + spider_sys_index_end(table_link_mon); + goto error; + } + if ( + (error_num = spider_set_connect_info_default( + tmp_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + NULL, + NULL, +#endif + NULL + )) || + (error_num = spider_set_connect_info_default_dbtable( + tmp_share, name, name_length + )) || + (error_num = spider_create_conn_keys(tmp_share)) + ) { + spider_sys_index_end(table_link_mon); + goto error; + } + DBUG_PRINT("info",("spider table_mon->server_id=%u", + table_mon->server_id)); + DBUG_PRINT("info",("spider server_id=%u", server_id)); + if (table_mon->server_id == server_id) + table_mon_list->current = table_mon; + list_size++; + error_num = spider_sys_index_next_same(table_link_mon, table_key); + } while (error_num == 0); + spider_sys_index_end(table_link_mon); + spider_close_sys_table(thd, table_link_mon, + &open_tables_backup, need_lock); + table_link_mon = NULL; + table_mon_list->list_size = list_size; + + if (!table_mon_list->current) + { + error_num = ER_SPIDER_UDF_PING_TABLE_NO_SERVER_ID_NUM; + my_printf_error(ER_SPIDER_UDF_PING_TABLE_NO_SERVER_ID_NUM, + ER_SPIDER_UDF_PING_TABLE_NO_SERVER_ID_STR, MYF(0)); + goto error; + } + + DBUG_RETURN(0); + +error: + if (table_link_mon) + spider_close_sys_table(thd, table_link_mon, + &open_tables_backup, need_lock); + table_mon = table_mon_list->first; + table_mon_list->first = NULL; + table_mon_list->current = NULL; + while (table_mon) + { + spider_free_tmp_share_alloc(table_mon->share); + table_mon_prev = table_mon->next; + spider_free(spider_current_trx, table_mon, MYF(0)); + table_mon = table_mon_prev; + } + DBUG_RETURN(error_num); +} + +SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( + THD *thd, + char *name, + uint name_length, + int link_idx, + uint32 server_id, + spider_string *str, + bool need_lock, + int *error_num +) { + TABLE *table_tables = NULL; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + char table_key[MAX_KEY_LENGTH]; + + SPIDER_TABLE_MON_LIST *table_mon_list = NULL; + SPIDER_SHARE *tmp_share; + char **tmp_connect_info; + uint *tmp_connect_info_length; + long *tmp_long; + longlong *tmp_longlong; + char *key_str; + MEM_ROOT mem_root; + DBUG_ENTER("spider_get_ping_table_tgt"); + + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + if (!(table_mon_list = (SPIDER_TABLE_MON_LIST *) + spider_bulk_malloc(spider_current_trx, 36, MYF(MY_WME | MY_ZEROFILL), + &table_mon_list, sizeof(SPIDER_TABLE_MON_LIST), + &tmp_share, sizeof(SPIDER_SHARE), + &tmp_connect_info, sizeof(char *) * SPIDER_TMP_SHARE_CHAR_PTR_COUNT, + &tmp_connect_info_length, sizeof(uint) * SPIDER_TMP_SHARE_UINT_COUNT, + &tmp_long, sizeof(long) * SPIDER_TMP_SHARE_LONG_COUNT, + &tmp_longlong, sizeof(longlong) * SPIDER_TMP_SHARE_LONGLONG_COUNT, + &key_str, str->length() + 1, + NullS)) + ) { + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + goto error; + } + spider_set_tmp_share_pointer(tmp_share, tmp_connect_info, + tmp_connect_info_length, tmp_long, tmp_longlong); + table_mon_list->share = tmp_share; + table_mon_list->key = key_str; + table_mon_list->key_length = str->length(); + memcpy(key_str, str->ptr(), table_mon_list->key_length); + tmp_share->access_charset = thd->variables.character_set_client; + + if ( + !(table_tables = spider_open_sys_table( + thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup, need_lock, + error_num)) + ) { + my_error(*error_num, MYF(0)); + goto error; + } + spider_store_tables_name(table_tables, name, name_length); + spider_store_tables_link_idx(table_tables, link_idx); + if ( + (*error_num = spider_check_sys_table(table_tables, table_key)) || + (*error_num = spider_get_sys_tables_connect_info( + table_tables, tmp_share, 0, &mem_root)) || + (*error_num = spider_get_sys_tables_link_status( + table_tables, tmp_share, 0, &mem_root)) + ) { + table_tables->file->print_error(*error_num, MYF(0)); + goto error; + } + spider_close_sys_table(thd, table_tables, + &open_tables_backup, need_lock); + table_tables = NULL; + + if ( + (*error_num = spider_set_connect_info_default( + tmp_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + NULL, + NULL, +#endif + NULL + )) || + (*error_num = spider_set_connect_info_default_dbtable( + tmp_share, name, name_length + )) || + (*error_num = spider_create_conn_keys(tmp_share)) || +/* + (*error_num = spider_db_create_table_names_str(tmp_share)) || +*/ + (*error_num = spider_get_ping_table_mon( + thd, table_mon_list, name, name_length, link_idx, server_id, &mem_root, + need_lock)) + ) + goto error; + + if (tmp_share->link_statuses[0] == SPIDER_LINK_STATUS_NG) + table_mon_list->mon_status = SPIDER_LINK_MON_NG; + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&table_mon_list->caller_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_mon_list_caller, + &table_mon_list->caller_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_caller_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&table_mon_list->receptor_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_mon_list_receptor, + &table_mon_list->receptor_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_receptor_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&table_mon_list->monitor_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_mon_list_monitor, + &table_mon_list->monitor_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_monitor_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&table_mon_list->update_status_mutex, + MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_mon_list_update_status, + &table_mon_list->update_status_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_update_status_mutex_init; + } + + free_root(&mem_root, MYF(0)); + DBUG_RETURN(table_mon_list); + +error_update_status_mutex_init: + pthread_mutex_destroy(&table_mon_list->monitor_mutex); +error_monitor_mutex_init: + pthread_mutex_destroy(&table_mon_list->receptor_mutex); +error_receptor_mutex_init: + pthread_mutex_destroy(&table_mon_list->caller_mutex); +error_caller_mutex_init: +error: + if (table_tables) + spider_close_sys_table(thd, table_tables, + &open_tables_backup, need_lock); + free_root(&mem_root, MYF(0)); + if (table_mon_list) + { + spider_free_tmp_share_alloc(table_mon_list->share); + spider_free(spider_current_trx, table_mon_list, MYF(0)); + } + DBUG_RETURN(NULL); +} + +SPIDER_CONN *spider_get_ping_table_tgt_conn( + SPIDER_TRX *trx, + SPIDER_SHARE *share, + int *error_num +) { + SPIDER_CONN *conn; + DBUG_ENTER("spider_get_ping_table_tgt_conn"); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (trx == spider_global_trx) + pthread_mutex_lock(&spider_global_trx_mutex); +#endif + if ( + !(conn = spider_get_conn( + share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE, + SPIDER_CONN_KIND_MYSQL, error_num)) + ) { +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (trx == spider_global_trx) + pthread_mutex_unlock(&spider_global_trx_mutex); +#endif + my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), + share->server_names[0]); + *error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; + goto error; + } + conn->error_mode = 0; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (trx == spider_global_trx) + pthread_mutex_unlock(&spider_global_trx_mutex); +#endif + DBUG_RETURN(conn); + +error: + DBUG_RETURN(NULL); +} + +int spider_init_ping_table_mon_cache( + THD *thd, + MEM_ROOT *mem_root, + bool need_lock +) { + int error_num, same; + TABLE *table_link_mon = NULL; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + SPIDER_MON_KEY mon_key; + DBUG_ENTER("spider_init_ping_table_mon_cache"); + + if ( + !(table_link_mon = spider_open_sys_table( + thd, SPIDER_SYS_LINK_MON_TABLE_NAME_STR, + SPIDER_SYS_LINK_MON_TABLE_NAME_LEN, FALSE, &open_tables_backup, + need_lock, &error_num)) + ) { + my_error(error_num, MYF(0)); + goto error_open_sys_table; + } + + pthread_mutex_lock(&spider_mon_table_cache_mutex); + if (spider_mon_table_cache_version != spider_mon_table_cache_version_req) + { + /* reset */ + spider_mon_table_cache.elements = 0; + + if ((error_num = spider_sys_index_first(table_link_mon, + table_link_mon->s->primary_key))) + { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table_link_mon->file->print_error(error_num, MYF(0)); + goto error_sys_index_first; + } + } + + if (!error_num) + { + mon_key.db_name_length = SPIDER_SYS_LINK_MON_TABLE_DB_NAME_SIZE + 1; + mon_key.table_name_length = SPIDER_SYS_LINK_MON_TABLE_TABLE_NAME_SIZE + 1; + mon_key.link_id_length = SPIDER_SYS_LINK_MON_TABLE_LINK_ID_SIZE + 1; + do { + if ((error_num = spider_get_sys_link_mon_key(table_link_mon, &mon_key, + mem_root, &same))) + goto error_get_sys_link_mon_key; + + if (!same) + { + mon_key.sort = spider_calc_for_sort(3, mon_key.db_name, + mon_key.table_name, mon_key.link_id); + if (push_dynamic(&spider_mon_table_cache, (uchar *) &mon_key)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_push_dynamic; + } + } + + if ((error_num = spider_sys_index_next(table_link_mon))) + { + if ( + error_num != HA_ERR_KEY_NOT_FOUND && + error_num != HA_ERR_END_OF_FILE + ) { + table_link_mon->file->print_error(error_num, MYF(0)); + goto error_sys_index_next; + } + } + } while (!error_num); + spider_sys_index_end(table_link_mon); + } + my_qsort( + (uchar *) dynamic_element(&spider_mon_table_cache, 0, SPIDER_MON_KEY *), + spider_mon_table_cache.elements, sizeof(SPIDER_MON_KEY), + (qsort_cmp) spider_compare_for_sort); + uint old_elements = spider_mon_table_cache.max_element; + freeze_size(&spider_mon_table_cache); + if (spider_mon_table_cache.max_element < old_elements) + { + spider_free_mem_calc(spider_current_trx, + spider_mon_table_cache_id, + spider_mon_table_cache.max_element * + spider_mon_table_cache.size_of_element); + } + spider_mon_table_cache_version = spider_mon_table_cache_version_req; + } + pthread_mutex_unlock(&spider_mon_table_cache_mutex); + spider_close_sys_table(thd, table_link_mon, &open_tables_backup, need_lock); + DBUG_RETURN(0); + +error_push_dynamic: +error_get_sys_link_mon_key: +error_sys_index_next: + spider_sys_index_end(table_link_mon); +error_sys_index_first: + pthread_mutex_unlock(&spider_mon_table_cache_mutex); + spider_close_sys_table(thd, table_link_mon, &open_tables_backup, need_lock); +error_open_sys_table: + DBUG_RETURN(error_num); +} + +int spider_ping_table_cache_compare( + TABLE *table, + MEM_ROOT *mem_root +) { + uint32 roop_count; + SPIDER_MON_KEY *mon_key; + char *db_name, *table_name, *link_id; + DBUG_ENTER("spider_ping_table_cache_compare"); + + if ( + !(db_name = get_field(mem_root, table->field[0])) || + !(table_name = get_field(mem_root, table->field[1])) || + !(link_id = get_field(mem_root, table->field[2])) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_PRINT("info", ("spider db_name=%s", db_name)); + DBUG_PRINT("info", ("spider table_name=%s", table_name)); + DBUG_PRINT("info", ("spider link_id=%s", link_id)); + + pthread_mutex_lock(&spider_mon_table_cache_mutex); + for (roop_count = 0; roop_count < spider_mon_table_cache.elements; + roop_count++) + { + mon_key = dynamic_element(&spider_mon_table_cache, roop_count, + SPIDER_MON_KEY *); + DBUG_PRINT("info", ("spider roop_count=%d", roop_count)); + DBUG_PRINT("info", ("spider mon_key.db_name=%s", mon_key->db_name)); + DBUG_PRINT("info", ("spider mon_key.table_name=%s", mon_key->table_name)); + DBUG_PRINT("info", ("spider mon_key.link_id=%s", mon_key->link_id)); + if ( + !wild_case_compare(system_charset_info, db_name, mon_key->db_name) && + !wild_case_compare(system_charset_info, table_name, + mon_key->table_name) && + !wild_case_compare(system_charset_info, link_id, mon_key->link_id) + ) { + spider_store_db_and_table_name( + table, + mon_key->db_name, + mon_key->db_name_length, + mon_key->table_name, + mon_key->table_name_length + ); + spider_store_tables_link_idx_str( + table, + mon_key->link_id, + mon_key->link_id_length + ); + pthread_mutex_unlock(&spider_mon_table_cache_mutex); + DBUG_PRINT("info", ("spider found")); + DBUG_RETURN(0); + } + } + pthread_mutex_unlock(&spider_mon_table_cache_mutex); + DBUG_PRINT("info", ("spider not found")); + DBUG_RETURN(1); +} + +long long spider_ping_table_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +) { + int error_num = 0, link_idx, flags, full_mon_count, current_mon_count, + success_count, fault_count, tmp_error_num = 0; + uint32 first_sid; + longlong limit, tmp_sid = -1; + SPIDER_MON_TABLE_RESULT *mon_table_result = + (SPIDER_MON_TABLE_RESULT *) initid->ptr; + SPIDER_TRX *trx = mon_table_result->trx; + THD *thd = trx->thd; + SPIDER_CONN *ping_conn = NULL, *mon_conn; + char *where_clause; + SPIDER_TABLE_MON_LIST *table_mon_list; + SPIDER_TABLE_MON *table_mon; + + char buf[MAX_FIELD_WIDTH]; + spider_string conv_name(buf, sizeof(buf), system_charset_info); + int conv_name_length; + char link_idx_str[SPIDER_SQL_INT_LEN]; + int link_idx_str_length; + bool get_lock = FALSE; + DBUG_ENTER("spider_ping_table_body"); + conv_name.init_calc_mem(135); + conv_name.length(0); + if ( + thd->open_tables != 0 || + thd->handler_tables_hash.records != 0 || + thd->derived_tables != 0 || + thd->lock != 0 || +#if MYSQL_VERSION_ID < 50500 + thd->locked_tables != 0 || + thd->prelocked_mode != NON_PRELOCKED +#else + thd->locked_tables_list.locked_tables() || + thd->locked_tables_mode != LTM_NONE +#endif + ) { + if (thd->open_tables != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->open_tables", thd->open_tables); + } else if (thd->handler_tables_hash.records != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), + "thd->handler_tables_hash.records", + (longlong) thd->handler_tables_hash.records); + } else if (thd->derived_tables != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->derived_tables", thd->derived_tables); + } else if (thd->lock != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->lock", thd->lock); +#if MYSQL_VERSION_ID < 50500 + } else if (thd->locked_tables != 0) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->locked_tables", thd->locked_tables); + } else if (thd->prelocked_mode != NON_PRELOCKED) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), + "thd->prelocked_mode", (longlong) thd->prelocked_mode); +#else + } else if (thd->locked_tables_list.locked_tables()) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), + "thd->locked_tables_list.locked_tables()", + thd->locked_tables_list.locked_tables()); + } else if (thd->locked_tables_mode != LTM_NONE) + { + my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, + ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), + "thd->locked_tables_mode", (longlong) thd->locked_tables_mode); +#endif + } + goto error; + } + + if ( + args->lengths[0] > SPIDER_CONNECT_INFO_MAX_LEN + ) { + my_printf_error(ER_SPIDER_UDF_PING_TABLE_PARAM_TOO_LONG_NUM, + ER_SPIDER_UDF_PING_TABLE_PARAM_TOO_LONG_STR, MYF(0)); + goto error; + } + if ( + args->lengths[0] == 0 + ) { + my_printf_error(ER_SPIDER_UDF_PING_TABLE_PARAM_REQIRED_NUM, + ER_SPIDER_UDF_PING_TABLE_PARAM_REQIRED_STR, MYF(0)); + goto error; + } + + link_idx = (int) (args->args[1] ? *((longlong *) args->args[1]) : 0); + flags = (int) (args->args[2] ? *((longlong *) args->args[2]) : 0); + limit = args->args[3] ? *((longlong *) args->args[3]) : 0; + where_clause = args->args[4] ? args->args[4] : (char *) ""; + + link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d", + link_idx)); + + if (conv_name.append(args->args[0], args->lengths[0], + trx->thd->variables.character_set_client)) + { + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + goto error; + } + conv_name_length = conv_name.length(); + if (conv_name.reserve(link_idx_str_length + 1)) + { + my_error(HA_ERR_OUT_OF_MEM, MYF(0)); + goto error; + } + conv_name.q_append(link_idx_str, link_idx_str_length + 1); + conv_name.length(conv_name.length() - 1); + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 + if (!(table_mon_list = spider_get_ping_table_mon_list(trx, trx->thd, + &conv_name, conv_name_length, link_idx, global_system_variables.server_id, + TRUE, &error_num))) +#else + if (!(table_mon_list = spider_get_ping_table_mon_list(trx, trx->thd, + &conv_name, conv_name_length, link_idx, thd->server_id, TRUE, &error_num))) +#endif + goto error; + + if (table_mon_list->mon_status == SPIDER_LINK_MON_NG) + { + mon_table_result->result_status = SPIDER_LINK_MON_NG; + DBUG_PRINT("info", + ("spider mon_table_result->result_status=SPIDER_LINK_MON_NG 1")); + goto end; + } + + if (args->args[5]) + tmp_sid = *((longlong *) args->args[5]); + + if (tmp_sid >= 0) + { + first_sid = (uint32) tmp_sid; + full_mon_count = (int) (args->args[6] ? *((longlong *) args->args[6]) : 0); + current_mon_count = + (int) (args->args[7] ? *((longlong *) args->args[7]) + 1 : 1); + if (full_mon_count != table_mon_list->list_size) + { + my_printf_error(ER_SPIDER_UDF_PING_TABLE_DIFFERENT_MON_NUM, + ER_SPIDER_UDF_PING_TABLE_DIFFERENT_MON_STR, MYF(0)); + goto error_with_free_table_mon_list; + } + } else { +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 + first_sid = global_system_variables.server_id; +#else + first_sid = thd->server_id; +#endif + full_mon_count = table_mon_list->list_size; + current_mon_count = 1; + } + + success_count = (int) (args->args[8] ? *((longlong *) args->args[8]) : 0); + fault_count = (int) (args->args[9] ? *((longlong *) args->args[9]) : 0); + if ( + table_mon_list->mon_status != SPIDER_LINK_MON_NG && + !(ping_conn = spider_get_ping_table_tgt_conn(trx, + table_mon_list->share, &error_num)) + ) { + if (error_num == HA_ERR_OUT_OF_MEM) + goto error_with_free_table_mon_list; + else + thd->clear_error(); + } + if ( + table_mon_list->mon_status == SPIDER_LINK_MON_NG || + error_num || + (tmp_error_num = spider_db_udf_ping_table(table_mon_list, table_mon_list->share, trx, + ping_conn, where_clause, args->lengths[4], + (flags & SPIDER_UDF_PING_TABLE_PING_ONLY), + (flags & SPIDER_UDF_PING_TABLE_USE_WHERE), + limit + )) + ) { + if (tmp_error_num == HA_ERR_OUT_OF_MEM) + goto error_with_free_table_mon_list; + else if(tmp_error_num) + thd->clear_error(); + fault_count++; + error_num = 0; + if (fault_count > full_mon_count / 2) + { + mon_table_result->result_status = SPIDER_LINK_MON_NG; + DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_NG 2")); + if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) + { + pthread_mutex_lock(&table_mon_list->update_status_mutex); + if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) + { + table_mon_list->mon_status = SPIDER_LINK_MON_NG; + table_mon_list->share->link_statuses[0] = SPIDER_LINK_STATUS_NG; + spider_sys_update_tables_link_status(trx->thd, + conv_name.c_ptr(), conv_name_length, link_idx, + SPIDER_LINK_STATUS_NG, TRUE); + spider_sys_log_tables_link_failed(trx->thd, + conv_name.c_ptr(), conv_name_length, link_idx, TRUE); + } + pthread_mutex_unlock(&table_mon_list->update_status_mutex); + } + goto end; + } + } else { + success_count++; + if (success_count > full_mon_count / 2) + { + mon_table_result->result_status = SPIDER_LINK_MON_OK; + DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_OK 1")); + goto end; + } + } + + if (tmp_sid < 0) + { + if (!pthread_mutex_trylock(&table_mon_list->receptor_mutex)) + get_lock = TRUE; + } + + if ( + tmp_sid >= 0 || + get_lock + ) { + table_mon = table_mon_list->current->next; + while (TRUE) + { + if (!table_mon) + table_mon = table_mon_list->first; + if ( + table_mon->server_id == first_sid || + current_mon_count > full_mon_count + ) { + if (success_count + fault_count > full_mon_count / 2) + { + mon_table_result->result_status = SPIDER_LINK_MON_DRAW; + DBUG_PRINT("info",( + "spider mon_table_result->result_status=SPIDER_LINK_MON_DRAW 1")); + } else { + mon_table_result->result_status = SPIDER_LINK_MON_DRAW_FEW_MON; + DBUG_PRINT("info",( + "spider mon_table_result->result_status=SPIDER_LINK_MON_DRAW_FEW_MON 1")); + } + table_mon_list->last_receptor_result = mon_table_result->result_status; + break; + } + if ((mon_conn = spider_get_ping_table_tgt_conn(trx, + table_mon->share, &error_num)) + ) { + if (!spider_db_udf_ping_table_mon_next( + thd, table_mon, mon_conn, mon_table_result, args->args[0], + args->lengths[0], link_idx, + where_clause, args->lengths[4], first_sid, full_mon_count, + current_mon_count, success_count, fault_count, flags, limit)) + { + if ( + mon_table_result->result_status == SPIDER_LINK_MON_NG && + table_mon_list->mon_status != SPIDER_LINK_MON_NG + ) { + pthread_mutex_lock(&table_mon_list->update_status_mutex); + if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) + { + table_mon_list->mon_status = SPIDER_LINK_MON_NG; + table_mon_list->share->link_statuses[0] = SPIDER_LINK_STATUS_NG; + spider_sys_update_tables_link_status(trx->thd, + conv_name.c_ptr(), conv_name_length, link_idx, + SPIDER_LINK_STATUS_NG, TRUE); + spider_sys_log_tables_link_failed(trx->thd, + conv_name.c_ptr(), conv_name_length, link_idx, TRUE); + } + pthread_mutex_unlock(&table_mon_list->update_status_mutex); + } + table_mon_list->last_receptor_result = + mon_table_result->result_status; + break; + } + } + thd->clear_error(); + table_mon = table_mon->next; + current_mon_count++; + } + if (get_lock) + pthread_mutex_unlock(&table_mon_list->receptor_mutex); + } else { + pthread_mutex_lock(&table_mon_list->receptor_mutex); + mon_table_result->result_status = table_mon_list->last_receptor_result; + DBUG_PRINT("info",("spider mon_table_result->result_status=%d 1", + table_mon_list->last_receptor_result)); + pthread_mutex_unlock(&table_mon_list->receptor_mutex); + } + +end: + spider_free_ping_table_mon_list(table_mon_list); + DBUG_RETURN(mon_table_result->result_status); + +error_with_free_table_mon_list: + spider_free_ping_table_mon_list(table_mon_list); +error: + *error = 1; + DBUG_RETURN(0); +} + +my_bool spider_ping_table_init_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +) { + int error_num; + THD *thd = current_thd; + SPIDER_TRX *trx; + SPIDER_MON_TABLE_RESULT *mon_table_result = NULL; + DBUG_ENTER("spider_ping_table_init_body"); + if (args->arg_count != 10) + { + strcpy(message, "spider_ping_table() requires 10 arguments"); + goto error; + } + if ( + args->arg_type[0] != STRING_RESULT || + args->arg_type[4] != STRING_RESULT + ) { + strcpy(message, "spider_ping_table() requires string 1st " + "and 5th arguments"); + goto error; + } + if ( + args->arg_type[1] != INT_RESULT || + args->arg_type[2] != INT_RESULT || + args->arg_type[3] != INT_RESULT || + args->arg_type[5] != INT_RESULT || + args->arg_type[6] != INT_RESULT || + args->arg_type[7] != INT_RESULT || + args->arg_type[8] != INT_RESULT || + args->arg_type[9] != INT_RESULT + ) { + strcpy(message, "spider_ping_table() requires integer 2nd, 3rd, 4,6,7,8," + "9th and 10th argument"); + goto error; + } + + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + { + my_error(error_num, MYF(0)); +#if MYSQL_VERSION_ID < 50500 + strcpy(message, thd->main_da.message()); +#else + strcpy(message, thd->stmt_da->message()); +#endif + goto error; + } + + if (!(mon_table_result = (SPIDER_MON_TABLE_RESULT *) + spider_malloc(spider_current_trx, 11, sizeof(SPIDER_MON_TABLE_RESULT), + MYF(MY_WME | MY_ZEROFILL))) + ) { + strcpy(message, "spider_ping_table() out of memory"); + goto error; + } + mon_table_result->trx = trx; + initid->ptr = (char *) mon_table_result; + DBUG_RETURN(FALSE); + +error: + if (mon_table_result) + { + spider_free(spider_current_trx, mon_table_result, MYF(0)); + } + DBUG_RETURN(TRUE); +} + +void spider_ping_table_deinit_body( + UDF_INIT *initid +) { + SPIDER_MON_TABLE_RESULT *mon_table_result = + (SPIDER_MON_TABLE_RESULT *) initid->ptr; + DBUG_ENTER("spider_ping_table_deinit_body"); + if (mon_table_result) + { + spider_free(spider_current_trx, mon_table_result, MYF(0)); + } + DBUG_VOID_RETURN; +} + +long long spider_flush_table_mon_cache_body() +{ + DBUG_ENTER("spider_flush_table_mon_cache_body"); + spider_mon_table_cache_version_req++; + DBUG_RETURN(1); +} + +void spider_ping_table_free_mon_list( + SPIDER_TABLE_MON_LIST *table_mon_list +) { + DBUG_ENTER("spider_ping_table_free_mon_list"); + if (table_mon_list) + { + spider_ping_table_free_mon(table_mon_list->first); + spider_free_tmp_share_alloc(table_mon_list->share); + pthread_mutex_destroy(&table_mon_list->update_status_mutex); + pthread_mutex_destroy(&table_mon_list->monitor_mutex); + pthread_mutex_destroy(&table_mon_list->receptor_mutex); + pthread_mutex_destroy(&table_mon_list->caller_mutex); + spider_free(spider_current_trx, table_mon_list, MYF(0)); + } + DBUG_VOID_RETURN; +} + +void spider_ping_table_free_mon( + SPIDER_TABLE_MON *table_mon +) { + SPIDER_TABLE_MON *table_mon_next; + DBUG_ENTER("spider_ping_table_free_mon"); + while (table_mon) + { + spider_free_tmp_share_alloc(table_mon->share); + table_mon_next = table_mon->next; + spider_free(spider_current_trx, table_mon, MYF(0)); + table_mon = table_mon_next; + } + DBUG_VOID_RETURN; +} + +int spider_ping_table_mon_from_table( + SPIDER_TRX *trx, + THD *thd, + SPIDER_SHARE *share, + uint32 server_id, + char *conv_name, + uint conv_name_length, + int link_idx, + char *where_clause, + uint where_clause_length, + long monitoring_kind, + longlong monitoring_limit, + bool need_lock +) { + int error_num = 0, current_mon_count, flags; + uint32 first_sid; +/* + THD *thd = trx->thd; +*/ + SPIDER_TABLE_MON_LIST *table_mon_list; + SPIDER_TABLE_MON *table_mon; + SPIDER_MON_TABLE_RESULT mon_table_result; + SPIDER_CONN *mon_conn; + TABLE_SHARE *table_share = share->table_share; + char link_idx_str[SPIDER_SQL_INT_LEN]; + int link_idx_str_length; + uint sql_command = thd_sql_command(thd); + DBUG_ENTER("spider_ping_table_mon_from_table"); + if (table_share->tmp_table != NO_TMP_TABLE) + { + my_printf_error(ER_SPIDER_TMP_TABLE_MON_NUM, + ER_SPIDER_TMP_TABLE_MON_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_TMP_TABLE_MON_NUM); + } + if ( + sql_command == SQLCOM_DROP_TABLE || + sql_command == SQLCOM_ALTER_TABLE + ) { + my_printf_error(ER_SPIDER_MON_AT_ALTER_TABLE_NUM, + ER_SPIDER_MON_AT_ALTER_TABLE_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_MON_AT_ALTER_TABLE_NUM); + } + + link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d", + link_idx)); +#ifdef _MSC_VER + spider_string conv_name_str(conv_name_length + link_idx_str_length + 1); + conv_name_str.set_charset(system_charset_info); + *((char *)(conv_name_str.ptr() + conv_name_length + link_idx_str_length)) = + '\0'; +#else + char buf[conv_name_length + link_idx_str_length + 1]; + buf[conv_name_length + link_idx_str_length] = '\0'; + spider_string conv_name_str(buf, conv_name_length + link_idx_str_length + 1, + system_charset_info); +#endif + conv_name_str.init_calc_mem(136); + conv_name_str.length(0); + conv_name_str.q_append(conv_name, conv_name_length); + conv_name_str.q_append(link_idx_str, link_idx_str_length + 1); + conv_name_str.length(conv_name_str.length() - 1); + + if (monitoring_kind == 1) + flags = SPIDER_UDF_PING_TABLE_PING_ONLY; + else if (monitoring_kind == 3) + flags = SPIDER_UDF_PING_TABLE_USE_WHERE; + else + flags = 0; + + if (!(table_mon_list = spider_get_ping_table_mon_list(trx, thd, + &conv_name_str, conv_name_length, link_idx, server_id, need_lock, + &error_num))) + goto end; + + if (table_mon_list->mon_status == SPIDER_LINK_MON_NG) + { + DBUG_PRINT("info", + ("spider share->link_statuses[%d]=SPIDER_LINK_STATUS_NG", link_idx)); + share->link_statuses[link_idx] = SPIDER_LINK_STATUS_NG; + error_num = ER_SPIDER_LINK_MON_NG_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_NG_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + goto end_with_free_table_mon_list; + } + + if (!pthread_mutex_trylock(&table_mon_list->caller_mutex)) + { + table_mon = table_mon_list->current; + first_sid = table_mon->server_id; + current_mon_count = 1; + while (TRUE) + { + if (!table_mon) + table_mon = table_mon_list->first; + if ( + current_mon_count > table_mon_list->list_size || + (current_mon_count > 1 && table_mon->server_id == first_sid) + ) { + table_mon_list->last_caller_result = SPIDER_LINK_MON_DRAW_FEW_MON; + mon_table_result.result_status = SPIDER_LINK_MON_DRAW_FEW_MON; + DBUG_PRINT("info",( + "spider mon_table_result->result_status=SPIDER_LINK_MON_DRAW_FEW_MON 1")); + error_num = ER_SPIDER_LINK_MON_DRAW_FEW_MON_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_DRAW_FEW_MON_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + } + thd->clear_error(); + if ((mon_conn = spider_get_ping_table_tgt_conn(trx, + table_mon->share, &error_num)) + ) { + if (!spider_db_udf_ping_table_mon_next( + thd, table_mon, mon_conn, &mon_table_result, conv_name, + conv_name_length, link_idx, + where_clause, where_clause_length, -1, table_mon_list->list_size, + 0, 0, 0, flags, monitoring_limit)) + { + if ( + mon_table_result.result_status == SPIDER_LINK_MON_NG && + table_mon_list->mon_status != SPIDER_LINK_MON_NG + ) { + pthread_mutex_lock(&table_mon_list->update_status_mutex); + if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) + { + table_mon_list->mon_status = SPIDER_LINK_MON_NG; + table_mon_list->share->link_statuses[0] = SPIDER_LINK_STATUS_NG; + DBUG_PRINT("info", ( + "spider share->link_statuses[%d]=SPIDER_LINK_STATUS_NG", + link_idx)); + share->link_statuses[link_idx] = SPIDER_LINK_STATUS_NG; + spider_sys_update_tables_link_status(thd, conv_name, + conv_name_length, link_idx, SPIDER_LINK_STATUS_NG, need_lock); + spider_sys_log_tables_link_failed(thd, conv_name, + conv_name_length, link_idx, need_lock); + } + pthread_mutex_unlock(&table_mon_list->update_status_mutex); + } + table_mon_list->last_caller_result = mon_table_result.result_status; + if (mon_table_result.result_status == SPIDER_LINK_MON_OK) + { + error_num = ER_SPIDER_LINK_MON_OK_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_OK_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + } + if (mon_table_result.result_status == SPIDER_LINK_MON_NG) + { + error_num = ER_SPIDER_LINK_MON_NG_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_NG_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + } + if (mon_table_result.result_status == + SPIDER_LINK_MON_DRAW_FEW_MON) + { + error_num = ER_SPIDER_LINK_MON_DRAW_FEW_MON_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_DRAW_FEW_MON_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + } + error_num = ER_SPIDER_LINK_MON_DRAW_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_DRAW_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + } + } + table_mon = table_mon->next; + current_mon_count++; + } + pthread_mutex_unlock(&table_mon_list->caller_mutex); + } else { + pthread_mutex_lock(&table_mon_list->caller_mutex); + switch (table_mon_list->last_caller_result) + { + case SPIDER_LINK_MON_OK: + error_num = ER_SPIDER_LINK_MON_OK_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_OK_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + case SPIDER_LINK_MON_NG: + error_num = ER_SPIDER_LINK_MON_NG_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_NG_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + case SPIDER_LINK_MON_DRAW_FEW_MON: + error_num = ER_SPIDER_LINK_MON_DRAW_FEW_MON_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_DRAW_FEW_MON_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + default: + error_num = ER_SPIDER_LINK_MON_DRAW_NUM; + my_printf_error(error_num, + ER_SPIDER_LINK_MON_DRAW_STR, MYF(0), + table_mon_list->share->tgt_dbs[0], + table_mon_list->share->tgt_table_names[0]); + break; + } + pthread_mutex_unlock(&table_mon_list->caller_mutex); + } + +end_with_free_table_mon_list: + spider_free_ping_table_mon_list(table_mon_list); +end: + DBUG_RETURN(error_num); +} diff --git a/storage/spider/spd_ping_table.h b/storage/spider/spd_ping_table.h new file mode 100644 index 00000000000..aca93012d78 --- /dev/null +++ b/storage/spider/spd_ping_table.h @@ -0,0 +1,102 @@ +/* Copyright (C) 2009-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( + SPIDER_TRX *trx, + THD *thd, + spider_string *str, + uint conv_name_length, + int link_idx, + uint32 server_id, + bool need_lock, + int *error_num +); + +void spider_free_ping_table_mon_list( + SPIDER_TABLE_MON_LIST *table_mon_list +); + +void spider_release_ping_table_mon_list_loop( + uint mutex_hash, + SPIDER_TABLE_MON_LIST *table_mon_list +); + +void spider_release_ping_table_mon_list( + const char *conv_name, + uint conv_name_length, + int link_idx +); + +int spider_get_ping_table_mon( + THD *thd, + SPIDER_TABLE_MON_LIST *table_mon_list, + char *name, + uint name_length, + int link_idx, + uint32 server_id, + MEM_ROOT *mem_root, + bool need_lock +); + +SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( + THD *thd, + char *name, + uint name_length, + int link_idx, + uint32 server_id, + spider_string *str, + bool need_lock, + int *error_num +); + +SPIDER_CONN *spider_get_ping_table_tgt_conn( + SPIDER_TRX *trx, + SPIDER_SHARE *share, + int *error_num +); + +int spider_init_ping_table_mon_cache( + THD *thd, + MEM_ROOT *mem_root, + bool need_lock +); + +int spider_ping_table_cache_compare( + TABLE *table, + MEM_ROOT *mem_root +); + +void spider_ping_table_free_mon_list( + SPIDER_TABLE_MON_LIST *table_mon_list +); + +void spider_ping_table_free_mon( + SPIDER_TABLE_MON *table_mon +); + +int spider_ping_table_mon_from_table( + SPIDER_TRX *trx, + THD *thd, + SPIDER_SHARE *share, + uint32 server_id, + char *conv_name, + uint conv_name_length, + int link_idx, + char *where_clause, + uint where_clause_length, + long monitoring_kind, + longlong monitoring_limit, + bool need_lock +); diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc new file mode 100644 index 00000000000..3e300bd21c9 --- /dev/null +++ b/storage/spider/spd_sys_table.cc @@ -0,0 +1,2417 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "key.h" +#include "sql_base.h" +#endif +#include "sql_select.h" +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_sys_table.h" +#include "spd_malloc.h" + +extern handlerton *spider_hton_ptr; + +#if MYSQL_VERSION_ID < 50500 +TABLE *spider_open_sys_table( + THD *thd, + const char *table_name, + int table_name_length, + bool write, + Open_tables_state *open_tables_backup, + bool need_lock, + int *error_num +) +#else +TABLE *spider_open_sys_table( + THD *thd, + const char *table_name, + int table_name_length, + bool write, + Open_tables_backup *open_tables_backup, + bool need_lock, + int *error_num +) +#endif +{ + TABLE *table; + TABLE_LIST tables; +#if MYSQL_VERSION_ID < 50500 + TABLE_SHARE *table_share; + char table_key[MAX_DBKEY_LENGTH]; + uint table_key_length; +#endif + DBUG_ENTER("spider_open_sys_table"); + +#if MYSQL_VERSION_ID < 50500 + memset(&tables, 0, sizeof(TABLE_LIST)); + tables.db = (char*)"mysql"; + tables.db_length = sizeof("mysql") - 1; + tables.alias = tables.table_name = (char *) table_name; + tables.table_name_length = table_name_length; + tables.lock_type = (write ? TL_WRITE : TL_READ); +#else + tables.init_one_table( + "mysql", sizeof("mysql") - 1, table_name, table_name_length, table_name, + (write ? TL_WRITE : TL_READ)); +#endif + +#if MYSQL_VERSION_ID < 50500 + if (need_lock) + { +#endif +#if MYSQL_VERSION_ID < 50500 + if (!(table = open_performance_schema_table(thd, &tables, + open_tables_backup))) +#else + if (!(table = spider_sys_open_table(thd, &tables, open_tables_backup))) +#endif + { + *error_num = my_errno; + DBUG_RETURN(NULL); + } +#if MYSQL_VERSION_ID < 50500 + } else { + thd->reset_n_backup_open_tables_state(open_tables_backup); + + if (!(table = (TABLE*) spider_malloc(spider_current_trx, 12, + sizeof(*table), MYF(MY_WME)))) + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_malloc; + } + + table_key_length = + create_table_def_key(thd, table_key, &tables, FALSE); + + if (!(table_share = get_table_share(thd, + &tables, table_key, table_key_length, 0, error_num))) + goto error; + if (open_table_from_share(thd, table_share, tables.alias, + (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX), + READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD, + (uint) HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_FROM_SQL_LAYER, + table, FALSE) + ) { + release_table_share(table_share, RELEASE_NORMAL); + *error_num = my_errno; + goto error; + } + } +#endif + if (table_name_length == SPIDER_SYS_XA_TABLE_NAME_LEN) + { + if ( + !memcmp(table_name, + SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN) && + table->s->fields != SPIDER_SYS_XA_COL_CNT + ) { + spider_close_sys_table(thd, table, open_tables_backup, need_lock); + spider_free(spider_current_trx, table, MYF(0)); + my_printf_error(ER_SPIDER_SYS_TABLE_VERSION_NUM, + ER_SPIDER_SYS_TABLE_VERSION_STR, MYF(0), + SPIDER_SYS_XA_TABLE_NAME_STR); + *error_num = ER_SPIDER_SYS_TABLE_VERSION_NUM; + goto error_col_num_chk; + } + } else if (table_name_length == SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN) + { + if ( + !memcmp(table_name, + SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR, + SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN) && + table->s->fields != SPIDER_SYS_XA_MEMBER_COL_CNT + ) { + spider_close_sys_table(thd, table, open_tables_backup, need_lock); + spider_free(spider_current_trx, table, MYF(0)); + my_printf_error(ER_SPIDER_SYS_TABLE_VERSION_NUM, + ER_SPIDER_SYS_TABLE_VERSION_STR, MYF(0), + SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR); + *error_num = ER_SPIDER_SYS_TABLE_VERSION_NUM; + goto error_col_num_chk; + } + } else if (table_name_length == SPIDER_SYS_TABLES_TABLE_NAME_LEN) + { + if ( + !memcmp(table_name, + SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN) && + table->s->fields != SPIDER_SYS_TABLES_COL_CNT + ) { + spider_close_sys_table(thd, table, open_tables_backup, need_lock); + spider_free(spider_current_trx, table, MYF(0)); + my_printf_error(ER_SPIDER_SYS_TABLE_VERSION_NUM, + ER_SPIDER_SYS_TABLE_VERSION_STR, MYF(0), + SPIDER_SYS_TABLES_TABLE_NAME_STR); + *error_num = ER_SPIDER_SYS_TABLE_VERSION_NUM; + goto error_col_num_chk; + } + } else if (table_name_length == SPIDER_SYS_LINK_MON_TABLE_NAME_LEN) + { + if ( + !memcmp(table_name, + SPIDER_SYS_LINK_MON_TABLE_NAME_STR, + SPIDER_SYS_LINK_MON_TABLE_NAME_LEN) && + table->s->fields != SPIDER_SYS_LINK_MON_TABLE_COL_CNT + ) { + spider_close_sys_table(thd, table, open_tables_backup, need_lock); + spider_free(spider_current_trx, table, MYF(0)); + my_printf_error(ER_SPIDER_SYS_TABLE_VERSION_NUM, + ER_SPIDER_SYS_TABLE_VERSION_STR, MYF(0), + SPIDER_SYS_LINK_MON_TABLE_NAME_STR); + *error_num = ER_SPIDER_SYS_TABLE_VERSION_NUM; + goto error_col_num_chk; + } + } + DBUG_RETURN(table); + +#if MYSQL_VERSION_ID < 50500 +error: + spider_free(spider_current_trx, table, MYF(0)); +error_malloc: + thd->restore_backup_open_tables_state(open_tables_backup); +#endif +error_col_num_chk: + DBUG_RETURN(NULL); +} + +#if MYSQL_VERSION_ID < 50500 +void spider_close_sys_table( + THD *thd, + TABLE *table, + Open_tables_state *open_tables_backup, + bool need_lock +) +#else +void spider_close_sys_table( + THD *thd, + TABLE *table, + Open_tables_backup *open_tables_backup, + bool need_lock +) +#endif +{ + DBUG_ENTER("spider_close_sys_table"); +#if MYSQL_VERSION_ID < 50500 + if (need_lock) + { + close_performance_schema_table(thd, open_tables_backup); + } else { + table->file->ha_reset(); + closefrm(table, TRUE); + spider_free(spider_current_trx, table, MYF(0)); + thd->restore_backup_open_tables_state(open_tables_backup); + } +#else + spider_sys_close_table(thd, open_tables_backup); +#endif + DBUG_VOID_RETURN; +} + +#if MYSQL_VERSION_ID < 50500 +#else +bool spider_sys_open_tables( + THD *thd, + TABLE_LIST **tables, + Open_tables_backup *open_tables_backup +) { + uint counter; + ulonglong utime_after_lock_backup = thd->utime_after_lock; + DBUG_ENTER("spider_sys_open_tables"); + thd->reset_n_backup_open_tables_state(open_tables_backup); + if (open_tables(thd, tables, &counter, + MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY | + MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT | MYSQL_LOCK_LOG_TABLE + )) { + thd->restore_backup_open_tables_state(open_tables_backup); + thd->utime_after_lock = utime_after_lock_backup; + DBUG_RETURN(TRUE); + } + thd->utime_after_lock = utime_after_lock_backup; + DBUG_RETURN(FALSE); +} + +TABLE *spider_sys_open_table( + THD *thd, + TABLE_LIST *tables, + Open_tables_backup *open_tables_backup +) { + TABLE *table; + ulonglong utime_after_lock_backup = thd->utime_after_lock; + DBUG_ENTER("spider_sys_open_table"); + thd->reset_n_backup_open_tables_state(open_tables_backup); + if ((table = open_ltable(thd, tables, tables->lock_type, + MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY | + MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT | MYSQL_LOCK_LOG_TABLE + ))) { + table->use_all_columns(); + table->no_replicate = 1; + } else + thd->restore_backup_open_tables_state(open_tables_backup); + thd->utime_after_lock = utime_after_lock_backup; + DBUG_RETURN(table); +} + +void spider_sys_close_table( + THD *thd, + Open_tables_backup *open_tables_backup +) { + DBUG_ENTER("spider_sys_close_table"); + close_thread_tables(thd); + thd->restore_backup_open_tables_state(open_tables_backup); + DBUG_VOID_RETURN; +} +#endif + +int spider_sys_index_init( + TABLE *table, + uint idx, + bool sorted +) { + DBUG_ENTER("spider_sys_index_init"); + DBUG_RETURN(table->file->ha_index_init(idx, sorted)); +} + +int spider_sys_index_end( + TABLE *table +) { + DBUG_ENTER("spider_sys_index_end"); + DBUG_RETURN(table->file->ha_index_end()); +} + +int spider_sys_rnd_init( + TABLE *table, + bool scan +) { + DBUG_ENTER("spider_sys_rnd_init"); + DBUG_RETURN(table->file->ha_rnd_init(scan)); +} + +int spider_sys_rnd_end( + TABLE *table +) { + DBUG_ENTER("spider_sys_rnd_end"); + DBUG_RETURN(table->file->ha_rnd_end()); +} + +int spider_check_sys_table( + TABLE *table, + char *table_key +) { + DBUG_ENTER("spider_check_sys_table"); + + key_copy( + (uchar *) table_key, + table->record[0], + table->key_info, + table->key_info->key_length); + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + DBUG_RETURN(table->file->ha_index_read_idx_map( + table->record[0], 0, (uchar *) table_key, + HA_WHOLE_KEY, HA_READ_KEY_EXACT)); +#else + DBUG_RETURN(table->file->index_read_idx_map( + table->record[0], 0, (uchar *) table_key, + HA_WHOLE_KEY, HA_READ_KEY_EXACT)); +#endif +} + +int spider_check_sys_table_with_find_flag( + TABLE *table, + char *table_key, + enum ha_rkey_function find_flag +) { + DBUG_ENTER("spider_check_sys_table"); + + key_copy( + (uchar *) table_key, + table->record[0], + table->key_info, + table->key_info->key_length); + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + DBUG_RETURN(table->file->ha_index_read_idx_map( + table->record[0], 0, (uchar *) table_key, + HA_WHOLE_KEY, find_flag)); +#else + DBUG_RETURN(table->file->index_read_idx_map( + table->record[0], 0, (uchar *) table_key, + HA_WHOLE_KEY, find_flag)); +#endif +} + +int spider_get_sys_table_by_idx( + TABLE *table, + char *table_key, + const int idx, + const int col_count +) { + int error_num; + DBUG_ENTER("spider_get_sys_table_by_idx"); + if ((error_num = spider_sys_index_init(table, idx, FALSE))) + DBUG_RETURN(error_num); + + key_copy( + (uchar *) table_key, + table->record[0], + table->key_info, + table->key_info->key_length); + + if ( +/* +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + (error_num = table->file->ha_index_read_idx_map( + table->record[0], idx, (uchar *) table_key, + make_prev_keypart_map(col_count), HA_READ_KEY_EXACT)) +#else + (error_num = table->file->index_read_idx_map( + table->record[0], idx, (uchar *) table_key, + make_prev_keypart_map(col_count), HA_READ_KEY_EXACT)) +#endif +*/ +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + (error_num = table->file->ha_index_read_map( + table->record[0], (uchar *) table_key, + make_prev_keypart_map(col_count), HA_READ_KEY_EXACT)) +#else + (error_num = table->file->index_read_map( + table->record[0], (uchar *) table_key, + make_prev_keypart_map(col_count), HA_READ_KEY_EXACT)) +#endif + ) { + spider_sys_index_end(table); + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_sys_index_next_same( + TABLE *table, + char *table_key +) { + DBUG_ENTER("spider_sys_index_next_same"); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + DBUG_RETURN(table->file->ha_index_next_same( + table->record[0], + (const uchar*) table_key, + table->key_info->key_length)); +#else + DBUG_RETURN(table->file->index_next_same( + table->record[0], + (const uchar*) table_key, + table->key_info->key_length)); +#endif +} + +int spider_sys_index_first( + TABLE *table, + const int idx +) { + int error_num; + DBUG_ENTER("spider_sys_index_first"); + if ((error_num = spider_sys_index_init(table, idx, FALSE))) + DBUG_RETURN(error_num); + + if ( +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + (error_num = table->file->ha_index_first(table->record[0])) +#else + (error_num = table->file->index_first(table->record[0])) +#endif + ) { + spider_sys_index_end(table); + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_sys_index_next( + TABLE *table +) { + DBUG_ENTER("spider_sys_index_next"); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + DBUG_RETURN(table->file->ha_index_next(table->record[0])); +#else + DBUG_RETURN(table->file->index_next(table->record[0])); +#endif +} + +void spider_store_xa_pk( + TABLE *table, + XID *xid +) { + DBUG_ENTER("spider_store_xa_pk"); + table->field[0]->store(xid->formatID); + table->field[1]->store(xid->gtrid_length); + table->field[3]->store( + xid->data, + (uint) xid->gtrid_length + xid->bqual_length, + system_charset_info); + DBUG_VOID_RETURN; +} + +void spider_store_xa_bqual_length( + TABLE *table, + XID *xid +) { + DBUG_ENTER("spider_store_xa_bqual_length"); + table->field[2]->store(xid->bqual_length); + DBUG_VOID_RETURN; +} + +void spider_store_xa_status( + TABLE *table, + const char *status +) { + DBUG_ENTER("spider_store_xa_status"); + table->field[4]->store( + status, + (uint) strlen(status), + system_charset_info); + DBUG_VOID_RETURN; +} + +void spider_store_xa_member_pk( + TABLE *table, + XID *xid, + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_store_xa_member_pk"); + table->field[0]->store(xid->formatID); + table->field[1]->store(xid->gtrid_length); + table->field[3]->store( + xid->data, + (uint) xid->gtrid_length + xid->bqual_length, + system_charset_info); + table->field[5]->store( + conn->tgt_host, + (uint) conn->tgt_host_length, + system_charset_info); + table->field[6]->store( + conn->tgt_port); + table->field[7]->store( + conn->tgt_socket, + (uint) conn->tgt_socket_length, + system_charset_info); + DBUG_VOID_RETURN; +} + +void spider_store_xa_member_info( + TABLE *table, + XID *xid, + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_store_xa_member_info"); + table->field[2]->store(xid->bqual_length); + table->field[4]->store( + conn->tgt_wrapper, + (uint) conn->tgt_wrapper_length, + system_charset_info); + table->field[8]->store( + conn->tgt_username, + (uint) conn->tgt_username_length, + system_charset_info); + table->field[9]->store( + conn->tgt_password, + (uint) conn->tgt_password_length, + system_charset_info); + if (conn->tgt_ssl_ca) + { + table->field[10]->set_notnull(); + table->field[10]->store( + conn->tgt_ssl_ca, + (uint) conn->tgt_ssl_ca_length, + system_charset_info); + } else { + table->field[10]->set_null(); + table->field[10]->reset(); + } + if (conn->tgt_ssl_capath) + { + table->field[11]->set_notnull(); + table->field[11]->store( + conn->tgt_ssl_capath, + (uint) conn->tgt_ssl_capath_length, + system_charset_info); + } else { + table->field[11]->set_null(); + table->field[11]->reset(); + } + if (conn->tgt_ssl_cert) + { + table->field[12]->set_notnull(); + table->field[12]->store( + conn->tgt_ssl_cert, + (uint) conn->tgt_ssl_cert_length, + system_charset_info); + } else { + table->field[12]->set_null(); + table->field[12]->reset(); + } + if (conn->tgt_ssl_cipher) + { + table->field[13]->set_notnull(); + table->field[13]->store( + conn->tgt_ssl_cipher, + (uint) conn->tgt_ssl_cipher_length, + system_charset_info); + } else { + table->field[13]->set_null(); + table->field[13]->reset(); + } + if (conn->tgt_ssl_key) + { + table->field[14]->set_notnull(); + table->field[14]->store( + conn->tgt_ssl_key, + (uint) conn->tgt_ssl_key_length, + system_charset_info); + } else { + table->field[14]->set_null(); + table->field[14]->reset(); + } + if (conn->tgt_ssl_vsc >= 0) + { + table->field[15]->set_notnull(); + table->field[15]->store( + conn->tgt_ssl_vsc); + } else { + table->field[15]->set_null(); + table->field[15]->reset(); + } + if (conn->tgt_default_file) + { + table->field[16]->set_notnull(); + table->field[16]->store( + conn->tgt_default_file, + (uint) conn->tgt_default_file_length, + system_charset_info); + } else { + table->field[16]->set_null(); + table->field[16]->reset(); + } + if (conn->tgt_default_group) + { + table->field[17]->set_notnull(); + table->field[17]->store( + conn->tgt_default_group, + (uint) conn->tgt_default_group_length, + system_charset_info); + } else { + table->field[17]->set_null(); + table->field[17]->reset(); + } + DBUG_VOID_RETURN; +} + +void spider_store_tables_name( + TABLE *table, + const char *name, + const uint name_length +) { + const char *ptr_db, *ptr_table; + my_ptrdiff_t ptr_diff_db, ptr_diff_table; + DBUG_ENTER("spider_store_tables_name"); + if (name[0] == FN_CURLIB && name[1] == FN_LIBCHAR) + { + ptr_db = strchr(name, FN_LIBCHAR); + ptr_db++; + ptr_diff_db = PTR_BYTE_DIFF(ptr_db, name); + DBUG_PRINT("info",("spider ptr_diff_db = %lld", (longlong) ptr_diff_db)); + ptr_table = strchr(ptr_db, FN_LIBCHAR); + ptr_table++; + ptr_diff_table = PTR_BYTE_DIFF(ptr_table, ptr_db); + DBUG_PRINT("info",("spider ptr_diff_table = %lld", + (longlong) ptr_diff_table)); + } else { + DBUG_PRINT("info",("spider temporary table")); + ptr_db = ""; + ptr_diff_db = 1; + ptr_table = ""; + ptr_diff_table = 1; + } + table->field[0]->store( + ptr_db, + ptr_diff_table - 1, + system_charset_info); + DBUG_PRINT("info",("spider field[0]->null_bit = %d", + table->field[0]->null_bit)); + table->field[1]->store( + ptr_table, + name_length - ptr_diff_db - ptr_diff_table, + system_charset_info); + DBUG_PRINT("info",("spider field[1]->null_bit = %d", + table->field[1]->null_bit)); + DBUG_VOID_RETURN; +} + +void spider_store_db_and_table_name( + TABLE *table, + const char *db_name, + const uint db_name_length, + const char *table_name, + const uint table_name_length +) { + DBUG_ENTER("spider_store_db_and_table_name"); + table->field[0]->store( + db_name, + db_name_length, + system_charset_info); + DBUG_PRINT("info",("spider field[0]->null_bit = %d", + table->field[0]->null_bit)); + table->field[1]->store( + table_name, + table_name_length, + system_charset_info); + DBUG_PRINT("info",("spider field[1]->null_bit = %d", + table->field[1]->null_bit)); + DBUG_VOID_RETURN; +} + +void spider_store_tables_link_idx( + TABLE *table, + int link_idx +) { + DBUG_ENTER("spider_store_tables_link_idx"); + table->field[2]->set_notnull(); + table->field[2]->store(link_idx); + DBUG_VOID_RETURN; +} + +void spider_store_tables_link_idx_str( + TABLE *table, + const char *link_idx, + const uint link_idx_length +) { + DBUG_ENTER("spider_store_tables_link_idx_str"); + table->field[2]->store( + link_idx, + link_idx_length, + system_charset_info); + DBUG_PRINT("info",("spider field[2]->null_bit = %d", + table->field[2]->null_bit)); + DBUG_VOID_RETURN; +} + +void spider_store_tables_priority( + TABLE *table, + longlong priority +) { + DBUG_ENTER("spider_store_tables_priority"); + DBUG_PRINT("info",("spider priority = %lld", priority)); + table->field[3]->store(priority, FALSE); + DBUG_VOID_RETURN; +} + +void spider_store_tables_connect_info( + TABLE *table, + SPIDER_ALTER_TABLE *alter_table, + int link_idx +) { + DBUG_ENTER("spider_store_tables_connect_info"); + if (alter_table->tmp_server_names[link_idx]) + { + table->field[4]->set_notnull(); + table->field[4]->store( + alter_table->tmp_server_names[link_idx], + (uint) alter_table->tmp_server_names_lengths[link_idx], + system_charset_info); + } else { + table->field[4]->set_null(); + table->field[4]->reset(); + } + if (alter_table->tmp_tgt_wrappers[link_idx]) + { + table->field[5]->set_notnull(); + table->field[5]->store( + alter_table->tmp_tgt_wrappers[link_idx], + (uint) alter_table->tmp_tgt_wrappers_lengths[link_idx], + system_charset_info); + } else { + table->field[5]->set_null(); + table->field[5]->reset(); + } + if (alter_table->tmp_tgt_hosts[link_idx]) + { + table->field[6]->set_notnull(); + table->field[6]->store( + alter_table->tmp_tgt_hosts[link_idx], + (uint) alter_table->tmp_tgt_hosts_lengths[link_idx], + system_charset_info); + } else { + table->field[6]->set_null(); + table->field[6]->reset(); + } + if (alter_table->tmp_tgt_ports[link_idx] >= 0) + { + table->field[7]->set_notnull(); + table->field[7]->store( + alter_table->tmp_tgt_ports[link_idx]); + } else { + table->field[7]->set_null(); + table->field[7]->reset(); + } + if (alter_table->tmp_tgt_sockets[link_idx]) + { + table->field[8]->set_notnull(); + table->field[8]->store( + alter_table->tmp_tgt_sockets[link_idx], + (uint) alter_table->tmp_tgt_sockets_lengths[link_idx], + system_charset_info); + } else { + table->field[8]->set_null(); + table->field[8]->reset(); + } + if (alter_table->tmp_tgt_usernames[link_idx]) + { + table->field[9]->set_notnull(); + table->field[9]->store( + alter_table->tmp_tgt_usernames[link_idx], + (uint) alter_table->tmp_tgt_usernames_lengths[link_idx], + system_charset_info); + } else { + table->field[9]->set_null(); + table->field[9]->reset(); + } + if (alter_table->tmp_tgt_passwords[link_idx]) + { + table->field[10]->set_notnull(); + table->field[10]->store( + alter_table->tmp_tgt_passwords[link_idx], + (uint) alter_table->tmp_tgt_passwords_lengths[link_idx], + system_charset_info); + } else { + table->field[10]->set_null(); + table->field[10]->reset(); + } + if (alter_table->tmp_tgt_ssl_cas[link_idx]) + { + table->field[11]->set_notnull(); + table->field[11]->store( + alter_table->tmp_tgt_ssl_cas[link_idx], + (uint) alter_table->tmp_tgt_ssl_cas_lengths[link_idx], + system_charset_info); + } else { + table->field[11]->set_null(); + table->field[11]->reset(); + } + if (alter_table->tmp_tgt_ssl_capaths[link_idx]) + { + table->field[12]->set_notnull(); + table->field[12]->store( + alter_table->tmp_tgt_ssl_capaths[link_idx], + (uint) alter_table->tmp_tgt_ssl_capaths_lengths[link_idx], + system_charset_info); + } else { + table->field[12]->set_null(); + table->field[12]->reset(); + } + if (alter_table->tmp_tgt_ssl_certs[link_idx]) + { + table->field[13]->set_notnull(); + table->field[13]->store( + alter_table->tmp_tgt_ssl_certs[link_idx], + (uint) alter_table->tmp_tgt_ssl_certs_lengths[link_idx], + system_charset_info); + } else { + table->field[13]->set_null(); + table->field[13]->reset(); + } + if (alter_table->tmp_tgt_ssl_ciphers[link_idx]) + { + table->field[14]->set_notnull(); + table->field[14]->store( + alter_table->tmp_tgt_ssl_ciphers[link_idx], + (uint) alter_table->tmp_tgt_ssl_ciphers_lengths[link_idx], + system_charset_info); + } else { + table->field[14]->set_null(); + table->field[14]->reset(); + } + if (alter_table->tmp_tgt_ssl_keys[link_idx]) + { + table->field[15]->set_notnull(); + table->field[15]->store( + alter_table->tmp_tgt_ssl_keys[link_idx], + (uint) alter_table->tmp_tgt_ssl_keys_lengths[link_idx], + system_charset_info); + } else { + table->field[15]->set_null(); + table->field[15]->reset(); + } + if (alter_table->tmp_tgt_ssl_vscs[link_idx] >= 0) + { + table->field[16]->set_notnull(); + table->field[16]->store( + alter_table->tmp_tgt_ssl_vscs[link_idx]); + } else { + table->field[16]->set_null(); + table->field[16]->reset(); + } + if (alter_table->tmp_tgt_default_files[link_idx]) + { + table->field[17]->set_notnull(); + table->field[17]->store( + alter_table->tmp_tgt_default_files[link_idx], + (uint) alter_table->tmp_tgt_default_files_lengths[link_idx], + system_charset_info); + } else { + table->field[17]->set_null(); + table->field[17]->reset(); + } + if (alter_table->tmp_tgt_default_groups[link_idx]) + { + table->field[18]->set_notnull(); + table->field[18]->store( + alter_table->tmp_tgt_default_groups[link_idx], + (uint) alter_table->tmp_tgt_default_groups_lengths[link_idx], + system_charset_info); + } else { + table->field[18]->set_null(); + table->field[18]->reset(); + } + if (alter_table->tmp_tgt_dbs[link_idx]) + { + table->field[19]->set_notnull(); + table->field[19]->store( + alter_table->tmp_tgt_dbs[link_idx], + (uint) alter_table->tmp_tgt_dbs_lengths[link_idx], + system_charset_info); + } else { + table->field[19]->set_null(); + table->field[19]->reset(); + } + if (alter_table->tmp_tgt_table_names[link_idx]) + { + table->field[20]->set_notnull(); + table->field[20]->store( + alter_table->tmp_tgt_table_names[link_idx], + (uint) alter_table->tmp_tgt_table_names_lengths[link_idx], + system_charset_info); + } else { + table->field[20]->set_null(); + table->field[20]->reset(); + } + DBUG_VOID_RETURN; +} + +void spider_store_tables_link_status( + TABLE *table, + long link_status +) { + DBUG_ENTER("spider_store_tables_link_status"); + DBUG_PRINT("info",("spider link_status = %ld", link_status)); + if (link_status > SPIDER_LINK_STATUS_NO_CHANGE) + table->field[21]->store(link_status, FALSE); + DBUG_VOID_RETURN; +} + +void spider_store_link_chk_server_id( + TABLE *table, + uint32 server_id +) { + DBUG_ENTER("spider_store_link_chk_server_id"); + table->field[3]->set_notnull(); + table->field[3]->store(server_id); + DBUG_VOID_RETURN; +} + +int spider_insert_xa( + TABLE *table, + XID *xid, + const char *status +) { + int error_num; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_insert_xa"); + table->use_all_columns(); + empty_record(table); + spider_store_xa_pk(table, xid); + + if ((error_num = spider_check_sys_table(table, table_key))) + { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + table->use_all_columns(); + spider_store_xa_bqual_length(table, xid); + spider_store_xa_status(table, status); + if ((error_num = table->file->ha_write_row(table->record[0]))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } else { + my_message(ER_SPIDER_XA_EXISTS_NUM, ER_SPIDER_XA_EXISTS_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_XA_EXISTS_NUM); + } + + DBUG_RETURN(0); +} + +int spider_insert_xa_member( + TABLE *table, + XID *xid, + SPIDER_CONN *conn +) { + int error_num; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_insert_xa_member"); + table->use_all_columns(); + empty_record(table); + spider_store_xa_member_pk(table, xid, conn); + + if ((error_num = spider_check_sys_table(table, table_key))) + { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + table->use_all_columns(); + spider_store_xa_member_info(table, xid, conn); + if ((error_num = table->file->ha_write_row(table->record[0]))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } else { + my_message(ER_SPIDER_XA_MEMBER_EXISTS_NUM, ER_SPIDER_XA_MEMBER_EXISTS_STR, + MYF(0)); + DBUG_RETURN(ER_SPIDER_XA_MEMBER_EXISTS_NUM); + } + + DBUG_RETURN(0); +} + +int spider_insert_tables( + TABLE *table, + SPIDER_SHARE *share +) { + int error_num, roop_count; + DBUG_ENTER("spider_insert_tables"); + table->use_all_columns(); + empty_record(table); + + spider_store_tables_name(table, share->table_name, share->table_name_length); + spider_store_tables_priority(table, share->priority); + for (roop_count = 0; roop_count < (int) share->all_link_count; roop_count++) + { + spider_store_tables_link_idx(table, roop_count); + spider_store_tables_connect_info(table, &share->alter_table, roop_count); + spider_store_tables_link_status(table, + share->alter_table.tmp_link_statuses[roop_count] > + SPIDER_LINK_STATUS_NO_CHANGE ? + share->alter_table.tmp_link_statuses[roop_count] : + SPIDER_LINK_STATUS_OK); + if ((error_num = table->file->ha_write_row(table->record[0]))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + + DBUG_RETURN(0); +} + +int spider_log_tables_link_failed( + TABLE *table, + char *name, + uint name_length, + int link_idx +) { + int error_num; + DBUG_ENTER("spider_log_tables_link_failed"); + table->use_all_columns(); + spider_store_tables_name(table, name, name_length); + spider_store_tables_link_idx(table, link_idx); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 +#else + if (table->field[3] == table->timestamp_field) + table->timestamp_field->set_time(); +#endif + if ((error_num = table->file->ha_write_row(table->record[0]))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +int spider_update_xa( + TABLE *table, + XID *xid, + const char *status +) { + int error_num; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_update_xa"); + table->use_all_columns(); + spider_store_xa_pk(table, xid); + + if ((error_num = spider_check_sys_table(table, table_key))) + { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + my_message(ER_SPIDER_XA_NOT_EXISTS_NUM, ER_SPIDER_XA_NOT_EXISTS_STR, + MYF(0)); + DBUG_RETURN(ER_SPIDER_XA_NOT_EXISTS_NUM); + } else { + store_record(table, record[1]); + table->use_all_columns(); + spider_store_xa_status(table, status); + if ( + (error_num = table->file->ha_update_row( + table->record[1], table->record[0])) && + error_num != HA_ERR_RECORD_IS_THE_SAME + ) { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + + DBUG_RETURN(0); +} + +int spider_update_tables_name( + TABLE *table, + const char *from, + const char *to, + int *old_link_count +) { + int error_num, roop_count = 0; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_update_tables_name"); + table->use_all_columns(); + while (TRUE) + { + spider_store_tables_name(table, from, strlen(from)); + spider_store_tables_link_idx(table, roop_count); + if ((error_num = spider_check_sys_table(table, table_key))) + { + if ( + roop_count && + (error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE) + ) + break; + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } else { + store_record(table, record[1]); + table->use_all_columns(); + spider_store_tables_name(table, to, strlen(to)); + if ( + (error_num = table->file->ha_update_row( + table->record[1], table->record[0])) && + error_num != HA_ERR_RECORD_IS_THE_SAME + ) { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + roop_count++; + } + + *old_link_count = roop_count; + DBUG_RETURN(0); +} + +int spider_update_tables_priority( + TABLE *table, + SPIDER_ALTER_TABLE *alter_table, + const char *name, + int *old_link_count +) { + int error_num, roop_count; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_update_tables_priority"); + table->use_all_columns(); + for (roop_count = 0; roop_count < (int) alter_table->all_link_count; + roop_count++) + { + spider_store_tables_name(table, alter_table->table_name, + alter_table->table_name_length); + spider_store_tables_link_idx(table, roop_count); + if ((error_num = spider_check_sys_table(table, table_key))) + { + if ( + roop_count && + (error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE) + ) { + *old_link_count = roop_count; + + /* insert for adding link */ + spider_store_tables_name(table, name, strlen(name)); + spider_store_tables_priority(table, alter_table->tmp_priority); + do { + spider_store_tables_link_idx(table, roop_count); + spider_store_tables_connect_info(table, alter_table, roop_count); + spider_store_tables_link_status(table, + alter_table->tmp_link_statuses[roop_count] != + SPIDER_LINK_STATUS_NO_CHANGE ? + alter_table->tmp_link_statuses[roop_count] : + SPIDER_LINK_STATUS_OK); + if ((error_num = table->file->ha_write_row(table->record[0]))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + roop_count++; + } while (roop_count < (int) alter_table->all_link_count); + DBUG_RETURN(0); + } else { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } else { + store_record(table, record[1]); + table->use_all_columns(); + spider_store_tables_name(table, name, strlen(name)); + spider_store_tables_priority(table, alter_table->tmp_priority); + spider_store_tables_connect_info(table, alter_table, roop_count); + spider_store_tables_link_status(table, + alter_table->tmp_link_statuses[roop_count]); + if ( + (error_num = table->file->ha_update_row( + table->record[1], table->record[0])) && + error_num != HA_ERR_RECORD_IS_THE_SAME + ) { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + } + while (TRUE) + { + /* delete for subtracting link */ + spider_store_tables_link_idx(table, roop_count); + if ((error_num = spider_check_sys_table(table, table_key))) + { + if ( + roop_count && + (error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE) + ) + break; + else { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + if ((error_num = table->file->ha_delete_row(table->record[0]))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + roop_count++; + } + + *old_link_count = roop_count; + DBUG_RETURN(0); +} + +int spider_update_tables_link_status( + TABLE *table, + char *name, + uint name_length, + int link_idx, + long link_status +) { + int error_num; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_update_tables_link_status"); + table->use_all_columns(); + spider_store_tables_name(table, name, name_length); + spider_store_tables_link_idx(table, link_idx); + if ((error_num = spider_check_sys_table(table, table_key))) + { + if ( + (error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE) + ) + DBUG_RETURN(0); + else { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } else { + store_record(table, record[1]); + table->use_all_columns(); + spider_store_tables_link_status(table, link_status); + if ( + (error_num = table->file->ha_update_row( + table->record[1], table->record[0])) && + error_num != HA_ERR_RECORD_IS_THE_SAME + ) { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + + DBUG_RETURN(0); +} + +int spider_delete_xa( + TABLE *table, + XID *xid +) { + int error_num; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_delete_xa"); + table->use_all_columns(); + spider_store_xa_pk(table, xid); + + if ((error_num = spider_check_sys_table(table, table_key))) + { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + my_message(ER_SPIDER_XA_NOT_EXISTS_NUM, ER_SPIDER_XA_NOT_EXISTS_STR, + MYF(0)); + DBUG_RETURN(ER_SPIDER_XA_NOT_EXISTS_NUM); + } else { + if ((error_num = table->file->ha_delete_row(table->record[0]))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + + DBUG_RETURN(0); +} + +int spider_delete_xa_member( + TABLE *table, + XID *xid +) { + int error_num; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_delete_xa_member"); + table->use_all_columns(); + spider_store_xa_pk(table, xid); + + if ((error_num = spider_get_sys_table_by_idx(table, table_key, 0, + SPIDER_SYS_XA_PK_COL_CNT))) + { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); + } else { + do { + if ((error_num = table->file->ha_delete_row(table->record[0]))) + { + spider_sys_index_end(table); + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + error_num = spider_sys_index_next_same(table, table_key); + } while (error_num == 0); + } + if ((error_num = spider_sys_index_end(table))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + + DBUG_RETURN(0); +} + +int spider_delete_tables( + TABLE *table, + const char *name, + int *old_link_count +) { + int error_num, roop_count = 0; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_delete_tables"); + table->use_all_columns(); + spider_store_tables_name(table, name, strlen(name)); + + while (TRUE) + { + spider_store_tables_link_idx(table, roop_count); + if ((error_num = spider_check_sys_table(table, table_key))) + break; + else { + if ((error_num = table->file->ha_delete_row(table->record[0]))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + roop_count++; + } + + *old_link_count = roop_count; + DBUG_RETURN(0); +} + +int spider_get_sys_xid( + TABLE *table, + XID *xid, + MEM_ROOT *mem_root +) { + char *ptr; + DBUG_ENTER("spider_get_sys_xid"); + ptr = get_field(mem_root, table->field[0]); + if (ptr) + { + xid->formatID = atoi(ptr); + } else + xid->formatID = 0; + ptr = get_field(mem_root, table->field[1]); + if (ptr) + { + xid->gtrid_length = atoi(ptr); + } else + xid->gtrid_length = 0; + ptr = get_field(mem_root, table->field[2]); + if (ptr) + { + xid->bqual_length = atoi(ptr); + } else + xid->bqual_length = 0; + ptr = get_field(mem_root, table->field[3]); + if (ptr) + { + strmov(xid->data, ptr); + } + DBUG_RETURN(0); +} + +int spider_get_sys_server_info( + TABLE *table, + SPIDER_SHARE *share, + int link_idx, + MEM_ROOT *mem_root +) { + char *ptr; + DBUG_ENTER("spider_get_sys_server_info"); + if ((ptr = get_field(mem_root, table->field[4]))) + { + share->tgt_wrappers_lengths[link_idx] = strlen(ptr); + share->tgt_wrappers[link_idx] = spider_create_string(ptr, + share->tgt_wrappers_lengths[link_idx]); + } else { + share->tgt_wrappers_lengths[link_idx] = 0; + share->tgt_wrappers[link_idx] = NULL; + } + if ((ptr = get_field(mem_root, table->field[5]))) + { + share->tgt_hosts_lengths[link_idx] = strlen(ptr); + share->tgt_hosts[link_idx] = spider_create_string(ptr, + share->tgt_hosts_lengths[link_idx]); + } else { + share->tgt_hosts_lengths[link_idx] = 0; + share->tgt_hosts[link_idx] = NULL; + } + if ((ptr = get_field(mem_root, table->field[6]))) + { + share->tgt_ports[link_idx] = atol(ptr); + } else + share->tgt_ports[link_idx] = MYSQL_PORT; + if ((ptr = get_field(mem_root, table->field[7]))) + { + share->tgt_sockets_lengths[link_idx] = strlen(ptr); + share->tgt_sockets[link_idx] = spider_create_string(ptr, + share->tgt_sockets_lengths[link_idx]); + } else { + share->tgt_sockets_lengths[link_idx] = 0; + share->tgt_sockets[link_idx] = NULL; + } + if ((ptr = get_field(mem_root, table->field[8]))) + { + share->tgt_usernames_lengths[link_idx] = strlen(ptr); + share->tgt_usernames[link_idx] = + spider_create_string(ptr, share->tgt_usernames_lengths[link_idx]); + } else { + share->tgt_usernames_lengths[link_idx] = 0; + share->tgt_usernames[link_idx] = NULL; + } + if ((ptr = get_field(mem_root, table->field[9]))) + { + share->tgt_passwords_lengths[link_idx] = strlen(ptr); + share->tgt_passwords[link_idx] = + spider_create_string(ptr, share->tgt_passwords_lengths[link_idx]); + } else { + share->tgt_passwords_lengths[link_idx] = 0; + share->tgt_passwords[link_idx] = NULL; + } + if ( + !table->field[10]->is_null() && + (ptr = get_field(mem_root, table->field[10])) + ) { + share->tgt_ssl_cas_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_cas[link_idx] = + spider_create_string(ptr, share->tgt_ssl_cas_lengths[link_idx]); + } else { + share->tgt_ssl_cas_lengths[link_idx] = 0; + share->tgt_ssl_cas[link_idx] = NULL; + } + if ( + !table->field[11]->is_null() && + (ptr = get_field(mem_root, table->field[11])) + ) { + share->tgt_ssl_capaths_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_capaths[link_idx] = + spider_create_string(ptr, share->tgt_ssl_capaths_lengths[link_idx]); + } else { + share->tgt_ssl_capaths_lengths[link_idx] = 0; + share->tgt_ssl_capaths[link_idx] = NULL; + } + if ( + !table->field[12]->is_null() && + (ptr = get_field(mem_root, table->field[12])) + ) { + share->tgt_ssl_certs_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_certs[link_idx] = + spider_create_string(ptr, share->tgt_ssl_certs_lengths[link_idx]); + } else { + share->tgt_ssl_certs_lengths[link_idx] = 0; + share->tgt_ssl_certs[link_idx] = NULL; + } + if ( + !table->field[13]->is_null() && + (ptr = get_field(mem_root, table->field[13])) + ) { + share->tgt_ssl_ciphers_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_ciphers[link_idx] = + spider_create_string(ptr, share->tgt_ssl_ciphers_lengths[link_idx]); + } else { + share->tgt_ssl_ciphers_lengths[link_idx] = 0; + share->tgt_ssl_ciphers[link_idx] = NULL; + } + if ( + !table->field[14]->is_null() && + (ptr = get_field(mem_root, table->field[14])) + ) { + share->tgt_ssl_keys_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_keys[link_idx] = + spider_create_string(ptr, share->tgt_ssl_keys_lengths[link_idx]); + } else { + share->tgt_ssl_keys_lengths[link_idx] = 0; + share->tgt_ssl_keys[link_idx] = NULL; + } + if ( + !table->field[15]->is_null() && + (ptr = get_field(mem_root, table->field[15])) + ) { + share->tgt_ssl_vscs[link_idx] = atol(ptr); + } else + share->tgt_ssl_vscs[link_idx] = 0; + if ( + !table->field[16]->is_null() && + (ptr = get_field(mem_root, table->field[16])) + ) { + share->tgt_default_files_lengths[link_idx] = strlen(ptr); + share->tgt_default_files[link_idx] = + spider_create_string(ptr, share->tgt_default_files_lengths[link_idx]); + } else { + share->tgt_default_files_lengths[link_idx] = 0; + share->tgt_default_files[link_idx] = NULL; + } + if ( + !table->field[17]->is_null() && + (ptr = get_field(mem_root, table->field[17])) + ) { + share->tgt_default_groups_lengths[link_idx] = strlen(ptr); + share->tgt_default_groups[link_idx] = + spider_create_string(ptr, share->tgt_default_groups_lengths[link_idx]); + } else { + share->tgt_default_groups_lengths[link_idx] = 0; + share->tgt_default_groups[link_idx] = NULL; + } + DBUG_RETURN(0); +} + +int spider_check_sys_xa_status( + TABLE *table, + const char *status1, + const char *status2, + const char *status3, + const int check_error_num, + MEM_ROOT *mem_root +) { + char *ptr; + int error_num; + DBUG_ENTER("spider_check_sys_xa_status"); + ptr = get_field(mem_root, table->field[4]); + if (ptr) + { + if ( + strcmp(ptr, status1) && + (status2 == NULL || strcmp(ptr, status2)) && + (status3 == NULL || strcmp(ptr, status3)) + ) + error_num = check_error_num; + else + error_num = 0; + } else + error_num = check_error_num; + DBUG_RETURN(error_num); +} + +int spider_get_sys_tables( + TABLE *table, + char **db_name, + char **table_name, + MEM_ROOT *mem_root +) { + char *ptr; + DBUG_ENTER("spider_get_sys_tables"); + if ((ptr = get_field(mem_root, table->field[0]))) + { + *db_name = spider_create_string(ptr, strlen(ptr)); + } else { + *db_name = NULL; + } + if ((ptr = get_field(mem_root, table->field[1]))) + { + *table_name = spider_create_string(ptr, strlen(ptr)); + } else { + *table_name = NULL; + } + DBUG_RETURN(0); +} + +int spider_get_sys_tables_connect_info( + TABLE *table, + SPIDER_SHARE *share, + int link_idx, + MEM_ROOT *mem_root +) { + char *ptr; + int error_num = 0; + DBUG_ENTER("spider_get_sys_tables_connect_info"); + if ((ptr = get_field(mem_root, table->field[3]))) + { + share->priority = my_strtoll10(ptr, (char**) NULL, &error_num); + } else + share->priority = 1000000; + if ( + !table->field[4]->is_null() && + (ptr = get_field(mem_root, table->field[4])) + ) { + share->server_names_lengths[link_idx] = strlen(ptr); + share->server_names[link_idx] = + spider_create_string(ptr, share->server_names_lengths[link_idx]); + } else { + share->server_names_lengths[link_idx] = 0; + share->server_names[link_idx] = NULL; + } + if ( + !table->field[5]->is_null() && + (ptr = get_field(mem_root, table->field[5])) + ) { + share->tgt_wrappers_lengths[link_idx] = strlen(ptr); + share->tgt_wrappers[link_idx] = + spider_create_string(ptr, share->tgt_wrappers_lengths[link_idx]); + } else { + share->tgt_wrappers_lengths[link_idx] = 0; + share->tgt_wrappers[link_idx] = NULL; + } + if ( + !table->field[6]->is_null() && + (ptr = get_field(mem_root, table->field[6])) + ) { + share->tgt_hosts_lengths[link_idx] = strlen(ptr); + share->tgt_hosts[link_idx] = + spider_create_string(ptr, share->tgt_hosts_lengths[link_idx]); + } else { + share->tgt_hosts_lengths[link_idx] = 0; + share->tgt_hosts[link_idx] = NULL; + } + if ( + !table->field[7]->is_null() && + (ptr = get_field(mem_root, table->field[7])) + ) { + share->tgt_ports[link_idx] = atol(ptr); + } else { + share->tgt_ports[link_idx] = -1; + } + if ( + !table->field[8]->is_null() && + (ptr = get_field(mem_root, table->field[8])) + ) { + share->tgt_sockets_lengths[link_idx] = strlen(ptr); + share->tgt_sockets[link_idx] = + spider_create_string(ptr, share->tgt_sockets_lengths[link_idx]); + } else { + share->tgt_sockets_lengths[link_idx] = 0; + share->tgt_sockets[link_idx] = NULL; + } + if ( + !table->field[9]->is_null() && + (ptr = get_field(mem_root, table->field[9])) + ) { + share->tgt_usernames_lengths[link_idx] = strlen(ptr); + share->tgt_usernames[link_idx] = + spider_create_string(ptr, share->tgt_usernames_lengths[link_idx]); + } else { + share->tgt_usernames_lengths[link_idx] = 0; + share->tgt_usernames[link_idx] = NULL; + } + if ( + !table->field[10]->is_null() && + (ptr = get_field(mem_root, table->field[10])) + ) { + share->tgt_passwords_lengths[link_idx] = strlen(ptr); + share->tgt_passwords[link_idx] = + spider_create_string(ptr, share->tgt_passwords_lengths[link_idx]); + } else { + share->tgt_passwords_lengths[link_idx] = 0; + share->tgt_passwords[link_idx] = NULL; + } + if ( + !table->field[11]->is_null() && + (ptr = get_field(mem_root, table->field[11])) + ) { + share->tgt_ssl_cas_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_cas[link_idx] = + spider_create_string(ptr, share->tgt_ssl_cas_lengths[link_idx]); + } else { + share->tgt_ssl_cas_lengths[link_idx] = 0; + share->tgt_ssl_cas[link_idx] = NULL; + } + if ( + !table->field[12]->is_null() && + (ptr = get_field(mem_root, table->field[12])) + ) { + share->tgt_ssl_capaths_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_capaths[link_idx] = + spider_create_string(ptr, share->tgt_ssl_capaths_lengths[link_idx]); + } else { + share->tgt_ssl_capaths_lengths[link_idx] = 0; + share->tgt_ssl_capaths[link_idx] = NULL; + } + if ( + !table->field[13]->is_null() && + (ptr = get_field(mem_root, table->field[13])) + ) { + share->tgt_ssl_certs_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_certs[link_idx] = + spider_create_string(ptr, share->tgt_ssl_certs_lengths[link_idx]); + } else { + share->tgt_ssl_certs_lengths[link_idx] = 0; + share->tgt_ssl_certs[link_idx] = NULL; + } + if ( + !table->field[14]->is_null() && + (ptr = get_field(mem_root, table->field[14])) + ) { + share->tgt_ssl_ciphers_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_ciphers[link_idx] = + spider_create_string(ptr, share->tgt_ssl_ciphers_lengths[link_idx]); + } else { + share->tgt_ssl_ciphers_lengths[link_idx] = 0; + share->tgt_ssl_ciphers[link_idx] = NULL; + } + if ( + !table->field[15]->is_null() && + (ptr = get_field(mem_root, table->field[15])) + ) { + share->tgt_ssl_keys_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_keys[link_idx] = + spider_create_string(ptr, share->tgt_ssl_keys_lengths[link_idx]); + } else { + share->tgt_ssl_keys_lengths[link_idx] = 0; + share->tgt_ssl_keys[link_idx] = NULL; + } + if ( + !table->field[16]->is_null() && + (ptr = get_field(mem_root, table->field[16])) + ) { + share->tgt_ssl_vscs[link_idx] = atol(ptr); + } else + share->tgt_ssl_vscs[link_idx] = -1; + if ( + !table->field[17]->is_null() && + (ptr = get_field(mem_root, table->field[17])) + ) { + share->tgt_default_files_lengths[link_idx] = strlen(ptr); + share->tgt_default_files[link_idx] = + spider_create_string(ptr, share->tgt_default_files_lengths[link_idx]); + } else { + share->tgt_default_files_lengths[link_idx] = 0; + share->tgt_default_files[link_idx] = NULL; + } + if ( + !table->field[18]->is_null() && + (ptr = get_field(mem_root, table->field[18])) + ) { + share->tgt_default_groups_lengths[link_idx] = strlen(ptr); + share->tgt_default_groups[link_idx] = + spider_create_string(ptr, share->tgt_default_groups_lengths[link_idx]); + } else { + share->tgt_default_groups_lengths[link_idx] = 0; + share->tgt_default_groups[link_idx] = NULL; + } + if ( + !table->field[19]->is_null() && + (ptr = get_field(mem_root, table->field[19])) + ) { + share->tgt_dbs_lengths[link_idx] = strlen(ptr); + share->tgt_dbs[link_idx] = + spider_create_string(ptr, share->tgt_dbs_lengths[link_idx]); + } else { + share->tgt_dbs_lengths[link_idx] = 0; + share->tgt_dbs[link_idx] = NULL; + } + if ( + !table->field[20]->is_null() && + (ptr = get_field(mem_root, table->field[20])) + ) { + share->tgt_table_names_lengths[link_idx] = strlen(ptr); + share->tgt_table_names[link_idx] = + spider_create_string(ptr, share->tgt_table_names_lengths[link_idx]); + } else { + share->tgt_table_names_lengths[link_idx] = 0; + share->tgt_table_names[link_idx] = NULL; + } + DBUG_RETURN(error_num); +} + +int spider_get_sys_tables_link_status( + TABLE *table, + SPIDER_SHARE *share, + int link_idx, + MEM_ROOT *mem_root +) { + char *ptr; + int error_num = 0; + DBUG_ENTER("spider_get_sys_tables_link_status"); + if ((ptr = get_field(mem_root, table->field[21]))) + { + share->link_statuses[link_idx] = + (long) my_strtoll10(ptr, (char**) NULL, &error_num); + } else + share->link_statuses[link_idx] = 1; + DBUG_PRINT("info",("spider link_statuses[%d]=%ld", + link_idx, share->link_statuses[link_idx])); + DBUG_RETURN(error_num); +} + +int spider_get_sys_tables_link_idx( + TABLE *table, + int *link_idx, + MEM_ROOT *mem_root +) { + char *ptr; + int error_num = 0; + DBUG_ENTER("spider_get_sys_tables_link_status"); + if ((ptr = get_field(mem_root, table->field[2]))) + *link_idx = (int) my_strtoll10(ptr, (char**) NULL, &error_num); + else + *link_idx = 1; + DBUG_PRINT("info",("spider link_idx=%d", *link_idx)); + DBUG_RETURN(error_num); +} + +int spider_sys_update_tables_link_status( + THD *thd, + char *name, + uint name_length, + int link_idx, + long link_status, + bool need_lock +) { + int error_num; + TABLE *table_tables = NULL; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + DBUG_ENTER("spider_sys_update_tables_link_status"); + if ( + !(table_tables = spider_open_sys_table( + thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock, + &error_num)) + ) { + my_error(error_num, MYF(0)); + goto error; + } + if ((error_num = spider_update_tables_link_status(table_tables, + name, name_length, link_idx, link_status))) + goto error; + spider_close_sys_table(thd, table_tables, + &open_tables_backup, need_lock); + table_tables = NULL; + DBUG_RETURN(0); + +error: + if (table_tables) + spider_close_sys_table(thd, table_tables, + &open_tables_backup, need_lock); + DBUG_RETURN(error_num); +} + +int spider_sys_log_tables_link_failed( + THD *thd, + char *name, + uint name_length, + int link_idx, + bool need_lock +) { + int error_num; + TABLE *table_tables = NULL; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + DBUG_ENTER("spider_sys_log_tables_link_failed"); + if ( + !(table_tables = spider_open_sys_table( + thd, SPIDER_SYS_LINK_FAILED_TABLE_NAME_STR, + SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup, + need_lock, &error_num)) + ) { + my_error(error_num, MYF(0)); + goto error; + } + empty_record(table_tables); + if ((error_num = spider_log_tables_link_failed(table_tables, + name, name_length, link_idx))) + goto error; + spider_close_sys_table(thd, table_tables, + &open_tables_backup, need_lock); + table_tables = NULL; + DBUG_RETURN(0); + +error: + if (table_tables) + spider_close_sys_table(thd, table_tables, + &open_tables_backup, need_lock); + DBUG_RETURN(error_num); +} + +int spider_get_sys_link_mon_key( + TABLE *table, + SPIDER_MON_KEY *mon_key, + MEM_ROOT *mem_root, + int *same +) { + char *db_name, *table_name, *link_id; + uint db_name_length, table_name_length, link_id_length; + DBUG_ENTER("spider_get_sys_link_mon_key"); + if ( + table->field[0]->is_null() || + table->field[1]->is_null() || + table->field[2]->is_null() + ) { + my_printf_error(ER_SPIDER_SYS_TABLE_VERSION_NUM, + ER_SPIDER_SYS_TABLE_VERSION_STR, MYF(0), + SPIDER_SYS_LINK_MON_TABLE_NAME_STR); + DBUG_RETURN(ER_SPIDER_SYS_TABLE_VERSION_NUM); + } + + if ( + !(db_name = get_field(mem_root, table->field[0])) || + !(table_name = get_field(mem_root, table->field[1])) || + !(link_id = get_field(mem_root, table->field[2])) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + db_name_length = strlen(db_name); + table_name_length = strlen(table_name); + link_id_length = strlen(link_id); + + if ( + db_name_length > SPIDER_SYS_LINK_MON_TABLE_DB_NAME_SIZE || + table_name_length > SPIDER_SYS_LINK_MON_TABLE_TABLE_NAME_SIZE || + link_id_length > SPIDER_SYS_LINK_MON_TABLE_LINK_ID_SIZE + ) { + my_printf_error(ER_SPIDER_SYS_TABLE_VERSION_NUM, + ER_SPIDER_SYS_TABLE_VERSION_STR, MYF(0), + SPIDER_SYS_LINK_MON_TABLE_NAME_STR); + DBUG_RETURN(ER_SPIDER_SYS_TABLE_VERSION_NUM); + } + + if ( + db_name_length == mon_key->db_name_length && + table_name_length == mon_key->table_name_length && + link_id_length == mon_key->link_id_length && + !memcmp(db_name, mon_key->db_name, db_name_length) && + !memcmp(table_name, mon_key->table_name, table_name_length) && + !memcmp(link_id, mon_key->link_id, link_id_length) + ) { + /* same key */ + *same = 1; + DBUG_RETURN(0); + } + + *same = 0; + mon_key->db_name_length = db_name_length; + memcpy(mon_key->db_name, db_name, db_name_length + 1); + mon_key->table_name_length = table_name_length; + memcpy(mon_key->table_name, table_name, table_name_length + 1); + mon_key->link_id_length = link_id_length; + memcpy(mon_key->link_id, link_id, link_id_length + 1); + DBUG_RETURN(0); +} + +int spider_get_sys_link_mon_server_id( + TABLE *table, + uint32 *server_id, + MEM_ROOT *mem_root +) { + char *ptr; + int error_num = 0; + DBUG_ENTER("spider_get_sys_link_mon_server_id"); + if ((ptr = get_field(mem_root, table->field[3]))) + *server_id = (uint32) my_strtoll10(ptr, (char**) NULL, &error_num); + else + *server_id = ~(uint32) 0; + DBUG_RETURN(error_num); +} + +int spider_get_sys_link_mon_connect_info( + TABLE *table, + SPIDER_SHARE *share, + int link_idx, + MEM_ROOT *mem_root +) { + char *ptr; + int error_num = 0; + DBUG_ENTER("spider_get_sys_link_mon_connect_info"); + if ( + !table->field[4]->is_null() && + (ptr = get_field(mem_root, table->field[4])) + ) { + share->server_names_lengths[link_idx] = strlen(ptr); + share->server_names[link_idx] = + spider_create_string(ptr, share->server_names_lengths[link_idx]); + } else { + share->server_names_lengths[link_idx] = 0; + share->server_names[link_idx] = NULL; + } + if ( + !table->field[5]->is_null() && + (ptr = get_field(mem_root, table->field[5])) + ) { + share->tgt_wrappers_lengths[link_idx] = strlen(ptr); + share->tgt_wrappers[link_idx] = + spider_create_string(ptr, share->tgt_wrappers_lengths[link_idx]); + } else { + share->tgt_wrappers_lengths[link_idx] = 0; + share->tgt_wrappers[link_idx] = NULL; + } + if ( + !table->field[6]->is_null() && + (ptr = get_field(mem_root, table->field[6])) + ) { + share->tgt_hosts_lengths[link_idx] = strlen(ptr); + share->tgt_hosts[link_idx] = + spider_create_string(ptr, share->tgt_hosts_lengths[link_idx]); + } else { + share->tgt_hosts_lengths[link_idx] = 0; + share->tgt_hosts[link_idx] = NULL; + } + if ( + !table->field[7]->is_null() && + (ptr = get_field(mem_root, table->field[7])) + ) { + share->tgt_ports[link_idx] = atol(ptr); + } else { + share->tgt_ports[link_idx] = -1; + } + if ( + !table->field[8]->is_null() && + (ptr = get_field(mem_root, table->field[8])) + ) { + share->tgt_sockets_lengths[link_idx] = strlen(ptr); + share->tgt_sockets[link_idx] = + spider_create_string(ptr, share->tgt_sockets_lengths[link_idx]); + } else { + share->tgt_sockets_lengths[link_idx] = 0; + share->tgt_sockets[link_idx] = NULL; + } + if ( + !table->field[9]->is_null() && + (ptr = get_field(mem_root, table->field[9])) + ) { + share->tgt_usernames_lengths[link_idx] = strlen(ptr); + share->tgt_usernames[link_idx] = + spider_create_string(ptr, share->tgt_usernames_lengths[link_idx]); + } else { + share->tgt_usernames_lengths[link_idx] = 0; + share->tgt_usernames[link_idx] = NULL; + } + if ( + !table->field[10]->is_null() && + (ptr = get_field(mem_root, table->field[10])) + ) { + share->tgt_passwords_lengths[link_idx] = strlen(ptr); + share->tgt_passwords[link_idx] = + spider_create_string(ptr, share->tgt_passwords_lengths[link_idx]); + } else { + share->tgt_passwords_lengths[link_idx] = 0; + share->tgt_passwords[link_idx] = NULL; + } + if ( + !table->field[11]->is_null() && + (ptr = get_field(mem_root, table->field[11])) + ) { + share->tgt_ssl_cas_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_cas[link_idx] = + spider_create_string(ptr, share->tgt_ssl_cas_lengths[link_idx]); + } else { + share->tgt_ssl_cas_lengths[link_idx] = 0; + share->tgt_ssl_cas[link_idx] = NULL; + } + if ( + !table->field[12]->is_null() && + (ptr = get_field(mem_root, table->field[12])) + ) { + share->tgt_ssl_capaths_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_capaths[link_idx] = + spider_create_string(ptr, share->tgt_ssl_capaths_lengths[link_idx]); + } else { + share->tgt_ssl_capaths_lengths[link_idx] = 0; + share->tgt_ssl_capaths[link_idx] = NULL; + } + if ( + !table->field[13]->is_null() && + (ptr = get_field(mem_root, table->field[13])) + ) { + share->tgt_ssl_certs_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_certs[link_idx] = + spider_create_string(ptr, share->tgt_ssl_certs_lengths[link_idx]); + } else { + share->tgt_ssl_certs_lengths[link_idx] = 0; + share->tgt_ssl_certs[link_idx] = NULL; + } + if ( + !table->field[14]->is_null() && + (ptr = get_field(mem_root, table->field[14])) + ) { + share->tgt_ssl_ciphers_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_ciphers[link_idx] = + spider_create_string(ptr, share->tgt_ssl_ciphers_lengths[link_idx]); + } else { + share->tgt_ssl_ciphers_lengths[link_idx] = 0; + share->tgt_ssl_ciphers[link_idx] = NULL; + } + if ( + !table->field[15]->is_null() && + (ptr = get_field(mem_root, table->field[15])) + ) { + share->tgt_ssl_keys_lengths[link_idx] = strlen(ptr); + share->tgt_ssl_keys[link_idx] = + spider_create_string(ptr, share->tgt_ssl_keys_lengths[link_idx]); + } else { + share->tgt_ssl_keys_lengths[link_idx] = 0; + share->tgt_ssl_keys[link_idx] = NULL; + } + if ( + !table->field[16]->is_null() && + (ptr = get_field(mem_root, table->field[16])) + ) { + share->tgt_ssl_vscs[link_idx] = atol(ptr); + } else + share->tgt_ssl_vscs[link_idx] = -1; + if ( + !table->field[17]->is_null() && + (ptr = get_field(mem_root, table->field[17])) + ) { + share->tgt_default_files_lengths[link_idx] = strlen(ptr); + share->tgt_default_files[link_idx] = + spider_create_string(ptr, share->tgt_default_files_lengths[link_idx]); + } else { + share->tgt_default_files_lengths[link_idx] = 0; + share->tgt_default_files[link_idx] = NULL; + } + if ( + !table->field[18]->is_null() && + (ptr = get_field(mem_root, table->field[18])) + ) { + share->tgt_default_groups_lengths[link_idx] = strlen(ptr); + share->tgt_default_groups[link_idx] = + spider_create_string(ptr, share->tgt_default_groups_lengths[link_idx]); + } else { + share->tgt_default_groups_lengths[link_idx] = 0; + share->tgt_default_groups[link_idx] = NULL; + } + DBUG_RETURN(error_num); +} + +int spider_get_link_statuses( + TABLE *table, + SPIDER_SHARE *share, + MEM_ROOT *mem_root +) { + int error_num, roop_count; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_get_link_statuses"); + table->use_all_columns(); + spider_store_tables_name(table, share->table_name, + share->table_name_length); + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + spider_store_tables_link_idx(table, roop_count); + if ((error_num = spider_check_sys_table(table, table_key))) + { + if ( + (error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE) + ) { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } else if ((error_num = + spider_get_sys_tables_link_status(table, share, roop_count, mem_root))) + { + table->file->print_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int spider_sys_replace( + TABLE *table, + bool *modified_non_trans_table +) { + int error_num, key_num; + bool last_uniq_key; + char table_key[MAX_KEY_LENGTH]; + DBUG_ENTER("spider_sys_replace"); + + while ((error_num = table->file->ha_write_row(table->record[0]))) + { + if ( + table->file->is_fatal_error(error_num, HA_CHECK_DUP) || + (key_num = table->file->get_dup_key(error_num)) < 0 + ) + goto error; + + if (table->file->ha_table_flags() & HA_DUPLICATE_POS) + { +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + error_num = table->file->ha_rnd_pos(table->record[1], + table->file->dup_ref); +#else + error_num = table->file->rnd_pos(table->record[1], table->file->dup_ref); +#endif + if (error_num) + { + if (error_num == HA_ERR_RECORD_DELETED) + error_num = HA_ERR_KEY_NOT_FOUND; + goto error; + } + } else { + if ((error_num = table->file->extra(HA_EXTRA_FLUSH_CACHE))) + goto error; + + key_copy((uchar*)table_key, table->record[0], + table->key_info + key_num, 0); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + error_num = table->file->ha_index_read_idx_map(table->record[1], key_num, + (const uchar*)table_key, HA_WHOLE_KEY, HA_READ_KEY_EXACT); +#else + error_num = table->file->index_read_idx_map(table->record[1], key_num, + (const uchar*)table_key, HA_WHOLE_KEY, HA_READ_KEY_EXACT); +#endif + if (error_num) + { + if (error_num == HA_ERR_RECORD_DELETED) + error_num = HA_ERR_KEY_NOT_FOUND; + goto error; + } + } + + last_uniq_key = TRUE; + while (++key_num < (int) table->s->keys) + if (table->key_info[key_num].flags & HA_NOSAME) + last_uniq_key = FALSE; + + if ( + last_uniq_key && + !table->file->referenced_by_foreign_key() + ) { + error_num = table->file->ha_update_row(table->record[1], + table->record[0]); + if (error_num && error_num != HA_ERR_RECORD_IS_THE_SAME) + goto error; + DBUG_RETURN(0); + } else { + if ((error_num = table->file->ha_delete_row(table->record[1]))) + goto error; + *modified_non_trans_table = TRUE; + } + } + + DBUG_RETURN(0); + +error: + DBUG_RETURN(error_num); +} + +TABLE *spider_mk_sys_tmp_table( + THD *thd, + TABLE *table, + TMP_TABLE_PARAM *tmp_tbl_prm, + const char *field_name, + CHARSET_INFO *cs +) { + Field_blob *field; + Item_field *i_field; + List i_list; + TABLE *tmp_table; + DBUG_ENTER("spider_mk_sys_tmp_table"); + + if (!(field = new Field_blob( + 4294967295U, FALSE, field_name, cs, TRUE))) + goto error_alloc_field; + field->init(table); + + if (!(i_field = new Item_field((Field *) field))) + goto error_alloc_item_field; + + if (i_list.push_back(i_field)) + goto error_push_item; + + if (!(tmp_table = create_tmp_table(thd, tmp_tbl_prm, + i_list, (ORDER*) NULL, FALSE, FALSE, TMP_TABLE_FORCE_MYISAM, + HA_POS_ERROR, (char *) ""))) + goto error_create_tmp_table; + DBUG_RETURN(tmp_table); + +error_create_tmp_table: +error_push_item: + delete i_field; +error_alloc_item_field: + delete field; +error_alloc_field: + DBUG_RETURN(NULL); +} + +void spider_rm_sys_tmp_table( + THD *thd, + TABLE *tmp_table, + TMP_TABLE_PARAM *tmp_tbl_prm +) { + DBUG_ENTER("spider_rm_sys_tmp_table"); + free_tmp_table(thd, tmp_table); + tmp_tbl_prm->cleanup(); + tmp_tbl_prm->field_count = 1; + DBUG_VOID_RETURN; +} + +TABLE *spider_mk_sys_tmp_table_for_result( + THD *thd, + TABLE *table, + TMP_TABLE_PARAM *tmp_tbl_prm, + const char *field_name1, + const char *field_name2, + const char *field_name3, + CHARSET_INFO *cs +) { + Field_blob *field1, *field2, *field3; + Item_field *i_field1, *i_field2, *i_field3; + List i_list; + TABLE *tmp_table; + DBUG_ENTER("spider_mk_sys_tmp_table_for_result"); + + if (!(field1 = new Field_blob( + 4294967295U, FALSE, field_name1, cs, TRUE))) + goto error_alloc_field1; + field1->init(table); + + if (!(i_field1 = new Item_field((Field *) field1))) + goto error_alloc_item_field1; + + if (i_list.push_back(i_field1)) + goto error_push_item1; + + if (!(field2 = new Field_blob( + 4294967295U, FALSE, field_name2, cs, TRUE))) + goto error_alloc_field2; + field2->init(table); + + if (!(i_field2 = new Item_field((Field *) field2))) + goto error_alloc_item_field2; + + if (i_list.push_back(i_field2)) + goto error_push_item2; + + if (!(field3 = new Field_blob( + 4294967295U, FALSE, field_name3, cs, TRUE))) + goto error_alloc_field3; + field3->init(table); + + if (!(i_field3 = new Item_field((Field *) field3))) + goto error_alloc_item_field3; + + if (i_list.push_back(i_field3)) + goto error_push_item3; + + if (!(tmp_table = create_tmp_table(thd, tmp_tbl_prm, + i_list, (ORDER*) NULL, FALSE, FALSE, TMP_TABLE_FORCE_MYISAM, + HA_POS_ERROR, (char *) ""))) + goto error_create_tmp_table; + DBUG_RETURN(tmp_table); + +error_create_tmp_table: +error_push_item3: + delete i_field3; +error_alloc_item_field3: + delete field3; +error_alloc_field3: +error_push_item2: + delete i_field2; +error_alloc_item_field2: + delete field2; +error_alloc_field2: +error_push_item1: + delete i_field1; +error_alloc_item_field1: + delete field1; +error_alloc_field1: + DBUG_RETURN(NULL); +} + +void spider_rm_sys_tmp_table_for_result( + THD *thd, + TABLE *tmp_table, + TMP_TABLE_PARAM *tmp_tbl_prm +) { + DBUG_ENTER("spider_rm_sys_tmp_table_for_result"); + free_tmp_table(thd, tmp_table); + tmp_tbl_prm->cleanup(); + tmp_tbl_prm->field_count = 3; + DBUG_VOID_RETURN; +} diff --git a/storage/spider/spd_sys_table.h b/storage/spider/spd_sys_table.h new file mode 100644 index 00000000000..5b83738bd59 --- /dev/null +++ b/storage/spider/spd_sys_table.h @@ -0,0 +1,427 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define SPIDER_SYS_XA_TABLE_NAME_STR "spider_xa" +#define SPIDER_SYS_XA_TABLE_NAME_LEN (sizeof(SPIDER_SYS_XA_TABLE_NAME_STR) - 1) +#define SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR "spider_xa_member" +#define SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN (sizeof(SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR) - 1) +#define SPIDER_SYS_TABLES_TABLE_NAME_STR "spider_tables" +#define SPIDER_SYS_TABLES_TABLE_NAME_LEN (sizeof(SPIDER_SYS_TABLES_TABLE_NAME_STR) - 1) +#define SPIDER_SYS_LINK_MON_TABLE_NAME_STR "spider_link_mon_servers" +#define SPIDER_SYS_LINK_MON_TABLE_NAME_LEN (sizeof(SPIDER_SYS_LINK_MON_TABLE_NAME_STR) - 1) +#define SPIDER_SYS_LINK_FAILED_TABLE_NAME_STR "spider_link_failed_log" +#define SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN (sizeof(SPIDER_SYS_LINK_FAILED_TABLE_NAME_STR) - 1) + +#define SPIDER_SYS_XA_PREPARED_STR "PREPARED" +#define SPIDER_SYS_XA_NOT_YET_STR "NOT YET" +#define SPIDER_SYS_XA_COMMIT_STR "COMMIT" +#define SPIDER_SYS_XA_ROLLBACK_STR "ROLLBACK" + +#define SPIDER_SYS_XA_COL_CNT 5 +#define SPIDER_SYS_XA_PK_COL_CNT 3 +#define SPIDER_SYS_XA_IDX1_COL_CNT 1 +#define SPIDER_SYS_XA_MEMBER_COL_CNT 18 +#define SPIDER_SYS_XA_MEMBER_PK_COL_CNT 6 +#define SPIDER_SYS_TABLES_COL_CNT 22 +#define SPIDER_SYS_TABLES_PK_COL_CNT 2 +#define SPIDER_SYS_TABLES_IDX1_COL_CNT 1 +#define SPIDER_SYS_LINK_MON_TABLE_COL_CNT 19 + +#define SPIDER_SYS_LINK_MON_TABLE_DB_NAME_SIZE 64 +#define SPIDER_SYS_LINK_MON_TABLE_TABLE_NAME_SIZE 64 +#define SPIDER_SYS_LINK_MON_TABLE_LINK_ID_SIZE 10 + +class SPIDER_MON_KEY: public SPIDER_SORT +{ +public: + char db_name[SPIDER_SYS_LINK_MON_TABLE_DB_NAME_SIZE + 1]; + char table_name[SPIDER_SYS_LINK_MON_TABLE_TABLE_NAME_SIZE + 1]; + char link_id[SPIDER_SYS_LINK_MON_TABLE_LINK_ID_SIZE + 1]; + uint db_name_length; + uint table_name_length; + uint link_id_length; +}; + +#if MYSQL_VERSION_ID < 50500 +TABLE *spider_open_sys_table( + THD *thd, + const char *table_name, + int table_name_length, + bool write, + Open_tables_state *open_tables_backup, + bool need_lock, + int *error_num +); + +void spider_close_sys_table( + THD *thd, + TABLE *table, + Open_tables_state *open_tables_backup, + bool need_lock +); +#else +TABLE *spider_open_sys_table( + THD *thd, + const char *table_name, + int table_name_length, + bool write, + Open_tables_backup *open_tables_backup, + bool need_lock, + int *error_num +); + +void spider_close_sys_table( + THD *thd, + TABLE *table, + Open_tables_backup *open_tables_backup, + bool need_lock +); + +bool spider_sys_open_tables( + THD *thd, + TABLE_LIST **tables, + Open_tables_backup *open_tables_backup +); + +TABLE *spider_sys_open_table( + THD *thd, + TABLE_LIST *tables, + Open_tables_backup *open_tables_backup +); + +void spider_sys_close_table( + THD *thd, + Open_tables_backup *open_tables_backup +); +#endif + +int spider_sys_index_init( + TABLE *table, + uint idx, + bool sorted +); + +int spider_sys_index_end( + TABLE *table +); + +int spider_sys_rnd_init( + TABLE *table, + bool scan +); + +int spider_sys_rnd_end( + TABLE *table +); + +int spider_check_sys_table( + TABLE *table, + char *table_key +); + +int spider_check_sys_table_with_find_flag( + TABLE *table, + char *table_key, + enum ha_rkey_function find_flag +); + +int spider_get_sys_table_by_idx( + TABLE *table, + char *table_key, + const int idx, + const int col_count +); + +int spider_sys_index_next_same( + TABLE *table, + char *table_key +); + +int spider_sys_index_first( + TABLE *table, + const int idx +); + +int spider_sys_index_next( + TABLE *table +); + +void spider_store_xa_pk( + TABLE *table, + XID *xid +); + +void spider_store_xa_bqual_length( + TABLE *table, + XID *xid +); + +void spider_store_xa_status( + TABLE *table, + const char *status +); + +void spider_store_xa_member_pk( + TABLE *table, + XID *xid, + SPIDER_CONN *conn +); + +void spider_store_xa_member_info( + TABLE *table, + XID *xid, + SPIDER_CONN *conn +); + +void spider_store_tables_name( + TABLE *table, + const char *name, + const uint name_length +); + +void spider_store_db_and_table_name( + TABLE *table, + const char *db_name, + const uint db_name_length, + const char *table_name, + const uint table_name_length +); + +void spider_store_tables_link_idx( + TABLE *table, + int link_idx +); + +void spider_store_tables_link_idx_str( + TABLE *table, + const char *link_idx, + const uint link_idx_length +); + +void spider_store_tables_priority( + TABLE *table, + longlong priority +); + +void spider_store_tables_connect_info( + TABLE *table, + SPIDER_ALTER_TABLE *alter_table, + int link_idx +); + +void spider_store_tables_link_status( + TABLE *table, + long link_status +); + +void spider_store_link_chk_server_id( + TABLE *table, + uint32 server_id +); + +int spider_insert_xa( + TABLE *table, + XID *xid, + const char *status +); + +int spider_insert_xa_member( + TABLE *table, + XID *xid, + SPIDER_CONN *conn +); + +int spider_insert_tables( + TABLE *table, + SPIDER_SHARE *share +); + +int spider_log_tables_link_failed( + TABLE *table, + char *name, + uint name_length, + int link_idx +); + +int spider_update_xa( + TABLE *table, + XID *xid, + const char *status +); + +int spider_update_tables_name( + TABLE *table, + const char *from, + const char *to, + int *old_link_count +); + +int spider_update_tables_priority( + TABLE *table, + SPIDER_ALTER_TABLE *alter_table, + const char *name, + int *old_link_count +); + +int spider_update_tables_link_status( + TABLE *table, + char *name, + uint name_length, + int link_idx, + long link_status +); + +int spider_delete_xa( + TABLE *table, + XID *xid +); + +int spider_delete_xa_member( + TABLE *table, + XID *xid +); + +int spider_delete_tables( + TABLE *table, + const char *name, + int *old_link_count +); + +int spider_get_sys_xid( + TABLE *table, + XID *xid, + MEM_ROOT *mem_root +); + +int spider_get_sys_server_info( + TABLE *table, + SPIDER_SHARE *share, + int link_idx, + MEM_ROOT *mem_root +); + +int spider_check_sys_xa_status( + TABLE *table, + const char *status1, + const char *status2, + const char *status3, + const int check_error_num, + MEM_ROOT *mem_root +); + +int spider_get_sys_tables( + TABLE *table, + char **db_name, + char **table_name, + MEM_ROOT *mem_root +); + +int spider_get_sys_tables_connect_info( + TABLE *table, + SPIDER_SHARE *share, + int link_idx, + MEM_ROOT *mem_root +); + +int spider_get_sys_tables_link_status( + TABLE *table, + SPIDER_SHARE *share, + int link_idx, + MEM_ROOT *mem_root +); + +int spider_get_sys_tables_link_idx( + TABLE *table, + int *link_idx, + MEM_ROOT *mem_root +); + +int spider_sys_update_tables_link_status( + THD *thd, + char *name, + uint name_length, + int link_idx, + long link_status, + bool need_lock +); + +int spider_sys_log_tables_link_failed( + THD *thd, + char *name, + uint name_length, + int link_idx, + bool need_lock +); + +int spider_get_sys_link_mon_key( + TABLE *table, + SPIDER_MON_KEY *mon_key, + MEM_ROOT *mem_root, + int *same +); + +int spider_get_sys_link_mon_server_id( + TABLE *table, + uint32 *server_id, + MEM_ROOT *mem_root +); + +int spider_get_sys_link_mon_connect_info( + TABLE *table, + SPIDER_SHARE *share, + int link_idx, + MEM_ROOT *mem_root +); + +int spider_get_link_statuses( + TABLE *table, + SPIDER_SHARE *share, + MEM_ROOT *mem_root +); + +int spider_sys_replace( + TABLE *table, + bool *modified_non_trans_table +); + +TABLE *spider_mk_sys_tmp_table( + THD *thd, + TABLE *table, + TMP_TABLE_PARAM *tmp_tbl_prm, + const char *field_name, + CHARSET_INFO *cs +); + +void spider_rm_sys_tmp_table( + THD *thd, + TABLE *tmp_table, + TMP_TABLE_PARAM *tmp_tbl_prm +); + +TABLE *spider_mk_sys_tmp_table_for_result( + THD *thd, + TABLE *table, + TMP_TABLE_PARAM *tmp_tbl_prm, + const char *field_name1, + const char *field_name2, + const char *field_name3, + CHARSET_INFO *cs +); + +void spider_rm_sys_tmp_table_for_result( + THD *thd, + TABLE *tmp_table, + TMP_TABLE_PARAM *tmp_tbl_prm +); diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc new file mode 100644 index 00000000000..40704f74437 --- /dev/null +++ b/storage/spider/spd_table.cc @@ -0,0 +1,7837 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#include "sql_servers.h" +#endif +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_sys_table.h" +#include "ha_spider.h" +#include "spd_trx.h" +#include "spd_db_conn.h" +#include "spd_table.h" +#include "spd_conn.h" +#include "spd_ping_table.h" +#include "spd_malloc.h" + +ulong *spd_db_att_thread_id; +pthread_mutex_t *spd_db_att_LOCK_xid_cache; +HASH *spd_db_att_xid_cache; +struct charset_info_st *spd_charset_utf8_bin; +const char **spd_defaults_extra_file; +const char **spd_defaults_file; + +handlerton *spider_hton_ptr; +SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; +extern SPIDER_DBTON spider_dbton_mysql; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +extern SPIDER_DBTON spider_dbton_handlersocket; +#endif +#ifdef HAVE_ORACLE_OCI +extern SPIDER_DBTON spider_dbton_oracle; +#endif + +#ifdef HAVE_PSI_INTERFACE +PSI_mutex_key spd_key_mutex_tbl; +PSI_mutex_key spd_key_mutex_init_error_tbl; +#ifdef WITH_PARTITION_STORAGE_ENGINE +PSI_mutex_key spd_key_mutex_pt_share; +#endif +PSI_mutex_key spd_key_mutex_conn; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +PSI_mutex_key spd_key_mutex_hs_r_conn; +PSI_mutex_key spd_key_mutex_hs_w_conn; +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH +PSI_mutex_key spd_key_mutex_global_trx; +#endif +PSI_mutex_key spd_key_mutex_open_conn; +PSI_mutex_key spd_key_mutex_allocated_thds; +PSI_mutex_key spd_key_mutex_mon_table_cache; +PSI_mutex_key spd_key_mutex_udf_table_mon; +PSI_mutex_key spd_key_mutex_mta_conn; +#ifndef WITHOUT_SPIDER_BG_SEARCH +PSI_mutex_key spd_key_mutex_bg_conn_chain; +PSI_mutex_key spd_key_mutex_bg_conn_sync; +PSI_mutex_key spd_key_mutex_bg_conn; +PSI_mutex_key spd_key_mutex_bg_job_stack; +PSI_mutex_key spd_key_mutex_bg_mon; +PSI_mutex_key spd_key_mutex_bg_direct_sql; +#endif +PSI_mutex_key spd_key_mutex_mon_list_caller; +PSI_mutex_key spd_key_mutex_mon_list_receptor; +PSI_mutex_key spd_key_mutex_mon_list_monitor; +PSI_mutex_key spd_key_mutex_mon_list_update_status; +PSI_mutex_key spd_key_mutex_share; +PSI_mutex_key spd_key_mutex_share_sts; +PSI_mutex_key spd_key_mutex_share_crd; +PSI_mutex_key spd_key_mutex_share_auto_increment; +#ifdef WITH_PARTITION_STORAGE_ENGINE +PSI_mutex_key spd_key_mutex_pt_share_sts; +PSI_mutex_key spd_key_mutex_pt_share_crd; +PSI_mutex_key spd_key_mutex_pt_handler; +#endif +PSI_mutex_key spd_key_mutex_udf_table; +PSI_mutex_key spd_key_mutex_mem_calc; +PSI_mutex_key spd_key_thread_id; +PSI_mutex_key spd_key_conn_id; + +static PSI_mutex_info all_spider_mutexes[]= +{ + { &spd_key_mutex_tbl, "tbl", PSI_FLAG_GLOBAL}, + { &spd_key_mutex_init_error_tbl, "init_error_tbl", PSI_FLAG_GLOBAL}, +#ifdef WITH_PARTITION_STORAGE_ENGINE + { &spd_key_mutex_pt_share, "pt_share", PSI_FLAG_GLOBAL}, +#endif + { &spd_key_mutex_conn, "conn", PSI_FLAG_GLOBAL}, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + { &spd_key_mutex_hs_r_conn, "hs_r_conn", PSI_FLAG_GLOBAL}, + { &spd_key_mutex_hs_w_conn, "hs_w_conn", PSI_FLAG_GLOBAL}, +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + { &spd_key_mutex_global_trx, "global_trx", PSI_FLAG_GLOBAL}, +#endif + { &spd_key_mutex_open_conn, "open_conn", PSI_FLAG_GLOBAL}, + { &spd_key_mutex_allocated_thds, "allocated_thds", PSI_FLAG_GLOBAL}, + { &spd_key_mutex_mon_table_cache, "mon_table_cache", PSI_FLAG_GLOBAL}, + { &spd_key_mutex_udf_table_mon, "udf_table_mon", PSI_FLAG_GLOBAL}, + { &spd_key_mutex_mem_calc, "mem_calc", PSI_FLAG_GLOBAL}, + { &spd_key_thread_id, "thread_id", PSI_FLAG_GLOBAL}, + { &spd_key_conn_id, "conn_id", PSI_FLAG_GLOBAL}, + { &spd_key_mutex_mta_conn, "mta_conn", 0}, +#ifndef WITHOUT_SPIDER_BG_SEARCH + { &spd_key_mutex_bg_conn_chain, "bg_conn_chain", 0}, + { &spd_key_mutex_bg_conn_sync, "bg_conn_sync", 0}, + { &spd_key_mutex_bg_conn, "bg_conn", 0}, + { &spd_key_mutex_bg_job_stack, "bg_job_stack", 0}, + { &spd_key_mutex_bg_mon, "bg_mon", 0}, + { &spd_key_mutex_bg_direct_sql, "bg_direct_sql", 0}, +#endif + { &spd_key_mutex_mon_list_caller, "mon_list_caller", 0}, + { &spd_key_mutex_mon_list_receptor, "mon_list_receptor", 0}, + { &spd_key_mutex_mon_list_monitor, "mon_list_monitor", 0}, + { &spd_key_mutex_mon_list_update_status, "mon_list_update_status", 0}, + { &spd_key_mutex_share, "share", 0}, + { &spd_key_mutex_share_sts, "share_sts", 0}, + { &spd_key_mutex_share_crd, "share_crd", 0}, + { &spd_key_mutex_share_auto_increment, "share_auto_increment", 0}, +#ifdef WITH_PARTITION_STORAGE_ENGINE + { &spd_key_mutex_pt_share_sts, "pt_share_sts", 0}, + { &spd_key_mutex_pt_share_crd, "pt_share_crd", 0}, + { &spd_key_mutex_pt_handler, "pt_handler", 0}, +#endif + { &spd_key_mutex_udf_table, "udf_table", 0}, +}; + +#ifndef WITHOUT_SPIDER_BG_SEARCH +PSI_cond_key spd_key_cond_bg_conn_sync; +PSI_cond_key spd_key_cond_bg_conn; +PSI_cond_key spd_key_cond_bg_sts; +PSI_cond_key spd_key_cond_bg_sts_sync; +PSI_cond_key spd_key_cond_bg_crd; +PSI_cond_key spd_key_cond_bg_crd_sync; +PSI_cond_key spd_key_cond_bg_mon; +PSI_cond_key spd_key_cond_bg_direct_sql; +#endif +PSI_cond_key spd_key_cond_udf_table_mon; + +static PSI_cond_info all_spider_conds[] = { +#ifndef WITHOUT_SPIDER_BG_SEARCH + {&spd_key_cond_bg_conn_sync, "bg_conn_sync", 0}, + {&spd_key_cond_bg_conn, "bg_conn", 0}, + {&spd_key_cond_bg_sts, "bg_sts", 0}, + {&spd_key_cond_bg_sts_sync, "bg_sts_sync", 0}, + {&spd_key_cond_bg_crd, "bg_crd", 0}, + {&spd_key_cond_bg_crd_sync, "bg_crd_sync", 0}, + {&spd_key_cond_bg_mon, "bg_mon", 0}, + {&spd_key_cond_bg_direct_sql, "bg_direct_sql", 0}, +#endif + {&spd_key_cond_udf_table_mon, "udf_table_mon", 0}, +}; + +#ifndef WITHOUT_SPIDER_BG_SEARCH +PSI_thread_key spd_key_thd_bg; +PSI_thread_key spd_key_thd_bg_sts; +PSI_thread_key spd_key_thd_bg_crd; +PSI_thread_key spd_key_thd_bg_mon; +#endif + +static PSI_thread_info all_spider_threads[] = { +#ifndef WITHOUT_SPIDER_BG_SEARCH + {&spd_key_thd_bg, "bg", 0}, + {&spd_key_thd_bg_sts, "bg_sts", 0}, + {&spd_key_thd_bg_crd, "bg_crd", 0}, + {&spd_key_thd_bg_mon, "bg_mon", 0}, +#endif +}; +#endif + +extern HASH spider_open_connections; +extern uint spider_open_connections_id; +extern const char *spider_open_connections_func_name; +extern const char *spider_open_connections_file_name; +extern ulong spider_open_connections_line_no; +extern pthread_mutex_t spider_conn_mutex; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +extern HASH spider_hs_r_conn_hash; +extern uint spider_hs_r_conn_hash_id; +extern const char *spider_hs_r_conn_hash_func_name; +extern const char *spider_hs_r_conn_hash_file_name; +extern ulong spider_hs_r_conn_hash_line_no; +extern pthread_mutex_t spider_hs_r_conn_mutex; +extern HASH spider_hs_w_conn_hash; +extern uint spider_hs_w_conn_hash_id; +extern const char *spider_hs_w_conn_hash_func_name; +extern const char *spider_hs_w_conn_hash_file_name; +extern ulong spider_hs_w_conn_hash_line_no; +extern pthread_mutex_t spider_hs_w_conn_mutex; +#endif +extern HASH *spider_udf_table_mon_list_hash; +extern uint spider_udf_table_mon_list_hash_id; +extern const char *spider_udf_table_mon_list_hash_func_name; +extern const char *spider_udf_table_mon_list_hash_file_name; +extern ulong spider_udf_table_mon_list_hash_line_no; +extern pthread_mutex_t *spider_udf_table_mon_mutexes; +extern pthread_cond_t *spider_udf_table_mon_conds; +extern pthread_mutex_t spider_open_conn_mutex; +extern pthread_mutex_t spider_mon_table_cache_mutex; +extern DYNAMIC_ARRAY spider_mon_table_cache; +extern uint spider_mon_table_cache_id; +extern const char *spider_mon_table_cache_func_name; +extern const char *spider_mon_table_cache_file_name; +extern ulong spider_mon_table_cache_line_no; + +HASH spider_open_tables; +uint spider_open_tables_id; +const char *spider_open_tables_func_name; +const char *spider_open_tables_file_name; +ulong spider_open_tables_line_no; +pthread_mutex_t spider_tbl_mutex; +HASH spider_init_error_tables; +uint spider_init_error_tables_id; +const char *spider_init_error_tables_func_name; +const char *spider_init_error_tables_file_name; +ulong spider_init_error_tables_line_no; +pthread_mutex_t spider_init_error_tbl_mutex; + +extern pthread_mutex_t spider_thread_id_mutex; +extern pthread_mutex_t spider_conn_id_mutex; + +#ifdef WITH_PARTITION_STORAGE_ENGINE +HASH spider_open_pt_share; +uint spider_open_pt_share_id; +const char *spider_open_pt_share_func_name; +const char *spider_open_pt_share_file_name; +ulong spider_open_pt_share_line_no; +pthread_mutex_t spider_pt_share_mutex; +#endif + +HASH spider_allocated_thds; +uint spider_allocated_thds_id; +const char *spider_allocated_thds_func_name; +const char *spider_allocated_thds_file_name; +ulong spider_allocated_thds_line_no; +pthread_mutex_t spider_allocated_thds_mutex; + +#ifndef WITHOUT_SPIDER_BG_SEARCH +pthread_attr_t spider_pt_attr; + +pthread_mutex_t spider_global_trx_mutex; +SPIDER_TRX *spider_global_trx; +#endif + +extern pthread_mutex_t spider_mem_calc_mutex; + +extern const char *spider_alloc_func_name[SPIDER_MEM_CALC_LIST_NUM]; +extern const char *spider_alloc_file_name[SPIDER_MEM_CALC_LIST_NUM]; +extern ulong spider_alloc_line_no[SPIDER_MEM_CALC_LIST_NUM]; +extern ulonglong spider_total_alloc_mem[SPIDER_MEM_CALC_LIST_NUM]; +extern longlong spider_current_alloc_mem[SPIDER_MEM_CALC_LIST_NUM]; +extern ulonglong spider_alloc_mem_count[SPIDER_MEM_CALC_LIST_NUM]; +extern ulonglong spider_free_mem_count[SPIDER_MEM_CALC_LIST_NUM]; + +static char spider_wild_many = '%', spider_wild_one = '_', + spider_wild_prefix='\\'; + +// for spider_open_tables +uchar *spider_tbl_get_key( + SPIDER_SHARE *share, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_tbl_get_key"); + *length = share->table_name_length; + DBUG_RETURN((uchar*) share->table_name); +} + +#ifdef WITH_PARTITION_STORAGE_ENGINE +uchar *spider_pt_share_get_key( + SPIDER_PARTITION_SHARE *share, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_pt_share_get_key"); + *length = share->table_name_length; + DBUG_RETURN((uchar*) share->table_name); +} + +uchar *spider_pt_handler_share_get_key( + SPIDER_PARTITION_HANDLER_SHARE *share, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_pt_handler_share_get_key"); + *length = sizeof(TABLE *); + DBUG_RETURN((uchar*) &share->table); +} +#endif + +uchar *spider_link_get_key( + SPIDER_LINK_FOR_HASH *link_for_hash, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_link_get_key"); + *length = link_for_hash->db_table_str->length(); + DBUG_RETURN((uchar*) link_for_hash->db_table_str->ptr()); +} + +uchar *spider_ha_get_key( + ha_spider *spider, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_ha_get_key"); + *length = spider->share->table_name_length; + DBUG_RETURN((uchar*) spider->share->table_name); +} + +uchar *spider_udf_tbl_mon_list_key( + SPIDER_TABLE_MON_LIST *table_mon_list, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_udf_tbl_mon_list_key"); + DBUG_PRINT("info",("spider hash key=%s", table_mon_list->key)); + DBUG_PRINT("info",("spider hash key length=%u", table_mon_list->key_length)); + *length = table_mon_list->key_length; + DBUG_RETURN((uchar*) table_mon_list->key); +} + +uchar *spider_allocated_thds_get_key( + THD *thd, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_allocated_thds_get_key"); + *length = sizeof(THD *); + DBUG_RETURN((uchar*) thd); +} + +#ifdef HAVE_PSI_INTERFACE +static void init_spider_psi_keys() +{ + DBUG_ENTER("init_spider_psi_keys"); + if (PSI_server == NULL) + DBUG_VOID_RETURN; + + PSI_server->register_mutex("spider", all_spider_mutexes, + array_elements(all_spider_mutexes)); + PSI_server->register_cond("spider", all_spider_conds, + array_elements(all_spider_conds)); + PSI_server->register_thread("spider", all_spider_threads, + array_elements(all_spider_threads)); + DBUG_VOID_RETURN; +} +#endif + +int spider_get_server( + SPIDER_SHARE *share, + int link_idx +) { + MEM_ROOT mem_root; + int error_num, length; + FOREIGN_SERVER *server, server_buf; + DBUG_ENTER("spider_get_server"); + SPD_INIT_ALLOC_ROOT(&mem_root, 128, 0, MYF(MY_WME)); + + if (!(server + = get_server_by_name(&mem_root, share->server_names[link_idx], + &server_buf))) + { + error_num = ER_FOREIGN_SERVER_DOESNT_EXIST; + goto error; + } + + if (!share->tgt_wrappers[link_idx] && server->scheme) + { + share->tgt_wrappers_lengths[link_idx] = strlen(server->scheme); + if (!(share->tgt_wrappers[link_idx] = + spider_create_string(server->scheme, + share->tgt_wrappers_lengths[link_idx]))) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + DBUG_PRINT("info",("spider tgt_wrappers=%s", + share->tgt_wrappers[link_idx])); + } + + if (!share->tgt_hosts[link_idx] && server->host) + { + share->tgt_hosts_lengths[link_idx] = strlen(server->host); + if (!(share->tgt_hosts[link_idx] = + spider_create_string(server->host, share->tgt_hosts_lengths[link_idx]))) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + DBUG_PRINT("info",("spider tgt_hosts=%s", share->tgt_hosts[link_idx])); + } + + if (share->tgt_ports[link_idx] == -1) + { + share->tgt_ports[link_idx] = server->port; + DBUG_PRINT("info",("spider tgt_ports=%ld", share->tgt_ports[link_idx])); + } + + if (!share->tgt_sockets[link_idx] && server->socket) + { + share->tgt_sockets_lengths[link_idx] = strlen(server->socket); + if (!(share->tgt_sockets[link_idx] = + spider_create_string(server->socket, + share->tgt_sockets_lengths[link_idx]))) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + DBUG_PRINT("info",("spider tgt_sockets=%s", share->tgt_sockets[link_idx])); + } + + if (!share->tgt_dbs[link_idx] && server->db && (length = strlen(server->db))) + { + share->tgt_dbs_lengths[link_idx] = length; + if (!(share->tgt_dbs[link_idx] = + spider_create_string(server->db, length))) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + DBUG_PRINT("info",("spider tgt_dbs=%s", share->tgt_dbs[link_idx])); + } + + if (!share->tgt_usernames[link_idx] && server->username) + { + share->tgt_usernames_lengths[link_idx] = strlen(server->username); + if (!(share->tgt_usernames[link_idx] = + spider_create_string(server->username, + share->tgt_usernames_lengths[link_idx]))) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + DBUG_PRINT("info",("spider tgt_usernames=%s", + share->tgt_usernames[link_idx])); + } + + if (!share->tgt_passwords[link_idx] && server->password) + { + share->tgt_passwords_lengths[link_idx] = strlen(server->password); + if (!(share->tgt_passwords[link_idx] = + spider_create_string(server->password, + share->tgt_passwords_lengths[link_idx]))) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + DBUG_PRINT("info",("spider tgt_passwords=%s", + share->tgt_passwords[link_idx])); + } + + free_root(&mem_root, MYF(0)); + DBUG_RETURN(0); + +error: + free_root(&mem_root, MYF(0)); + my_error(error_num, MYF(0), share->server_names[link_idx]); + DBUG_RETURN(error_num); +} + +int spider_free_share_alloc( + SPIDER_SHARE *share +) { + int roop_count; + DBUG_ENTER("spider_free_share_alloc"); + if (share->dbton_bitmap) + { + for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; roop_count--) + { + if (share->dbton_share[roop_count]) + { + delete share->dbton_share[roop_count]; + share->dbton_share[roop_count] = NULL; + } + } + } + if (share->server_names) + { + for (roop_count = 0; roop_count < (int) share->server_names_length; + roop_count++) + { + if (share->server_names[roop_count]) + spider_free(spider_current_trx, share->server_names[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->server_names, MYF(0)); + } + if (share->tgt_table_names) + { + for (roop_count = 0; roop_count < (int) share->tgt_table_names_length; + roop_count++) + { + if (share->tgt_table_names[roop_count]) + spider_free(spider_current_trx, share->tgt_table_names[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_table_names, MYF(0)); + } + if (share->tgt_dbs) + { + for (roop_count = 0; roop_count < (int) share->tgt_dbs_length; + roop_count++) + { + if (share->tgt_dbs[roop_count]) + spider_free(spider_current_trx, share->tgt_dbs[roop_count], MYF(0)); + } + spider_free(spider_current_trx, share->tgt_dbs, MYF(0)); + } + if (share->tgt_hosts) + { + for (roop_count = 0; roop_count < (int) share->tgt_hosts_length; + roop_count++) + { + if (share->tgt_hosts[roop_count]) + spider_free(spider_current_trx, share->tgt_hosts[roop_count], MYF(0)); + } + spider_free(spider_current_trx, share->tgt_hosts, MYF(0)); + } + if (share->tgt_usernames) + { + for (roop_count = 0; roop_count < (int) share->tgt_usernames_length; + roop_count++) + { + if (share->tgt_usernames[roop_count]) + spider_free(spider_current_trx, share->tgt_usernames[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_usernames, MYF(0)); + } + if (share->tgt_passwords) + { + for (roop_count = 0; roop_count < (int) share->tgt_passwords_length; + roop_count++) + { + if (share->tgt_passwords[roop_count]) + spider_free(spider_current_trx, share->tgt_passwords[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_passwords, MYF(0)); + } + if (share->tgt_sockets) + { + for (roop_count = 0; roop_count < (int) share->tgt_sockets_length; + roop_count++) + { + if (share->tgt_sockets[roop_count]) + spider_free(spider_current_trx, share->tgt_sockets[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_sockets, MYF(0)); + } + if (share->tgt_wrappers) + { + for (roop_count = 0; roop_count < (int) share->tgt_wrappers_length; + roop_count++) + { + if (share->tgt_wrappers[roop_count]) + spider_free(spider_current_trx, share->tgt_wrappers[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_wrappers, MYF(0)); + } + if (share->tgt_ssl_cas) + { + for (roop_count = 0; roop_count < (int) share->tgt_ssl_cas_length; + roop_count++) + { + if (share->tgt_ssl_cas[roop_count]) + spider_free(spider_current_trx, share->tgt_ssl_cas[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_ssl_cas, MYF(0)); + } + if (share->tgt_ssl_capaths) + { + for (roop_count = 0; roop_count < (int) share->tgt_ssl_capaths_length; + roop_count++) + { + if (share->tgt_ssl_capaths[roop_count]) + spider_free(spider_current_trx, share->tgt_ssl_capaths[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_ssl_capaths, MYF(0)); + } + if (share->tgt_ssl_certs) + { + for (roop_count = 0; roop_count < (int) share->tgt_ssl_certs_length; + roop_count++) + { + if (share->tgt_ssl_certs[roop_count]) + spider_free(spider_current_trx, share->tgt_ssl_certs[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_ssl_certs, MYF(0)); + } + if (share->tgt_ssl_ciphers) + { + for (roop_count = 0; roop_count < (int) share->tgt_ssl_ciphers_length; + roop_count++) + { + if (share->tgt_ssl_ciphers[roop_count]) + spider_free(spider_current_trx, share->tgt_ssl_ciphers[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_ssl_ciphers, MYF(0)); + } + if (share->tgt_ssl_keys) + { + for (roop_count = 0; roop_count < (int) share->tgt_ssl_keys_length; + roop_count++) + { + if (share->tgt_ssl_keys[roop_count]) + spider_free(spider_current_trx, share->tgt_ssl_keys[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_ssl_keys, MYF(0)); + } + if (share->tgt_default_files) + { + for (roop_count = 0; roop_count < (int) share->tgt_default_files_length; + roop_count++) + { + if (share->tgt_default_files[roop_count]) + spider_free(spider_current_trx, share->tgt_default_files[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_default_files, MYF(0)); + } + if (share->tgt_default_groups) + { + for (roop_count = 0; roop_count < (int) share->tgt_default_groups_length; + roop_count++) + { + if (share->tgt_default_groups[roop_count]) + spider_free(spider_current_trx, share->tgt_default_groups[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_default_groups, MYF(0)); + } + if (share->tgt_pk_names) + { + for (roop_count = 0; roop_count < (int) share->tgt_pk_names_length; + roop_count++) + { + if (share->tgt_pk_names[roop_count]) + spider_free(spider_current_trx, share->tgt_pk_names[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_pk_names, MYF(0)); + } + if (share->tgt_sequence_names) + { + for (roop_count = 0; roop_count < (int) share->tgt_sequence_names_length; + roop_count++) + { + if (share->tgt_sequence_names[roop_count]) + spider_free(spider_current_trx, share->tgt_sequence_names[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->tgt_sequence_names, MYF(0)); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (share->hs_read_socks) + { + for (roop_count = 0; roop_count < (int) share->hs_read_socks_length; + roop_count++) + { + if (share->hs_read_socks[roop_count]) + spider_free(spider_current_trx, share->hs_read_socks[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->hs_read_socks, MYF(0)); + } + if (share->hs_write_socks) + { + for (roop_count = 0; roop_count < (int) share->hs_write_socks_length; + roop_count++) + { + if (share->hs_write_socks[roop_count]) + spider_free(spider_current_trx, share->hs_write_socks[roop_count], + MYF(0)); + } + spider_free(spider_current_trx, share->hs_write_socks, MYF(0)); + } +#endif + if (share->bka_engine) + spider_free(spider_current_trx, share->bka_engine, MYF(0)); + if (share->conn_keys) + spider_free(spider_current_trx, share->conn_keys, MYF(0)); + if (share->tgt_ports) + spider_free(spider_current_trx, share->tgt_ports, MYF(0)); + if (share->tgt_ssl_vscs) + spider_free(spider_current_trx, share->tgt_ssl_vscs, MYF(0)); + if (share->link_statuses) + spider_free(spider_current_trx, share->link_statuses, MYF(0)); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (share->monitoring_bg_kind) + spider_free(spider_current_trx, share->monitoring_bg_kind, MYF(0)); +#endif + if (share->monitoring_kind) + spider_free(spider_current_trx, share->monitoring_kind, MYF(0)); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (share->use_hs_reads) + spider_free(spider_current_trx, share->use_hs_reads, MYF(0)); + if (share->use_hs_writes) + spider_free(spider_current_trx, share->use_hs_writes, MYF(0)); + if (share->hs_read_ports) + spider_free(spider_current_trx, share->hs_read_ports, MYF(0)); + if (share->hs_write_ports) + spider_free(spider_current_trx, share->hs_write_ports, MYF(0)); + if (share->hs_write_to_reads) + spider_free(spider_current_trx, share->hs_write_to_reads, MYF(0)); +#endif + if (share->use_handlers) + spider_free(spider_current_trx, share->use_handlers, MYF(0)); + if (share->connect_timeouts) + spider_free(spider_current_trx, share->connect_timeouts, MYF(0)); + if (share->net_read_timeouts) + spider_free(spider_current_trx, share->net_read_timeouts, MYF(0)); + if (share->net_write_timeouts) + spider_free(spider_current_trx, share->net_write_timeouts, MYF(0)); + if (share->access_balances) + spider_free(spider_current_trx, share->access_balances, MYF(0)); +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (share->monitoring_bg_interval) + spider_free(spider_current_trx, share->monitoring_bg_interval, MYF(0)); +#endif + if (share->monitoring_limit) + spider_free(spider_current_trx, share->monitoring_limit, MYF(0)); + if (share->monitoring_sid) + spider_free(spider_current_trx, share->monitoring_sid, MYF(0)); + if (share->alter_table.tmp_server_names) + spider_free(spider_current_trx, share->alter_table.tmp_server_names, + MYF(0)); + if (share->key_hint) + { + delete [] share->key_hint; + share->key_hint = NULL; + } +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (share->partition_share) + spider_free_pt_share(share->partition_share); +#endif + DBUG_RETURN(0); +} + +void spider_free_tmp_share_alloc( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_free_tmp_share_alloc"); + if (share->server_names && share->server_names[0]) + { + spider_free(spider_current_trx, share->server_names[0], MYF(0)); + share->server_names[0] = NULL; + } + if (share->tgt_table_names && share->tgt_table_names[0]) + { + spider_free(spider_current_trx, share->tgt_table_names[0], MYF(0)); + share->tgt_table_names[0] = NULL; + } + if (share->tgt_dbs && share->tgt_dbs[0]) + { + spider_free(spider_current_trx, share->tgt_dbs[0], MYF(0)); + share->tgt_dbs[0] = NULL; + } + if (share->tgt_hosts && share->tgt_hosts[0]) + { + spider_free(spider_current_trx, share->tgt_hosts[0], MYF(0)); + share->tgt_hosts[0] = NULL; + } + if (share->tgt_usernames && share->tgt_usernames[0]) + { + spider_free(spider_current_trx, share->tgt_usernames[0], MYF(0)); + share->tgt_usernames[0] = NULL; + } + if (share->tgt_passwords && share->tgt_passwords[0]) + { + spider_free(spider_current_trx, share->tgt_passwords[0], MYF(0)); + share->tgt_passwords[0] = NULL; + } + if (share->tgt_sockets && share->tgt_sockets[0]) + { + spider_free(spider_current_trx, share->tgt_sockets[0], MYF(0)); + share->tgt_sockets[0] = NULL; + } + if (share->tgt_wrappers && share->tgt_wrappers[0]) + { + spider_free(spider_current_trx, share->tgt_wrappers[0], MYF(0)); + share->tgt_wrappers[0] = NULL; + } + if (share->tgt_ssl_cas && share->tgt_ssl_cas[0]) + { + spider_free(spider_current_trx, share->tgt_ssl_cas[0], MYF(0)); + share->tgt_ssl_cas[0] = NULL; + } + if (share->tgt_ssl_capaths && share->tgt_ssl_capaths[0]) + { + spider_free(spider_current_trx, share->tgt_ssl_capaths[0], MYF(0)); + share->tgt_ssl_capaths[0] = NULL; + } + if (share->tgt_ssl_certs && share->tgt_ssl_certs[0]) + { + spider_free(spider_current_trx, share->tgt_ssl_certs[0], MYF(0)); + share->tgt_ssl_certs[0] = NULL; + } + if (share->tgt_ssl_ciphers && share->tgt_ssl_ciphers[0]) + { + spider_free(spider_current_trx, share->tgt_ssl_ciphers[0], MYF(0)); + share->tgt_ssl_ciphers[0] = NULL; + } + if (share->tgt_ssl_keys && share->tgt_ssl_keys[0]) + { + spider_free(spider_current_trx, share->tgt_ssl_keys[0], MYF(0)); + share->tgt_ssl_keys[0] = NULL; + } + if (share->tgt_default_files && share->tgt_default_files[0]) + { + spider_free(spider_current_trx, share->tgt_default_files[0], MYF(0)); + share->tgt_default_files[0] = NULL; + } + if (share->tgt_default_groups && share->tgt_default_groups[0]) + { + spider_free(spider_current_trx, share->tgt_default_groups[0], MYF(0)); + share->tgt_default_groups[0] = NULL; + } + if (share->tgt_pk_names && share->tgt_pk_names[0]) + { + spider_free(spider_current_trx, share->tgt_pk_names[0], MYF(0)); + share->tgt_pk_names[0] = NULL; + } + if (share->tgt_sequence_names && share->tgt_sequence_names[0]) + { + spider_free(spider_current_trx, share->tgt_sequence_names[0], MYF(0)); + share->tgt_sequence_names[0] = NULL; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (share->hs_read_socks && share->hs_read_socks[0]) + { + spider_free(spider_current_trx, share->hs_read_socks[0], MYF(0)); + share->hs_read_socks[0] = NULL; + } + if (share->hs_write_socks && share->hs_write_socks[0]) + { + spider_free(spider_current_trx, share->hs_write_socks[0], MYF(0)); + share->hs_write_socks[0] = NULL; + } +#endif + if (share->bka_engine) + { + spider_free(spider_current_trx, share->bka_engine, MYF(0)); + share->bka_engine = NULL; + } + if (share->conn_keys) + { + spider_free(spider_current_trx, share->conn_keys, MYF(0)); + share->conn_keys = NULL; + } + if (share->key_hint) + { + delete [] share->key_hint; + share->key_hint = NULL; + } + DBUG_VOID_RETURN; +} + +char *spider_get_string_between_quote( + char *ptr, + bool alloc +) { + char *start_ptr, *end_ptr, *tmp_ptr, *esc_ptr; + bool find_flg = FALSE, esc_flg = FALSE; + DBUG_ENTER("spider_get_string_between_quote"); + + start_ptr = strchr(ptr, '\''); + end_ptr = strchr(ptr, '"'); + if (start_ptr && (!end_ptr || start_ptr < end_ptr)) + { + tmp_ptr = ++start_ptr; + while (!find_flg) + { + if (!(end_ptr = strchr(tmp_ptr, '\''))) + DBUG_RETURN(NULL); + esc_ptr = tmp_ptr; + while (!find_flg) + { + esc_ptr = strchr(esc_ptr, '\\'); + if (!esc_ptr || esc_ptr > end_ptr) + find_flg = TRUE; + else if (esc_ptr == end_ptr - 1) + { + esc_flg = TRUE; + tmp_ptr = end_ptr + 1; + break; + } else { + esc_flg = TRUE; + esc_ptr += 2; + } + } + } + } else if (end_ptr) + { + start_ptr = end_ptr; + tmp_ptr = ++start_ptr; + while (!find_flg) + { + if (!(end_ptr = strchr(tmp_ptr, '"'))) + DBUG_RETURN(NULL); + esc_ptr = tmp_ptr; + while (!find_flg) + { + esc_ptr = strchr(esc_ptr, '\\'); + if (!esc_ptr || esc_ptr > end_ptr) + find_flg = TRUE; + else if (esc_ptr == end_ptr - 1) + { + esc_flg = TRUE; + tmp_ptr = end_ptr + 1; + break; + } else { + esc_flg = TRUE; + esc_ptr += 2; + } + } + } + } else + DBUG_RETURN(NULL); + + *end_ptr = '\0'; + if (esc_flg) + { + esc_ptr = start_ptr; + while (TRUE) + { + esc_ptr = strchr(esc_ptr, '\\'); + if (!esc_ptr) + break; + switch(*(esc_ptr + 1)) + { + case 'b': + *esc_ptr = '\b'; + break; + case 'n': + *esc_ptr = '\n'; + break; + case 'r': + *esc_ptr = '\r'; + break; + case 't': + *esc_ptr = '\t'; + break; + default: + *esc_ptr = *(esc_ptr + 1); + break; + } + esc_ptr++; + strcpy(esc_ptr, esc_ptr + 1); + } + } + if (alloc) + { + DBUG_RETURN( + spider_create_string( + start_ptr, + strlen(start_ptr)) + ); + } else { + DBUG_RETURN(start_ptr); + } +} + +int spider_create_string_list( + char ***string_list, + uint **string_length_list, + uint *list_length, + char *str, + uint length +) { + int roop_count; + char *tmp_ptr, *tmp_ptr2, *tmp_ptr3, *esc_ptr; + bool find_flg = FALSE; + DBUG_ENTER("spider_create_string_list"); + + *list_length = 0; + if (!str) + { + *string_list = NULL; + DBUG_RETURN(0); + } + + tmp_ptr = str; + while (*tmp_ptr == ' ') + tmp_ptr++; + if (*tmp_ptr) + *list_length = 1; + else { + *string_list = NULL; + DBUG_RETURN(0); + } + + while (TRUE) + { + if ((tmp_ptr2 = strchr(tmp_ptr, ' '))) + { + esc_ptr = tmp_ptr; + while (!find_flg) + { + esc_ptr = strchr(esc_ptr, '\\'); + if (!esc_ptr || esc_ptr > tmp_ptr2) + find_flg = TRUE; + else if (esc_ptr == tmp_ptr2 - 1) + { + tmp_ptr = tmp_ptr2 + 1; + break; + } else + esc_ptr += 2; + } + if (find_flg) + { + (*list_length)++; + tmp_ptr = tmp_ptr2 + 1; + while (*tmp_ptr == ' ') + tmp_ptr++; + } + } else + break; + } + + if (!(*string_list = (char**) + spider_bulk_malloc(spider_current_trx, 37, MYF(MY_WME | MY_ZEROFILL), + string_list, sizeof(char*) * (*list_length), + string_length_list, sizeof(int) * (*list_length), + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + tmp_ptr = str; + while (*tmp_ptr == ' ') + { + *tmp_ptr = '\0'; + tmp_ptr++; + } + tmp_ptr3 = tmp_ptr; + + for (roop_count = 0; roop_count < (int) *list_length - 1; roop_count++) + { + while (TRUE) + { + tmp_ptr2 = strchr(tmp_ptr, ' '); + + esc_ptr = tmp_ptr; + while (!find_flg) + { + esc_ptr = strchr(esc_ptr, '\\'); + if (!esc_ptr || esc_ptr > tmp_ptr2) + find_flg = TRUE; + else if (esc_ptr == tmp_ptr2 - 1) + { + tmp_ptr = tmp_ptr2 + 1; + break; + } else + esc_ptr += 2; + } + if (find_flg) + break; + } + tmp_ptr = tmp_ptr2; + + while (*tmp_ptr == ' ') + { + *tmp_ptr = '\0'; + tmp_ptr++; + } + + (*string_length_list)[roop_count] = strlen(tmp_ptr3); + if (!((*string_list)[roop_count] = spider_create_string( + tmp_ptr3, (*string_length_list)[roop_count])) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + DBUG_PRINT("info",("spider string_list[%d]=%s", roop_count, + (*string_list)[roop_count])); + tmp_ptr3 = tmp_ptr; + } + (*string_length_list)[roop_count] = strlen(tmp_ptr3); + if (!((*string_list)[roop_count] = spider_create_string( + tmp_ptr3, (*string_length_list)[roop_count])) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + DBUG_PRINT("info",("spider string_list[%d]=%s", roop_count, + (*string_list)[roop_count])); + + DBUG_RETURN(0); +} + +int spider_create_long_list( + long **long_list, + uint *list_length, + char *str, + uint length, + long min_val, + long max_val +) { + int roop_count; + char *tmp_ptr; + DBUG_ENTER("spider_create_long_list"); + + *list_length = 0; + if (!str) + { + *long_list = NULL; + DBUG_RETURN(0); + } + + tmp_ptr = str; + while (*tmp_ptr == ' ') + tmp_ptr++; + if (*tmp_ptr) + *list_length = 1; + else { + *long_list = NULL; + DBUG_RETURN(0); + } + + while (TRUE) + { + if ((tmp_ptr = strchr(tmp_ptr, ' '))) + { + (*list_length)++; + tmp_ptr = tmp_ptr + 1; + while (*tmp_ptr == ' ') + tmp_ptr++; + } else + break; + } + + if (!(*long_list = (long*) + spider_bulk_malloc(spider_current_trx, 38, MYF(MY_WME | MY_ZEROFILL), + long_list, sizeof(long) * (*list_length), + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + tmp_ptr = str; + for (roop_count = 0; roop_count < (int) *list_length; roop_count++) + { + if (roop_count != 0) + tmp_ptr = strchr(tmp_ptr, ' '); + + while (*tmp_ptr == ' ') + { + *tmp_ptr = '\0'; + tmp_ptr++; + } + (*long_list)[roop_count] = atol(tmp_ptr); + if ((*long_list)[roop_count] < min_val) + (*long_list)[roop_count] = min_val; + else if ((*long_list)[roop_count] > max_val) + (*long_list)[roop_count] = max_val; + } + +#ifndef DBUG_OFF + for (roop_count = 0; roop_count < (int) *list_length; roop_count++) + { + DBUG_PRINT("info",("spider long_list[%d]=%ld", roop_count, + (*long_list)[roop_count])); + } +#endif + + DBUG_RETURN(0); +} + +int spider_create_longlong_list( + longlong **longlong_list, + uint *list_length, + char *str, + uint length, + longlong min_val, + longlong max_val +) { + int error_num, roop_count; + char *tmp_ptr; + DBUG_ENTER("spider_create_longlong_list"); + + *list_length = 0; + if (!str) + { + *longlong_list = NULL; + DBUG_RETURN(0); + } + + tmp_ptr = str; + while (*tmp_ptr == ' ') + tmp_ptr++; + if (*tmp_ptr) + *list_length = 1; + else { + *longlong_list = NULL; + DBUG_RETURN(0); + } + + while (TRUE) + { + if ((tmp_ptr = strchr(tmp_ptr, ' '))) + { + (*list_length)++; + tmp_ptr = tmp_ptr + 1; + while (*tmp_ptr == ' ') + tmp_ptr++; + } else + break; + } + + if (!(*longlong_list = (longlong *) + spider_bulk_malloc(spider_current_trx, 39, MYF(MY_WME | MY_ZEROFILL), + longlong_list, sizeof(longlong) * (*list_length), + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + tmp_ptr = str; + for (roop_count = 0; roop_count < (int) *list_length; roop_count++) + { + if (roop_count != 0) + tmp_ptr = strchr(tmp_ptr, ' '); + + while (*tmp_ptr == ' ') + { + *tmp_ptr = '\0'; + tmp_ptr++; + } + (*longlong_list)[roop_count] = my_strtoll10(tmp_ptr, (char**) NULL, + &error_num); + if ((*longlong_list)[roop_count] < min_val) + (*longlong_list)[roop_count] = min_val; + else if ((*longlong_list)[roop_count] > max_val) + (*longlong_list)[roop_count] = max_val; + } + +#ifndef DBUG_OFF + for (roop_count = 0; roop_count < (int) *list_length; roop_count++) + { + DBUG_PRINT("info",("spider longlong_list[%d]=%lld", roop_count, + (*longlong_list)[roop_count])); + } +#endif + + DBUG_RETURN(0); +} + +int spider_increase_string_list( + char ***string_list, + uint **string_length_list, + uint *list_length, + uint *list_charlen, + uint link_count +) { + int roop_count; + char **tmp_str_list, *tmp_str; + uint *tmp_length_list, tmp_length; + DBUG_ENTER("spider_increase_string_list"); + if (*list_length == link_count) + DBUG_RETURN(0); + if (*list_length > 1) + { + my_printf_error(ER_SPIDER_DIFFERENT_LINK_COUNT_NUM, + ER_SPIDER_DIFFERENT_LINK_COUNT_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_DIFFERENT_LINK_COUNT_NUM); + } + + if (*string_list) + { + tmp_str = (*string_list)[0]; + tmp_length = (*string_length_list)[0]; + } else { + tmp_str = NULL; + tmp_length = 0; + } + + if (!(tmp_str_list = (char**) + spider_bulk_malloc(spider_current_trx, 40, MYF(MY_WME | MY_ZEROFILL), + &tmp_str_list, sizeof(char*) * link_count, + &tmp_length_list, sizeof(uint) * link_count, + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + for (roop_count = 0; roop_count < (int) link_count; roop_count++) + { + tmp_length_list[roop_count] = tmp_length; + if (tmp_str) + { + if (!(tmp_str_list[roop_count] = spider_create_string( + tmp_str, tmp_length)) + ) + goto error; + DBUG_PRINT("info",("spider string_list[%d]=%s", roop_count, + tmp_str_list[roop_count])); + } else + tmp_str_list[roop_count] = NULL; + } + if (*string_list) + { + if ((*string_list)[0]) + spider_free(spider_current_trx, (*string_list)[0], MYF(0)); + spider_free(spider_current_trx, *string_list, MYF(0)); + } + *list_charlen = (tmp_length + 1) * link_count - 1; + *list_length = link_count; + *string_list = tmp_str_list; + *string_length_list = tmp_length_list; + + DBUG_RETURN(0); + +error: + for (roop_count = 0; roop_count < (int) link_count; roop_count++) + { + if (tmp_str_list[roop_count]) + spider_free(spider_current_trx, tmp_str_list[roop_count], MYF(0)); + } + if (tmp_str_list) + spider_free(spider_current_trx, tmp_str_list, MYF(0)); + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +} + +int spider_increase_long_list( + long **long_list, + uint *list_length, + uint link_count +) { + int roop_count; + long *tmp_long_list, tmp_long; + DBUG_ENTER("spider_increase_long_list"); + if (*list_length == link_count) + DBUG_RETURN(0); + if (*list_length > 1) + { + my_printf_error(ER_SPIDER_DIFFERENT_LINK_COUNT_NUM, + ER_SPIDER_DIFFERENT_LINK_COUNT_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_DIFFERENT_LINK_COUNT_NUM); + } + + if (*long_list) + tmp_long = (*long_list)[0]; + else + tmp_long = -1; + + if (!(tmp_long_list = (long*) + spider_bulk_malloc(spider_current_trx, 41, MYF(MY_WME | MY_ZEROFILL), + &tmp_long_list, sizeof(long) * link_count, + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + for (roop_count = 0; roop_count < (int) link_count; roop_count++) + { + tmp_long_list[roop_count] = tmp_long; + DBUG_PRINT("info",("spider long_list[%d]=%ld", roop_count, + tmp_long)); + } + if (*long_list) + spider_free(spider_current_trx, *long_list, MYF(0)); + *list_length = link_count; + *long_list = tmp_long_list; + + DBUG_RETURN(0); +} + +int spider_increase_longlong_list( + longlong **longlong_list, + uint *list_length, + uint link_count +) { + int roop_count; + longlong *tmp_longlong_list, tmp_longlong; + DBUG_ENTER("spider_increase_longlong_list"); + if (*list_length == link_count) + DBUG_RETURN(0); + if (*list_length > 1) + { + my_printf_error(ER_SPIDER_DIFFERENT_LINK_COUNT_NUM, + ER_SPIDER_DIFFERENT_LINK_COUNT_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_DIFFERENT_LINK_COUNT_NUM); + } + + if (*longlong_list) + tmp_longlong = (*longlong_list)[0]; + else + tmp_longlong = -1; + + if (!(tmp_longlong_list = (longlong*) + spider_bulk_malloc(spider_current_trx, 42, MYF(MY_WME | MY_ZEROFILL), + &tmp_longlong_list, sizeof(longlong) * link_count, + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + for (roop_count = 0; roop_count < (int) link_count; roop_count++) + { + tmp_longlong_list[roop_count] = tmp_longlong; + DBUG_PRINT("info",("spider longlong_list[%d]=%lld", roop_count, + tmp_longlong)); + } + if (*longlong_list) + spider_free(spider_current_trx, *longlong_list, MYF(0)); + *list_length = link_count; + *longlong_list = tmp_longlong_list; + + DBUG_RETURN(0); +} + +#define SPIDER_PARAM_STR_LEN(name) name ## _length +#define SPIDER_PARAM_STR(title_name, param_name) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (!share->param_name) \ + { \ + if ((share->param_name = spider_get_string_between_quote( \ + start_ptr, TRUE))) \ + share->SPIDER_PARAM_STR_LEN(param_name) = strlen(share->param_name); \ + else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%s", share->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_STR_LENS(name) name ## _lengths +#define SPIDER_PARAM_STR_CHARLEN(name) name ## _charlen +#define SPIDER_PARAM_STR_LIST(title_name, param_name) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (!share->param_name) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + share->SPIDER_PARAM_STR_CHARLEN(param_name) = strlen(tmp_ptr2); \ + if ((error_num = spider_create_string_list( \ + &share->param_name, \ + &share->SPIDER_PARAM_STR_LENS(param_name), \ + &share->SPIDER_PARAM_STR_LEN(param_name), \ + tmp_ptr2, \ + share->SPIDER_PARAM_STR_CHARLEN(param_name)))) \ + goto error; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + } \ + break; \ + } +#define SPIDER_PARAM_HINT(title_name, param_name, check_length, max_size, append_method) \ + if (!strncasecmp(tmp_ptr, title_name, check_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider max_size=%d", max_size)); \ + int hint_num = atoi(tmp_ptr + check_length); \ + DBUG_PRINT("info",("spider hint_num=%d", hint_num)); \ + DBUG_PRINT("info",("spider share->param_name=%p", share->param_name)); \ + if (share->param_name) \ + { \ + if (hint_num < 0 || hint_num >= max_size) \ + { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } else if (share->param_name[hint_num].length() > 0) \ + break; \ + char *hint_str = spider_get_string_between_quote(start_ptr, FALSE); \ + if ((error_num = \ + append_method(&share->param_name[hint_num], hint_str))) \ + goto error; \ + DBUG_PRINT("info",("spider "title_name"[%d]=%s", hint_num, \ + share->param_name[hint_num].ptr())); \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + break; \ + } +#define SPIDER_PARAM_LONG_LEN(name) name ## _length +#define SPIDER_PARAM_LONG_LIST_WITH_MAX(title_name, param_name, \ + min_val, max_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (!share->param_name) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + if ((error_num = spider_create_long_list( \ + &share->param_name, \ + &share->SPIDER_PARAM_LONG_LEN(param_name), \ + tmp_ptr2, \ + strlen(tmp_ptr2), \ + min_val, max_val))) \ + goto error; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + } \ + break; \ + } +#define SPIDER_PARAM_LONGLONG_LEN(name) name ## _length +#define SPIDER_PARAM_LONGLONG_LIST_WITH_MAX(title_name, param_name, \ + min_val, max_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (!share->param_name) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + if ((error_num = spider_create_longlong_list( \ + &share->param_name, \ + &share->SPIDER_PARAM_LONGLONG_LEN(param_name), \ + tmp_ptr2, \ + strlen(tmp_ptr2), \ + min_val, max_val))) \ + goto error; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + } \ + break; \ + } +#define SPIDER_PARAM_INT_WITH_MAX(title_name, param_name, min_val, max_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (share->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + share->param_name = atoi(tmp_ptr2); \ + if (share->param_name < min_val) \ + share->param_name = min_val; \ + else if (share->param_name > max_val) \ + share->param_name = max_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%d", share->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_INT(title_name, param_name, min_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (share->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + share->param_name = atoi(tmp_ptr2); \ + if (share->param_name < min_val) \ + share->param_name = min_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%d", share->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_DOUBLE(title_name, param_name, min_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (share->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + share->param_name = my_atof(tmp_ptr2); \ + if (share->param_name < min_val) \ + share->param_name = min_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%f", share->param_name)); \ + } \ + break; \ + } +#define SPIDER_PARAM_LONGLONG(title_name, param_name, min_val) \ + if (!strncasecmp(tmp_ptr, title_name, title_length)) \ + { \ + DBUG_PRINT("info",("spider "title_name" start")); \ + if (share->param_name == -1) \ + { \ + if ((tmp_ptr2 = spider_get_string_between_quote( \ + start_ptr, FALSE))) \ + { \ + share->param_name = my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \ + if (share->param_name < min_val) \ + share->param_name = min_val; \ + } else { \ + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ + MYF(0), tmp_ptr); \ + goto error; \ + } \ + DBUG_PRINT("info",("spider "title_name"=%lld", share->param_name)); \ + } \ + break; \ + } + +int spider_parse_connect_info( + SPIDER_SHARE *share, + TABLE_SHARE *table_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_info *part_info, +#endif + uint create_table +) { + int error_num = 0; + char *connect_string = NULL; + char *sprit_ptr[2]; + char *tmp_ptr, *tmp_ptr2, *start_ptr; + int roop_count; + int title_length; + SPIDER_ALTER_TABLE *share_alter; +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_element *part_elem; + partition_element *sub_elem; +#endif + DBUG_ENTER("spider_parse_connect_info"); +#if MYSQL_VERSION_ID < 50500 + DBUG_PRINT("info",("spider partition_info=%s", table_share->partition_info)); +#else + DBUG_PRINT("info",("spider partition_info=%s", + table_share->partition_info_str)); +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + DBUG_PRINT("info",("spider part_info=%p", part_info)); +#endif + DBUG_PRINT("info",("spider s->db=%s", table_share->db.str)); + DBUG_PRINT("info",("spider s->table_name=%s", table_share->table_name.str)); + DBUG_PRINT("info",("spider s->path=%s", table_share->path.str)); + DBUG_PRINT("info", + ("spider s->normalized_path=%s", table_share->normalized_path.str)); +#ifdef WITH_PARTITION_STORAGE_ENGINE + spider_get_partition_info(share->table_name, share->table_name_length, + table_share, part_info, &part_elem, &sub_elem); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + share->sts_bg_mode = -1; +#endif + share->sts_interval = -1; + share->sts_mode = -1; +#ifdef WITH_PARTITION_STORAGE_ENGINE + share->sts_sync = -1; +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + share->crd_bg_mode = -1; +#endif + share->crd_interval = -1; + share->crd_mode = -1; +#ifdef WITH_PARTITION_STORAGE_ENGINE + share->crd_sync = -1; +#endif + share->crd_type = -1; + share->crd_weight = -1; + share->internal_offset = -1; + share->internal_limit = -1; + share->split_read = -1; + share->semi_split_read = -1; + share->semi_split_read_limit = -1; + share->init_sql_alloc_size = -1; + share->reset_sql_alloc = -1; + share->multi_split_read = -1; + share->max_order = -1; + share->semi_table_lock = -1; + share->semi_table_lock_conn = -1; + share->selupd_lock_mode = -1; + share->query_cache = -1; + share->internal_delayed = -1; + share->bulk_size = -1; + share->bulk_update_mode = -1; + share->bulk_update_size = -1; + share->internal_optimize = -1; + share->internal_optimize_local = -1; + share->scan_rate = -1; + share->read_rate = -1; + share->priority = -1; + share->quick_mode = -1; + share->quick_page_size = -1; + share->low_mem_read = -1; + share->table_count_mode = -1; + share->select_column_mode = -1; +#ifndef WITHOUT_SPIDER_BG_SEARCH + share->bgs_mode = -1; + share->bgs_first_read = -1; + share->bgs_second_read = -1; +#endif + share->first_read = -1; + share->second_read = -1; + share->auto_increment_mode = -1; + share->use_table_charset = -1; + share->use_pushdown_udf = -1; + share->skip_default_condition = -1; + share->direct_dup_insert = -1; + share->direct_order_limit = -1; + share->bka_mode = -1; + share->read_only_mode = -1; + share->error_read_mode = -1; + share->error_write_mode = -1; + share->active_link_count = -1; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + share->hs_result_free_size = -1; +#endif +#ifdef HA_CAN_BULK_ACCESS + share->bulk_access_free = -1; +#endif + +#ifdef WITH_PARTITION_STORAGE_ENGINE + for (roop_count = 4; roop_count > 0; roop_count--) +#else + for (roop_count = 2; roop_count > 0; roop_count--) +#endif + { + if (connect_string) + { + spider_free(spider_current_trx, connect_string, MYF(0)); + connect_string = NULL; + } + switch (roop_count) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + case 4: + if (!sub_elem || !sub_elem->part_comment) + continue; + DBUG_PRINT("info",("spider create sub comment string")); + if ( + !(connect_string = spider_create_string( + sub_elem->part_comment, + strlen(sub_elem->part_comment))) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn_string; + } + DBUG_PRINT("info",("spider sub comment string=%s", connect_string)); + break; + case 3: + if (!part_elem || !part_elem->part_comment) + continue; + DBUG_PRINT("info",("spider create part comment string")); + if ( + !(connect_string = spider_create_string( + part_elem->part_comment, + strlen(part_elem->part_comment))) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn_string; + } + DBUG_PRINT("info",("spider part comment string=%s", connect_string)); + break; +#endif + case 2: + if (table_share->comment.length == 0) + continue; + DBUG_PRINT("info",("spider create comment string")); + if ( + !(connect_string = spider_create_string( + table_share->comment.str, + table_share->comment.length)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn_string; + } + DBUG_PRINT("info",("spider comment string=%s", connect_string)); + break; + default: + if (table_share->connect_string.length == 0) + continue; + DBUG_PRINT("info",("spider create connect_string string")); + if ( + !(connect_string = spider_create_string( + table_share->connect_string.str, + table_share->connect_string.length)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_conn_string; + } + DBUG_PRINT("info",("spider connect_string=%s", connect_string)); + break; + } + + sprit_ptr[0] = connect_string; + while (sprit_ptr[0]) + { + if ((sprit_ptr[1] = strchr(sprit_ptr[0], ','))) + { + *sprit_ptr[1] = '\0'; + sprit_ptr[1]++; + } + tmp_ptr = sprit_ptr[0]; + sprit_ptr[0] = sprit_ptr[1]; + while (*tmp_ptr == ' ' || *tmp_ptr == '\r' || + *tmp_ptr == '\n' || *tmp_ptr == '\t') + tmp_ptr++; + + if (*tmp_ptr == '\0') + continue; + + title_length = 0; + start_ptr = tmp_ptr; + while (*start_ptr != ' ' && *start_ptr != '\'' && + *start_ptr != '"' && *start_ptr != '\0' && + *start_ptr != '\r' && *start_ptr != '\n' && + *start_ptr != '\t') + { + title_length++; + start_ptr++; + } + + switch (title_length) + { + case 0: + continue; + case 3: + SPIDER_PARAM_LONG_LIST_WITH_MAX("abl", access_balances, 0, + 2147483647); + SPIDER_PARAM_INT_WITH_MAX("aim", auto_increment_mode, 0, 3); + SPIDER_PARAM_INT("alc", active_link_count, 1); +#ifdef HA_CAN_BULK_ACCESS + SPIDER_PARAM_INT_WITH_MAX("baf", bulk_access_free, 0, 1); +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_LONGLONG("bfr", bgs_first_read, 0); + SPIDER_PARAM_INT("bmd", bgs_mode, 0); + SPIDER_PARAM_LONGLONG("bsr", bgs_second_read, 0); +#endif + SPIDER_PARAM_STR("bke", bka_engine); + SPIDER_PARAM_INT_WITH_MAX("bkm", bka_mode, 0, 1); + SPIDER_PARAM_INT("bsz", bulk_size, 0); + SPIDER_PARAM_INT_WITH_MAX("bum", bulk_update_mode, 0, 2); + SPIDER_PARAM_INT("bus", bulk_update_size, 0); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_INT_WITH_MAX("cbm", crd_bg_mode, 0, 1); +#endif + SPIDER_PARAM_DOUBLE("civ", crd_interval, 0); + SPIDER_PARAM_INT_WITH_MAX("cmd", crd_mode, 0, 3); +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARAM_INT_WITH_MAX("csy", crd_sync, 0, 2); +#endif + SPIDER_PARAM_LONG_LIST_WITH_MAX("cto", connect_timeouts, 0, + 2147483647); + SPIDER_PARAM_INT_WITH_MAX("ctp", crd_type, 0, 2); + SPIDER_PARAM_DOUBLE("cwg", crd_weight, 1); + SPIDER_PARAM_INT_WITH_MAX("ddi", direct_dup_insert, 0, 1); + SPIDER_PARAM_STR_LIST("dff", tgt_default_files); + SPIDER_PARAM_STR_LIST("dfg", tgt_default_groups); + SPIDER_PARAM_LONGLONG("dol", direct_order_limit, 0); + SPIDER_PARAM_INT_WITH_MAX("erm", error_read_mode, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("ewm", error_write_mode, 0, 1); + SPIDER_PARAM_LONGLONG("frd", first_read, 0); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_LONGLONG("hrf", hs_result_free_size, 0); + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "hrp", hs_read_ports, 0, 65535); + SPIDER_PARAM_STR_LIST("hrs", hs_read_socks); + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "hwp", hs_write_ports, 0, 65535); + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "hwr", hs_write_to_reads, 0, 1); + SPIDER_PARAM_STR_LIST("hws", hs_write_socks); +#endif + SPIDER_PARAM_INT("isa", init_sql_alloc_size, 0); + SPIDER_PARAM_INT_WITH_MAX("idl", internal_delayed, 0, 1); + SPIDER_PARAM_LONGLONG("ilm", internal_limit, 0); + SPIDER_PARAM_LONGLONG("ios", internal_offset, 0); + SPIDER_PARAM_INT_WITH_MAX("iom", internal_optimize, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("iol", internal_optimize_local, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("lmr", low_mem_read, 0, 1); + SPIDER_PARAM_LONG_LIST_WITH_MAX("lst", link_statuses, 0, 3); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_LONGLONG_LIST_WITH_MAX( + "mbi", monitoring_bg_interval, 0, 4294967295LL); + SPIDER_PARAM_LONG_LIST_WITH_MAX("mbk", monitoring_bg_kind, 0, 3); +#endif + SPIDER_PARAM_LONG_LIST_WITH_MAX("mkd", monitoring_kind, 0, 3); + SPIDER_PARAM_LONGLONG_LIST_WITH_MAX( + "mlt", monitoring_limit, 0, 9223372036854775807LL); + SPIDER_PARAM_INT("mod", max_order, 0); + SPIDER_PARAM_LONGLONG_LIST_WITH_MAX( + "msi", monitoring_sid, 0, 4294967295LL); + SPIDER_PARAM_INT_WITH_MAX("msr", multi_split_read, 0, 2147483647); + SPIDER_PARAM_LONG_LIST_WITH_MAX("nrt", net_read_timeouts, 0, + 2147483647); + SPIDER_PARAM_LONG_LIST_WITH_MAX("nwt", net_write_timeouts, 0, + 2147483647); + SPIDER_PARAM_STR_LIST("pkn", tgt_pk_names); + SPIDER_PARAM_LONGLONG("prt", priority, 0); + SPIDER_PARAM_INT_WITH_MAX("qch", query_cache, 0, 2); + SPIDER_PARAM_INT_WITH_MAX("qmd", quick_mode, 0, 3); + SPIDER_PARAM_LONGLONG("qps", quick_page_size, 0); + SPIDER_PARAM_INT_WITH_MAX("rom", read_only_mode, 0, 1); + SPIDER_PARAM_DOUBLE("rrt", read_rate, 0); + SPIDER_PARAM_INT_WITH_MAX("rsa", reset_sql_alloc, 0, 1); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_INT_WITH_MAX("sbm", sts_bg_mode, 0, 1); +#endif + SPIDER_PARAM_STR_LIST("sca", tgt_ssl_cas); + SPIDER_PARAM_STR_LIST("sch", tgt_ssl_ciphers); + SPIDER_PARAM_INT_WITH_MAX("scm", select_column_mode, 0, 1); + SPIDER_PARAM_STR_LIST("scp", tgt_ssl_capaths); + SPIDER_PARAM_STR_LIST("scr", tgt_ssl_certs); + SPIDER_PARAM_INT_WITH_MAX("sdc", skip_default_condition, 0, 1); + SPIDER_PARAM_DOUBLE("siv", sts_interval, 0); + SPIDER_PARAM_STR_LIST("sky", tgt_ssl_keys); + SPIDER_PARAM_INT_WITH_MAX("slm", selupd_lock_mode, 0, 2); + SPIDER_PARAM_INT_WITH_MAX("smd", sts_mode, 1, 2); + SPIDER_PARAM_LONGLONG("spr", split_read, 0); + SPIDER_PARAM_STR_LIST("sqn", tgt_sequence_names); + SPIDER_PARAM_LONGLONG("srd", second_read, 0); + SPIDER_PARAM_DOUBLE("srt", scan_rate, 0); + SPIDER_PARAM_STR_LIST("srv", server_names); + SPIDER_PARAM_DOUBLE("ssr", semi_split_read, 0); + SPIDER_PARAM_LONGLONG("ssl", semi_split_read_limit, 0); +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARAM_INT_WITH_MAX("ssy", sts_sync, 0, 2); +#endif + SPIDER_PARAM_INT_WITH_MAX("stc", semi_table_lock_conn, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("stl", semi_table_lock, 0, 1); + SPIDER_PARAM_LONG_LIST_WITH_MAX("svc", tgt_ssl_vscs, 0, 1); + SPIDER_PARAM_STR_LIST("tbl", tgt_table_names); + SPIDER_PARAM_INT_WITH_MAX("tcm", table_count_mode, 0, 1); + SPIDER_PARAM_LONG_LIST_WITH_MAX("uhd", use_handlers, 0, 3); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "uhr", use_hs_reads, 0, 1); + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "uhw", use_hs_writes, 0, 1); +#endif + SPIDER_PARAM_INT_WITH_MAX("upu", use_pushdown_udf, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("utc", use_table_charset, 0, 1); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 4: + SPIDER_PARAM_STR_LIST("host", tgt_hosts); + SPIDER_PARAM_STR_LIST("user", tgt_usernames); + SPIDER_PARAM_LONG_LIST_WITH_MAX("port", tgt_ports, 0, 65535); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 5: + SPIDER_PARAM_STR_LIST("table", tgt_table_names); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 6: + SPIDER_PARAM_STR_LIST("server", server_names); + SPIDER_PARAM_STR_LIST("socket", tgt_sockets); + SPIDER_PARAM_HINT("idx", key_hint, 3, (int) table_share->keys, + spider_db_append_key_hint); + SPIDER_PARAM_STR_LIST("ssl_ca", tgt_ssl_cas); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 7: + SPIDER_PARAM_STR_LIST("wrapper", tgt_wrappers); + SPIDER_PARAM_STR_LIST("ssl_key", tgt_ssl_keys); + SPIDER_PARAM_STR_LIST("pk_name", tgt_pk_names); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 8: + SPIDER_PARAM_STR_LIST("database", tgt_dbs); + SPIDER_PARAM_STR_LIST("password", tgt_passwords); + SPIDER_PARAM_INT_WITH_MAX("sts_mode", sts_mode, 1, 2); +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARAM_INT_WITH_MAX("sts_sync", sts_sync, 0, 2); +#endif + SPIDER_PARAM_INT_WITH_MAX("crd_mode", crd_mode, 0, 3); +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARAM_INT_WITH_MAX("crd_sync", crd_sync, 0, 2); +#endif + SPIDER_PARAM_INT_WITH_MAX("crd_type", crd_type, 0, 2); + SPIDER_PARAM_LONGLONG("priority", priority, 0); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_INT("bgs_mode", bgs_mode, 0); +#endif + SPIDER_PARAM_STR_LIST("ssl_cert", tgt_ssl_certs); + SPIDER_PARAM_INT_WITH_MAX("bka_mode", bka_mode, 0, 1); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 9: + SPIDER_PARAM_INT("max_order", max_order, 0); + SPIDER_PARAM_INT("bulk_size", bulk_size, 0); + SPIDER_PARAM_DOUBLE("scan_rate", scan_rate, 0); + SPIDER_PARAM_DOUBLE("read_rate", read_rate, 0); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 10: + SPIDER_PARAM_DOUBLE("crd_weight", crd_weight, 1); + SPIDER_PARAM_LONGLONG("split_read", split_read, 0); + SPIDER_PARAM_INT_WITH_MAX("quick_mode", quick_mode, 0, 3); + SPIDER_PARAM_STR_LIST("ssl_cipher", tgt_ssl_ciphers); + SPIDER_PARAM_STR_LIST("ssl_capath", tgt_ssl_capaths); + SPIDER_PARAM_STR("bka_engine", bka_engine); + SPIDER_PARAM_LONGLONG("first_read", first_read, 0); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 11: + SPIDER_PARAM_INT_WITH_MAX("query_cache", query_cache, 0, 2); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_INT_WITH_MAX("crd_bg_mode", crd_bg_mode, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("sts_bg_mode", sts_bg_mode, 0, 1); +#endif + SPIDER_PARAM_LONG_LIST_WITH_MAX("link_status", link_statuses, 0, 3); + SPIDER_PARAM_LONG_LIST_WITH_MAX("use_handler", use_handlers, 0, 3); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_LONG_LIST_WITH_MAX("use_hs_read", use_hs_reads, 0, 1); +#endif + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 12: + SPIDER_PARAM_DOUBLE("sts_interval", sts_interval, 0); + SPIDER_PARAM_DOUBLE("crd_interval", crd_interval, 0); + SPIDER_PARAM_INT_WITH_MAX("low_mem_read", low_mem_read, 0, 1); + SPIDER_PARAM_STR_LIST("default_file", tgt_default_files); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "use_hs_write", use_hs_writes, 0, 1); + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "hs_read_port", hs_read_ports, 0, 65535); +#endif + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 13: + SPIDER_PARAM_STR_LIST("default_group", tgt_default_groups); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "hs_write_port", hs_write_ports, 0, 65535); +#endif + SPIDER_PARAM_STR_LIST("sequence_name", tgt_sequence_names); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 14: + SPIDER_PARAM_LONGLONG("internal_limit", internal_limit, 0); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_LONGLONG("bgs_first_read", bgs_first_read, 0); +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_STR_LIST( + "hs_read_socket", hs_read_socks); +#endif + SPIDER_PARAM_INT_WITH_MAX("read_only_mode", read_only_mode, 0, 1); + SPIDER_PARAM_LONG_LIST_WITH_MAX("access_balance", access_balances, 0, + 2147483647); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 15: + SPIDER_PARAM_LONGLONG("internal_offset", internal_offset, 0); + SPIDER_PARAM_INT_WITH_MAX("reset_sql_alloc", reset_sql_alloc, 0, 1); + SPIDER_PARAM_INT_WITH_MAX("semi_table_lock", semi_table_lock, 0, 1); + SPIDER_PARAM_LONGLONG("quick_page_size", quick_page_size, 0); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_LONGLONG("bgs_second_read", bgs_second_read, 0); +#endif + SPIDER_PARAM_LONG_LIST_WITH_MAX("monitoring_kind", monitoring_kind, 0, 3); + SPIDER_PARAM_DOUBLE("semi_split_read", semi_split_read, 0); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_STR_LIST( + "hs_write_socket", hs_write_socks); +#endif + SPIDER_PARAM_LONG_LIST_WITH_MAX("connect_timeout", connect_timeouts, + 0, 2147483647); + SPIDER_PARAM_INT_WITH_MAX("error_read_mode", error_read_mode, 0, 1); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 16: + SPIDER_PARAM_INT_WITH_MAX( + "multi_split_read", multi_split_read, 0, 2147483647); + SPIDER_PARAM_INT_WITH_MAX( + "selupd_lock_mode", selupd_lock_mode, 0, 2); + SPIDER_PARAM_INT_WITH_MAX( + "internal_delayed", internal_delayed, 0, 1); + SPIDER_PARAM_INT_WITH_MAX( + "table_count_mode", table_count_mode, 0, 1); + SPIDER_PARAM_INT_WITH_MAX( + "use_pushdown_udf", use_pushdown_udf, 0, 1); + SPIDER_PARAM_LONGLONG_LIST_WITH_MAX( + "monitoring_limit", monitoring_limit, 0, 9223372036854775807LL); + SPIDER_PARAM_INT_WITH_MAX( + "bulk_update_mode", bulk_update_mode, 0, 2); + SPIDER_PARAM_INT("bulk_update_size", bulk_update_size, 0); + SPIDER_PARAM_LONG_LIST_WITH_MAX("net_read_timeout", + net_read_timeouts, 0, 2147483647); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "hs_write_to_read", hs_write_to_reads, 0, 1); +#endif + SPIDER_PARAM_INT_WITH_MAX( + "error_write_mode", error_write_mode, 0, 1); +#ifdef HA_CAN_BULK_ACCESS + SPIDER_PARAM_INT_WITH_MAX( + "bulk_access_free", bulk_access_free, 0, 1); +#endif + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 17: + SPIDER_PARAM_INT_WITH_MAX( + "internal_optimize", internal_optimize, 0, 1); + SPIDER_PARAM_INT_WITH_MAX( + "use_table_charset", use_table_charset, 0, 1); + SPIDER_PARAM_INT_WITH_MAX( + "direct_dup_insert", direct_dup_insert, 0, 1); + SPIDER_PARAM_INT("active_link_count", active_link_count, 1); + SPIDER_PARAM_LONG_LIST_WITH_MAX("net_write_timeout", + net_write_timeouts, 0, 2147483647); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 18: + SPIDER_PARAM_INT_WITH_MAX( + "select_column_mode", select_column_mode, 0, 1); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "monitoring_bg_kind", monitoring_bg_kind, 0, 3); +#endif + SPIDER_PARAM_LONGLONG( + "direct_order_limit", direct_order_limit, 0); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 19: + SPIDER_PARAM_INT("init_sql_alloc_size", init_sql_alloc_size, 0); + SPIDER_PARAM_INT_WITH_MAX( + "auto_increment_mode", auto_increment_mode, 0, 3); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + SPIDER_PARAM_LONGLONG("hs_result_free_size", hs_result_free_size, 0); +#endif + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 20: + SPIDER_PARAM_LONGLONG_LIST_WITH_MAX( + "monitoring_server_id", monitoring_sid, 0, 4294967295LL); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 21: + SPIDER_PARAM_LONGLONG( + "semi_split_read_limit", semi_split_read_limit, 0); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 22: + SPIDER_PARAM_LONG_LIST_WITH_MAX( + "ssl_verify_server_cert", tgt_ssl_vscs, 0, 1); +#ifndef WITHOUT_SPIDER_BG_SEARCH + SPIDER_PARAM_LONGLONG_LIST_WITH_MAX( + "monitoring_bg_interval", monitoring_bg_interval, 0, 4294967295LL); +#endif + SPIDER_PARAM_INT_WITH_MAX( + "skip_default_condition", skip_default_condition, 0, 1); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 23: + SPIDER_PARAM_INT_WITH_MAX( + "internal_optimize_local", internal_optimize_local, 0, 1); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + case 26: + SPIDER_PARAM_INT_WITH_MAX( + "semi_table_lock_connection", semi_table_lock_conn, 0, 1); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + default: + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), tmp_ptr); + goto error; + } + } + } + + /* check all_link_count */ + share->all_link_count = 1; + if (share->all_link_count < share->server_names_length) + share->all_link_count = share->server_names_length; + if (share->all_link_count < share->tgt_table_names_length) + share->all_link_count = share->tgt_table_names_length; + if (share->all_link_count < share->tgt_dbs_length) + share->all_link_count = share->tgt_dbs_length; + if (share->all_link_count < share->tgt_hosts_length) + share->all_link_count = share->tgt_hosts_length; + if (share->all_link_count < share->tgt_usernames_length) + share->all_link_count = share->tgt_usernames_length; + if (share->all_link_count < share->tgt_passwords_length) + share->all_link_count = share->tgt_passwords_length; + if (share->all_link_count < share->tgt_sockets_length) + share->all_link_count = share->tgt_sockets_length; + if (share->all_link_count < share->tgt_wrappers_length) + share->all_link_count = share->tgt_wrappers_length; + if (share->all_link_count < share->tgt_ssl_cas_length) + share->all_link_count = share->tgt_ssl_cas_length; + if (share->all_link_count < share->tgt_ssl_capaths_length) + share->all_link_count = share->tgt_ssl_capaths_length; + if (share->all_link_count < share->tgt_ssl_certs_length) + share->all_link_count = share->tgt_ssl_certs_length; + if (share->all_link_count < share->tgt_ssl_ciphers_length) + share->all_link_count = share->tgt_ssl_ciphers_length; + if (share->all_link_count < share->tgt_ssl_keys_length) + share->all_link_count = share->tgt_ssl_keys_length; + if (share->all_link_count < share->tgt_default_files_length) + share->all_link_count = share->tgt_default_files_length; + if (share->all_link_count < share->tgt_default_groups_length) + share->all_link_count = share->tgt_default_groups_length; + if (share->all_link_count < share->tgt_pk_names_length) + share->all_link_count = share->tgt_pk_names_length; + if (share->all_link_count < share->tgt_sequence_names_length) + share->all_link_count = share->tgt_sequence_names_length; + if (share->all_link_count < share->tgt_ports_length) + share->all_link_count = share->tgt_ports_length; + if (share->all_link_count < share->tgt_ssl_vscs_length) + share->all_link_count = share->tgt_ssl_vscs_length; + if (share->all_link_count < share->link_statuses_length) + share->all_link_count = share->link_statuses_length; + if (share->all_link_count < share->monitoring_kind_length) + share->all_link_count = share->monitoring_kind_length; + if (share->all_link_count < share->monitoring_limit_length) + share->all_link_count = share->monitoring_limit_length; + if (share->all_link_count < share->monitoring_sid_length) + share->all_link_count = share->monitoring_sid_length; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (share->all_link_count < share->monitoring_bg_kind_length) + share->all_link_count = share->monitoring_bg_kind_length; + if (share->all_link_count < share->monitoring_bg_interval_length) + share->all_link_count = share->monitoring_bg_interval_length; +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (share->all_link_count < share->use_hs_reads_length) + share->all_link_count = share->use_hs_reads_length; + if (share->all_link_count < share->use_hs_writes_length) + share->all_link_count = share->use_hs_writes_length; + if (share->all_link_count < share->hs_read_ports_length) + share->all_link_count = share->hs_read_ports_length; + if (share->all_link_count < share->hs_write_ports_length) + share->all_link_count = share->hs_write_ports_length; + if (share->all_link_count < share->hs_read_socks_length) + share->all_link_count = share->hs_read_socks_length; + if (share->all_link_count < share->hs_write_socks_length) + share->all_link_count = share->hs_write_socks_length; + if (share->all_link_count < share->hs_write_to_reads_length) + share->all_link_count = share->hs_write_to_reads_length; +#endif + if (share->all_link_count < share->use_handlers_length) + share->all_link_count = share->use_handlers_length; + if (share->all_link_count < share->connect_timeouts_length) + share->all_link_count = share->connect_timeouts_length; + if (share->all_link_count < share->net_read_timeouts_length) + share->all_link_count = share->net_read_timeouts_length; + if (share->all_link_count < share->net_write_timeouts_length) + share->all_link_count = share->net_write_timeouts_length; + if (share->all_link_count < share->access_balances_length) + share->all_link_count = share->access_balances_length; + if ((error_num = spider_increase_string_list( + &share->server_names, + &share->server_names_lengths, + &share->server_names_length, + &share->server_names_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_table_names, + &share->tgt_table_names_lengths, + &share->tgt_table_names_length, + &share->tgt_table_names_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_dbs, + &share->tgt_dbs_lengths, + &share->tgt_dbs_length, + &share->tgt_dbs_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_hosts, + &share->tgt_hosts_lengths, + &share->tgt_hosts_length, + &share->tgt_hosts_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_usernames, + &share->tgt_usernames_lengths, + &share->tgt_usernames_length, + &share->tgt_usernames_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_passwords, + &share->tgt_passwords_lengths, + &share->tgt_passwords_length, + &share->tgt_passwords_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_sockets, + &share->tgt_sockets_lengths, + &share->tgt_sockets_length, + &share->tgt_sockets_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_wrappers, + &share->tgt_wrappers_lengths, + &share->tgt_wrappers_length, + &share->tgt_wrappers_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_ssl_cas, + &share->tgt_ssl_cas_lengths, + &share->tgt_ssl_cas_length, + &share->tgt_ssl_cas_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_ssl_capaths, + &share->tgt_ssl_capaths_lengths, + &share->tgt_ssl_capaths_length, + &share->tgt_ssl_capaths_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_ssl_certs, + &share->tgt_ssl_certs_lengths, + &share->tgt_ssl_certs_length, + &share->tgt_ssl_certs_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_ssl_ciphers, + &share->tgt_ssl_ciphers_lengths, + &share->tgt_ssl_ciphers_length, + &share->tgt_ssl_ciphers_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_ssl_keys, + &share->tgt_ssl_keys_lengths, + &share->tgt_ssl_keys_length, + &share->tgt_ssl_keys_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_default_files, + &share->tgt_default_files_lengths, + &share->tgt_default_files_length, + &share->tgt_default_files_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_default_groups, + &share->tgt_default_groups_lengths, + &share->tgt_default_groups_length, + &share->tgt_default_groups_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_pk_names, + &share->tgt_pk_names_lengths, + &share->tgt_pk_names_length, + &share->tgt_pk_names_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->tgt_sequence_names, + &share->tgt_sequence_names_lengths, + &share->tgt_sequence_names_length, + &share->tgt_sequence_names_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->tgt_ports, + &share->tgt_ports_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->tgt_ssl_vscs, + &share->tgt_ssl_vscs_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->link_statuses, + &share->link_statuses_length, + share->all_link_count))) + goto error; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_increase_long_list( + &share->monitoring_bg_kind, + &share->monitoring_bg_kind_length, + share->all_link_count))) + goto error; +#endif + if ((error_num = spider_increase_long_list( + &share->monitoring_kind, + &share->monitoring_kind_length, + share->all_link_count))) + goto error; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ((error_num = spider_increase_longlong_list( + &share->monitoring_bg_interval, + &share->monitoring_bg_interval_length, + share->all_link_count))) + goto error; +#endif + if ((error_num = spider_increase_longlong_list( + &share->monitoring_limit, + &share->monitoring_limit_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_longlong_list( + &share->monitoring_sid, + &share->monitoring_sid_length, + share->all_link_count))) + goto error; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ((error_num = spider_increase_long_list( + &share->use_hs_reads, + &share->use_hs_reads_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->use_hs_writes, + &share->use_hs_writes_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->hs_read_ports, + &share->hs_read_ports_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->hs_write_ports, + &share->hs_write_ports_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->hs_read_socks, + &share->hs_read_socks_lengths, + &share->hs_read_socks_length, + &share->hs_read_socks_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_string_list( + &share->hs_write_socks, + &share->hs_write_socks_lengths, + &share->hs_write_socks_length, + &share->hs_write_socks_charlen, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->hs_write_to_reads, + &share->hs_write_to_reads_length, + share->all_link_count))) + goto error; +#endif + if ((error_num = spider_increase_long_list( + &share->use_handlers, + &share->use_handlers_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->connect_timeouts, + &share->connect_timeouts_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->net_read_timeouts, + &share->net_read_timeouts_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->net_write_timeouts, + &share->net_write_timeouts_length, + share->all_link_count))) + goto error; + if ((error_num = spider_increase_long_list( + &share->access_balances, + &share->access_balances_length, + share->all_link_count))) + goto error; + + /* copy for tables start */ + share_alter = &share->alter_table; + share_alter->all_link_count = share->all_link_count; + if (!(share_alter->tmp_server_names = (char **) + spider_bulk_malloc(spider_current_trx, 43, MYF(MY_WME | MY_ZEROFILL), + &share_alter->tmp_server_names, + sizeof(char *) * 15 * share->all_link_count, + &share_alter->tmp_server_names_lengths, + sizeof(uint *) * 15 * share->all_link_count, + &share_alter->tmp_tgt_ports, + sizeof(long) * share->all_link_count, + &share_alter->tmp_tgt_ssl_vscs, + sizeof(long) * share->all_link_count, + &share_alter->tmp_link_statuses, + sizeof(long) * share->all_link_count, + NullS)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + + + memcpy(share_alter->tmp_server_names, share->server_names, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_table_names = + share_alter->tmp_server_names + share->all_link_count; + memcpy(share_alter->tmp_tgt_table_names, share->tgt_table_names, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_dbs = + share_alter->tmp_tgt_table_names + share->all_link_count; + memcpy(share_alter->tmp_tgt_dbs, share->tgt_dbs, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_hosts = + share_alter->tmp_tgt_dbs + share->all_link_count; + memcpy(share_alter->tmp_tgt_hosts, share->tgt_hosts, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_usernames = + share_alter->tmp_tgt_hosts + share->all_link_count; + memcpy(share_alter->tmp_tgt_usernames, share->tgt_usernames, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_passwords = + share_alter->tmp_tgt_usernames + share->all_link_count; + memcpy(share_alter->tmp_tgt_passwords, share->tgt_passwords, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_sockets = + share_alter->tmp_tgt_passwords + share->all_link_count; + memcpy(share_alter->tmp_tgt_sockets, share->tgt_sockets, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_wrappers = + share_alter->tmp_tgt_sockets + share->all_link_count; + memcpy(share_alter->tmp_tgt_wrappers, share->tgt_wrappers, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_ssl_cas = + share_alter->tmp_tgt_wrappers + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_cas, share->tgt_ssl_cas, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_ssl_capaths = + share_alter->tmp_tgt_ssl_cas + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_capaths, share->tgt_ssl_capaths, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_ssl_certs = + share_alter->tmp_tgt_ssl_capaths + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_certs, share->tgt_ssl_certs, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_ssl_ciphers = + share_alter->tmp_tgt_ssl_certs + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_ciphers, share->tgt_ssl_ciphers, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_ssl_keys = + share_alter->tmp_tgt_ssl_ciphers + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_keys, share->tgt_ssl_keys, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_default_files = + share_alter->tmp_tgt_ssl_keys + share->all_link_count; + memcpy(share_alter->tmp_tgt_default_files, share->tgt_default_files, + sizeof(char *) * share->all_link_count); + share_alter->tmp_tgt_default_groups = + share_alter->tmp_tgt_default_files + share->all_link_count; + memcpy(share_alter->tmp_tgt_default_groups, share->tgt_default_groups, + sizeof(char *) * share->all_link_count); + + memcpy(share_alter->tmp_tgt_ports, share->tgt_ports, + sizeof(long) * share->all_link_count); + memcpy(share_alter->tmp_tgt_ssl_vscs, share->tgt_ssl_vscs, + sizeof(long) * share->all_link_count); + memcpy(share_alter->tmp_link_statuses, share->link_statuses, + sizeof(long) * share->all_link_count); + + memcpy(share_alter->tmp_server_names_lengths, + share->server_names_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_table_names_lengths = + share_alter->tmp_server_names_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_table_names_lengths, + share->tgt_table_names_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_dbs_lengths = + share_alter->tmp_tgt_table_names_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_dbs_lengths, share->tgt_dbs_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_hosts_lengths = + share_alter->tmp_tgt_dbs_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_hosts_lengths, share->tgt_hosts_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_usernames_lengths = + share_alter->tmp_tgt_hosts_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_usernames_lengths, + share->tgt_usernames_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_passwords_lengths = + share_alter->tmp_tgt_usernames_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_passwords_lengths, + share->tgt_passwords_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_sockets_lengths = + share_alter->tmp_tgt_passwords_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_sockets_lengths, share->tgt_sockets_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_wrappers_lengths = + share_alter->tmp_tgt_sockets_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_wrappers_lengths, + share->tgt_wrappers_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_ssl_cas_lengths = + share_alter->tmp_tgt_wrappers_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_cas_lengths, + share->tgt_ssl_cas_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_ssl_capaths_lengths = + share_alter->tmp_tgt_ssl_cas_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_capaths_lengths, + share->tgt_ssl_capaths_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_ssl_certs_lengths = + share_alter->tmp_tgt_ssl_capaths_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_certs_lengths, + share->tgt_ssl_certs_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_ssl_ciphers_lengths = + share_alter->tmp_tgt_ssl_certs_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_ciphers_lengths, + share->tgt_ssl_ciphers_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_ssl_keys_lengths = + share_alter->tmp_tgt_ssl_ciphers_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_ssl_keys_lengths, + share->tgt_ssl_keys_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_default_files_lengths = + share_alter->tmp_tgt_ssl_keys_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_default_files_lengths, + share->tgt_default_files_lengths, + sizeof(uint) * share->all_link_count); + share_alter->tmp_tgt_default_groups_lengths = + share_alter->tmp_tgt_default_files_lengths + share->all_link_count; + memcpy(share_alter->tmp_tgt_default_groups_lengths, + share->tgt_default_groups_lengths, + sizeof(uint) * share->all_link_count); + + share_alter->tmp_server_names_charlen = share->server_names_charlen; + share_alter->tmp_tgt_table_names_charlen = share->tgt_table_names_charlen; + share_alter->tmp_tgt_dbs_charlen = share->tgt_dbs_charlen; + share_alter->tmp_tgt_hosts_charlen = share->tgt_hosts_charlen; + share_alter->tmp_tgt_usernames_charlen = share->tgt_usernames_charlen; + share_alter->tmp_tgt_passwords_charlen = share->tgt_passwords_charlen; + share_alter->tmp_tgt_sockets_charlen = share->tgt_sockets_charlen; + share_alter->tmp_tgt_wrappers_charlen = share->tgt_wrappers_charlen; + share_alter->tmp_tgt_ssl_cas_charlen = share->tgt_ssl_cas_charlen; + share_alter->tmp_tgt_ssl_capaths_charlen = share->tgt_ssl_capaths_charlen; + share_alter->tmp_tgt_ssl_certs_charlen = share->tgt_ssl_certs_charlen; + share_alter->tmp_tgt_ssl_ciphers_charlen = share->tgt_ssl_ciphers_charlen; + share_alter->tmp_tgt_ssl_keys_charlen = share->tgt_ssl_keys_charlen; + share_alter->tmp_tgt_default_files_charlen = + share->tgt_default_files_charlen; + share_alter->tmp_tgt_default_groups_charlen = + share->tgt_default_groups_charlen; + + share_alter->tmp_server_names_length = share->server_names_length; + share_alter->tmp_tgt_table_names_length = share->tgt_table_names_length; + share_alter->tmp_tgt_dbs_length = share->tgt_dbs_length; + share_alter->tmp_tgt_hosts_length = share->tgt_hosts_length; + share_alter->tmp_tgt_usernames_length = share->tgt_usernames_length; + share_alter->tmp_tgt_passwords_length = share->tgt_passwords_length; + share_alter->tmp_tgt_sockets_length = share->tgt_sockets_length; + share_alter->tmp_tgt_wrappers_length = share->tgt_wrappers_length; + share_alter->tmp_tgt_ssl_cas_length = share->tgt_ssl_cas_length; + share_alter->tmp_tgt_ssl_capaths_length = share->tgt_ssl_capaths_length; + share_alter->tmp_tgt_ssl_certs_length = share->tgt_ssl_certs_length; + share_alter->tmp_tgt_ssl_ciphers_length = share->tgt_ssl_ciphers_length; + share_alter->tmp_tgt_ssl_keys_length = share->tgt_ssl_keys_length; + share_alter->tmp_tgt_default_files_length = share->tgt_default_files_length; + share_alter->tmp_tgt_default_groups_length = + share->tgt_default_groups_length; + share_alter->tmp_tgt_ports_length = share->tgt_ports_length; + share_alter->tmp_tgt_ssl_vscs_length = share->tgt_ssl_vscs_length; + share_alter->tmp_link_statuses_length = share->link_statuses_length; + /* copy for tables end */ + + if ((error_num = spider_set_connect_info_default( + share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + part_elem, + sub_elem, +#endif + table_share + ))) + goto error; + + if (create_table) + { + for (roop_count = 0; roop_count < (int) share->all_link_count; + roop_count++) + { + int roop_count2; + for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) + { + if ( + spider_dbton[roop_count2].wrapper && + !strcmp(share->tgt_wrappers[roop_count], + spider_dbton[roop_count2].wrapper) + ) { + break; + } + } + if (roop_count2 == SPIDER_DBTON_SIZE) + { + DBUG_PRINT("info",("spider err tgt_wrappers[%d]=%s", roop_count, + share->tgt_wrappers[roop_count])); + error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), share->tgt_wrappers[roop_count]); + goto error; + } + + DBUG_PRINT("info", + ("spider server_names_lengths[%d] = %u", roop_count, + share->server_names_lengths[roop_count])); + if (share->server_names_lengths[roop_count] > SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->server_names[roop_count], "server"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_table_names_lengths[%d] = %u", roop_count, + share->tgt_table_names_lengths[roop_count])); + if (share->tgt_table_names_lengths[roop_count] > + SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_table_names[roop_count], "table"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_dbs_lengths[%d] = %u", roop_count, + share->tgt_dbs_lengths[roop_count])); + if (share->tgt_dbs_lengths[roop_count] > SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_dbs[roop_count], "database"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_hosts_lengths[%d] = %u", roop_count, + share->tgt_hosts_lengths[roop_count])); + if (share->tgt_hosts_lengths[roop_count] > SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_hosts[roop_count], "host"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_usernames_lengths[%d] = %u", roop_count, + share->tgt_usernames_lengths[roop_count])); + if (share->tgt_usernames_lengths[roop_count] > + SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_usernames[roop_count], "user"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_passwords_lengths[%d] = %u", roop_count, + share->tgt_passwords_lengths[roop_count])); + if (share->tgt_passwords_lengths[roop_count] > + SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_passwords[roop_count], "password"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_sockets_lengths[%d] = %u", roop_count, + share->tgt_sockets_lengths[roop_count])); + if (share->tgt_sockets_lengths[roop_count] > + SPIDER_CONNECT_INFO_PATH_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_sockets[roop_count], "socket"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_wrappers_lengths[%d] = %u", roop_count, + share->tgt_wrappers_lengths[roop_count])); + if (share->tgt_wrappers_lengths[roop_count] > + SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_wrappers[roop_count], "wrapper"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_ssl_cas_lengths[%d] = %u", roop_count, + share->tgt_ssl_cas_lengths[roop_count])); + if (share->tgt_ssl_cas_lengths[roop_count] > + SPIDER_CONNECT_INFO_PATH_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_ssl_cas[roop_count], "ssl_ca"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_ssl_capaths_lengths[%d] = %u", roop_count, + share->tgt_ssl_capaths_lengths[roop_count])); + if (share->tgt_ssl_capaths_lengths[roop_count] > + SPIDER_CONNECT_INFO_PATH_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_ssl_capaths[roop_count], "ssl_capath"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_ssl_certs_lengths[%d] = %u", roop_count, + share->tgt_ssl_certs_lengths[roop_count])); + if (share->tgt_ssl_certs_lengths[roop_count] > + SPIDER_CONNECT_INFO_PATH_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_ssl_certs[roop_count], "ssl_cert"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_ssl_ciphers_lengths[%d] = %u", roop_count, + share->tgt_ssl_ciphers_lengths[roop_count])); + if (share->tgt_ssl_ciphers_lengths[roop_count] > + SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_ssl_ciphers[roop_count], "ssl_cipher"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_ssl_keys_lengths[%d] = %u", roop_count, + share->tgt_ssl_keys_lengths[roop_count])); + if (share->tgt_ssl_keys_lengths[roop_count] > + SPIDER_CONNECT_INFO_PATH_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_ssl_keys[roop_count], "ssl_key"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_default_files_lengths[%d] = %u", roop_count, + share->tgt_default_files_lengths[roop_count])); + if (share->tgt_default_files_lengths[roop_count] > + SPIDER_CONNECT_INFO_PATH_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_default_files[roop_count], "default_file"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_default_groups_lengths[%d] = %u", roop_count, + share->tgt_default_groups_lengths[roop_count])); + if (share->tgt_default_groups_lengths[roop_count] > + SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_default_groups[roop_count], "default_group"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_pk_names_lengths[%d] = %u", roop_count, + share->tgt_pk_names_lengths[roop_count])); + if (share->tgt_pk_names_lengths[roop_count] > + SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_pk_names[roop_count], "pk_name"); + goto error; + } + + DBUG_PRINT("info", + ("spider tgt_sequence_names_lengths[%d] = %u", roop_count, + share->tgt_sequence_names_lengths[roop_count])); + if (share->tgt_sequence_names_lengths[roop_count] > + SPIDER_CONNECT_INFO_MAX_LEN) + { + error_num = ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_NUM; + my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_TOO_LONG_STR, + MYF(0), share->tgt_sequence_names[roop_count], "sequence_name"); + goto error; + } + } + } + + DBUG_PRINT("info", ("spider share->active_link_count = %d", + share->active_link_count)); + share->link_count = (uint) share->active_link_count; + share_alter->link_count = share->link_count; + share->link_bitmap_size = (share->link_count + 7) / 8; + + if (connect_string) + spider_free(spider_current_trx, connect_string, MYF(0)); + DBUG_RETURN(0); + +error: + if (connect_string) + spider_free(spider_current_trx, connect_string, MYF(0)); +error_alloc_conn_string: + DBUG_RETURN(error_num); +} + +int spider_set_connect_info_default( + SPIDER_SHARE *share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_element *part_elem, + partition_element *sub_elem, +#endif + TABLE_SHARE *table_share +) { + int error_num, roop_count; + DBUG_ENTER("spider_set_connect_info_default"); + for (roop_count = 0; roop_count < (int) share->all_link_count; roop_count++) + { + if (share->server_names[roop_count]) + { + if ((error_num = spider_get_server(share, roop_count))) + DBUG_RETURN(error_num); + } + + if (!share->tgt_wrappers[roop_count]) + { + DBUG_PRINT("info",("spider create default tgt_wrappers")); + share->tgt_wrappers_lengths[roop_count] = SPIDER_DB_WRAPPER_LEN; + if ( + !(share->tgt_wrappers[roop_count] = spider_create_string( + SPIDER_DB_WRAPPER_STR, + share->tgt_wrappers_lengths[roop_count])) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (!share->tgt_hosts[roop_count]) + { + DBUG_PRINT("info",("spider create default tgt_hosts")); + share->tgt_hosts_lengths[roop_count] = strlen(my_localhost); + if ( + !(share->tgt_hosts[roop_count] = spider_create_string( + my_localhost, + share->tgt_hosts_lengths[roop_count])) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (!share->tgt_dbs[roop_count] && table_share) + { + DBUG_PRINT("info",("spider create default tgt_dbs")); + share->tgt_dbs_lengths[roop_count] = table_share->db.length; + if ( + !(share->tgt_dbs[roop_count] = spider_create_string( + table_share->db.str, + table_share->db.length)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (!share->tgt_table_names[roop_count] && table_share) + { + DBUG_PRINT("info",("spider create default tgt_table_names")); + share->tgt_table_names_lengths[roop_count] = share->table_name_length; + if ( + !(share->tgt_table_names[roop_count] = spider_create_table_name_string( + table_share->table_name.str, +#ifdef WITH_PARTITION_STORAGE_ENGINE + (part_elem ? part_elem->partition_name : NULL), + (sub_elem ? sub_elem->partition_name : NULL) +#else + NULL, + NULL +#endif + )) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if ( + !share->tgt_default_files[roop_count] && + share->tgt_default_groups[roop_count] && + (*spd_defaults_file || *spd_defaults_extra_file) + ) { + DBUG_PRINT("info",("spider create default tgt_default_files")); + if (*spd_defaults_extra_file) + { + share->tgt_default_files_lengths[roop_count] = + strlen(*spd_defaults_extra_file); + if ( + !(share->tgt_default_files[roop_count] = spider_create_string( + *spd_defaults_extra_file, + share->tgt_default_files_lengths[roop_count])) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } else { + share->tgt_default_files_lengths[roop_count] = + strlen(*spd_defaults_file); + if ( + !(share->tgt_default_files[roop_count] = spider_create_string( + *spd_defaults_file, + share->tgt_default_files_lengths[roop_count])) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + } + + if (!share->tgt_pk_names[roop_count]) + { + DBUG_PRINT("info",("spider create default tgt_pk_names")); + share->tgt_pk_names_lengths[roop_count] = SPIDER_DB_PK_NAME_LEN; + if ( + !(share->tgt_pk_names[roop_count] = spider_create_string( + SPIDER_DB_PK_NAME_STR, + share->tgt_pk_names_lengths[roop_count])) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (!share->tgt_sequence_names[roop_count]) + { + DBUG_PRINT("info",("spider create default tgt_sequence_names")); + share->tgt_sequence_names_lengths[roop_count] = + SPIDER_DB_SEQUENCE_NAME_LEN; + if ( + !(share->tgt_sequence_names[roop_count] = spider_create_string( + SPIDER_DB_SEQUENCE_NAME_STR, + share->tgt_sequence_names_lengths[roop_count])) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (share->tgt_ports[roop_count] == -1) + { + share->tgt_ports[roop_count] = MYSQL_PORT; + } else if (share->tgt_ports[roop_count] < 0) + { + share->tgt_ports[roop_count] = 0; + } else if (share->tgt_ports[roop_count] > 65535) + { + share->tgt_ports[roop_count] = 65535; + } + + if (share->tgt_ssl_vscs[roop_count] == -1) + share->tgt_ssl_vscs[roop_count] = 0; + + if ( + !share->tgt_sockets[roop_count] && + !strcmp(share->tgt_hosts[roop_count], my_localhost) + ) { + DBUG_PRINT("info",("spider create default tgt_sockets")); + share->tgt_sockets_lengths[roop_count] = + strlen((char *) MYSQL_UNIX_ADDR); + if ( + !(share->tgt_sockets[roop_count] = spider_create_string( + (char *) MYSQL_UNIX_ADDR, + share->tgt_sockets_lengths[roop_count])) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (share->link_statuses[roop_count] == -1) + share->link_statuses[roop_count] = SPIDER_LINK_STATUS_NO_CHANGE; + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (share->monitoring_bg_kind[roop_count] == -1) + share->monitoring_bg_kind[roop_count] = 0; +#endif + if (share->monitoring_kind[roop_count] == -1) + share->monitoring_kind[roop_count] = 0; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (share->monitoring_bg_interval[roop_count] == -1) + share->monitoring_bg_interval[roop_count] = 10000000; +#endif + if (share->monitoring_limit[roop_count] == -1) + share->monitoring_limit[roop_count] = 1; + if (share->monitoring_sid[roop_count] == -1) +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 + share->monitoring_sid[roop_count] = global_system_variables.server_id; +#else + share->monitoring_sid[roop_count] = current_thd->server_id; +#endif + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (share->use_hs_reads[roop_count] == -1) + share->use_hs_reads[roop_count] = 0; + if (share->use_hs_writes[roop_count] == -1) + share->use_hs_writes[roop_count] = 0; + if (share->hs_read_ports[roop_count] == -1) + { + share->hs_read_ports[roop_count] = 9998; + } else if (share->hs_read_ports[roop_count] < 0) + { + share->hs_read_ports[roop_count] = 0; + } else if (share->hs_read_ports[roop_count] > 65535) + { + share->hs_read_ports[roop_count] = 65535; + } + if (share->hs_write_ports[roop_count] == -1) + { + share->hs_write_ports[roop_count] = 9999; + } else if (share->hs_write_ports[roop_count] < 0) + { + share->hs_write_ports[roop_count] = 0; + } else if (share->hs_write_ports[roop_count] > 65535) + { + share->hs_write_ports[roop_count] = 65535; + } + if (share->hs_write_to_reads[roop_count] == -1) + { + share->hs_write_to_reads[roop_count] = 1; + } else if (share->hs_write_to_reads[roop_count] < 0) + { + share->hs_write_to_reads[roop_count] = 0; + } else if (share->hs_write_to_reads[roop_count] > 1) + { + share->hs_write_to_reads[roop_count] = 1; + } +#endif + if (share->use_handlers[roop_count] == -1) + share->use_handlers[roop_count] = 0; + if (share->connect_timeouts[roop_count] == -1) + share->connect_timeouts[roop_count] = 6; + if (share->net_read_timeouts[roop_count] == -1) + share->net_read_timeouts[roop_count] = 600; + if (share->net_write_timeouts[roop_count] == -1) + share->net_write_timeouts[roop_count] = 600; + if (share->access_balances[roop_count] == -1) + share->access_balances[roop_count] = 100; + } + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (share->sts_bg_mode == -1) + share->sts_bg_mode = 1; +#endif + if (share->sts_interval == -1) + share->sts_interval = 10; + if (share->sts_mode == -1) + share->sts_mode = 1; +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (share->sts_sync == -1) + share->sts_sync = 0; +#endif +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (share->crd_bg_mode == -1) + share->crd_bg_mode = 1; +#endif + if (share->crd_interval == -1) + share->crd_interval = 51; + if (share->crd_mode == -1) + share->crd_mode = 1; +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (share->crd_sync == -1) + share->crd_sync = 0; +#endif + if (share->crd_type == -1) + share->crd_type = 2; + if (share->crd_weight == -1) + share->crd_weight = 2; + if (share->internal_offset == -1) + share->internal_offset = 0; + if (share->internal_limit == -1) + share->internal_limit = 9223372036854775807LL; + if (share->split_read == -1) + share->split_read = 9223372036854775807LL; + if (share->semi_split_read == -1) + share->semi_split_read = 2; + if (share->semi_split_read_limit == -1) + share->semi_split_read_limit = 9223372036854775807LL; + if (share->init_sql_alloc_size == -1) + share->init_sql_alloc_size = 1024; + if (share->reset_sql_alloc == -1) + share->reset_sql_alloc = 1; + if (share->multi_split_read == -1) + share->multi_split_read = 100; + if (share->max_order == -1) + share->max_order = 32767; + if (share->semi_table_lock == -1) + share->semi_table_lock = 0; + if (share->semi_table_lock_conn == -1) + share->semi_table_lock_conn = 1; + if (share->selupd_lock_mode == -1) + share->selupd_lock_mode = 1; + if (share->query_cache == -1) + share->query_cache = 0; + if (share->internal_delayed == -1) + share->internal_delayed = 0; + if (share->bulk_size == -1) + share->bulk_size = 16000; + if (share->bulk_update_mode == -1) + share->bulk_update_mode = 0; + if (share->bulk_update_size == -1) + share->bulk_update_size = 16000; + if (share->internal_optimize == -1) + share->internal_optimize = 0; + if (share->internal_optimize_local == -1) + share->internal_optimize_local = 0; + if (share->scan_rate == -1) + share->scan_rate = 1; + if (share->read_rate == -1) + share->read_rate = 0.0002; + if (share->priority == -1) + share->priority = 1000000; + if (share->quick_mode == -1) + share->quick_mode = 0; + if (share->quick_page_size == -1) + share->quick_page_size = 100; + if (share->low_mem_read == -1) + share->low_mem_read = 1; + if (share->table_count_mode == -1) + share->table_count_mode = 0; + if (share->select_column_mode == -1) + share->select_column_mode = 1; +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (share->bgs_mode == -1) + share->bgs_mode = 0; + if (share->bgs_first_read == -1) + share->bgs_first_read = 2; + if (share->bgs_second_read == -1) + share->bgs_second_read = 100; +#endif + if (share->first_read == -1) + share->first_read = 0; + if (share->second_read == -1) + share->second_read = 0; + if (share->auto_increment_mode == -1) + share->auto_increment_mode = 0; + if (share->use_table_charset == -1) + share->use_table_charset = 1; + if (share->use_pushdown_udf == -1) + share->use_pushdown_udf = 1; + if (share->skip_default_condition == -1) + share->skip_default_condition = 0; + if (share->direct_dup_insert == -1) + share->direct_dup_insert = 0; + if (share->direct_order_limit == -1) + share->direct_order_limit = 9223372036854775807LL; + if (share->read_only_mode == -1) + share->read_only_mode = 0; + if (share->error_read_mode == -1) + share->error_read_mode = 0; + if (share->error_write_mode == -1) + share->error_write_mode = 0; + if (share->active_link_count == -1) + share->active_link_count = share->all_link_count; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (share->hs_result_free_size == -1) + share->hs_result_free_size = 1048576; +#endif +#ifdef HA_CAN_BULK_ACCESS + if (share->bulk_access_free == -1) + share->bulk_access_free = 0; +#endif + if (share->bka_mode == -1) + share->bka_mode = 1; + if (!share->bka_engine) + { + DBUG_PRINT("info",("spider create default bka_engine")); + share->bka_engine_length = SPIDER_SQL_TMP_BKA_ENGINE_LEN; + if ( + !(share->bka_engine = spider_create_string( + SPIDER_SQL_TMP_BKA_ENGINE_STR, + SPIDER_SQL_TMP_BKA_ENGINE_LEN)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + DBUG_RETURN(0); +} + +int spider_set_connect_info_default_db_table( + SPIDER_SHARE *share, + const char *db_name, + uint db_name_length, + const char *table_name, + uint table_name_length +) { + int roop_count; + DBUG_ENTER("spider_set_connect_info_default_db_table"); + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + if (!share->tgt_dbs[roop_count] && db_name) + { + DBUG_PRINT("info",("spider create default tgt_dbs")); + share->tgt_dbs_lengths[roop_count] = db_name_length; + if ( + !(share->tgt_dbs[roop_count] = spider_create_string( + db_name, + db_name_length)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + + if (!share->tgt_table_names[roop_count] && table_name) + { + const char *tmp_ptr; + DBUG_PRINT("info",("spider create default tgt_table_names")); + if ((tmp_ptr = strstr(table_name, "#P#"))) + table_name_length = (uint) PTR_BYTE_DIFF(tmp_ptr, table_name); + share->tgt_table_names_lengths[roop_count] = table_name_length; + if ( + !(share->tgt_table_names[roop_count] = spider_create_string( + table_name, + table_name_length)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + } + } + DBUG_RETURN(0); +} + +int spider_set_connect_info_default_dbtable( + SPIDER_SHARE *share, + const char *dbtable_name, + int dbtable_name_length +) { + const char *ptr_db, *ptr_table; + my_ptrdiff_t ptr_diff_db, ptr_diff_table; + DBUG_ENTER("spider_set_connect_info_default_dbtable"); + ptr_db = strchr(dbtable_name, FN_LIBCHAR); + ptr_db++; + ptr_diff_db = PTR_BYTE_DIFF(ptr_db, dbtable_name); + DBUG_PRINT("info",("spider ptr_diff_db = %lld", (longlong) ptr_diff_db)); + ptr_table = strchr(ptr_db, FN_LIBCHAR); + ptr_table++; + ptr_diff_table = PTR_BYTE_DIFF(ptr_table, ptr_db); + DBUG_PRINT("info",("spider ptr_diff_table = %lld", (longlong) ptr_diff_table)); + DBUG_RETURN(spider_set_connect_info_default_db_table( + share, + ptr_db, + (uint)(ptr_diff_table - 1), + ptr_table, + (uint)(dbtable_name_length - ptr_diff_db - ptr_diff_table) + )); +} + +#ifndef DBUG_OFF +void spider_print_keys( + const char *key, + uint length +) { + const char *end_ptr; + uint roop_count = 1; + DBUG_ENTER("spider_print_keys"); + DBUG_PRINT("info",("spider key_length=%u", length)); + end_ptr = key + length; + while (key < end_ptr) + { + DBUG_PRINT("info",("spider key[%u]=%s", roop_count, key)); + key = strchr(key, '\0') + 1; + roop_count++; + } + DBUG_VOID_RETURN; +} +#endif + +int spider_create_conn_keys( + SPIDER_SHARE *share +) { + int roop_count, roop_count2; + char *tmp_name, port_str[6]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char *tmp_hs_r_name, *tmp_hs_w_name; +#endif +#ifdef _MSC_VER + uint *conn_keys_lengths; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint *hs_r_conn_keys_lengths; + uint *hs_w_conn_keys_lengths; +#endif +#else + uint conn_keys_lengths[share->all_link_count]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + uint hs_r_conn_keys_lengths[share->all_link_count]; + uint hs_w_conn_keys_lengths[share->all_link_count]; +#endif +#endif + DBUG_ENTER("spider_create_conn_keys"); +#ifdef _MSC_VER + if (!(conn_keys_lengths = + (uint *) spider_bulk_alloc_mem(spider_current_trx, 44, + __func__, __FILE__, __LINE__, MYF(MY_WME), + &conn_keys_lengths, sizeof(uint) * share->all_link_count, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + &hs_r_conn_keys_lengths, sizeof(uint) * share->all_link_count, + &hs_w_conn_keys_lengths, sizeof(uint) * share->all_link_count, +#endif + NullS))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); +#endif + + share->conn_keys_charlen = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + share->hs_read_conn_keys_charlen = 0; + share->hs_write_conn_keys_charlen = 0; +#endif + for (roop_count = 0; roop_count < (int) share->all_link_count; roop_count++) + { + /* tgt_db not use */ + conn_keys_lengths[roop_count] + = 1 + + share->tgt_wrappers_lengths[roop_count] + 1 + + share->tgt_hosts_lengths[roop_count] + 1 + + 5 + 1 + + share->tgt_sockets_lengths[roop_count] + 1 + + share->tgt_usernames_lengths[roop_count] + 1 + + share->tgt_passwords_lengths[roop_count] + 1 + + share->tgt_ssl_cas_lengths[roop_count] + 1 + + share->tgt_ssl_capaths_lengths[roop_count] + 1 + + share->tgt_ssl_certs_lengths[roop_count] + 1 + + share->tgt_ssl_ciphers_lengths[roop_count] + 1 + + share->tgt_ssl_keys_lengths[roop_count] + 1 + + 1 + 1 + + share->tgt_default_files_lengths[roop_count] + 1 + + share->tgt_default_groups_lengths[roop_count]; + share->conn_keys_charlen += conn_keys_lengths[roop_count] + 2; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + hs_r_conn_keys_lengths[roop_count] + = 1 + + share->tgt_wrappers_lengths[roop_count] + 1 + + share->tgt_hosts_lengths[roop_count] + 1 + + 5 + 1 + + share->hs_read_socks_lengths[roop_count]; + share->hs_read_conn_keys_charlen += + hs_r_conn_keys_lengths[roop_count] + 2; + hs_w_conn_keys_lengths[roop_count] + = 1 + + share->tgt_wrappers_lengths[roop_count] + 1 + + share->tgt_hosts_lengths[roop_count] + 1 + + 5 + 1 + + share->hs_write_socks_lengths[roop_count]; + share->hs_write_conn_keys_charlen += + hs_w_conn_keys_lengths[roop_count] + 2; +#endif + } + if (!(share->conn_keys = (char **) + spider_bulk_alloc_mem(spider_current_trx, 45, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &share->conn_keys, sizeof(char *) * share->all_link_count, + &share->conn_keys_lengths, sizeof(uint) * share->all_link_count, +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + &share->conn_keys_hash_value, + sizeof(my_hash_value_type) * share->all_link_count, +#endif + &tmp_name, sizeof(char) * share->conn_keys_charlen, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + &share->hs_read_conn_keys, sizeof(char *) * share->all_link_count, + &share->hs_read_conn_keys_lengths, sizeof(uint) * share->all_link_count, +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + &share->hs_read_conn_keys_hash_value, + sizeof(my_hash_value_type) * share->all_link_count, +#endif + &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, + &share->hs_write_conn_keys, sizeof(char *) * share->all_link_count, + &share->hs_write_conn_keys_lengths, sizeof(uint) * share->all_link_count, +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + &share->hs_write_conn_keys_hash_value, + sizeof(my_hash_value_type) * share->all_link_count, +#endif + &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, +#endif + &share->sql_dbton_ids, sizeof(uint) * share->all_link_count, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + &share->hs_dbton_ids, sizeof(uint) * share->all_link_count, +#endif + NullS)) + ) { +#ifdef _MSC_VER + spider_free(spider_current_trx, conn_keys_lengths, MYF(MY_WME)); +#endif + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + share->conn_keys_length = share->all_link_count; + memcpy(share->conn_keys_lengths, conn_keys_lengths, + sizeof(uint) * share->all_link_count); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + share->hs_read_conn_keys_length = share->all_link_count; + share->hs_write_conn_keys_length = share->all_link_count; + memcpy(share->hs_read_conn_keys_lengths, hs_r_conn_keys_lengths, + sizeof(uint) * share->all_link_count); + memcpy(share->hs_write_conn_keys_lengths, hs_w_conn_keys_lengths, + sizeof(uint) * share->all_link_count); +#endif + +#ifdef _MSC_VER + spider_free(spider_current_trx, conn_keys_lengths, MYF(MY_WME)); +#endif + + for (roop_count = 0; roop_count < (int) share->all_link_count; roop_count++) + { + share->conn_keys[roop_count] = tmp_name; + *tmp_name = '0'; + DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count, + share->tgt_wrappers[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_wrappers[roop_count]); + DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count, + share->tgt_hosts[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_hosts[roop_count]); + my_sprintf(port_str, (port_str, "%05ld", share->tgt_ports[roop_count])); + DBUG_PRINT("info",("spider port_str=%s", port_str)); + tmp_name = strmov(tmp_name + 1, port_str); + if (share->tgt_sockets[roop_count]) + { + DBUG_PRINT("info",("spider tgt_sockets[%d]=%s", roop_count, + share->tgt_sockets[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_sockets[roop_count]); + } else + tmp_name++; + if (share->tgt_usernames[roop_count]) + { + DBUG_PRINT("info",("spider tgt_usernames[%d]=%s", roop_count, + share->tgt_usernames[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_usernames[roop_count]); + } else + tmp_name++; + if (share->tgt_passwords[roop_count]) + { + DBUG_PRINT("info",("spider tgt_passwords[%d]=%s", roop_count, + share->tgt_passwords[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_passwords[roop_count]); + } else + tmp_name++; + if (share->tgt_ssl_cas[roop_count]) + { + DBUG_PRINT("info",("spider tgt_ssl_cas[%d]=%s", roop_count, + share->tgt_ssl_cas[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_ssl_cas[roop_count]); + } else + tmp_name++; + if (share->tgt_ssl_capaths[roop_count]) + { + DBUG_PRINT("info",("spider tgt_ssl_capaths[%d]=%s", roop_count, + share->tgt_ssl_capaths[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_ssl_capaths[roop_count]); + } else + tmp_name++; + if (share->tgt_ssl_certs[roop_count]) + { + DBUG_PRINT("info",("spider tgt_ssl_certs[%d]=%s", roop_count, + share->tgt_ssl_certs[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_ssl_certs[roop_count]); + } else + tmp_name++; + if (share->tgt_ssl_ciphers[roop_count]) + { + DBUG_PRINT("info",("spider tgt_ssl_ciphers[%d]=%s", roop_count, + share->tgt_ssl_ciphers[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_ssl_ciphers[roop_count]); + } else + tmp_name++; + if (share->tgt_ssl_keys[roop_count]) + { + DBUG_PRINT("info",("spider tgt_ssl_keys[%d]=%s", roop_count, + share->tgt_ssl_keys[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_ssl_keys[roop_count]); + } else + tmp_name++; + tmp_name++; + *tmp_name = '0' + ((char) share->tgt_ssl_vscs[roop_count]); + if (share->tgt_default_files[roop_count]) + { + DBUG_PRINT("info",("spider tgt_default_files[%d]=%s", roop_count, + share->tgt_default_files[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_default_files[roop_count]); + } else + tmp_name++; + if (share->tgt_default_groups[roop_count]) + { + DBUG_PRINT("info",("spider tgt_default_groups[%d]=%s", roop_count, + share->tgt_default_groups[roop_count])); + tmp_name = strmov(tmp_name + 1, share->tgt_default_groups[roop_count]); + } else + tmp_name++; + tmp_name++; + tmp_name++; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + share->conn_keys_hash_value[roop_count] = my_calc_hash( + &spider_open_connections, (uchar*) share->conn_keys[roop_count], + share->conn_keys_lengths[roop_count]); +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + share->hs_read_conn_keys[roop_count] = tmp_hs_r_name; + *tmp_hs_r_name = '0'; + DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count, + share->tgt_wrappers[roop_count])); + tmp_hs_r_name = strmov(tmp_hs_r_name + 1, share->tgt_wrappers[roop_count]); + DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count, + share->tgt_hosts[roop_count])); + tmp_hs_r_name = strmov(tmp_hs_r_name + 1, share->tgt_hosts[roop_count]); + my_sprintf(port_str, (port_str, "%05ld", + share->hs_read_ports[roop_count])); + DBUG_PRINT("info",("spider port_str=%s", port_str)); + tmp_hs_r_name = strmov(tmp_hs_r_name + 1, port_str); + if (share->hs_read_socks[roop_count]) + { + DBUG_PRINT("info",("spider hs_read_socks[%d]=%s", roop_count, + share->hs_read_socks[roop_count])); + tmp_hs_r_name = strmov(tmp_hs_r_name + 1, + share->hs_read_socks[roop_count]); + } else + tmp_hs_r_name++; + tmp_hs_r_name++; + tmp_hs_r_name++; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + share->hs_read_conn_keys_hash_value[roop_count] = my_calc_hash( + &spider_open_connections, (uchar*) share->hs_read_conn_keys[roop_count], + share->hs_read_conn_keys_lengths[roop_count]); +#endif + share->hs_write_conn_keys[roop_count] = tmp_hs_w_name; + *tmp_hs_w_name = '0'; + DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count, + share->tgt_wrappers[roop_count])); + tmp_hs_w_name = strmov(tmp_hs_w_name + 1, share->tgt_wrappers[roop_count]); + DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count, + share->tgt_hosts[roop_count])); + tmp_hs_w_name = strmov(tmp_hs_w_name + 1, share->tgt_hosts[roop_count]); + my_sprintf(port_str, (port_str, "%05ld", + share->hs_write_ports[roop_count])); + DBUG_PRINT("info",("spider port_str=%s", port_str)); + tmp_hs_w_name = strmov(tmp_hs_w_name + 1, port_str); + if (share->hs_write_socks[roop_count]) + { + DBUG_PRINT("info",("spider hs_write_socks[%d]=%s", roop_count, + share->hs_write_socks[roop_count])); + tmp_hs_w_name = strmov(tmp_hs_w_name + 1, + share->hs_write_socks[roop_count]); + } else + tmp_hs_w_name++; + tmp_hs_w_name++; + tmp_hs_w_name++; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + share->hs_write_conn_keys_hash_value[roop_count] = my_calc_hash( + &spider_open_connections, (uchar*) share->hs_write_conn_keys[roop_count], + share->hs_write_conn_keys_lengths[roop_count]); +#endif +#endif + + bool get_sql_id = FALSE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + bool get_nosql_id = FALSE; +#endif + for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) + { + DBUG_PRINT("info",("spider share->tgt_wrappers[%d]=%s", roop_count, + share->tgt_wrappers[roop_count])); + DBUG_PRINT("info",("spider spider_dbton[%d].wrapper=%s", roop_count2, + spider_dbton[roop_count2].wrapper ? + spider_dbton[roop_count2].wrapper : "NULL")); + if ( + spider_dbton[roop_count2].wrapper && + !strcmp(share->tgt_wrappers[roop_count], + spider_dbton[roop_count2].wrapper) + ) { + spider_set_bit(share->dbton_bitmap, roop_count2); + if ( + !get_sql_id && + spider_dbton[roop_count2].db_access_type == SPIDER_DB_ACCESS_TYPE_SQL + ) { + share->sql_dbton_ids[roop_count] = roop_count2; + get_sql_id = TRUE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (get_nosql_id) +#endif + break; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + else + continue; +#endif + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ( + !get_nosql_id && + spider_dbton[roop_count2].db_access_type == + SPIDER_DB_ACCESS_TYPE_NOSQL + ) { + share->hs_dbton_ids[roop_count] = roop_count2; + get_nosql_id = TRUE; + if (get_sql_id) + break; + } +#endif + } + } + if (!get_sql_id) + share->sql_dbton_ids[roop_count] = SPIDER_DBTON_SIZE; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!get_nosql_id) + share->hs_dbton_ids[roop_count] = SPIDER_DBTON_SIZE; +#endif + } + for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) + { + if (spider_bit_is_set(share->dbton_bitmap, roop_count2)) + { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (spider_dbton[roop_count2].db_access_type == + SPIDER_DB_ACCESS_TYPE_SQL) + { +#endif + share->use_sql_dbton_ids[share->use_dbton_count] = roop_count2; + share->sql_dbton_id_to_seq[roop_count2] = share->use_dbton_count; + share->use_sql_dbton_count++; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else { + share->use_hs_dbton_ids[share->use_hs_dbton_count] = roop_count2; + share->hs_dbton_id_to_seq[roop_count2] = share->use_hs_dbton_count; + share->use_hs_dbton_count++; + } +#endif + share->use_dbton_ids[share->use_dbton_count] = roop_count2; + share->dbton_id_to_seq[roop_count2] = share->use_dbton_count; + share->use_dbton_count++; + } + } + DBUG_RETURN(0); +} + +SPIDER_SHARE *spider_create_share( + const char *table_name, + TABLE_SHARE *table_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_info *part_info, +#endif +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value, +#endif + int *error_num +) { + int bitmap_size, roop_count; + uint length; + int use_table_charset; + SPIDER_SHARE *share; + char *tmp_name; + longlong *tmp_cardinality; + uchar *tmp_cardinality_upd; + DBUG_ENTER("spider_create_share"); + length = (uint) strlen(table_name); + bitmap_size = spider_bitmap_size(table_share->fields); + if (!(share = (SPIDER_SHARE *) + spider_bulk_malloc(spider_current_trx, 46, MYF(MY_WME | MY_ZEROFILL), + &share, sizeof(*share), + &tmp_name, length + 1, + &tmp_cardinality, sizeof(*tmp_cardinality) * table_share->fields, + &tmp_cardinality_upd, sizeof(*tmp_cardinality_upd) * bitmap_size, + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_share; + } + + share->use_count = 0; + share->use_dbton_count = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + share->use_hs_dbton_count = 0; +#endif + share->table_name_length = length; + share->table_name = tmp_name; + strmov(share->table_name, table_name); + share->cardinality = tmp_cardinality; + share->cardinality_upd = tmp_cardinality_upd; + share->bitmap_size = bitmap_size; + share->table_share = table_share; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + share->table_name_hash_value = hash_value; +#ifdef WITH_PARTITION_STORAGE_ENGINE + share->table_path_hash_value = my_calc_hash(&spider_open_tables, + (uchar*) table_share->path.str, table_share->path.length); +#endif +#endif + + if (table_share->keys > 0 && + !(share->key_hint = new spider_string[table_share->keys]) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_hint_string; + } + for (roop_count = 0; roop_count < (int) table_share->keys; roop_count++) + share->key_hint[roop_count].init_calc_mem(95); + DBUG_PRINT("info",("spider share->key_hint=%p", share->key_hint)); + + if ((*error_num = spider_parse_connect_info(share, table_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + part_info, +#endif + 0))) + goto error_parse_connect_string; + + use_table_charset = spider_param_use_table_charset( + share->use_table_charset); + if (use_table_charset) + share->access_charset = table_share->table_charset; + else + share->access_charset = system_charset_info; + + if ((*error_num = spider_create_conn_keys(share))) + goto error_create_conn_keys; + + if (share->table_count_mode) + share->additional_table_flags |= HA_STATS_RECORDS_IS_EXACT; + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_share, + &share->mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_mutex; + } + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&share->sts_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_share_sts, + &share->sts_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_sts_mutex; + } + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&share->crd_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_share_crd, + &share->crd_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_crd_mutex; + } + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&share->auto_increment_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_share_auto_increment, + &share->auto_increment_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_auto_increment_mutex; + } + + thr_lock_init(&share->lock); + +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (!(share->partition_share = + spider_get_pt_share(share, table_share, error_num))) + goto error_get_pt_share; +#endif + + for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++) + { + if (spider_bit_is_set(share->dbton_bitmap, roop_count)) + { + if (!(share->dbton_share[roop_count] = + spider_dbton[roop_count].create_db_share(share))) + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_dbton; + } + if ((*error_num = share->dbton_share[roop_count]->init())) + { + goto error_init_dbton; + } + } + } + DBUG_RETURN(share); + +/* + roop_count = SPIDER_DBTON_SIZE - 1; +*/ +error_init_dbton: + for (; roop_count >= 0; roop_count--) + { + if (share->dbton_share[roop_count]) + { + delete share->dbton_share[roop_count]; + share->dbton_share[roop_count] = NULL; + } + } +#ifdef WITH_PARTITION_STORAGE_ENGINE +error_get_pt_share: +#endif + thr_lock_delete(&share->lock); + pthread_mutex_destroy(&share->auto_increment_mutex); +error_init_auto_increment_mutex: + pthread_mutex_destroy(&share->crd_mutex); +error_init_crd_mutex: + pthread_mutex_destroy(&share->sts_mutex); +error_init_sts_mutex: + pthread_mutex_destroy(&share->mutex); +error_init_mutex: +error_create_conn_keys: +error_parse_connect_string: +error_init_hint_string: + spider_free_share_alloc(share); + spider_free(spider_current_trx, share, MYF(0)); +error_alloc_share: + DBUG_RETURN(NULL); +} + +SPIDER_SHARE *spider_get_share( + const char *table_name, + TABLE *table, + THD *thd, + ha_spider *spider, + int *error_num +) { + SPIDER_SHARE *share; + TABLE_SHARE *table_share = table->s; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + uint length, tmp_conn_link_idx = 0; + char *tmp_name, *tmp_cid; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + char *tmp_hs_r_name, *tmp_hs_w_name; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + uint32 *tmp_hs_r_ret_fields, *tmp_hs_w_ret_fields; +#endif +#endif + int roop_count; + double sts_interval; + int sts_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + int sts_sync; + int auto_increment_mode; +#endif + double crd_interval; + int crd_mode; +#ifdef WITH_PARTITION_STORAGE_ENGINE + int crd_sync; +#endif + char first_byte; + int semi_table_lock_conn; + int search_link_idx; + uint sql_command = thd_sql_command(thd); +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + MEM_ROOT mem_root; + TABLE *table_tables = NULL; + bool init_mem_root = FALSE; + DBUG_ENTER("spider_get_share"); + + length = (uint) strlen(table_name); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value = my_calc_hash(&spider_open_tables, + (uchar*) table_name, length); +#endif + pthread_mutex_lock(&spider_tbl_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(share = (SPIDER_SHARE*) my_hash_search_using_hash_value( + &spider_open_tables, hash_value, (uchar*) table_name, length))) +#else + if (!(share = (SPIDER_SHARE*) my_hash_search(&spider_open_tables, + (uchar*) table_name, length))) +#endif + { + if (!(share = spider_create_share( + table_name, table_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + table->part_info, +#endif +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + hash_value, +#endif + error_num + ))) { + goto error_alloc_share; + } + + uint old_elements = spider_open_tables.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&spider_open_tables, hash_value, + (uchar*) share)) +#else + if (my_hash_insert(&spider_open_tables, (uchar*) share)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_hash_insert; + } + if (spider_open_tables.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + spider_open_tables, + (spider_open_tables.array.max_element - old_elements) * + spider_open_tables.array.size_of_element); + } + + spider->share = share; + spider->conn_link_idx = &tmp_conn_link_idx; + + share->use_count++; + pthread_mutex_unlock(&spider_tbl_mutex); + + if (!share->link_status_init) + { + pthread_mutex_lock(&share->mutex); + if (!share->link_status_init) + { + if ( + table_share->tmp_table == NO_TMP_TABLE && + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE && + sql_command != SQLCOM_SHOW_CREATE + ) { + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + init_mem_root = TRUE; + if ( + !(table_tables = spider_open_sys_table( + thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup, + FALSE, error_num)) + ) { + pthread_mutex_unlock(&share->mutex); + spider_free_share(share); + goto error_open_sys_table; + } + *error_num = spider_get_link_statuses(table_tables, share, + &mem_root); + if (*error_num) + { + pthread_mutex_unlock(&share->mutex); + spider_free_share(share); + goto error_get_link_statuses; + } + } + share->have_recovery_link = spider_conn_check_recovery_link(share); + if (table_tables) + { + spider_close_sys_table(thd, table_tables, + &open_tables_backup, FALSE); + table_tables = NULL; + } + if (init_mem_root) + { + free_root(&mem_root, MYF(0)); + init_mem_root = FALSE; + } + } + pthread_mutex_unlock(&share->mutex); + } + + semi_table_lock_conn = spider_param_semi_table_lock_connection(thd, + share->semi_table_lock_conn); + if (semi_table_lock_conn) + first_byte = '0' + + spider_param_semi_table_lock(thd, share->semi_table_lock); + else + first_byte = '0'; + + if (!(spider->trx = spider_get_trx(thd, TRUE, error_num))) + { + share->init_error = TRUE; + share->init_error_time = (time_t) time((time_t*) 0); + share->init = TRUE; + spider_free_share(share); + goto error_but_no_delete; + } + spider->set_error_mode(); + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ( + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE && + sql_command != SQLCOM_SHOW_CREATE && + (*error_num = spider_create_mon_threads(spider->trx, share)) + ) { + share->init_error = TRUE; + share->init_error_time = (time_t) time((time_t*) 0); + share->init = TRUE; + spider_free_share(share); + goto error_but_no_delete; + } +#endif + + if (!(spider->conn_keys = (char **) + spider_bulk_alloc_mem(spider_current_trx, 47, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &spider->conn_keys, sizeof(char *) * share->link_count, + &tmp_name, sizeof(char) * share->conn_keys_charlen, + &spider->conns, sizeof(SPIDER_CONN *) * share->link_count, + &spider->conn_link_idx, sizeof(uint) * share->link_count, + &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + &spider->hs_r_conn_keys, sizeof(char *) * share->link_count, + &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, + &spider->hs_r_conns, sizeof(SPIDER_CONN *) * share->link_count, + &spider->hs_r_conn_ages, sizeof(ulonglong) * share->link_count, + &spider->hs_w_conn_keys, sizeof(char *) * share->link_count, + &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, + &spider->hs_w_conns, sizeof(SPIDER_CONN *) * share->link_count, + &spider->hs_w_conn_ages, sizeof(ulonglong) * share->link_count, +#endif + &spider->sql_kind, sizeof(uint) * share->link_count, + &spider->connection_ids, sizeof(ulonglong) * share->link_count, + &spider->conn_kind, sizeof(uint) * share->link_count, + &spider->db_request_id, sizeof(ulonglong) * share->link_count, + &spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size, + &spider->m_handler_opened, sizeof(uchar) * share->link_bitmap_size, + &spider->m_handler_id, sizeof(uint) * share->link_count, + &spider->m_handler_cid, sizeof(char *) * share->link_count, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + &spider->r_handler_opened, sizeof(uchar) * share->link_bitmap_size, + &spider->r_handler_id, sizeof(uint) * share->link_count, + &spider->r_handler_index, sizeof(uint) * share->link_count, + &spider->w_handler_opened, sizeof(uchar) * share->link_bitmap_size, + &spider->w_handler_id, sizeof(uint) * share->link_count, + &spider->w_handler_index, sizeof(uint) * share->link_count, +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + &spider->do_hs_direct_update, sizeof(uchar) * share->link_bitmap_size, + &spider->hs_r_ret_fields, sizeof(uint32 *) * share->link_count, + &spider->hs_w_ret_fields, sizeof(uint32 *) * share->link_count, + &spider->hs_r_ret_fields_num, sizeof(size_t) * share->link_count, + &spider->hs_w_ret_fields_num, sizeof(size_t) * share->link_count, + &tmp_hs_r_ret_fields, + sizeof(uint32) * share->link_count * table_share->fields, + &tmp_hs_w_ret_fields, + sizeof(uint32) * share->link_count * table_share->fields, + &spider->tmp_column_bitmap, sizeof(uchar) * share->bitmap_size, +#endif +#endif + &tmp_cid, sizeof(char) * (SPIDER_SQL_HANDLER_CID_LEN + 1) * + share->link_count, + &spider->need_mons, sizeof(int) * share->link_count, + &spider->quick_targets, sizeof(void *) * share->link_count, + &result_list->upd_tmp_tbls, sizeof(TABLE *) * share->link_count, + &result_list->upd_tmp_tbl_prms, + sizeof(TMP_TABLE_PARAM) * share->link_count, + &result_list->tmp_table_join_first, + sizeof(uchar) * share->link_bitmap_size, + &result_list->tmp_table_created, + sizeof(uchar) * share->link_bitmap_size, +#ifdef HA_CAN_BULK_ACCESS + &result_list->hs_r_bulk_open_index, + sizeof(uchar) * share->link_bitmap_size, + &result_list->hs_w_bulk_open_index, + sizeof(uchar) * share->link_bitmap_size, +#endif + &result_list->sql_kind_backup, sizeof(uint) * share->link_count, + &spider->dbton_handler, + sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + NullS)) + ) { + share->init_error = TRUE; + share->init_error_time = (time_t) time((time_t*) 0); + share->init = TRUE; + spider_free_share(share); + goto error_but_no_delete; + } + memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + memcpy(tmp_hs_r_name, share->hs_read_conn_keys[0], + share->hs_read_conn_keys_charlen); + memcpy(tmp_hs_w_name, share->hs_write_conn_keys[0], + share->hs_write_conn_keys_charlen); +#endif + + spider->conn_keys_first_ptr = tmp_name; + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + spider->conn_keys[roop_count] = tmp_name; + *tmp_name = first_byte; + tmp_name += share->conn_keys_lengths[roop_count] + 1; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider->hs_r_conn_keys[roop_count] = tmp_hs_r_name; + tmp_hs_r_name += share->hs_read_conn_keys_lengths[roop_count] + 1; + spider->hs_w_conn_keys[roop_count] = tmp_hs_w_name; + tmp_hs_w_name += share->hs_write_conn_keys_lengths[roop_count] + 1; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + spider->hs_r_ret_fields[roop_count] = tmp_hs_r_ret_fields; + tmp_hs_r_ret_fields += table_share->fields; + spider->hs_w_ret_fields[roop_count] = tmp_hs_w_ret_fields; + tmp_hs_w_ret_fields += table_share->fields; +#endif +#endif + spider->m_handler_cid[roop_count] = tmp_cid; + tmp_cid += SPIDER_SQL_HANDLER_CID_LEN + 1; + result_list->upd_tmp_tbl_prms[roop_count].init(); + result_list->upd_tmp_tbl_prms[roop_count].field_count = 1; + spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + } + spider_trx_set_link_idx_for_all(spider); + + for (roop_count = 0; roop_count < (int) share->use_dbton_count; + roop_count++) + { + uint dbton_id = share->use_dbton_ids[roop_count]; + if (!(spider->dbton_handler[dbton_id] = + spider_dbton[dbton_id].create_db_handler(spider, + share->dbton_share[dbton_id]))) + { + *error_num = HA_ERR_OUT_OF_MEM; + break; + } + if ((*error_num = spider->dbton_handler[dbton_id]->init())) + { + break; + } + } + if (roop_count < (int) share->use_dbton_count) + { + for (; roop_count >= 0; roop_count--) + { + uint dbton_id = share->use_dbton_ids[roop_count]; + if (spider->dbton_handler[dbton_id]) + { + delete spider->dbton_handler[dbton_id]; + spider->dbton_handler[dbton_id] = NULL; + } + } + goto error_but_no_delete; + } + + if ( + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE && + sql_command != SQLCOM_SHOW_CREATE + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if ( + !(spider->conns[roop_count] = + spider_get_conn(share, roop_count, spider->conn_keys[roop_count], + spider->trx, spider, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL, + error_num)) + ) { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + *error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + FALSE + ); + } + share->init_error = TRUE; + share->init_error_time = (time_t) time((time_t*) 0); + share->init = TRUE; + spider_free_share(share); + goto error_but_no_delete; + } + spider->conns[roop_count]->error_mode &= spider->error_mode; + } + } + search_link_idx = spider_conn_first_link_idx(thd, + share->link_statuses, share->access_balances, spider->conn_link_idx, + share->link_count, SPIDER_LINK_STATUS_OK); + if (search_link_idx == -1) + { +#ifdef _MSC_VER + char *db, *table_name; + if (!(db = (char *) + spider_bulk_malloc(spider_current_trx, 48, MYF(MY_WME), + &db, table_share->db.length + 1, + &table_name, table_share->table_name.length + 1, + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + share->init_error = TRUE; + share->init_error_time = (time_t) time((time_t*) 0); + share->init = TRUE; + spider_free_share(share); + goto error_but_no_delete; + } +#else + char db[table_share->db.length + 1], + table_name[table_share->table_name.length + 1]; +#endif + memcpy(db, table_share->db.str, table_share->db.length); + db[table_share->db.length] = '\0'; + memcpy(table_name, table_share->table_name.str, + table_share->table_name.length); + table_name[table_share->table_name.length] = '\0'; + my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM, + ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name); +#ifdef _MSC_VER + spider_free(spider->trx, db, MYF(MY_WME)); +#endif + *error_num = ER_SPIDER_ALL_LINKS_FAILED_NUM; + share->init_error = TRUE; + share->init_error_time = (time_t) time((time_t*) 0); + share->init = TRUE; + spider_free_share(share); + goto error_but_no_delete; + } + spider->search_link_idx = search_link_idx; + + if ( + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE && + sql_command != SQLCOM_SHOW_CREATE && + !spider->error_mode && + !spider_param_same_server_link(thd) + ) { + SPIDER_INIT_ERROR_TABLE *spider_init_error_table; + sts_interval = spider_param_sts_interval(thd, share->sts_interval); + sts_mode = spider_param_sts_mode(thd, share->sts_mode); +#ifdef WITH_PARTITION_STORAGE_ENGINE + sts_sync = spider_param_sts_sync(thd, share->sts_sync); + auto_increment_mode = spider_param_auto_increment_mode(thd, + share->auto_increment_mode); + if (auto_increment_mode == 1) + sts_sync = 0; +#endif + crd_interval = spider_param_crd_interval(thd, share->crd_interval); + crd_mode = spider_param_crd_mode(thd, share->crd_mode); + if (crd_mode == 3) + crd_mode = 1; +#ifdef WITH_PARTITION_STORAGE_ENGINE + crd_sync = spider_param_crd_sync(thd, share->crd_sync); +#endif + time_t tmp_time = (time_t) time((time_t*) 0); + pthread_mutex_lock(&share->sts_mutex); + pthread_mutex_lock(&share->crd_mutex); + if ((spider_init_error_table = + spider_get_init_error_table(spider->trx, share, FALSE))) + { + DBUG_PRINT("info",("spider diff1=%f", + difftime(tmp_time, spider_init_error_table->init_error_time))); + if (difftime(tmp_time, + spider_init_error_table->init_error_time) < + spider_param_table_init_error_interval()) + { + *error_num = spider_init_error_table->init_error; + if (spider_init_error_table->init_error_with_message) + my_message(spider_init_error_table->init_error, + spider_init_error_table->init_error_msg, MYF(0)); + share->init_error = TRUE; + share->init = TRUE; + pthread_mutex_unlock(&share->crd_mutex); + pthread_mutex_unlock(&share->sts_mutex); + spider_free_share(share); + goto error_but_no_delete; + } + } + + spider_get_sts(share, spider->search_link_idx, tmp_time, + spider, sts_interval, sts_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + sts_sync, +#endif + 1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO); + spider_get_crd(share, spider->search_link_idx, tmp_time, + spider, table, crd_interval, crd_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + crd_sync, +#endif + 1); +/* + if ( + (*error_num = spider_get_sts(share, spider->search_link_idx, tmp_time, + spider, sts_interval, sts_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + sts_sync, +#endif + 1)) || + (*error_num = spider_get_crd(share, spider->search_link_idx, tmp_time, + spider, table, crd_interval, crd_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + crd_sync, +#endif + 1)) + ) { + if ( + share->monitoring_kind[spider->search_link_idx] && + spider->need_mons[spider->search_link_idx] + ) { + *error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + share->monitoring_sid[spider->search_link_idx], + share->table_name, + share->table_name_length, + spider->conn_link_idx[spider->search_link_idx], + NULL, + 0, + share->monitoring_kind[spider->search_link_idx], + share->monitoring_limit[spider->search_link_idx], + FALSE + ); + } + if ( + spider_init_error_table || + (spider_init_error_table = + spider_get_init_error_table(spider->trx, share, TRUE)) + ) { + spider_init_error_table->init_error = *error_num; + if ((spider_init_error_table->init_error_with_message = + thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(spider_init_error_table->init_error_msg, + thd->main_da.message()); +#else + strmov(spider_init_error_table->init_error_msg, + thd->stmt_da->message()); +#endif + spider_init_error_table->init_error_time = + (time_t) time((time_t*) 0); + } + share->init_error = TRUE; + share->init = TRUE; + spider_free_share(share); + goto error_but_no_delete; + } +*/ + pthread_mutex_unlock(&share->crd_mutex); + pthread_mutex_unlock(&share->sts_mutex); + } + + share->init = TRUE; + } else { + share->use_count++; + pthread_mutex_unlock(&spider_tbl_mutex); + + while (!share->init) + { + my_sleep(10); + } + + if (!share->link_status_init) + { + pthread_mutex_lock(&share->mutex); + if (!share->link_status_init) + { + if ( + table_share->tmp_table == NO_TMP_TABLE && + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE && + sql_command != SQLCOM_SHOW_CREATE + ) { + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + init_mem_root = TRUE; + if ( + !(table_tables = spider_open_sys_table( + thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup, + FALSE, error_num)) + ) { + pthread_mutex_unlock(&share->mutex); + spider_free_share(share); + goto error_open_sys_table; + } + *error_num = spider_get_link_statuses(table_tables, share, + &mem_root); + if (*error_num) + { + pthread_mutex_unlock(&share->mutex); + spider_free_share(share); + goto error_get_link_statuses; + } + } + share->have_recovery_link = spider_conn_check_recovery_link(share); + if (table_tables) + { + spider_close_sys_table(thd, table_tables, + &open_tables_backup, FALSE); + table_tables = NULL; + } + if (init_mem_root) + { + free_root(&mem_root, MYF(0)); + init_mem_root = FALSE; + } + } + pthread_mutex_unlock(&share->mutex); + } + + semi_table_lock_conn = spider_param_semi_table_lock_connection(thd, + share->semi_table_lock_conn); + if (semi_table_lock_conn) + first_byte = '0' + + spider_param_semi_table_lock(thd, share->semi_table_lock); + else + first_byte = '0'; + + spider->share = share; + if (!(spider->trx = spider_get_trx(thd, TRUE, error_num))) + { + spider_free_share(share); + goto error_but_no_delete; + } + spider->set_error_mode(); + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if ( + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE && + sql_command != SQLCOM_SHOW_CREATE && + (*error_num = spider_create_mon_threads(spider->trx, share)) + ) { + spider_free_share(share); + goto error_but_no_delete; + } +#endif + + if (!(spider->conn_keys = (char **) + spider_bulk_alloc_mem(spider_current_trx, 49, + __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), + &spider->conn_keys, sizeof(char *) * share->link_count, + &tmp_name, sizeof(char) * share->conn_keys_charlen, + &spider->conns, sizeof(SPIDER_CONN *) * share->link_count, + &spider->conn_link_idx, sizeof(uint) * share->link_count, + &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + &spider->hs_r_conn_keys, sizeof(char *) * share->link_count, + &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, + &spider->hs_r_conns, sizeof(SPIDER_CONN *) * share->link_count, + &spider->hs_r_conn_ages, sizeof(ulonglong) * share->link_count, + &spider->hs_w_conn_keys, sizeof(char *) * share->link_count, + &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, + &spider->hs_w_conns, sizeof(SPIDER_CONN *) * share->link_count, + &spider->hs_w_conn_ages, sizeof(ulonglong) * share->link_count, +#endif + &spider->sql_kind, sizeof(uint) * share->link_count, + &spider->connection_ids, sizeof(ulonglong) * share->link_count, + &spider->conn_kind, sizeof(uint) * share->link_count, + &spider->db_request_id, sizeof(ulonglong) * share->link_count, + &spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size, + &spider->m_handler_opened, sizeof(uchar) * share->link_bitmap_size, + &spider->m_handler_id, sizeof(uint) * share->link_count, + &spider->m_handler_cid, sizeof(char *) * share->link_count, +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + &spider->r_handler_opened, sizeof(uchar) * share->link_bitmap_size, + &spider->r_handler_id, sizeof(uint) * share->link_count, + &spider->r_handler_index, sizeof(uint) * share->link_count, + &spider->w_handler_opened, sizeof(uchar) * share->link_bitmap_size, + &spider->w_handler_id, sizeof(uint) * share->link_count, + &spider->w_handler_index, sizeof(uint) * share->link_count, +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + &spider->do_hs_direct_update, sizeof(uchar) * share->link_bitmap_size, + &spider->hs_r_ret_fields, sizeof(uint32 *) * share->link_count, + &spider->hs_w_ret_fields, sizeof(uint32 *) * share->link_count, + &spider->hs_r_ret_fields_num, sizeof(size_t) * share->link_count, + &spider->hs_w_ret_fields_num, sizeof(size_t) * share->link_count, + &tmp_hs_r_ret_fields, + sizeof(uint32) * share->link_count * table_share->fields, + &tmp_hs_w_ret_fields, + sizeof(uint32) * share->link_count * table_share->fields, + &spider->tmp_column_bitmap, sizeof(uchar) * share->bitmap_size, +#endif +#endif + &tmp_cid, sizeof(char) * (SPIDER_SQL_HANDLER_CID_LEN + 1) * + share->link_count, + &spider->need_mons, sizeof(int) * share->link_count, + &spider->quick_targets, sizeof(void *) * share->link_count, + &result_list->upd_tmp_tbls, sizeof(TABLE *) * share->link_count, + &result_list->upd_tmp_tbl_prms, + sizeof(TMP_TABLE_PARAM) * share->link_count, + &result_list->tmp_table_join_first, + sizeof(uchar) * share->link_bitmap_size, + &result_list->tmp_table_created, + sizeof(uchar) * share->link_bitmap_size, +#ifdef HA_CAN_BULK_ACCESS + &result_list->hs_r_bulk_open_index, + sizeof(uchar) * share->link_bitmap_size, + &result_list->hs_w_bulk_open_index, + sizeof(uchar) * share->link_bitmap_size, +#endif + &result_list->sql_kind_backup, sizeof(uint) * share->link_count, + &spider->dbton_handler, + sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE, + NullS)) + ) { + spider_free_share(share); + goto error_but_no_delete; + } + memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + memcpy(tmp_hs_r_name, share->hs_read_conn_keys[0], + share->hs_read_conn_keys_charlen); + memcpy(tmp_hs_w_name, share->hs_write_conn_keys[0], + share->hs_write_conn_keys_charlen); +#endif + + spider->conn_keys_first_ptr = tmp_name; + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + spider->conn_keys[roop_count] = tmp_name; + *tmp_name = first_byte; + tmp_name += share->conn_keys_lengths[roop_count] + 1; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider->hs_r_conn_keys[roop_count] = tmp_hs_r_name; + tmp_hs_r_name += share->hs_read_conn_keys_lengths[roop_count] + 1; + spider->hs_w_conn_keys[roop_count] = tmp_hs_w_name; + tmp_hs_w_name += share->hs_write_conn_keys_lengths[roop_count] + 1; +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + spider->hs_r_ret_fields[roop_count] = tmp_hs_r_ret_fields; + tmp_hs_r_ret_fields += table_share->fields; + spider->hs_w_ret_fields[roop_count] = tmp_hs_w_ret_fields; + tmp_hs_w_ret_fields += table_share->fields; +#endif +#endif + spider->m_handler_cid[roop_count] = tmp_cid; + tmp_cid += SPIDER_SQL_HANDLER_CID_LEN + 1; + result_list->upd_tmp_tbl_prms[roop_count].init(); + result_list->upd_tmp_tbl_prms[roop_count].field_count = 1; + spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + } + spider_trx_set_link_idx_for_all(spider); + + for (roop_count = 0; roop_count < (int) share->use_dbton_count; + roop_count++) + { + uint dbton_id = share->use_dbton_ids[roop_count]; + if (!(spider->dbton_handler[dbton_id] = + spider_dbton[dbton_id].create_db_handler(spider, + share->dbton_share[dbton_id]))) + { + *error_num = HA_ERR_OUT_OF_MEM; + break; + } + if ((*error_num = spider->dbton_handler[dbton_id]->init())) + { + break; + } + } + if (roop_count < (int) share->use_dbton_count) + { + for (; roop_count >= 0; roop_count--) + { + uint dbton_id = share->use_dbton_ids[roop_count]; + if (spider->dbton_handler[dbton_id]) + { + delete spider->dbton_handler[dbton_id]; + spider->dbton_handler[dbton_id] = NULL; + } + } + goto error_but_no_delete; + } + + if ( + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE && + sql_command != SQLCOM_SHOW_CREATE + ) { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + if ( + !(spider->conns[roop_count] = + spider_get_conn(share, roop_count, spider->conn_keys[roop_count], + spider->trx, spider, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL, + error_num)) + ) { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + *error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + FALSE + ); + } + spider_free_share(share); + goto error_but_no_delete; + } + spider->conns[roop_count]->error_mode &= spider->error_mode; + } + } + search_link_idx = spider_conn_first_link_idx(thd, + share->link_statuses, share->access_balances, spider->conn_link_idx, + share->link_count, SPIDER_LINK_STATUS_OK); + if (search_link_idx == -1) + { +#ifdef _MSC_VER + char *db, *table_name; + if (!(db = (char *) + spider_bulk_malloc(spider_current_trx, 50, MYF(MY_WME), + &db, table_share->db.length + 1, + &table_name, table_share->table_name.length + 1, + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + spider_free_share(share); + goto error_but_no_delete; + } +#else + char db[table_share->db.length + 1], + table_name[table_share->table_name.length + 1]; +#endif + memcpy(db, table_share->db.str, table_share->db.length); + db[table_share->db.length] = '\0'; + memcpy(table_name, table_share->table_name.str, + table_share->table_name.length); + table_name[table_share->table_name.length] = '\0'; + my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM, + ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name); +#ifdef _MSC_VER + spider_free(spider->trx, db, MYF(MY_WME)); +#endif + *error_num = ER_SPIDER_ALL_LINKS_FAILED_NUM; + spider_free_share(share); + goto error_but_no_delete; + } + spider->search_link_idx = search_link_idx; + + if (share->init_error) + { + pthread_mutex_lock(&share->sts_mutex); + pthread_mutex_lock(&share->crd_mutex); + if (share->init_error) + { + if ( + sql_command != SQLCOM_DROP_TABLE && + sql_command != SQLCOM_ALTER_TABLE && + sql_command != SQLCOM_SHOW_CREATE && + !spider->error_mode && + !spider_param_same_server_link(thd) + ) { + SPIDER_INIT_ERROR_TABLE *spider_init_error_table; + sts_interval = spider_param_sts_interval(thd, share->sts_interval); + sts_mode = spider_param_sts_mode(thd, share->sts_mode); +#ifdef WITH_PARTITION_STORAGE_ENGINE + sts_sync = spider_param_sts_sync(thd, share->sts_sync); + auto_increment_mode = spider_param_auto_increment_mode(thd, + share->auto_increment_mode); + if (auto_increment_mode == 1) + sts_sync = 0; +#endif + crd_interval = spider_param_crd_interval(thd, share->crd_interval); + crd_mode = spider_param_crd_mode(thd, share->crd_mode); + if (crd_mode == 3) + crd_mode = 1; +#ifdef WITH_PARTITION_STORAGE_ENGINE + crd_sync = spider_param_crd_sync(thd, share->crd_sync); +#endif + time_t tmp_time = (time_t) time((time_t*) 0); + if ((spider_init_error_table = + spider_get_init_error_table(spider->trx, share, FALSE))) + { + DBUG_PRINT("info",("spider diff2=%f", + difftime(tmp_time, spider_init_error_table->init_error_time))); + if (difftime(tmp_time, + spider_init_error_table->init_error_time) < + spider_param_table_init_error_interval()) + { + *error_num = spider_init_error_table->init_error; + if (spider_init_error_table->init_error_with_message) + my_message(spider_init_error_table->init_error, + spider_init_error_table->init_error_msg, MYF(0)); + pthread_mutex_unlock(&share->crd_mutex); + pthread_mutex_unlock(&share->sts_mutex); + spider_free_share(share); + goto error_but_no_delete; + } + } + + spider_get_sts(share, spider->search_link_idx, + tmp_time, spider, sts_interval, sts_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + sts_sync, +#endif + 1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO); + spider_get_crd(share, spider->search_link_idx, + tmp_time, spider, table, crd_interval, crd_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + crd_sync, +#endif + 1); +/* + if ( + (*error_num = spider_get_sts(share, spider->search_link_idx, + tmp_time, spider, sts_interval, sts_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + sts_sync, +#endif + 1)) || + (*error_num = spider_get_crd(share, spider->search_link_idx, + tmp_time, spider, table, crd_interval, crd_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + crd_sync, +#endif + 1)) + ) { + if ( + share->monitoring_kind[spider->search_link_idx] && + spider->need_mons[spider->search_link_idx] + ) { + *error_num = spider_ping_table_mon_from_table( + spider->trx, + spider->trx->thd, + share, + share->monitoring_sid[spider->search_link_idx], + share->table_name, + share->table_name_length, + spider->conn_link_idx[spider->search_link_idx], + NULL, + 0, + share->monitoring_kind[spider->search_link_idx], + share->monitoring_limit[spider->search_link_idx], + FALSE + ); + } + if ( + spider_init_error_table || + (spider_init_error_table = + spider_get_init_error_table(spider->trx, share, TRUE)) + ) { + spider_init_error_table->init_error = *error_num; + if ((spider_init_error_table->init_error_with_message = + thd->is_error())) +#if MYSQL_VERSION_ID < 50500 + strmov(spider_init_error_table->init_error_msg, + thd->main_da.message()); +#else + strmov(spider_init_error_table->init_error_msg, + thd->stmt_da->message()); +#endif + spider_init_error_table->init_error_time = + (time_t) time((time_t*) 0); + } + pthread_mutex_unlock(&share->crd_mutex); + pthread_mutex_unlock(&share->sts_mutex); + spider_free_share(share); + goto error_but_no_delete; + } +*/ + } + share->init_error = FALSE; + } + pthread_mutex_unlock(&share->crd_mutex); + pthread_mutex_unlock(&share->sts_mutex); + } + } + + DBUG_PRINT("info",("spider share=%p", share)); + DBUG_RETURN(share); + +error_hash_insert: + spider_free_share_resource_only(share); +error_alloc_share: + pthread_mutex_unlock(&spider_tbl_mutex); +error_get_link_statuses: + if (table_tables) + { + spider_close_sys_table(thd, table_tables, + &open_tables_backup, FALSE); + table_tables = NULL; + } +error_open_sys_table: + if (init_mem_root) + { + free_root(&mem_root, MYF(0)); + init_mem_root = FALSE; + } +error_but_no_delete: + DBUG_RETURN(NULL); +} + +void spider_free_share_resource_only( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_free_share_resource_only"); + spider_free_share_alloc(share); + thr_lock_delete(&share->lock); + pthread_mutex_destroy(&share->auto_increment_mutex); + pthread_mutex_destroy(&share->crd_mutex); + pthread_mutex_destroy(&share->sts_mutex); + pthread_mutex_destroy(&share->mutex); + spider_free(spider_current_trx, share, MYF(0)); + DBUG_VOID_RETURN; +} + +int spider_free_share( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_free_share"); + pthread_mutex_lock(&spider_tbl_mutex); + if (!--share->use_count) + { +#ifndef WITHOUT_SPIDER_BG_SEARCH + spider_free_sts_thread(share); + spider_free_crd_thread(share); + spider_free_mon_threads(share); +#endif + spider_free_share_alloc(share); +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_open_tables, + share->table_name_hash_value, (uchar*) share); +#else + my_hash_delete(&spider_open_tables, (uchar*) share); +#endif + thr_lock_delete(&share->lock); + pthread_mutex_destroy(&share->auto_increment_mutex); + pthread_mutex_destroy(&share->crd_mutex); + pthread_mutex_destroy(&share->sts_mutex); + pthread_mutex_destroy(&share->mutex); + spider_free(spider_current_trx, share, MYF(0)); + } + pthread_mutex_unlock(&spider_tbl_mutex); + DBUG_RETURN(0); +} + +#ifdef WITH_PARTITION_STORAGE_ENGINE +SPIDER_PARTITION_SHARE *spider_get_pt_share( + SPIDER_SHARE *share, + TABLE_SHARE *table_share, + int *error_num +) { + SPIDER_PARTITION_SHARE *partition_share; + char *tmp_name; + longlong *tmp_cardinality; + DBUG_ENTER("spider_get_pt_share"); + + pthread_mutex_lock(&spider_pt_share_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(partition_share = (SPIDER_PARTITION_SHARE*) + my_hash_search_using_hash_value( + &spider_open_pt_share, share->table_path_hash_value, + (uchar*) table_share->path.str, table_share->path.length))) +#else + if (!(partition_share = (SPIDER_PARTITION_SHARE*) my_hash_search( + &spider_open_pt_share, + (uchar*) table_share->path.str, table_share->path.length))) +#endif + { + DBUG_PRINT("info",("spider create new pt share")); + if (!(partition_share = (SPIDER_PARTITION_SHARE *) + spider_bulk_malloc(spider_current_trx, 51, MYF(MY_WME | MY_ZEROFILL), + &partition_share, sizeof(*partition_share), + &tmp_name, table_share->path.length + 1, + &tmp_cardinality, sizeof(*tmp_cardinality) * table_share->fields, + NullS)) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_share; + } + + partition_share->use_count = 0; + partition_share->table_name_length = table_share->path.length; + partition_share->table_name = tmp_name; + memcpy(partition_share->table_name, table_share->path.str, + partition_share->table_name_length); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + partition_share->table_path_hash_value = share->table_path_hash_value; +#endif + partition_share->cardinality = tmp_cardinality; + + partition_share->crd_get_time = partition_share->sts_get_time = + share->crd_get_time; + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&partition_share->sts_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_pt_share_sts, + &partition_share->sts_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_sts_mutex; + } + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&partition_share->crd_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_pt_share_crd, + &partition_share->crd_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_crd_mutex; + } + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&partition_share->pt_handler_mutex, + MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_pt_handler, + &partition_share->pt_handler_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_pt_handler_mutex; + } + + if( + my_hash_init(&partition_share->pt_handler_hash, spd_charset_utf8_bin, + 32, 0, 0, (my_hash_get_key) spider_pt_handler_share_get_key, 0, 0) + ) { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_pt_handler_hash; + } + spider_alloc_calc_mem_init(partition_share->pt_handler_hash, 142); + spider_alloc_calc_mem(spider_current_trx, + partition_share->pt_handler_hash, + partition_share->pt_handler_hash.array.max_element * + partition_share->pt_handler_hash.array.size_of_element); + + uint old_elements = spider_open_pt_share.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&spider_open_pt_share, + share->table_path_hash_value, + (uchar*) partition_share)) +#else + if (my_hash_insert(&spider_open_pt_share, (uchar*) partition_share)) +#endif + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_hash_insert; + } + if (spider_open_pt_share.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + spider_open_pt_share, + (spider_open_pt_share.array.max_element - old_elements) * + spider_open_pt_share.array.size_of_element); + } + } + partition_share->use_count++; + pthread_mutex_unlock(&spider_pt_share_mutex); + + DBUG_PRINT("info",("spider partition_share=%p", partition_share)); + DBUG_RETURN(partition_share); + +error_hash_insert: + spider_free_mem_calc(spider_current_trx, + partition_share->pt_handler_hash_id, + partition_share->pt_handler_hash.array.max_element * + partition_share->pt_handler_hash.array.size_of_element); + my_hash_free(&partition_share->pt_handler_hash); +error_init_pt_handler_hash: + pthread_mutex_destroy(&partition_share->pt_handler_mutex); +error_init_pt_handler_mutex: + pthread_mutex_destroy(&partition_share->crd_mutex); +error_init_crd_mutex: + pthread_mutex_destroy(&partition_share->sts_mutex); +error_init_sts_mutex: + spider_free(spider_current_trx, partition_share, MYF(0)); +error_alloc_share: + pthread_mutex_unlock(&spider_pt_share_mutex); + DBUG_RETURN(NULL); +} + +int spider_free_pt_share( + SPIDER_PARTITION_SHARE *partition_share +) { + DBUG_ENTER("spider_free_pt_share"); + pthread_mutex_lock(&spider_pt_share_mutex); + if (!--partition_share->use_count) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_open_pt_share, + partition_share->table_path_hash_value, (uchar*) partition_share); +#else + my_hash_delete(&spider_open_pt_share, (uchar*) partition_share); +#endif + spider_free_mem_calc(spider_current_trx, + partition_share->pt_handler_hash_id, + partition_share->pt_handler_hash.array.max_element * + partition_share->pt_handler_hash.array.size_of_element); + my_hash_free(&partition_share->pt_handler_hash); + pthread_mutex_destroy(&partition_share->pt_handler_mutex); + pthread_mutex_destroy(&partition_share->crd_mutex); + pthread_mutex_destroy(&partition_share->sts_mutex); + spider_free(spider_current_trx, partition_share, MYF(0)); + } + pthread_mutex_unlock(&spider_pt_share_mutex); + DBUG_RETURN(0); +} + +void spider_copy_sts_to_pt_share( + SPIDER_PARTITION_SHARE *partition_share, + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_copy_sts_to_pt_share"); + memcpy(&partition_share->data_file_length, &share->data_file_length, + sizeof(ulonglong) * 4 + sizeof(ha_rows) + + sizeof(ulong) + sizeof(time_t) * 3); +/* + partition_share->data_file_length = share->data_file_length; + partition_share->max_data_file_length = share->max_data_file_length; + partition_share->index_file_length = share->index_file_length; + partition_share->auto_increment_value = share->auto_increment_value; + partition_share->records = share->records; + partition_share->mean_rec_length = share->mean_rec_length; + partition_share->check_time = share->check_time; + partition_share->create_time = share->create_time; + partition_share->update_time = share->update_time; +*/ + DBUG_VOID_RETURN; +} + +void spider_copy_sts_to_share( + SPIDER_SHARE *share, + SPIDER_PARTITION_SHARE *partition_share +) { + DBUG_ENTER("spider_copy_sts_to_share"); + memcpy(&share->data_file_length, &partition_share->data_file_length, + sizeof(ulonglong) * 4 + sizeof(ha_rows) + + sizeof(ulong) + sizeof(time_t) * 3); +/* + share->data_file_length = partition_share->data_file_length; + share->max_data_file_length = partition_share->max_data_file_length; + share->index_file_length = partition_share->index_file_length; + share->auto_increment_value = partition_share->auto_increment_value; + share->records = partition_share->records; + share->mean_rec_length = partition_share->mean_rec_length; + share->check_time = partition_share->check_time; + share->create_time = partition_share->create_time; + share->update_time = partition_share->update_time; +*/ + DBUG_VOID_RETURN; +} + +void spider_copy_crd_to_pt_share( + SPIDER_PARTITION_SHARE *partition_share, + SPIDER_SHARE *share, + int fields +) { + DBUG_ENTER("spider_copy_crd_to_pt_share"); + memcpy(partition_share->cardinality, share->cardinality, + sizeof(longlong) * fields); + DBUG_VOID_RETURN; +} + +void spider_copy_crd_to_share( + SPIDER_SHARE *share, + SPIDER_PARTITION_SHARE *partition_share, + int fields +) { + DBUG_ENTER("spider_copy_crd_to_share"); + memcpy(share->cardinality, partition_share->cardinality, + sizeof(longlong) * fields); + DBUG_VOID_RETURN; +} +#endif + +int spider_open_all_tables( + SPIDER_TRX *trx, + bool lock +) { + THD *thd = trx->thd; + TABLE *table_tables; + int error_num, *need_mon, mon_val; + SPIDER_SHARE tmp_share; + char *db_name, *table_name; + uint db_name_length, table_name_length; + char *tmp_connect_info[SPIDER_TMP_SHARE_CHAR_PTR_COUNT]; + uint tmp_connect_info_length[SPIDER_TMP_SHARE_UINT_COUNT]; + long tmp_long[SPIDER_TMP_SHARE_LONG_COUNT]; + longlong tmp_longlong[SPIDER_TMP_SHARE_LONGLONG_COUNT]; + SPIDER_CONN *conn, **conns; + ha_spider *spider; + SPIDER_SHARE *share; + char **connect_info; + uint *connect_info_length; + long *long_info; + longlong *longlong_info; + MEM_ROOT mem_root; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + DBUG_ENTER("spider_open_all_tables"); + if ( + !(table_tables = spider_open_sys_table( + thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, + SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE, + &error_num)) + ) + DBUG_RETURN(error_num); + if ( + (error_num = spider_sys_index_first(table_tables, 1)) + ) { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table_tables->file->print_error(error_num, MYF(0)); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + DBUG_RETURN(error_num); + } else { + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + DBUG_RETURN(0); + } + } + + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + memset(&tmp_share, 0, sizeof(SPIDER_SHARE)); + memset(&tmp_connect_info, 0, + sizeof(char *) * SPIDER_TMP_SHARE_CHAR_PTR_COUNT); + memset(tmp_connect_info_length, 0, + sizeof(uint) * SPIDER_TMP_SHARE_UINT_COUNT); + memset(tmp_long, 0, sizeof(long) * SPIDER_TMP_SHARE_LONG_COUNT); + memset(tmp_longlong, 0, sizeof(longlong) * SPIDER_TMP_SHARE_LONGLONG_COUNT); + spider_set_tmp_share_pointer(&tmp_share, (char **) &tmp_connect_info, + tmp_connect_info_length, tmp_long, tmp_longlong); + tmp_share.link_statuses[0] = -1; + + do { + if ( + (error_num = spider_get_sys_tables( + table_tables, &db_name, &table_name, &mem_root)) || + (error_num = spider_get_sys_tables_connect_info( + table_tables, &tmp_share, 0, &mem_root)) || + (error_num = spider_set_connect_info_default( + &tmp_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + NULL, + NULL, +#endif + NULL + )) + ) { + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(error_num); + } + db_name_length = strlen(db_name); + table_name_length = strlen(table_name); + + if ( + (error_num = spider_set_connect_info_default_db_table( + &tmp_share, + db_name, + db_name_length, + table_name, + table_name_length + )) || + (error_num = spider_create_conn_keys(&tmp_share)) || +/* + (error_num = spider_db_create_table_names_str(&tmp_share)) || +*/ + (error_num = spider_create_tmp_dbton_share(&tmp_share)) + ) { + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(error_num); + } + + /* create conn */ + if ( + !(conn = spider_get_conn( + &tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE, + SPIDER_CONN_KIND_MYSQL, &error_num)) + ) { + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_dbton_share(&tmp_share); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(error_num); + } + conn->error_mode &= spider_param_error_read_mode(thd, 0); + conn->error_mode &= spider_param_error_write_mode(thd, 0); + pthread_mutex_lock(&conn->mta_conn_mutex); + SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); + conn->need_mon = &mon_val; + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; + if ((error_num = spider_db_before_query(conn, &mon_val))) + { + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_dbton_share(&tmp_share); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(error_num); + } + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + + if (lock && spider_param_use_snapshot_with_flush_tables(thd) == 2) + { + if (!(spider = new ha_spider())) + { + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_dbton_share(&tmp_share); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + spider->lock_type = TL_READ_NO_INSERT; + + if (!(share = (SPIDER_SHARE *) + spider_bulk_malloc(spider_current_trx, 52, MYF(MY_WME | MY_ZEROFILL), + &share, sizeof(*share), + &connect_info, sizeof(char *) * SPIDER_TMP_SHARE_CHAR_PTR_COUNT, + &connect_info_length, sizeof(uint) * SPIDER_TMP_SHARE_UINT_COUNT, + &long_info, sizeof(long) * SPIDER_TMP_SHARE_LONG_COUNT, + &longlong_info, sizeof(longlong) * SPIDER_TMP_SHARE_LONGLONG_COUNT, + &conns, sizeof(SPIDER_CONN *), + &need_mon, sizeof(int), + &spider->conn_link_idx, sizeof(uint), + &spider->conn_can_fo, sizeof(uchar), + NullS)) + ) { + delete spider; + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_dbton_share(&tmp_share); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + memcpy(share, &tmp_share, sizeof(*share)); + spider_set_tmp_share_pointer(share, connect_info, + connect_info_length, long_info, longlong_info); + memcpy(connect_info, &tmp_connect_info, sizeof(char *) * + SPIDER_TMP_SHARE_CHAR_PTR_COUNT); + memcpy(connect_info_length, &tmp_connect_info_length, sizeof(uint) * + SPIDER_TMP_SHARE_UINT_COUNT); + memcpy(long_info, &tmp_long, sizeof(long) * SPIDER_TMP_SHARE_LONG_COUNT); + memcpy(longlong_info, &tmp_longlong, sizeof(longlong) * + SPIDER_TMP_SHARE_LONGLONG_COUNT); + spider->share = share; + spider->trx = trx; + spider->conns = conns; + spider->need_mons = need_mon; + spider->conn_link_idx[0] = 0; + spider->conn_can_fo[0] = 0; + if ((error_num = spider_create_tmp_dbton_handler(spider))) + { + spider_free(trx, share, MYF(0)); + delete spider; + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_dbton_share(&tmp_share); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(error_num); + } + + /* create another conn */ + if ( + (!(conn = spider_get_conn( + &tmp_share, 0, tmp_share.conn_keys[0], trx, spider, TRUE, FALSE, + SPIDER_CONN_KIND_MYSQL, &error_num))) + ) { + spider_free_tmp_dbton_handler(spider); + spider_free(trx, share, MYF(0)); + delete spider; + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_dbton_share(&tmp_share); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(error_num); + } + conn->error_mode &= spider_param_error_read_mode(thd, 0); + conn->error_mode &= spider_param_error_write_mode(thd, 0); + + spider->next = NULL; + if (conn->another_ha_last) + { + ((ha_spider*) conn->another_ha_last)->next = spider; + } else { + conn->another_ha_first = (void*) spider; + } + conn->another_ha_last = (void*) spider; + + int appended = 0; + if ((error_num = spider->dbton_handler[conn->dbton_id]-> + append_lock_tables_list(conn, 0, &appended))) + { + spider_free_tmp_dbton_handler(spider); + spider_free(trx, share, MYF(0)); + delete spider; + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + spider_free_tmp_dbton_share(&tmp_share); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + DBUG_RETURN(error_num); + } + } else { + spider_free_tmp_dbton_share(&tmp_share); + spider_free_tmp_share_alloc(&tmp_share); + } + error_num = spider_sys_index_next(table_tables); + } while (error_num == 0); + free_root(&mem_root, MYF(0)); + + spider_sys_index_end(table_tables); + spider_close_sys_table(thd, table_tables, + &open_tables_backup, TRUE); + DBUG_RETURN(0); +} + +bool spider_flush_logs( + handlerton *hton +) { + int error_num; + THD* thd = current_thd; + SPIDER_TRX *trx; + DBUG_ENTER("spider_flush_logs"); + + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + { + my_errno = error_num; + DBUG_RETURN(TRUE); + } + if ( + spider_param_use_flash_logs(trx->thd) && + ( + !trx->trx_consistent_snapshot || + !spider_param_use_all_conns_snapshot(trx->thd) || + !spider_param_use_snapshot_with_flush_tables(trx->thd) + ) + ) { + if ( + (error_num = spider_open_all_tables(trx, FALSE)) || + (error_num = spider_trx_all_flush_logs(trx)) + ) { + my_errno = error_num; + DBUG_RETURN(TRUE); + } + } + + DBUG_RETURN(FALSE); +} + +handler* spider_create_handler( + handlerton *hton, + TABLE_SHARE *table, + MEM_ROOT *mem_root +) { + DBUG_ENTER("spider_create_handler"); + DBUG_RETURN(new (mem_root) ha_spider(hton, table)); +} + +int spider_close_connection( + handlerton* hton, + THD* thd +) { + int roop_count = 0, need_mon = 0; + SPIDER_CONN *conn; + SPIDER_TRX *trx; + ha_spider tmp_spider; + char buf[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin); + DBUG_ENTER("spider_close_connection"); + tmp_str.init_calc_mem(121); + if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr))) + DBUG_RETURN(0); /* transaction is not started */ + + tmp_spider.conns = &conn; + tmp_spider.need_mons = &need_mon; + tmp_spider.trx = trx; + tmp_spider.result_list.sqls = &tmp_str; + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, + roop_count))) + { + SPIDER_BACKUP_DASTATUS; + DBUG_PRINT("info",("spider conn->table_lock=%d", conn->table_lock)); + if (conn->table_lock > 0) + { + if (!conn->trx_start) + conn->disable_reconnect = FALSE; + if (conn->table_lock != 2) + { + spider_db_unlock_tables(&tmp_spider, 0); + } + conn->table_lock = 0; + } + roop_count++; + SPIDER_CONN_RESTORE_DASTATUS; + } + + spider_rollback(spider_hton_ptr, thd, TRUE); + spider_free_trx(trx, TRUE); + + DBUG_RETURN(0); +} + +void spider_drop_database( + handlerton *hton, + char* path +) { + DBUG_ENTER("spider_drop_database"); + DBUG_VOID_RETURN; +} + +bool spider_show_status( + handlerton *hton, + THD *thd, + stat_print_fn *stat_print, + enum ha_stat_type stat_type +) { + DBUG_ENTER("spider_show_status"); + switch (stat_type) { + case HA_ENGINE_STATUS: + default: + DBUG_RETURN(FALSE); + } +} + +int spider_db_done( + void *p +) { + int roop_count; + THD *thd = current_thd, *tmp_thd; + SPIDER_CONN *conn; + SPIDER_INIT_ERROR_TABLE *spider_init_error_table; + SPIDER_TABLE_MON_LIST *table_mon_list; + DBUG_ENTER("spider_db_done"); + +#ifndef WITHOUT_SPIDER_BG_SEARCH + spider_free_trx(spider_global_trx, TRUE); +#endif + + for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; roop_count--) + { + if (spider_dbton[roop_count].deinit) + { + spider_dbton[roop_count].deinit(); + } + } + + for (roop_count = spider_param_udf_table_mon_mutex_count() - 1; + roop_count >= 0; roop_count--) + { + while ((table_mon_list = (SPIDER_TABLE_MON_LIST *) my_hash_element( + &spider_udf_table_mon_list_hash[roop_count], 0))) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value( + &spider_udf_table_mon_list_hash[roop_count], + table_mon_list->key_hash_value, (uchar*) table_mon_list); +#else + my_hash_delete(&spider_udf_table_mon_list_hash[roop_count], + (uchar*) table_mon_list); +#endif + spider_ping_table_free_mon_list(table_mon_list); + } + spider_free_mem_calc(spider_current_trx, + spider_udf_table_mon_list_hash_id, + spider_udf_table_mon_list_hash[roop_count].array.max_element * + spider_udf_table_mon_list_hash[roop_count].array.size_of_element); + my_hash_free(&spider_udf_table_mon_list_hash[roop_count]); + } + for (roop_count = spider_param_udf_table_mon_mutex_count() - 1; + roop_count >= 0; roop_count--) + pthread_cond_destroy(&spider_udf_table_mon_conds[roop_count]); + for (roop_count = spider_param_udf_table_mon_mutex_count() - 1; + roop_count >= 0; roop_count--) + pthread_mutex_destroy(&spider_udf_table_mon_mutexes[roop_count]); + spider_free(NULL, spider_udf_table_mon_mutexes, MYF(0)); + + if (thd && thd_sql_command(thd) == SQLCOM_UNINSTALL_PLUGIN) { + pthread_mutex_lock(&spider_allocated_thds_mutex); + while ((tmp_thd = (THD *) my_hash_element(&spider_allocated_thds, 0))) + { + SPIDER_TRX *trx = (SPIDER_TRX *) *thd_ha_data(tmp_thd, spider_hton_ptr); + if (trx) + { + DBUG_ASSERT(tmp_thd == trx->thd); + spider_free_trx(trx, FALSE); + *thd_ha_data(tmp_thd, spider_hton_ptr) = (void *) NULL; + } else + my_hash_delete(&spider_allocated_thds, (uchar *) tmp_thd); + } + pthread_mutex_unlock(&spider_allocated_thds_mutex); + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + pthread_mutex_lock(&spider_hs_w_conn_mutex); + while ((conn = (SPIDER_CONN*) my_hash_element(&spider_hs_w_conn_hash, 0))) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_hs_w_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&spider_hs_w_conn_hash, (uchar*) conn); +#endif + spider_free_conn(conn); + } + pthread_mutex_unlock(&spider_hs_w_conn_mutex); + pthread_mutex_lock(&spider_hs_r_conn_mutex); + while ((conn = (SPIDER_CONN*) my_hash_element(&spider_hs_r_conn_hash, 0))) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_hs_r_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&spider_hs_r_conn_hash, (uchar*) conn); +#endif + spider_free_conn(conn); + } + pthread_mutex_unlock(&spider_hs_r_conn_mutex); +#endif + pthread_mutex_lock(&spider_conn_mutex); + while ((conn = (SPIDER_CONN*) my_hash_element(&spider_open_connections, 0))) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_open_connections, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&spider_open_connections, (uchar*) conn); +#endif + spider_free_conn(conn); + } + pthread_mutex_unlock(&spider_conn_mutex); + spider_free_mem_calc(spider_current_trx, + spider_mon_table_cache_id, + spider_mon_table_cache.max_element * + spider_mon_table_cache.size_of_element); + delete_dynamic(&spider_mon_table_cache); + spider_free_mem_calc(spider_current_trx, + spider_allocated_thds_id, + spider_allocated_thds.array.max_element * + spider_allocated_thds.array.size_of_element); + my_hash_free(&spider_allocated_thds); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider_free_mem_calc(spider_current_trx, + spider_hs_w_conn_hash_id, + spider_hs_w_conn_hash.array.max_element * + spider_hs_w_conn_hash.array.size_of_element); + my_hash_free(&spider_hs_w_conn_hash); + spider_free_mem_calc(spider_current_trx, + spider_hs_r_conn_hash_id, + spider_hs_r_conn_hash.array.max_element * + spider_hs_r_conn_hash.array.size_of_element); + my_hash_free(&spider_hs_r_conn_hash); +#endif + spider_free_mem_calc(spider_current_trx, + spider_open_connections_id, + spider_open_connections.array.max_element * + spider_open_connections.array.size_of_element); + my_hash_free(&spider_open_connections); +#ifdef WITH_PARTITION_STORAGE_ENGINE + spider_free_mem_calc(spider_current_trx, + spider_open_pt_share_id, + spider_open_pt_share.array.max_element * + spider_open_pt_share.array.size_of_element); + my_hash_free(&spider_open_pt_share); +#endif + pthread_mutex_lock(&spider_init_error_tbl_mutex); + while ((spider_init_error_table = (SPIDER_INIT_ERROR_TABLE*) + my_hash_element(&spider_init_error_tables, 0))) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_init_error_tables, + spider_init_error_table->table_name_hash_value, + (uchar*) spider_init_error_table); +#else + my_hash_delete(&spider_init_error_tables, + (uchar*) spider_init_error_table); +#endif + spider_free(NULL, spider_init_error_table, MYF(0)); + } + pthread_mutex_unlock(&spider_init_error_tbl_mutex); + spider_free_mem_calc(spider_current_trx, + spider_init_error_tables_id, + spider_init_error_tables.array.max_element * + spider_init_error_tables.array.size_of_element); + my_hash_free(&spider_init_error_tables); + spider_free_mem_calc(spider_current_trx, + spider_open_tables_id, + spider_open_tables.array.max_element * + spider_open_tables.array.size_of_element); + my_hash_free(&spider_open_tables); + pthread_mutex_destroy(&spider_mem_calc_mutex); + pthread_mutex_destroy(&spider_mon_table_cache_mutex); + pthread_mutex_destroy(&spider_allocated_thds_mutex); + pthread_mutex_destroy(&spider_open_conn_mutex); +#ifndef WITHOUT_SPIDER_BG_SEARCH + pthread_mutex_destroy(&spider_global_trx_mutex); +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + pthread_mutex_destroy(&spider_hs_w_conn_mutex); + pthread_mutex_destroy(&spider_hs_r_conn_mutex); +#endif + pthread_mutex_destroy(&spider_conn_mutex); +#ifdef WITH_PARTITION_STORAGE_ENGINE + pthread_mutex_destroy(&spider_pt_share_mutex); +#endif + pthread_mutex_destroy(&spider_init_error_tbl_mutex); + pthread_mutex_destroy(&spider_conn_id_mutex); + pthread_mutex_destroy(&spider_thread_id_mutex); + pthread_mutex_destroy(&spider_tbl_mutex); +#ifndef WITHOUT_SPIDER_BG_SEARCH + pthread_attr_destroy(&spider_pt_attr); +#endif + + for (roop_count = 0; roop_count < SPIDER_MEM_CALC_LIST_NUM; roop_count++) + { + if (spider_alloc_func_name[roop_count]) + DBUG_PRINT("info",("spider %d %s %s %lu %llu %lld %llu %llu %s", + roop_count, + spider_alloc_func_name[roop_count], + spider_alloc_file_name[roop_count], + spider_alloc_line_no[roop_count], + spider_total_alloc_mem[roop_count], + spider_current_alloc_mem[roop_count], + spider_alloc_mem_count[roop_count], + spider_free_mem_count[roop_count], + spider_current_alloc_mem[roop_count] ? "NG" : "OK" + )); + } +/* +DBUG_ASSERT(0); +*/ + DBUG_RETURN(0); +} + +int spider_panic( + handlerton *hton, + ha_panic_function type +) { + DBUG_ENTER("spider_panic"); + DBUG_RETURN(0); +} + +int spider_db_init( + void *p +) { + int error_num, roop_count; + uint dbton_id = 0; + handlerton *spider_hton = (handlerton *)p; + DBUG_ENTER("spider_db_init"); + spider_hton_ptr = spider_hton; + + spider_hton->state = SHOW_OPTION_YES; + spider_hton->flags = HTON_NO_FLAGS; + /* spider_hton->db_type = DB_TYPE_SPIDER; */ + /* + spider_hton->savepoint_offset; + spider_hton->savepoint_set = spider_savepoint_set; + spider_hton->savepoint_rollback = spider_savepoint_rollback; + spider_hton->savepoint_release = spider_savepoint_release; + spider_hton->create_cursor_read_view = spider_create_cursor_read_view; + spider_hton->set_cursor_read_view = spider_set_cursor_read_view; + spider_hton->close_cursor_read_view = spider_close_cursor_read_view; + */ + spider_hton->panic = spider_panic; + spider_hton->close_connection = spider_close_connection; + spider_hton->start_consistent_snapshot = spider_start_consistent_snapshot; + spider_hton->flush_logs = spider_flush_logs; + spider_hton->commit = spider_commit; + spider_hton->rollback = spider_rollback; +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE + spider_hton->discover_table_structure = spider_discover_table_structure; +#endif + if (spider_param_support_xa()) + { + spider_hton->prepare = spider_xa_prepare; + spider_hton->recover = spider_xa_recover; + spider_hton->commit_by_xid = spider_xa_commit_by_xid; + spider_hton->rollback_by_xid = spider_xa_rollback_by_xid; + } + spider_hton->create = spider_create_handler; + spider_hton->drop_database = spider_drop_database; + spider_hton->show_status = spider_show_status; + + memset(&spider_alloc_func_name, 0, sizeof(spider_alloc_func_name)); + memset(&spider_alloc_file_name, 0, sizeof(spider_alloc_file_name)); + memset(&spider_alloc_line_no, 0, sizeof(spider_alloc_line_no)); + memset(&spider_total_alloc_mem, 0, sizeof(spider_total_alloc_mem)); + memset(&spider_current_alloc_mem, 0, sizeof(spider_current_alloc_mem)); + memset(&spider_alloc_mem_count, 0, sizeof(spider_alloc_mem_count)); + memset(&spider_free_mem_count, 0, sizeof(spider_free_mem_count)); + +#ifdef _WIN32 + HMODULE current_module = GetModuleHandle(NULL); + spd_db_att_thread_id = (ulong *) + GetProcAddress(current_module, "?thread_id@@3KA"); + spd_db_att_LOCK_xid_cache = (pthread_mutex_t *) +#if MYSQL_VERSION_ID < 50500 + GetProcAddress(current_module, + "?LOCK_xid_cache@@3U_RTL_CRITICAL_SECTION@@A"); +#else + GetProcAddress(current_module, + "?LOCK_xid_cache@@3Ust_mysql_mutex@@A"); +#endif + spd_db_att_xid_cache = (HASH *) + GetProcAddress(current_module, "?xid_cache@@3Ust_hash@@A"); + spd_charset_utf8_bin = (struct charset_info_st *) + GetProcAddress(current_module, "my_charset_utf8_bin"); + spd_defaults_extra_file = (const char **) + GetProcAddress(current_module, "my_defaults_extra_file"); + spd_defaults_file = (const char **) + GetProcAddress(current_module, "my_defaults_file"); +#else + spd_db_att_thread_id = &thread_id; + spd_db_att_LOCK_xid_cache = &LOCK_xid_cache; + spd_db_att_xid_cache = &xid_cache; + spd_charset_utf8_bin = &my_charset_utf8_bin; + spd_defaults_extra_file = &my_defaults_extra_file; + spd_defaults_file = &my_defaults_file; +#endif + +#ifdef HAVE_PSI_INTERFACE + init_spider_psi_keys(); +#endif + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (pthread_attr_init(&spider_pt_attr)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_pt_attr_init; + } +/* + if (pthread_attr_setdetachstate(&spider_pt_attr, PTHREAD_CREATE_DETACHED)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_pt_attr_setstate; + } +*/ +#endif + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_tbl_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_tbl, + &spider_tbl_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_tbl_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_thread_id_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_thread_id, + &spider_thread_id_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_thread_id_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_conn_id_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_conn_id, + &spider_conn_id_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_conn_id_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_init_error_tbl_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_init_error_tbl, + &spider_init_error_tbl_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_error_tbl_mutex_init; + } +#ifdef WITH_PARTITION_STORAGE_ENGINE +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_pt_share_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_pt_share, + &spider_pt_share_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_pt_share_mutex_init; + } +#endif +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_conn_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_conn, + &spider_conn_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_conn_mutex_init; + } +#ifndef WITHOUT_SPIDER_BG_SEARCH +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_global_trx_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_global_trx, + &spider_global_trx_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_global_trx_mutex_init; + } +#endif +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_open_conn_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_open_conn, + &spider_open_conn_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_open_conn_mutex_init; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_hs_r_conn_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_hs_r_conn, + &spider_hs_r_conn_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_hs_r_conn_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_hs_w_conn_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_hs_w_conn, + &spider_hs_w_conn_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_hs_w_conn_mutex_init; + } +#endif +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_allocated_thds_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_allocated_thds, + &spider_allocated_thds_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_allocated_thds_mutex_init; + } +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_mon_table_cache_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_mon_table_cache, + &spider_mon_table_cache_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_mon_table_cache_mutex_init; + } + +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_mem_calc_mutex, MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_mem_calc, + &spider_mem_calc_mutex, MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_mem_calc_mutex_init; + } + + if( + my_hash_init(&spider_open_tables, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_tbl_get_key, 0, 0) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_open_tables_hash_init; + } + spider_alloc_calc_mem_init(spider_open_tables, 143); + spider_alloc_calc_mem(NULL, + spider_open_tables, + spider_open_tables.array.max_element * + spider_open_tables.array.size_of_element); + if( + my_hash_init(&spider_init_error_tables, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_tbl_get_key, 0, 0) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_error_tables_hash_init; + } + spider_alloc_calc_mem_init(spider_init_error_tables, 144); + spider_alloc_calc_mem(NULL, + spider_init_error_tables, + spider_init_error_tables.array.max_element * + spider_init_error_tables.array.size_of_element); +#ifdef WITH_PARTITION_STORAGE_ENGINE + if( + my_hash_init(&spider_open_pt_share, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_pt_share_get_key, 0, 0) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_open_pt_share_hash_init; + } + spider_alloc_calc_mem_init(spider_open_pt_share, 145); + spider_alloc_calc_mem(NULL, + spider_open_pt_share, + spider_open_pt_share.array.max_element * + spider_open_pt_share.array.size_of_element); +#endif + if( + my_hash_init(&spider_open_connections, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_conn_get_key, 0, 0) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_open_connections_hash_init; + } + spider_alloc_calc_mem_init(spider_open_connections, 146); + spider_alloc_calc_mem(NULL, + spider_open_connections, + spider_open_connections.array.max_element * + spider_open_connections.array.size_of_element); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if( + my_hash_init(&spider_hs_r_conn_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_conn_get_key, 0, 0) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_hs_r_conn_hash_init; + } + spider_alloc_calc_mem_init(spider_hs_r_conn_hash, 147); + spider_alloc_calc_mem(NULL, + spider_hs_r_conn_hash, + spider_hs_r_conn_hash.array.max_element * + spider_hs_r_conn_hash.array.size_of_element); + if( + my_hash_init(&spider_hs_w_conn_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_conn_get_key, 0, 0) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_hs_w_conn_hash_init; + } + spider_alloc_calc_mem_init(spider_hs_w_conn_hash, 148); + spider_alloc_calc_mem(NULL, + spider_hs_w_conn_hash, + spider_hs_w_conn_hash.array.max_element * + spider_hs_w_conn_hash.array.size_of_element); +#endif + if( + my_hash_init(&spider_allocated_thds, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_allocated_thds_get_key, 0, 0) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_allocated_thds_hash_init; + } + spider_alloc_calc_mem_init(spider_allocated_thds, 149); + spider_alloc_calc_mem(NULL, + spider_allocated_thds, + spider_allocated_thds.array.max_element * + spider_allocated_thds.array.size_of_element); + + if( + SPD_INIT_DYNAMIC_ARRAY2(&spider_mon_table_cache, sizeof(SPIDER_MON_KEY), + NULL, 64, 64, MYF(MY_WME)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_mon_table_cache_array_init; + } + spider_alloc_calc_mem_init(spider_mon_table_cache, 165); + spider_alloc_calc_mem(NULL, + spider_mon_table_cache, + spider_mon_table_cache.max_element * + spider_mon_table_cache.size_of_element); + + if (!(spider_udf_table_mon_mutexes = (pthread_mutex_t *) + spider_bulk_malloc(NULL, 53, MYF(MY_WME | MY_ZEROFILL), + &spider_udf_table_mon_mutexes, sizeof(pthread_mutex_t) * + spider_param_udf_table_mon_mutex_count(), + &spider_udf_table_mon_conds, sizeof(pthread_cond_t) * + spider_param_udf_table_mon_mutex_count(), + &spider_udf_table_mon_list_hash, sizeof(HASH) * + spider_param_udf_table_mon_mutex_count(), + NullS)) + ) + goto error_alloc_mon_mutxes; + + for (roop_count = 0; + roop_count < (int) spider_param_udf_table_mon_mutex_count(); + roop_count++) + { +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&spider_udf_table_mon_mutexes[roop_count], + MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_udf_table_mon, + &spider_udf_table_mon_mutexes[roop_count], MY_MUTEX_INIT_FAST)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_udf_table_mon_mutex; + } + } + for (roop_count = 0; + roop_count < (int) spider_param_udf_table_mon_mutex_count(); + roop_count++) + { +#if MYSQL_VERSION_ID < 50500 + if (pthread_cond_init(&spider_udf_table_mon_conds[roop_count], NULL)) +#else + if (mysql_cond_init(spd_key_cond_udf_table_mon, + &spider_udf_table_mon_conds[roop_count], NULL)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_udf_table_mon_cond; + } + } + for (roop_count = 0; + roop_count < (int) spider_param_udf_table_mon_mutex_count(); + roop_count++) + { + if (my_hash_init(&spider_udf_table_mon_list_hash[roop_count], + spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_udf_tbl_mon_list_key, 0, 0)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_udf_table_mon_list_hash; + } + spider_alloc_calc_mem_init(spider_udf_table_mon_list_hash, 150); + spider_alloc_calc_mem(NULL, + spider_udf_table_mon_list_hash, + spider_udf_table_mon_list_hash[roop_count].array.max_element * + spider_udf_table_mon_list_hash[roop_count].array.size_of_element); + } + + spider_dbton_mysql.dbton_id = dbton_id; + spider_dbton[dbton_id] = spider_dbton_mysql; + ++dbton_id; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider_dbton_handlersocket.dbton_id = dbton_id; + spider_dbton[dbton_id] = spider_dbton_handlersocket; + ++dbton_id; +#endif +#ifdef HAVE_ORACLE_OCI + spider_dbton_oracle.dbton_id = dbton_id; + spider_dbton[dbton_id] = spider_dbton_oracle; + ++dbton_id; +#endif + for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++) + { + if (spider_dbton[roop_count].init) + { + if ((error_num = spider_dbton[roop_count].init())) + { + goto error_init_dbton; + } + } + } + +#ifndef WITHOUT_SPIDER_BG_SEARCH + if (!(spider_global_trx = spider_get_trx(NULL, FALSE, &error_num))) + goto error; +#endif + + DBUG_RETURN(0); + +#ifndef WITHOUT_SPIDER_BG_SEARCH +error: + roop_count = SPIDER_DBTON_SIZE; +error_init_dbton: + for (roop_count--; roop_count >= 0; roop_count--) + { + if (spider_dbton[roop_count].deinit) + { + spider_dbton[roop_count].deinit(); + } + } + roop_count = spider_param_udf_table_mon_mutex_count() - 1; +#endif +error_init_udf_table_mon_list_hash: + for (; roop_count >= 0; roop_count--) + { + spider_free_mem_calc(NULL, + spider_udf_table_mon_list_hash_id, + spider_udf_table_mon_list_hash[roop_count].array.max_element * + spider_udf_table_mon_list_hash[roop_count].array.size_of_element); + my_hash_free(&spider_udf_table_mon_list_hash[roop_count]); + } + roop_count = spider_param_udf_table_mon_mutex_count() - 1; +error_init_udf_table_mon_cond: + for (; roop_count >= 0; roop_count--) + pthread_cond_destroy(&spider_udf_table_mon_conds[roop_count]); + roop_count = spider_param_udf_table_mon_mutex_count() - 1; +error_init_udf_table_mon_mutex: + for (; roop_count >= 0; roop_count--) + pthread_mutex_destroy(&spider_udf_table_mon_mutexes[roop_count]); + spider_free(NULL, spider_udf_table_mon_mutexes, MYF(0)); +error_alloc_mon_mutxes: + spider_free_mem_calc(NULL, + spider_mon_table_cache_id, + spider_mon_table_cache.max_element * + spider_mon_table_cache.size_of_element); + delete_dynamic(&spider_mon_table_cache); +error_mon_table_cache_array_init: + spider_free_mem_calc(NULL, + spider_allocated_thds_id, + spider_allocated_thds.array.max_element * + spider_allocated_thds.array.size_of_element); + my_hash_free(&spider_allocated_thds); +error_allocated_thds_hash_init: +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider_free_mem_calc(NULL, + spider_hs_w_conn_hash_id, + spider_hs_w_conn_hash.array.max_element * + spider_hs_w_conn_hash.array.size_of_element); + my_hash_free(&spider_hs_w_conn_hash); +error_hs_w_conn_hash_init: + spider_free_mem_calc(NULL, + spider_hs_r_conn_hash_id, + spider_hs_r_conn_hash.array.max_element * + spider_hs_r_conn_hash.array.size_of_element); + my_hash_free(&spider_hs_r_conn_hash); +error_hs_r_conn_hash_init: +#endif + spider_free_mem_calc(NULL, + spider_open_connections_id, + spider_open_connections.array.max_element * + spider_open_connections.array.size_of_element); + my_hash_free(&spider_open_connections); +error_open_connections_hash_init: +#ifdef WITH_PARTITION_STORAGE_ENGINE + spider_free_mem_calc(NULL, + spider_open_pt_share_id, + spider_open_pt_share.array.max_element * + spider_open_pt_share.array.size_of_element); + my_hash_free(&spider_open_pt_share); +error_open_pt_share_hash_init: +#endif + spider_free_mem_calc(NULL, + spider_init_error_tables_id, + spider_init_error_tables.array.max_element * + spider_init_error_tables.array.size_of_element); + my_hash_free(&spider_init_error_tables); +error_init_error_tables_hash_init: + spider_free_mem_calc(NULL, + spider_open_tables_id, + spider_open_tables.array.max_element * + spider_open_tables.array.size_of_element); + my_hash_free(&spider_open_tables); +error_open_tables_hash_init: + pthread_mutex_destroy(&spider_mem_calc_mutex); +error_mem_calc_mutex_init: + pthread_mutex_destroy(&spider_mon_table_cache_mutex); +error_mon_table_cache_mutex_init: + pthread_mutex_destroy(&spider_allocated_thds_mutex); +error_allocated_thds_mutex_init: +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + pthread_mutex_destroy(&spider_hs_w_conn_mutex); +error_hs_w_conn_mutex_init: + pthread_mutex_destroy(&spider_hs_r_conn_mutex); +error_hs_r_conn_mutex_init: +#endif + pthread_mutex_destroy(&spider_open_conn_mutex); +error_open_conn_mutex_init: +#ifndef WITHOUT_SPIDER_BG_SEARCH + pthread_mutex_destroy(&spider_global_trx_mutex); +error_global_trx_mutex_init: +#endif + pthread_mutex_destroy(&spider_conn_mutex); +error_conn_mutex_init: +#ifdef WITH_PARTITION_STORAGE_ENGINE + pthread_mutex_destroy(&spider_pt_share_mutex); +error_pt_share_mutex_init: +#endif + pthread_mutex_destroy(&spider_init_error_tbl_mutex); +error_init_error_tbl_mutex_init: + pthread_mutex_destroy(&spider_conn_id_mutex); +error_conn_id_mutex_init: + pthread_mutex_destroy(&spider_thread_id_mutex); +error_thread_id_mutex_init: + pthread_mutex_destroy(&spider_tbl_mutex); +error_tbl_mutex_init: +#ifndef WITHOUT_SPIDER_BG_SEARCH +/* +error_pt_attr_setstate: +*/ + pthread_attr_destroy(&spider_pt_attr); +error_pt_attr_init: +#endif + DBUG_RETURN(error_num); +} + +char *spider_create_string( + const char *str, + uint length +) { + char *res; + DBUG_ENTER("spider_create_string"); + if (!(res = (char*) spider_malloc(spider_current_trx, 13, length + 1, + MYF(MY_WME)))) + DBUG_RETURN(NULL); + memcpy(res, str, length); + res[length] = '\0'; + DBUG_RETURN(res); +} + +char *spider_create_table_name_string( + const char *table_name, + const char *part_name, + const char *sub_name +) { + char *res, *tmp; + uint length = strlen(table_name); + DBUG_ENTER("spider_create_table_name_string"); + if (part_name) + { + length += sizeof("#P#") - 1 + strlen(part_name); + if (sub_name) + length += sizeof("#SP#") - 1 + strlen(sub_name); + } + if (!(res = (char*) spider_malloc(spider_current_trx, 14, length + 1, + MYF(MY_WME)))) + DBUG_RETURN(NULL); + tmp = strmov(res, table_name); + if (part_name) + { + tmp = strmov(tmp, "#P#"); + tmp = strmov(tmp, part_name); + if (sub_name) + { + tmp = strmov(tmp, "#SP#"); + tmp = strmov(tmp, sub_name); + } + } + DBUG_RETURN(res); +} + +#ifdef WITH_PARTITION_STORAGE_ENGINE +void spider_get_partition_info( + const char *table_name, + uint table_name_length, + const TABLE_SHARE *table_share, + partition_info *part_info, + partition_element **part_elem, + partition_element **sub_elem +) { + char tmp_name[FN_LEN]; + partition_element *tmp_part_elem = NULL, *tmp_sub_elem = NULL; + bool tmp_flg = FALSE, tmp_find_flg = FALSE; + DBUG_ENTER("spider_get_partition_info"); + *part_elem = NULL; + *sub_elem = NULL; + if (!part_info) + DBUG_VOID_RETURN; + + if (!memcmp(table_name + table_name_length - 5, "#TMP#", 5)) + tmp_flg = TRUE; + + DBUG_PRINT("info",("spider table_name=%s", table_name)); + List_iterator part_it(part_info->partitions); + while ((*part_elem = part_it++)) + { + if ((*part_elem)->subpartitions.elements) + { + List_iterator sub_it((*part_elem)->subpartitions); + while ((*sub_elem = sub_it++)) + { + create_subpartition_name(tmp_name, table_share->path.str, + (*part_elem)->partition_name, (*sub_elem)->partition_name, + NORMAL_PART_NAME); + DBUG_PRINT("info",("spider tmp_name=%s", tmp_name)); + if (!memcmp(table_name, tmp_name, table_name_length + 1)) + DBUG_VOID_RETURN; + if ( + tmp_flg && + *(tmp_name + table_name_length - 5) == '\0' && + !memcmp(table_name, tmp_name, table_name_length - 5) + ) { + tmp_part_elem = *part_elem; + tmp_sub_elem = *sub_elem; + tmp_flg = FALSE; + tmp_find_flg = TRUE; + } + } + } else { + create_partition_name(tmp_name, table_share->path.str, + (*part_elem)->partition_name, NORMAL_PART_NAME, TRUE); + DBUG_PRINT("info",("spider tmp_name=%s", tmp_name)); + if (!memcmp(table_name, tmp_name, table_name_length + 1)) + DBUG_VOID_RETURN; + if ( + tmp_flg && + *(tmp_name + table_name_length - 5) == '\0' && + !memcmp(table_name, tmp_name, table_name_length - 5) + ) { + tmp_part_elem = *part_elem; + tmp_flg = FALSE; + tmp_find_flg = TRUE; + } + } + } + if (tmp_find_flg) + { + *part_elem = tmp_part_elem; + *sub_elem = tmp_sub_elem; + DBUG_PRINT("info",("spider tmp find")); + DBUG_VOID_RETURN; + } + *part_elem = NULL; + *sub_elem = NULL; + DBUG_PRINT("info",("spider no hit")); + DBUG_VOID_RETURN; +} +#endif + +int spider_get_sts( + SPIDER_SHARE *share, + int link_idx, + time_t tmp_time, + ha_spider *spider, + double sts_interval, + int sts_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + int sts_sync, +#endif + int sts_sync_level, + uint flag +) { + int get_type; + int error_num = 0; + DBUG_ENTER("spider_get_sts"); + +#ifdef WITH_PARTITION_STORAGE_ENGINE + if ( + sts_sync == 0 + ) { +#endif + /* get */ + get_type = 1; +#ifdef WITH_PARTITION_STORAGE_ENGINE + } else if ( + !share->partition_share->sts_init + ) { + pthread_mutex_lock(&share->partition_share->sts_mutex); + if (!share->partition_share->sts_init) + { + /* get after mutex_lock */ + get_type = 2; + } else { + pthread_mutex_unlock(&share->partition_share->sts_mutex); + /* copy */ + get_type = 0; + } + } else if ( + difftime(share->sts_get_time, share->partition_share->sts_get_time) < + sts_interval + ) { + /* copy */ + get_type = 0; + } else if ( + !pthread_mutex_trylock(&share->partition_share->sts_mutex) + ) { + /* get after mutex_trylock */ + get_type = 3; + } else { + /* copy */ + get_type = 0; + } + if (get_type == 0) + spider_copy_sts_to_share(share, share->partition_share); + else +#endif + error_num = spider_db_show_table_status(spider, link_idx, sts_mode, flag); +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (get_type >= 2) + pthread_mutex_unlock(&share->partition_share->sts_mutex); +#endif + if (error_num) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share = + spider->partition_handler_share; + if ( + !share->partition_share->sts_init && + sts_sync >= sts_sync_level && + get_type > 1 && + partition_handler_share && + partition_handler_share->handlers && + partition_handler_share->handlers[0] == spider + ) { + int roop_count; + ha_spider *tmp_spider; + SPIDER_SHARE *tmp_share; + double tmp_sts_interval; + int tmp_sts_mode; + int tmp_sts_sync; + THD *thd = spider->trx->thd; + for (roop_count = 1; + roop_count < (int) partition_handler_share->use_count; + roop_count++) + { + tmp_spider = + (ha_spider *) partition_handler_share->handlers[roop_count]; + tmp_share = tmp_spider->share; + tmp_sts_interval = spider_param_sts_interval(thd, share->sts_interval); + tmp_sts_mode = spider_param_sts_mode(thd, share->sts_mode); + tmp_sts_sync = spider_param_sts_sync(thd, share->sts_sync); + spider_get_sts(tmp_share, tmp_spider->search_link_idx, + tmp_time, tmp_spider, tmp_sts_interval, tmp_sts_mode, tmp_sts_sync, + 1, flag); + if (share->partition_share->sts_init) + { + error_num = 0; + thd->clear_error(); + get_type = 0; + spider_copy_sts_to_share(share, share->partition_share); + break; + } + } + } + if (error_num) +#endif + DBUG_RETURN(error_num); + } +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (sts_sync >= sts_sync_level && get_type > 0) + { + spider_copy_sts_to_pt_share(share->partition_share, share); + share->partition_share->sts_get_time = tmp_time; + share->partition_share->sts_init = TRUE; + } +#endif + share->sts_get_time = tmp_time; + share->sts_init = TRUE; + DBUG_RETURN(0); +} + +int spider_get_crd( + SPIDER_SHARE *share, + int link_idx, + time_t tmp_time, + ha_spider *spider, + TABLE *table, + double crd_interval, + int crd_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + int crd_sync, +#endif + int crd_sync_level +) { + int get_type; + int error_num = 0; + DBUG_ENTER("spider_get_crd"); + +#ifdef WITH_PARTITION_STORAGE_ENGINE + if ( + crd_sync == 0 + ) { +#endif + /* get */ + get_type = 1; +#ifdef WITH_PARTITION_STORAGE_ENGINE + } else if ( + !share->partition_share->crd_init + ) { + pthread_mutex_lock(&share->partition_share->crd_mutex); + if (!share->partition_share->crd_init) + { + /* get after mutex_lock */ + get_type = 2; + } else { + pthread_mutex_unlock(&share->partition_share->crd_mutex); + /* copy */ + get_type = 0; + } + } else if ( + difftime(share->crd_get_time, share->partition_share->crd_get_time) < + crd_interval + ) { + /* copy */ + get_type = 0; + } else if ( + !pthread_mutex_trylock(&share->partition_share->crd_mutex) + ) { + /* get after mutex_trylock */ + get_type = 3; + } else { + /* copy */ + get_type = 0; + } + if (get_type == 0) + spider_copy_crd_to_share(share, share->partition_share, + table->s->fields); + else +#endif + error_num = spider_db_show_index(spider, link_idx, table, crd_mode); +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (get_type >= 2) + pthread_mutex_unlock(&share->partition_share->crd_mutex); +#endif + if (error_num) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share = + spider->partition_handler_share; + if ( + !share->partition_share->crd_init && + crd_sync >= crd_sync_level && + get_type > 1 && + partition_handler_share && + partition_handler_share->handlers && + partition_handler_share->handlers[0] == spider + ) { + int roop_count; + ha_spider *tmp_spider; + SPIDER_SHARE *tmp_share; + double tmp_crd_interval; + int tmp_crd_mode; + int tmp_crd_sync; + THD *thd = spider->trx->thd; + for (roop_count = 1; + roop_count < (int) partition_handler_share->use_count; + roop_count++) + { + tmp_spider = + (ha_spider *) partition_handler_share->handlers[roop_count]; + tmp_share = tmp_spider->share; + tmp_crd_interval = spider_param_crd_interval(thd, share->crd_interval); + tmp_crd_mode = spider_param_crd_mode(thd, share->crd_mode); + tmp_crd_sync = spider_param_crd_sync(thd, share->crd_sync); + spider_get_crd(tmp_share, tmp_spider->search_link_idx, + tmp_time, tmp_spider, table, tmp_crd_interval, tmp_crd_mode, + tmp_crd_sync, 1); + if (share->partition_share->crd_init) + { + error_num = 0; + thd->clear_error(); + get_type = 0; + spider_copy_crd_to_share(share, share->partition_share, + table->s->fields); + break; + } + } + } + if (error_num) +#endif + DBUG_RETURN(error_num); + } +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (crd_sync >= crd_sync_level && get_type > 0) + { + spider_copy_crd_to_pt_share(share->partition_share, share, + table->s->fields); + share->partition_share->crd_get_time = tmp_time; + share->partition_share->crd_init = TRUE; + } +#endif + share->crd_get_time = tmp_time; + share->crd_init = TRUE; + DBUG_RETURN(0); +} + +void spider_set_result_list_param( + ha_spider *spider +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + SPIDER_SHARE *share = spider->share; + THD *thd = spider->trx->thd; + DBUG_ENTER("spider_set_result_list_param"); + result_list->internal_offset = + spider_param_internal_offset(thd, share->internal_offset); + result_list->internal_limit = +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + spider->info_limit < 9223372036854775807LL ? + spider->info_limit : +#endif + spider_param_internal_limit(thd, share->internal_limit); + result_list->split_read = spider_split_read_param(spider); + if (spider->support_multi_split_read_sql()) + { + result_list->multi_split_read = + spider_param_multi_split_read(thd, share->multi_split_read); + } else { + result_list->multi_split_read = 1; + } + result_list->max_order = + spider_param_max_order(thd, share->max_order); + result_list->quick_mode = + spider_param_quick_mode(thd, share->quick_mode); + result_list->quick_page_size = + spider_param_quick_page_size(thd, share->quick_page_size); + result_list->low_mem_read = + spider_param_low_mem_read(thd, share->low_mem_read); + DBUG_VOID_RETURN; +} + +SPIDER_INIT_ERROR_TABLE *spider_get_init_error_table( + SPIDER_TRX *trx, + SPIDER_SHARE *share, + bool create +) { + SPIDER_INIT_ERROR_TABLE *spider_init_error_table; + char *tmp_name; + DBUG_ENTER("spider_get_init_error_table"); + pthread_mutex_lock(&spider_init_error_tbl_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (!(spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) + my_hash_search_using_hash_value( + &spider_init_error_tables, share->table_name_hash_value, + (uchar*) share->table_name, share->table_name_length))) +#else + if (!(spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) my_hash_search( + &spider_init_error_tables, + (uchar*) share->table_name, share->table_name_length))) +#endif + { + if (!create) + { + pthread_mutex_unlock(&spider_init_error_tbl_mutex); + DBUG_RETURN(NULL); + } + if (!(spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) + spider_bulk_malloc(spider_current_trx, 54, MYF(MY_WME | MY_ZEROFILL), + &spider_init_error_table, sizeof(*spider_init_error_table), + &tmp_name, share->table_name_length + 1, + NullS)) + ) { + pthread_mutex_unlock(&spider_init_error_tbl_mutex); + DBUG_RETURN(NULL); + } + memcpy(tmp_name, share->table_name, share->table_name_length); + spider_init_error_table->table_name = tmp_name; + spider_init_error_table->table_name_length = share->table_name_length; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + spider_init_error_table->table_name_hash_value = + share->table_name_hash_value; +#endif + uint old_elements = spider_init_error_tables.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&spider_init_error_tables, + share->table_name_hash_value, (uchar*) spider_init_error_table)) +#else + if (my_hash_insert(&spider_init_error_tables, + (uchar*) spider_init_error_table)) +#endif + { + spider_free(trx, spider_init_error_table, MYF(0)); + pthread_mutex_unlock(&spider_init_error_tbl_mutex); + DBUG_RETURN(NULL); + } + if (spider_init_error_tables.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + spider_init_error_tables, + (spider_init_error_tables.array.max_element - old_elements) * + spider_init_error_tables.array.size_of_element); + } + } + pthread_mutex_unlock(&spider_init_error_tbl_mutex); + DBUG_RETURN(spider_init_error_table); +} + +void spider_delete_init_error_table( + const char *name +) { + SPIDER_INIT_ERROR_TABLE *spider_init_error_table; + uint length = strlen(name); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value = my_calc_hash(&spider_open_tables, + (uchar*) name, length); +#endif + DBUG_ENTER("spider_delete_init_error_table"); + pthread_mutex_lock(&spider_init_error_tbl_mutex); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if ((spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) + my_hash_search_using_hash_value(&spider_init_error_tables, hash_value, + (uchar*) name, length))) +#else + if ((spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) my_hash_search( + &spider_init_error_tables, (uchar*) name, length))) +#endif + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_init_error_tables, + spider_init_error_table->table_name_hash_value, + (uchar*) spider_init_error_table); +#else + my_hash_delete(&spider_init_error_tables, + (uchar*) spider_init_error_table); +#endif + spider_free(spider_current_trx, spider_init_error_table, MYF(0)); + } + pthread_mutex_unlock(&spider_init_error_tbl_mutex); + DBUG_VOID_RETURN; +} + +bool spider_check_pk_update( + TABLE *table +) { + int roop_count; + TABLE_SHARE *table_share = table->s; + KEY *key_info; + KEY_PART_INFO *key_part; + DBUG_ENTER("spider_check_pk_update"); + if (table_share->primary_key == MAX_KEY) + DBUG_RETURN(FALSE); + + key_info = &table_share->key_info[table_share->primary_key]; + key_part = key_info->key_part; + for (roop_count = 0; roop_count < (int) key_info->key_parts; roop_count++) + { + if (bitmap_is_set(table->write_set, + key_part[roop_count].field->field_index)) + DBUG_RETURN(TRUE); + } + DBUG_RETURN(FALSE); +} + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +bool spider_check_hs_pk_update( + ha_spider *spider, + key_range *key +) { + uint roop_count, field_index, set_count = 0; + TABLE *table = spider->get_table(); + TABLE_SHARE *table_share = table->s; + SPIDER_SHARE *share = spider->share; + KEY *key_info; + KEY_PART_INFO *key_part; + char buf[MAX_FIELD_WIDTH], buf2[MAX_FIELD_WIDTH]; + spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin), + tmp_str2(buf2, MAX_FIELD_WIDTH, &my_charset_bin); + String *str, *str2; + DBUG_ENTER("spider_check_hs_pk_update"); + tmp_str.init_calc_mem(137); + + if (table_share->primary_key == MAX_KEY) + DBUG_RETURN(FALSE); + memset(spider->tmp_column_bitmap, 0, sizeof(uchar) * share->bitmap_size); + key_info = &table->key_info[table_share->primary_key]; + key_part = key_info->key_part; + for (roop_count = 0; roop_count < key_info->key_parts; roop_count++) + { + field_index = key_part[roop_count].field->field_index; + if (bitmap_is_set(table->write_set, field_index)) + { + DBUG_PRINT("info", ("spider set key_part=%u field_index=%u", + roop_count, field_index)); + spider_set_bit(spider->tmp_column_bitmap, field_index); + set_count++; + } + } + DBUG_PRINT("info", ("spider set_count=%u", set_count)); + + Field *field; + uint store_length, length, var_len; + const uchar *ptr; + bool key_eq; + key_part_map tgt_key_part_map = key->keypart_map; + key_info = &table->key_info[spider->active_index]; + for ( + key_part = key_info->key_part, + length = 0; + tgt_key_part_map; + length += store_length, + tgt_key_part_map >>= 1, + key_part++ + ) { + store_length = key_part->store_length; + field = key_part->field; + field_index = field->field_index; + if (spider_bit_is_set(spider->tmp_column_bitmap, field_index)) + { + ptr = key->key + length; + key_eq = (tgt_key_part_map > 1); + if (key_part->null_bit && *ptr++) + { + if (key->flag != HA_READ_KEY_EXACT || !field->is_null()) + { + DBUG_PRINT("info", ("spider flag=%u is_null=%s", + key->flag, field->is_null() ? "TRUE" : "FALSE")); + DBUG_RETURN(TRUE); + } + } else { + if ( + field->type() == MYSQL_TYPE_BLOB || + field->real_type() == MYSQL_TYPE_VARCHAR || + field->type() == MYSQL_TYPE_GEOMETRY + ) { + var_len = uint2korr(ptr); + tmp_str.set_quick((char *) ptr + HA_KEY_BLOB_LENGTH, var_len, + &my_charset_bin); + str = tmp_str.get_str(); + } else { + str = field->val_str(tmp_str.get_str(), ptr); + tmp_str.mem_calc(); + } + str2 = field->val_str(tmp_str2.get_str()); + tmp_str2.mem_calc(); + if ( + str->length() != str2->length() || + memcmp(str->ptr(), str2->ptr(), str->length()) + ) { + DBUG_PRINT("info", ("spider length=%u %u", + str->length(), str2->length())); + DBUG_PRINT("info", ("spider length=%s %s", + str->c_ptr_safe(), str2->c_ptr_safe())); + DBUG_RETURN(TRUE); + } + } + set_count--; + } + } + DBUG_PRINT("info", ("spider set_count=%u", set_count)); + if (set_count) + { + DBUG_RETURN(TRUE); + } + DBUG_RETURN(FALSE); +} +#endif +#endif + +void spider_set_tmp_share_pointer( + SPIDER_SHARE *tmp_share, + char **tmp_connect_info, + uint *tmp_connect_info_length, + long *tmp_long, + longlong *tmp_longlong +) { + DBUG_ENTER("spider_set_tmp_share_pointer"); + tmp_share->link_count = 1; + tmp_share->all_link_count = 1; + tmp_share->server_names = &tmp_connect_info[0]; + tmp_share->tgt_table_names = &tmp_connect_info[1]; + tmp_share->tgt_dbs = &tmp_connect_info[2]; + tmp_share->tgt_hosts = &tmp_connect_info[3]; + tmp_share->tgt_usernames = &tmp_connect_info[4]; + tmp_share->tgt_passwords = &tmp_connect_info[5]; + tmp_share->tgt_sockets = &tmp_connect_info[6]; + tmp_share->tgt_wrappers = &tmp_connect_info[7]; + tmp_share->tgt_ssl_cas = &tmp_connect_info[8]; + tmp_share->tgt_ssl_capaths = &tmp_connect_info[9]; + tmp_share->tgt_ssl_certs = &tmp_connect_info[10]; + tmp_share->tgt_ssl_ciphers = &tmp_connect_info[11]; + tmp_share->tgt_ssl_keys = &tmp_connect_info[12]; + tmp_share->tgt_default_files = &tmp_connect_info[13]; + tmp_share->tgt_default_groups = &tmp_connect_info[14]; + tmp_share->tgt_pk_names = &tmp_connect_info[15]; + tmp_share->tgt_sequence_names = &tmp_connect_info[16]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + tmp_share->hs_read_socks = &tmp_connect_info[17]; + tmp_share->hs_write_socks = &tmp_connect_info[18]; +#endif + tmp_share->tgt_ports = &tmp_long[0]; + tmp_share->tgt_ssl_vscs = &tmp_long[1]; + tmp_share->link_statuses = &tmp_long[2]; + tmp_share->monitoring_kind = &tmp_long[3]; +#ifndef WITHOUT_SPIDER_BG_SEARCH + tmp_share->monitoring_bg_kind = &tmp_long[4]; +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + tmp_share->use_hs_reads = &tmp_long[5]; + tmp_share->use_hs_writes = &tmp_long[6]; + tmp_share->hs_read_ports = &tmp_long[7]; + tmp_share->hs_write_ports = &tmp_long[8]; + tmp_share->hs_write_to_reads = &tmp_long[9]; +#endif + tmp_share->use_handlers = &tmp_long[10]; + tmp_share->connect_timeouts = &tmp_long[11]; + tmp_long[11] = -1; + tmp_share->net_read_timeouts = &tmp_long[12]; + tmp_long[12] = -1; + tmp_share->net_write_timeouts = &tmp_long[13]; + tmp_long[13] = -1; + tmp_share->access_balances = &tmp_long[14]; + tmp_share->monitoring_limit = &tmp_longlong[0]; + tmp_share->monitoring_sid = &tmp_longlong[1]; +#ifndef WITHOUT_SPIDER_BG_SEARCH + tmp_share->monitoring_bg_interval = &tmp_longlong[2]; +#endif + tmp_share->server_names_lengths = &tmp_connect_info_length[0]; + tmp_share->tgt_table_names_lengths = &tmp_connect_info_length[1]; + tmp_share->tgt_dbs_lengths = &tmp_connect_info_length[2]; + tmp_share->tgt_hosts_lengths = &tmp_connect_info_length[3]; + tmp_share->tgt_usernames_lengths = &tmp_connect_info_length[4]; + tmp_share->tgt_passwords_lengths = &tmp_connect_info_length[5]; + tmp_share->tgt_sockets_lengths = &tmp_connect_info_length[6]; + tmp_share->tgt_wrappers_lengths = &tmp_connect_info_length[7]; + tmp_share->tgt_ssl_cas_lengths = &tmp_connect_info_length[8]; + tmp_share->tgt_ssl_capaths_lengths = &tmp_connect_info_length[9]; + tmp_share->tgt_ssl_certs_lengths = &tmp_connect_info_length[10]; + tmp_share->tgt_ssl_ciphers_lengths = &tmp_connect_info_length[11]; + tmp_share->tgt_ssl_keys_lengths = &tmp_connect_info_length[12]; + tmp_share->tgt_default_files_lengths = &tmp_connect_info_length[13]; + tmp_share->tgt_default_groups_lengths = &tmp_connect_info_length[14]; + tmp_share->tgt_pk_names_lengths = &tmp_connect_info_length[15]; + tmp_share->tgt_sequence_names_lengths = &tmp_connect_info_length[16]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + tmp_share->hs_read_socks_lengths = &tmp_connect_info_length[17]; + tmp_share->hs_write_socks_lengths = &tmp_connect_info_length[18]; +#endif + tmp_share->server_names_length = 1; + tmp_share->tgt_table_names_length = 1; + tmp_share->tgt_dbs_length = 1; + tmp_share->tgt_hosts_length = 1; + tmp_share->tgt_usernames_length = 1; + tmp_share->tgt_passwords_length = 1; + tmp_share->tgt_sockets_length = 1; + tmp_share->tgt_wrappers_length = 1; + tmp_share->tgt_ssl_cas_length = 1; + tmp_share->tgt_ssl_capaths_length = 1; + tmp_share->tgt_ssl_certs_length = 1; + tmp_share->tgt_ssl_ciphers_length = 1; + tmp_share->tgt_ssl_keys_length = 1; + tmp_share->tgt_default_files_length = 1; + tmp_share->tgt_default_groups_length = 1; + tmp_share->tgt_pk_names_length = 1; + tmp_share->tgt_sequence_names_length = 1; + tmp_share->tgt_ports_length = 1; + tmp_share->tgt_ssl_vscs_length = 1; + tmp_share->link_statuses_length = 1; + tmp_share->monitoring_kind_length = 1; +#ifndef WITHOUT_SPIDER_BG_SEARCH + tmp_share->monitoring_bg_kind_length = 1; +#endif + tmp_share->monitoring_limit_length = 1; + tmp_share->monitoring_sid_length = 1; +#ifndef WITHOUT_SPIDER_BG_SEARCH + tmp_share->monitoring_bg_interval_length = 1; +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + tmp_share->hs_read_socks_length = 1; + tmp_share->hs_write_socks_length = 1; + tmp_share->use_hs_reads_length = 1; + tmp_share->use_hs_writes_length = 1; + tmp_share->hs_read_ports_length = 1; + tmp_share->hs_write_ports_length = 1; + tmp_share->hs_write_to_reads_length = 1; +#endif + tmp_share->use_handlers_length = 1; + tmp_share->connect_timeouts_length = 1; + tmp_share->net_read_timeouts_length = 1; + tmp_share->net_write_timeouts_length = 1; + tmp_share->access_balances_length = 1; + +#ifndef WITHOUT_SPIDER_BG_SEARCH + tmp_share->monitoring_bg_kind[0] = -1; +#endif + tmp_share->monitoring_kind[0] = -1; +#ifndef WITHOUT_SPIDER_BG_SEARCH + tmp_share->monitoring_bg_interval[0] = -1; +#endif + tmp_share->monitoring_limit[0] = -1; + tmp_share->monitoring_sid[0] = -1; + tmp_share->bka_engine = NULL; + tmp_share->use_dbton_count = 0; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + tmp_share->use_hs_dbton_count = 0; +#endif + DBUG_VOID_RETURN; +} + +int spider_create_tmp_dbton_share( + SPIDER_SHARE *tmp_share +) { + int error_num; + uint dbton_id = tmp_share->use_dbton_ids[0]; + DBUG_ENTER("spider_create_tmp_dbton_share"); + if (!(tmp_share->dbton_share[dbton_id] = + spider_dbton[dbton_id].create_db_share(tmp_share))) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if ((error_num = tmp_share->dbton_share[dbton_id]->init())) + { + delete tmp_share->dbton_share[dbton_id]; + tmp_share->dbton_share[dbton_id] = NULL; + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +void spider_free_tmp_dbton_share( + SPIDER_SHARE *tmp_share +) { + uint dbton_id = tmp_share->use_dbton_ids[0]; + DBUG_ENTER("spider_free_tmp_dbton_share"); + if (tmp_share->dbton_share[dbton_id]) + { + delete tmp_share->dbton_share[dbton_id]; + tmp_share->dbton_share[dbton_id] = NULL; + } + DBUG_VOID_RETURN; +} + +int spider_create_tmp_dbton_handler( + ha_spider *tmp_spider +) { + int error_num; + SPIDER_SHARE *tmp_share = tmp_spider->share; + uint dbton_id = tmp_share->use_dbton_ids[0]; + DBUG_ENTER("spider_create_tmp_dbton_handler"); + if (!(tmp_spider->dbton_handler[dbton_id] = + spider_dbton[dbton_id].create_db_handler(tmp_spider, + tmp_share->dbton_share[dbton_id]))) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if ((error_num = tmp_spider->dbton_handler[dbton_id]->init())) + { + delete tmp_spider->dbton_handler[dbton_id]; + tmp_spider->dbton_handler[dbton_id] = NULL; + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + +void spider_free_tmp_dbton_handler( + ha_spider *tmp_spider +) { + SPIDER_SHARE *tmp_share = tmp_spider->share; + uint dbton_id = tmp_share->use_dbton_ids[0]; + DBUG_ENTER("spider_create_tmp_dbton_handler"); + if (tmp_spider->dbton_handler[dbton_id]) + { + delete tmp_spider->dbton_handler[dbton_id]; + tmp_spider->dbton_handler[dbton_id] = NULL; + } + DBUG_VOID_RETURN; +} + +void spider_get_select_limit( + ha_spider *spider, + st_select_lex **select_lex, + longlong *select_limit, + longlong *offset_limit +) { + TABLE *table = spider->get_table(); + TABLE_LIST *table_list = table->pos_in_table_list; + DBUG_ENTER("spider_get_select_limit"); + *select_lex = NULL; + *select_limit = 9223372036854775807LL; + *offset_limit = 0; + if (table_list) + { + while (table_list->parent_l) + table_list = table_list->parent_l; + *select_lex = table_list->select_lex; + if (*select_lex && (*select_lex)->explicit_limit) + { + *select_limit = (*select_lex)->select_limit ? + (*select_lex)->select_limit->val_int() : 0; + *offset_limit = (*select_lex)->offset_limit ? + (*select_lex)->offset_limit->val_int() : 0; + } + } + DBUG_VOID_RETURN; +} + +longlong spider_split_read_param( + ha_spider *spider +) { + SPIDER_SHARE *share = spider->share; + SPIDER_RESULT_LIST *result_list = &spider->result_list; + THD *thd = spider->trx->thd; + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + double semi_split_read; + longlong split_read; + DBUG_ENTER("spider_split_read_param"); + result_list->set_split_read_count = 1; +#ifdef INFO_KIND_FORCE_LIMIT_BEGIN + if (spider->info_limit < 9223372036854775807LL) + { + DBUG_PRINT("info",("spider info_limit=%lld", spider->info_limit)); + longlong info_limit = spider->info_limit; + result_list->split_read_base = info_limit; + result_list->semi_split_read = 0; + result_list->first_read = info_limit; + result_list->second_read = info_limit; + result_list->semi_split_read_base = 0; + result_list->set_split_read = FALSE; + DBUG_RETURN(info_limit); + } +#endif + if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) + { + DBUG_RETURN(result_list->semi_split_read_base); + } + spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); + if (!result_list->set_split_read) + { + result_list->split_read_base = + spider_param_split_read(thd, share->split_read); + result_list->semi_split_read = + spider_param_semi_split_read(thd, share->semi_split_read); + result_list->semi_split_read_limit = + spider_param_semi_split_read_limit(thd, share->semi_split_read_limit); + result_list->first_read = + spider_param_first_read(thd, share->first_read); + result_list->second_read = + spider_param_second_read(thd, share->second_read); + result_list->semi_split_read_base = 0; + result_list->set_split_read = TRUE; + } + if ( + result_list->semi_split_read > 0 && + select_lex && select_lex->explicit_limit && + !(select_lex->options & OPTION_FOUND_ROWS) && + !select_lex->group_list.elements && + !select_lex->with_sum_func + ) { + semi_split_read = result_list->semi_split_read * + (select_limit + offset_limit); + DBUG_PRINT("info",("spider semi_split_read=%f", semi_split_read)); + if (semi_split_read >= result_list->semi_split_read_limit) + { + result_list->semi_split_read_base = result_list->semi_split_read_limit; + DBUG_RETURN(result_list->semi_split_read_limit); + } else { + split_read = (longlong) semi_split_read; + if (split_read < 0) + { + result_list->semi_split_read_base = result_list->semi_split_read_limit; + DBUG_RETURN(result_list->semi_split_read_limit); + } else if (split_read == 0) + { + result_list->semi_split_read_base = 1; + DBUG_RETURN(1); + } else { + result_list->semi_split_read_base = split_read; + DBUG_RETURN(split_read); + } + } + } else if (result_list->first_read > 0) + DBUG_RETURN(result_list->first_read); + DBUG_RETURN(result_list->split_read_base); +} + +longlong spider_bg_split_read_param( + ha_spider *spider +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_bg_split_read_param"); + if (result_list->semi_split_read_base) + DBUG_RETURN(result_list->semi_split_read_base); + DBUG_RETURN(result_list->split_read_base); +} + +void spider_first_split_read_param( + ha_spider *spider +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_first_split_read_param"); + if (result_list->semi_split_read_base) + result_list->split_read = result_list->semi_split_read_base; + else if (result_list->second_read > 0) + result_list->split_read = result_list->first_read; + else + result_list->split_read = result_list->split_read_base; + result_list->set_split_read_count = 1; + DBUG_VOID_RETURN; +} + +void spider_next_split_read_param( + ha_spider *spider +) { + SPIDER_RESULT_LIST *result_list = &spider->result_list; + DBUG_ENTER("spider_next_split_read_param"); + if (result_list->semi_split_read_base) + result_list->split_read = result_list->semi_split_read_base; + else if ( + result_list->set_split_read_count == 1 && + result_list->second_read > 0 + ) + result_list->split_read = result_list->second_read; + else + result_list->split_read = result_list->split_read_base; + result_list->set_split_read_count++; + DBUG_VOID_RETURN; +} + +bool spider_check_direct_order_limit( + ha_spider *spider +) { + THD *thd = spider->trx->thd; + SPIDER_SHARE *share = spider->share; + longlong direct_order_limit = spider_param_direct_order_limit(thd, + share->direct_order_limit); + DBUG_ENTER("spider_check_direct_order_limit"); + if ( + direct_order_limit && + spider->sql_command != SQLCOM_HA_READ + ) { + st_select_lex *select_lex; + longlong select_limit; + longlong offset_limit; + spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); + DBUG_PRINT("info",("spider select_limit=%lld", select_limit)); + DBUG_PRINT("info",("spider offset_limit=%lld", offset_limit)); + if ( +#if MYSQL_VERSION_ID < 50500 + !thd->variables.engine_condition_pushdown || +#else + !(thd->variables.optimizer_switch & + OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || +#endif + !select_lex || + !select_lex->explicit_limit || + (select_lex->options & OPTION_FOUND_ROWS) || + select_lex->group_list.elements || + select_lex->with_sum_func || + select_lex->having || + select_lex->table_list.elements != 1 || + !select_lex->order_list.elements || + select_limit > direct_order_limit - offset_limit + ) { + DBUG_PRINT("info",("spider FALSE by select_lex")); + DBUG_RETURN(FALSE); + } + ORDER *order; + for (order = (ORDER *) select_lex->order_list.first; order; + order = order->next) + { + if (spider->print_item_type((*order->item), NULL, NULL, 0)) + { + DBUG_PRINT("info",("spider FALSE by order")); + DBUG_RETURN(FALSE); + } + } + if (spider_db_append_condition(spider, NULL, 0, TRUE)) + { + DBUG_PRINT("info",("spider FALSE by condition")); + DBUG_RETURN(FALSE); + } + DBUG_PRINT("info",("spider TRUE")); + spider->result_list.internal_limit = select_limit + offset_limit; + spider->result_list.split_read = select_limit + offset_limit; + spider->trx->direct_order_limit_count++; + DBUG_RETURN(TRUE); + } + DBUG_PRINT("info",("spider FALSE by parameter")); + DBUG_RETURN(FALSE); +} + +int spider_compare_for_sort( + SPIDER_SORT *a, + SPIDER_SORT *b +) { + DBUG_ENTER("spider_compare_for_sort"); + if (a->sort > b->sort) + DBUG_RETURN(-1); + if (a->sort < b->sort) + DBUG_RETURN(1); + DBUG_RETURN(0); +} + +ulong spider_calc_for_sort( + uint count, + ... +) { + ulong sort = 0; + va_list args; + va_start(args, count); + DBUG_ENTER("spider_calc_for_sort"); + while (count--) + { + char *start = va_arg(args, char *), *str; + uint wild_pos = 0; + + if ((str = start)) + { + wild_pos = 128; + for (; *str; str++) + { + if (*str == spider_wild_prefix && str[1]) + str++; + else if (*str == spider_wild_many || *str == spider_wild_one) + { + wild_pos = (uint) (str - start) + 1; + if (wild_pos > 127) + wild_pos = 127; + break; + } + } + } + sort = (sort << 8) + wild_pos; + } + va_end(args); + DBUG_RETURN(sort); +} + +double spider_rand( + uint32 rand_source +) { +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + struct my_rnd_struct rand; +#else + struct rand_struct rand; +#endif + DBUG_ENTER("spider_rand"); + /* generate same as rand function for applications */ +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + my_rnd_init(&rand, (uint32) (rand_source * 65537L + 55555555L), + (uint32) (rand_source * 268435457L)); +#else + randominit(&rand, (uint32) (rand_source * 65537L + 55555555L), + (uint32) (rand_source * 268435457L)); +#endif + DBUG_RETURN(my_rnd(&rand)); +} + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +int spider_discover_table_structure_internal( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str +) { + int error_num, roop_count; + DBUG_ENTER("spider_discover_table_structure"); + for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++) + { + if (spider_bit_is_set(spider_share->dbton_bitmap, roop_count)) + { + if ((error_num = spider_share->dbton_share[roop_count]-> + discover_table_structure(trx, spider_share, str))) + { + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_discover_table_structure( + handlerton *hton, + THD* thd, + TABLE_SHARE *share, + HA_CREATE_INFO *info +) { + int error_num = HA_ERR_WRONG_COMMAND; + SPIDER_SHARE *spider_share; + const char *table_name = share->path.str; + uint table_name_length = (uint) strlen(table_name); + SPIDER_TRX *trx; +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_info *part_info = thd->work_part_info; +#endif + uint str_len; + char buf[MAX_FIELD_WIDTH]; + spider_string str(buf, sizeof(buf), system_charset_info); + DBUG_ENTER("spider_discover_table_structure"); + str.init_calc_mem(229); + str.length(0); + if (str.reserve( + SPIDER_SQL_CREATE_TABLE_LEN + share->db.length + + SPIDER_SQL_DOT_LEN + share->table_name.length + + /* SPIDER_SQL_LCL_NAME_QUOTE_LEN */ 4 + SPIDER_SQL_OPEN_PAREN_LEN + )) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str.q_append(SPIDER_SQL_CREATE_TABLE_STR, SPIDER_SQL_CREATE_TABLE_LEN); + str.q_append(SPIDER_SQL_LCL_NAME_QUOTE_STR, SPIDER_SQL_LCL_NAME_QUOTE_LEN); + str.q_append(share->db.str, share->db.length); + str.q_append(SPIDER_SQL_LCL_NAME_QUOTE_STR, SPIDER_SQL_LCL_NAME_QUOTE_LEN); + str.q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); + str.q_append(SPIDER_SQL_LCL_NAME_QUOTE_STR, SPIDER_SQL_LCL_NAME_QUOTE_LEN); + str.q_append(share->table_name.str, share->table_name.length); + str.q_append(SPIDER_SQL_LCL_NAME_QUOTE_STR, SPIDER_SQL_LCL_NAME_QUOTE_LEN); + str.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + str_len = str.length(); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value = my_calc_hash(&spider_open_tables, + (uchar*) table_name, table_name_length); +#endif + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + { + DBUG_PRINT("info",("spider spider_get_trx error")); + my_error(error_num, MYF(0)); + DBUG_RETURN(error_num); + } + share->table_charset = info->default_table_charset; + share->comment = info->comment; +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (!part_info) + { +#endif + if (!(spider_share = spider_create_share(table_name, share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + NULL, +#endif +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + hash_value, +#endif + &error_num + ))) { + DBUG_RETURN(error_num); + } + + error_num = spider_discover_table_structure_internal(trx, spider_share, &str); + + spider_free_share_resource_only(spider_share); +#ifdef WITH_PARTITION_STORAGE_ENGINE + } else { + char tmp_name[FN_LEN]; + List_iterator part_it(part_info->partitions); + partition_element *part_elem, *sub_elem; + while ((part_elem = part_it++)) + { + if ((part_elem)->subpartitions.elements) + { + List_iterator sub_it((part_elem)->subpartitions); + while ((sub_elem = sub_it++)) + { + str.length(str_len); + create_subpartition_name(tmp_name, table_name, + (part_elem)->partition_name, (sub_elem)->partition_name, + NORMAL_PART_NAME); + DBUG_PRINT("info",("spider tmp_name=%s", tmp_name)); + if (!(spider_share = spider_create_share(table_name, share, + part_info, +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + hash_value, +#endif + &error_num + ))) { + continue; + } + + error_num = spider_discover_table_structure_internal( + trx, spider_share, &str); + + spider_free_share_resource_only(spider_share); + if (!error_num) + break; + } + if (!error_num) + break; + } else { + str.length(str_len); + create_partition_name(tmp_name, table_name, + (part_elem)->partition_name, NORMAL_PART_NAME, TRUE); + DBUG_PRINT("info",("spider tmp_name=%s", tmp_name)); + if (!(spider_share = spider_create_share(table_name, share, + part_info, +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + hash_value, +#endif + &error_num + ))) { + continue; + } + + error_num = spider_discover_table_structure_internal( + trx, spider_share, &str); + + spider_free_share_resource_only(spider_share); + if (!error_num) + break; + } + } + } +#endif + + if (!error_num) + thd->clear_error(); + else + DBUG_RETURN(error_num); + + str.length(str.length() - SPIDER_SQL_COMMA_LEN); + uint csnamelen = strlen(share->table_charset->csname); + uint collatelen = strlen(share->table_charset->name); + if (str.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_DEFAULT_CHARSET_LEN + + csnamelen + SPIDER_SQL_COLLATE_LEN + collatelen + + SPIDER_SQL_CONNECTION_LEN + SPIDER_SQL_VALUE_QUOTE_LEN + )) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str.q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); + str.q_append(SPIDER_SQL_DEFAULT_CHARSET_STR, SPIDER_SQL_DEFAULT_CHARSET_LEN); + str.q_append(share->table_charset->csname, csnamelen); + str.q_append(SPIDER_SQL_COLLATE_STR, SPIDER_SQL_COLLATE_LEN); + str.q_append(share->table_charset->name, collatelen); + str.q_append(SPIDER_SQL_COMMENT_STR, SPIDER_SQL_COMMENT_LEN); + str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if (str.append_for_single_quote(share->comment.str, share->comment.length)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str.reserve(SPIDER_SQL_CONNECTION_LEN + + (SPIDER_SQL_VALUE_QUOTE_LEN * 2))) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + str.q_append(SPIDER_SQL_CONNECTION_STR, SPIDER_SQL_CONNECTION_LEN); + str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); + if (str.append_for_single_quote(share->connect_string.str, + share->connect_string.length)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str.reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); +#ifdef WITH_PARTITION_STORAGE_ENGINE + DBUG_PRINT("info",("spider part_info=%p", part_info)); + if (part_info) + { + uint part_syntax_len; + char *part_syntax; + List_iterator part_it(part_info->partitions); + partition_element *part_elem, *sub_elem; + while ((part_elem = part_it++)) + { + part_elem->engine_type = hton; + if ((part_elem)->subpartitions.elements) + { + List_iterator sub_it((part_elem)->subpartitions); + while ((sub_elem = sub_it++)) + { + sub_elem->engine_type = hton; + } + } + } + if (part_info->fix_parser_data(thd)) + { + DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); + } +#ifdef SPIDER_GENERATE_PARTITION_SYNTAX_HAS_CURRENT_COMMENT_START + if (!(part_syntax = generate_partition_syntax(part_info, &part_syntax_len, + FALSE, TRUE, info, NULL, NULL))) +#else + if (!(part_syntax = generate_partition_syntax(part_info, &part_syntax_len, + FALSE, TRUE, info, NULL))) +#endif + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (str.reserve(part_syntax_len)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str.q_append(part_syntax, part_syntax_len); + my_free(part_syntax, MYF(0)); + } +#endif + DBUG_PRINT("info",("spider str=%s", str.c_ptr_safe())); + + error_num = share->init_from_sql_statement_string(thd, TRUE, str.ptr(), + str.length()); + DBUG_RETURN(error_num); +} +#endif diff --git a/storage/spider/spd_table.h b/storage/spider/spd_table.h new file mode 100644 index 00000000000..7a0732276dc --- /dev/null +++ b/storage/spider/spd_table.h @@ -0,0 +1,412 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +uchar *spider_tbl_get_key( + SPIDER_SHARE *share, + size_t *length, + my_bool not_used __attribute__ ((unused)) +); + +#ifdef WITH_PARTITION_STORAGE_ENGINE +uchar *spider_pt_share_get_key( + SPIDER_PARTITION_SHARE *share, + size_t *length, + my_bool not_used __attribute__ ((unused)) +); + +uchar *spider_pt_handler_share_get_key( + SPIDER_PARTITION_HANDLER_SHARE *share, + size_t *length, + my_bool not_used __attribute__ ((unused)) +); +#endif + +uchar *spider_link_get_key( + SPIDER_LINK_FOR_HASH *link_for_hash, + size_t *length, + my_bool not_used __attribute__ ((unused)) +); + +uchar *spider_ha_get_key( + ha_spider *spider, + size_t *length, + my_bool not_used __attribute__ ((unused)) +); + +int spider_get_server( + SPIDER_SHARE *share, + int link_idx +); + +int spider_free_share_alloc( + SPIDER_SHARE *share +); + +void spider_free_tmp_share_alloc( + SPIDER_SHARE *share +); + +char *spider_get_string_between_quote( + char *ptr, + bool alloc +); + +int spider_create_string_list( + char ***string_list, + uint **string_length_list, + uint *list_length, + char *str, + uint length +); + +int spider_create_long_list( + long **long_list, + uint *list_length, + char *str, + uint length, + long min_val, + long max_val +); + +int spider_create_longlong_list( + longlong **longlong_list, + uint *list_length, + char *str, + uint length, + longlong min_val, + longlong max_val +); + +int spider_increase_string_list( + char ***string_list, + uint **string_length_list, + uint *list_length, + uint *list_charlen, + uint link_count +); + +int spider_increase_long_list( + long **long_list, + uint *list_length, + uint link_count +); + +int spider_increase_longlong_list( + longlong **longlong_list, + uint *list_length, + uint link_count +); + +int spider_parse_connect_info( + SPIDER_SHARE *share, + TABLE_SHARE *table_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_info *part_info, +#endif + uint create_table +); + +int spider_set_connect_info_default( + SPIDER_SHARE *share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_element *part_elem, + partition_element *sub_elem, +#endif + TABLE_SHARE *table_share +); + +int spider_set_connect_info_default_db_table( + SPIDER_SHARE *share, + const char *db_name, + uint db_name_length, + const char *table_name, + uint table_name_length +); + +int spider_set_connect_info_default_dbtable( + SPIDER_SHARE *share, + const char *dbtable_name, + int dbtable_name_length +); + +#ifndef DBUG_OFF +void spider_print_keys( + const char *key, + uint length +); +#endif + +int spider_create_conn_keys( + SPIDER_SHARE *share +); + +SPIDER_SHARE *spider_create_share( + const char *table_name, + TABLE_SHARE *table_share, +#ifdef WITH_PARTITION_STORAGE_ENGINE + partition_info *part_info, +#endif +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value, +#endif + int *error_num +); + +SPIDER_SHARE *spider_get_share( + const char *table_name, + TABLE *table, + THD *thd, + ha_spider *spider, + int *error_num +); + +void spider_free_share_resource_only( + SPIDER_SHARE *share +); + +int spider_free_share( + SPIDER_SHARE *share +); + +#ifdef WITH_PARTITION_STORAGE_ENGINE +SPIDER_PARTITION_SHARE *spider_get_pt_share( + SPIDER_SHARE *share, + TABLE_SHARE *table_share, + int *error_num +); + +int spider_free_pt_share( + SPIDER_PARTITION_SHARE *partition_share +); + +void spider_copy_sts_to_pt_share( + SPIDER_PARTITION_SHARE *partition_share, + SPIDER_SHARE *share +); + +void spider_copy_sts_to_share( + SPIDER_SHARE *share, + SPIDER_PARTITION_SHARE *partition_share +); + +void spider_copy_crd_to_pt_share( + SPIDER_PARTITION_SHARE *partition_share, + SPIDER_SHARE *share, + int fields +); + +void spider_copy_crd_to_share( + SPIDER_SHARE *share, + SPIDER_PARTITION_SHARE *partition_share, + int fields +); +#endif + +int spider_open_all_tables( + SPIDER_TRX *trx, + bool lock +); + +bool spider_flush_logs( + handlerton *hton +); + +handler* spider_create_handler( + handlerton *hton, + TABLE_SHARE *table, + MEM_ROOT *mem_root +); + +int spider_close_connection( + handlerton* hton, + THD* thd +); + +void spider_drop_database( + handlerton *hton, + char* path +); + +bool spider_show_status( + handlerton *hton, + THD *thd, + stat_print_fn *stat_print, + enum ha_stat_type stat_type +); + +int spider_db_done( + void *p +); + +int spider_panic( + handlerton *hton, + ha_panic_function type +); + +int spider_db_init( + void *p +); + +char *spider_create_table_name_string( + const char *table_name, + const char *part_name, + const char *sub_name +); + +#ifdef WITH_PARTITION_STORAGE_ENGINE +void spider_get_partition_info( + const char *table_name, + uint table_name_length, + const TABLE_SHARE *table_share, + partition_info *part_info, + partition_element **part_elem, + partition_element **sub_elem +); +#endif + +int spider_get_sts( + SPIDER_SHARE *share, + int link_idx, + time_t tmp_time, + ha_spider *spider, + double sts_interval, + int sts_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + int sts_sync, +#endif + int sts_sync_level, + uint flag +); + +int spider_get_crd( + SPIDER_SHARE *share, + int link_idx, + time_t tmp_time, + ha_spider *spider, + TABLE *table, + double crd_interval, + int crd_mode, +#ifdef WITH_PARTITION_STORAGE_ENGINE + int crd_sync, +#endif + int crd_sync_level +); + +void spider_set_result_list_param( + ha_spider *spider +); + +SPIDER_INIT_ERROR_TABLE *spider_get_init_error_table( + SPIDER_TRX *trx, + SPIDER_SHARE *share, + bool create +); + +void spider_delete_init_error_table( + const char *name +); + +bool spider_check_pk_update( + TABLE *table +); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS +bool spider_check_hs_pk_update( + ha_spider *spider, + key_range *key +); +#endif +#endif + +void spider_set_tmp_share_pointer( + SPIDER_SHARE *tmp_share, + char **tmp_connect_info, + uint *tmp_connect_info_length, + long *tmp_long, + longlong *tmp_longlong +); + +int spider_create_tmp_dbton_share( + SPIDER_SHARE *tmp_share +); + +void spider_free_tmp_dbton_share( + SPIDER_SHARE *tmp_share +); + +int spider_create_tmp_dbton_handler( + ha_spider *tmp_spider +); + +void spider_free_tmp_dbton_handler( + ha_spider *tmp_spider +); + +void spider_get_select_limit( + ha_spider *spider, + st_select_lex **select_lex, + longlong *select_limit, + longlong *offset_limit +); + +longlong spider_split_read_param( + ha_spider *spider +); + +longlong spider_bg_split_read_param( + ha_spider *spider +); + +void spider_first_split_read_param( + ha_spider *spider +); + +void spider_next_split_read_param( + ha_spider *spider +); + +bool spider_check_direct_order_limit( + ha_spider *spider +); + +int spider_compare_for_sort( + SPIDER_SORT *a, + SPIDER_SORT *b +); + +ulong spider_calc_for_sort( + uint count, + ... +); + +double spider_rand( + uint32 rand_source +); + +#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE +int spider_discover_table_structure_internal( + SPIDER_TRX *trx, + SPIDER_SHARE *spider_share, + spider_string *str +); + +int spider_discover_table_structure( + handlerton *hton, + THD* thd, + TABLE_SHARE *share, + HA_CREATE_INFO *info +); +#endif diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc new file mode 100644 index 00000000000..4bd1cbcae99 --- /dev/null +++ b/storage/spider/spd_trx.cc @@ -0,0 +1,4049 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#include "sql_partition.h" +#include "records.h" +#endif +#include "spd_err.h" +#include "spd_param.h" +#include "spd_db_include.h" +#include "spd_include.h" +#include "spd_sys_table.h" +#include "ha_spider.h" +#include "spd_trx.h" +#include "spd_db_conn.h" +#include "spd_table.h" +#include "spd_conn.h" +#include "spd_ping_table.h" +#include "spd_malloc.h" + +extern pthread_mutex_t *spd_db_att_LOCK_xid_cache; +extern HASH *spd_db_att_xid_cache; +extern struct charset_info_st *spd_charset_utf8_bin; + +extern handlerton *spider_hton_ptr; +pthread_mutex_t spider_thread_id_mutex; +ulonglong spider_thread_id = 1; + +#ifdef HAVE_PSI_INTERFACE +extern PSI_mutex_key spd_key_mutex_udf_table; +#endif + +extern HASH spider_allocated_thds; +extern uint spider_allocated_thds_id; +extern const char *spider_allocated_thds_func_name; +extern const char *spider_allocated_thds_file_name; +extern ulong spider_allocated_thds_line_no; +extern pthread_mutex_t spider_allocated_thds_mutex; + +// for spider_alter_tables +uchar *spider_alter_tbl_get_key( + SPIDER_ALTER_TABLE *alter_table, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_alter_tbl_get_key"); + *length = alter_table->table_name_length; + DBUG_PRINT("info",("spider table_name_length=%zu", *length)); + DBUG_PRINT("info",("spider table_name=%s", alter_table->table_name)); + DBUG_RETURN((uchar*) alter_table->table_name); +} + +// for SPIDER_TRX_HA +uchar *spider_trx_ha_get_key( + SPIDER_TRX_HA *trx_ha, + size_t *length, + my_bool not_used __attribute__ ((unused)) +) { + DBUG_ENTER("spider_trx_ha_get_key"); + *length = trx_ha->table_name_length; + DBUG_PRINT("info",("spider table_name_length=%zu", *length)); + DBUG_PRINT("info",("spider table_name=%s", trx_ha->table_name)); + DBUG_RETURN((uchar*) trx_ha->table_name); +} + +int spider_free_trx_conn( + SPIDER_TRX *trx, + bool trx_free +) { + int roop_count; + SPIDER_CONN *conn; + DBUG_ENTER("spider_free_trx_conn"); + roop_count = 0; + if ( + trx_free || + spider_param_conn_recycle_mode(trx->thd) != 2 + ) { + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, + roop_count))) + { + spider_conn_clear_queue_at_commit(conn); + if (conn->table_lock) + { + DBUG_ASSERT(!trx_free); + roop_count++; + } else + spider_free_conn_from_trx(trx, conn, FALSE, trx_free, &roop_count); + } + trx->trx_conn_adjustment++; + } else { + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, + roop_count))) + { + spider_conn_clear_queue_at_commit(conn); + if (conn->table_lock) + { + DBUG_ASSERT(!trx_free); + } else + conn->error_mode = 1; + roop_count++; + } + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + roop_count = 0; + if ( + trx_free || + spider_param_hs_r_conn_recycle_mode(trx->thd) != 2 + ) { + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_hs_r_conn_hash, + roop_count))) + { + if (conn->table_lock) + { + DBUG_ASSERT(!trx_free); + roop_count++; + } else + spider_free_conn_from_trx(trx, conn, FALSE, trx_free, &roop_count); + } + trx->trx_hs_r_conn_adjustment++; + } else { + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_hs_r_conn_hash, + roop_count))) + { + if (conn->table_lock) + { + DBUG_ASSERT(!trx_free); + } else + conn->error_mode = 1; + roop_count++; + } + } + roop_count = 0; + if ( + trx_free || + spider_param_hs_w_conn_recycle_mode(trx->thd) != 2 + ) { + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_hs_w_conn_hash, + roop_count))) + { + if (conn->table_lock) + { + DBUG_ASSERT(!trx_free); + roop_count++; + } else + spider_free_conn_from_trx(trx, conn, FALSE, trx_free, &roop_count); + } + trx->trx_hs_w_conn_adjustment++; + } else { + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_hs_w_conn_hash, + roop_count))) + { + if (conn->table_lock) + { + DBUG_ASSERT(!trx_free); + } else + conn->error_mode = 1; + roop_count++; + } + } +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (trx_free) + { + while ((conn = (SPIDER_CONN*) my_hash_element( + &trx->trx_direct_hs_r_conn_hash, 0))) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&trx->trx_direct_hs_r_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&trx->trx_direct_hs_r_conn_hash, (uchar*) conn); +#endif + spider_free_conn(conn); + } + while ((conn = (SPIDER_CONN*) my_hash_element( + &trx->trx_direct_hs_w_conn_hash, 0))) + { +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&trx->trx_direct_hs_w_conn_hash, + conn->conn_key_hash_value, (uchar*) conn); +#else + my_hash_delete(&trx->trx_direct_hs_w_conn_hash, (uchar*) conn); +#endif + spider_free_conn(conn); + } + } +#endif + DBUG_RETURN(0); +} + +int spider_free_trx_another_conn( + SPIDER_TRX *trx, + bool lock +) { + int error_num, tmp_error_num; + int roop_count = 0, need_mon = 0; + SPIDER_CONN *conn; + ha_spider tmp_spider; + DBUG_ENTER("spider_free_trx_another_conn"); + tmp_spider.conns = &conn; + tmp_spider.need_mons = &need_mon; + error_num = 0; + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_another_conn_hash, + roop_count))) + { + tmp_spider.trx = trx; + if (lock && (tmp_error_num = spider_db_unlock_tables(&tmp_spider, 0))) + error_num = tmp_error_num; + spider_free_conn_from_trx(trx, conn, TRUE, TRUE, &roop_count); + } + DBUG_RETURN(error_num); +} + +int spider_trx_another_lock_tables( + SPIDER_TRX *trx +) { + int error_num; + int roop_count = 0, need_mon = 0; + THD *thd = trx->thd; + SPIDER_CONN *conn; + ha_spider tmp_spider; + SPIDER_SHARE tmp_share; + char sql_buf[MAX_FIELD_WIDTH]; + spider_string sql_str(sql_buf, sizeof(sql_buf), system_charset_info); + DBUG_ENTER("spider_trx_another_lock_tables"); + SPIDER_BACKUP_DASTATUS; + sql_str.init_calc_mem(188); + sql_str.length(0); + memset(&tmp_spider, 0, sizeof(ha_spider)); + memset(&tmp_share, 0, sizeof(SPIDER_SHARE)); + tmp_spider.share = &tmp_share; + tmp_spider.trx = trx; + tmp_share.access_charset = system_charset_info; +/* + if ((error_num = spider_db_append_set_names(&tmp_share))) + DBUG_RETURN(error_num); +*/ + tmp_spider.conns = &conn; + tmp_spider.result_list.sqls = &sql_str; + tmp_spider.need_mons = &need_mon; + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_another_conn_hash, + roop_count))) + { + if ((error_num = spider_db_lock_tables(&tmp_spider, 0))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + { +/* + spider_db_free_set_names(&tmp_share); +*/ + DBUG_RETURN(error_num); + } + } + roop_count++; + } +/* + spider_db_free_set_names(&tmp_share); +*/ + DBUG_RETURN(0); +} + +int spider_trx_another_flush_tables( + SPIDER_TRX *trx +) { + int error_num; + int roop_count = 0, need_mon = 0; + THD *thd = trx->thd; + SPIDER_CONN *conn; + ha_spider tmp_spider; + SPIDER_SHARE tmp_share; + long tmp_link_statuses = SPIDER_LINK_STATUS_OK; + DBUG_ENTER("spider_trx_another_flush_tables"); + SPIDER_BACKUP_DASTATUS; + memset(&tmp_spider, 0, sizeof(ha_spider)); + tmp_share.link_count = 1; + tmp_share.all_link_count = 1; + tmp_share.link_statuses = &tmp_link_statuses; + tmp_share.link_statuses_length = 1; + tmp_spider.share = &tmp_share; + tmp_spider.conns = &conn; + tmp_spider.need_mons = &need_mon; + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_another_conn_hash, + roop_count))) + { + if ((error_num = spider_db_flush_tables(&tmp_spider, FALSE))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + DBUG_RETURN(error_num); + } + roop_count++; + } + DBUG_RETURN(0); +} + +int spider_trx_all_flush_tables( + SPIDER_TRX *trx +) { + int error_num; + int roop_count = 0, need_mon = 0; + THD *thd = trx->thd; + SPIDER_CONN *conn; + ha_spider tmp_spider; + SPIDER_SHARE tmp_share; + long tmp_link_statuses = SPIDER_LINK_STATUS_OK; + DBUG_ENTER("spider_trx_all_flush_tables"); + SPIDER_BACKUP_DASTATUS; + memset(&tmp_spider, 0, sizeof(ha_spider)); + tmp_share.link_count = 1; + tmp_share.all_link_count = 1; + tmp_share.link_statuses = &tmp_link_statuses; + tmp_share.link_statuses_length = 1; + tmp_spider.share = &tmp_share; + tmp_spider.conns = &conn; + tmp_spider.need_mons = &need_mon; + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, + roop_count))) + { + if ((error_num = spider_db_flush_tables(&tmp_spider, TRUE))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + DBUG_RETURN(error_num); + } + roop_count++; + } + DBUG_RETURN(0); +} + +int spider_trx_all_unlock_tables( + SPIDER_TRX *trx +) { + int error_num; + int roop_count = 0, need_mon = 0; + THD *thd = trx->thd; + SPIDER_CONN *conn; + ha_spider tmp_spider; + DBUG_ENTER("spider_trx_all_unlock_tables"); + SPIDER_BACKUP_DASTATUS; + memset(&tmp_spider, 0, sizeof(ha_spider)); + tmp_spider.conns = &conn; + tmp_spider.need_mons = &need_mon; + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, + roop_count))) + { + tmp_spider.trx = trx; + if ((error_num = spider_db_unlock_tables(&tmp_spider, 0))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + DBUG_RETURN(error_num); + } + roop_count++; + } + DBUG_RETURN(0); +} + +int spider_trx_all_start_trx( + SPIDER_TRX *trx +) { + int error_num, need_mon = 0; + int roop_count = 0; + THD *thd = trx->thd; + SPIDER_CONN *conn; + ha_spider tmp_spider; + DBUG_ENTER("spider_trx_all_start_trx"); + SPIDER_BACKUP_DASTATUS; + memset(&tmp_spider, 0, sizeof(ha_spider)); + tmp_spider.trx = trx; + tmp_spider.need_mons = &need_mon; + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, + roop_count))) + { + if ( + (spider_param_sync_trx_isolation(trx->thd) && + (error_num = spider_check_and_set_trx_isolation(conn, &need_mon))) || + (error_num = spider_internal_start_trx(&tmp_spider, conn, 0)) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + DBUG_RETURN(error_num); + } + roop_count++; + } + DBUG_RETURN(0); +} + +int spider_trx_all_flush_logs( + SPIDER_TRX *trx +) { + int error_num; + int roop_count = 0, need_mon = 0; + THD *thd = trx->thd; + SPIDER_CONN *conn; + ha_spider tmp_spider; + SPIDER_SHARE tmp_share; + long tmp_link_statuses = SPIDER_LINK_STATUS_OK; + uint conn_link_idx = 0; + long net_read_timeout = 600; + long net_write_timeout = 600; + DBUG_ENTER("spider_trx_all_flush_logs"); + SPIDER_BACKUP_DASTATUS; + memset(&tmp_spider, 0, sizeof(ha_spider)); + tmp_share.link_count = 1; + tmp_share.all_link_count = 1; + tmp_share.link_statuses = &tmp_link_statuses; + tmp_share.link_statuses_length = 1; + tmp_share.net_read_timeouts = &net_read_timeout; + tmp_share.net_read_timeouts_length = 1; + tmp_share.net_write_timeouts = &net_write_timeout; + tmp_share.net_write_timeouts_length = 1; + tmp_spider.share = &tmp_share; + tmp_spider.conns = &conn; + tmp_spider.need_mons = &need_mon; + tmp_spider.conn_link_idx = &conn_link_idx; + tmp_spider.trx = trx; + while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash, + roop_count))) + { + if ((error_num = spider_db_flush_logs(&tmp_spider))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + DBUG_RETURN(error_num); + } + roop_count++; + } + DBUG_RETURN(0); +} + +void spider_free_trx_alter_table_alloc( + SPIDER_TRX *trx, + SPIDER_ALTER_TABLE *alter_table +) { + DBUG_ENTER("spider_free_trx_alter_table_alloc"); +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&trx->trx_alter_table_hash, + alter_table->table_name_hash_value, (uchar*) alter_table); +#else + my_hash_delete(&trx->trx_alter_table_hash, (uchar*) alter_table); +#endif + if (alter_table->tmp_char) + spider_free(trx, alter_table->tmp_char, MYF(0)); + spider_free(trx, alter_table, MYF(0)); + DBUG_VOID_RETURN; +} + +int spider_free_trx_alter_table( + SPIDER_TRX *trx +) { + SPIDER_ALTER_TABLE *alter_table; + DBUG_ENTER("spider_free_trx_alter_table"); + while ((alter_table = + (SPIDER_ALTER_TABLE*) my_hash_element(&trx->trx_alter_table_hash, 0))) + { + spider_free_trx_alter_table_alloc(trx, alter_table); + } + DBUG_RETURN(0); +} + +int spider_create_trx_alter_table( + SPIDER_TRX *trx, + SPIDER_SHARE *share, + bool now_create +) { + int error_num, roop_count; + SPIDER_ALTER_TABLE *alter_table, *share_alter; + char *tmp_name; + char **tmp_server_names; + char **tmp_tgt_table_names; + char **tmp_tgt_dbs; + char **tmp_tgt_hosts; + char **tmp_tgt_usernames; + char **tmp_tgt_passwords; + char **tmp_tgt_sockets; + char **tmp_tgt_wrappers; + char **tmp_tgt_ssl_cas; + char **tmp_tgt_ssl_capaths; + char **tmp_tgt_ssl_certs; + char **tmp_tgt_ssl_ciphers; + char **tmp_tgt_ssl_keys; + char **tmp_tgt_default_files; + char **tmp_tgt_default_groups; + uint *tmp_server_names_lengths; + uint *tmp_tgt_table_names_lengths; + uint *tmp_tgt_dbs_lengths; + uint *tmp_tgt_hosts_lengths; + uint *tmp_tgt_usernames_lengths; + uint *tmp_tgt_passwords_lengths; + uint *tmp_tgt_sockets_lengths; + uint *tmp_tgt_wrappers_lengths; + uint *tmp_tgt_ssl_cas_lengths; + uint *tmp_tgt_ssl_capaths_lengths; + uint *tmp_tgt_ssl_certs_lengths; + uint *tmp_tgt_ssl_ciphers_lengths; + uint *tmp_tgt_ssl_keys_lengths; + uint *tmp_tgt_default_files_lengths; + uint *tmp_tgt_default_groups_lengths; + long *tmp_tgt_ports; + long *tmp_tgt_ssl_vscs; + long *tmp_link_statuses; + char *tmp_server_names_char; + char *tmp_tgt_table_names_char; + char *tmp_tgt_dbs_char; + char *tmp_tgt_hosts_char; + char *tmp_tgt_usernames_char; + char *tmp_tgt_passwords_char; + char *tmp_tgt_sockets_char; + char *tmp_tgt_wrappers_char; + char *tmp_tgt_ssl_cas_char; + char *tmp_tgt_ssl_capaths_char; + char *tmp_tgt_ssl_certs_char; + char *tmp_tgt_ssl_ciphers_char; + char *tmp_tgt_ssl_keys_char; + char *tmp_tgt_default_files_char; + char *tmp_tgt_default_groups_char; + uint old_elements; + + DBUG_ENTER("spider_create_trx_alter_table"); + share_alter = &share->alter_table; + + if (!(alter_table = (SPIDER_ALTER_TABLE *) + spider_bulk_malloc(spider_current_trx, 55, MYF(MY_WME | MY_ZEROFILL), + &alter_table, sizeof(*alter_table), + &tmp_name, sizeof(char) * (share->table_name_length + 1), + + &tmp_server_names, sizeof(char *) * share->all_link_count, + &tmp_tgt_table_names, sizeof(char *) * share->all_link_count, + &tmp_tgt_dbs, sizeof(char *) * share->all_link_count, + &tmp_tgt_hosts, sizeof(char *) * share->all_link_count, + &tmp_tgt_usernames, sizeof(char *) * share->all_link_count, + &tmp_tgt_passwords, sizeof(char *) * share->all_link_count, + &tmp_tgt_sockets, sizeof(char *) * share->all_link_count, + &tmp_tgt_wrappers, sizeof(char *) * share->all_link_count, + &tmp_tgt_ssl_cas, sizeof(char *) * share->all_link_count, + &tmp_tgt_ssl_capaths, sizeof(char *) * share->all_link_count, + &tmp_tgt_ssl_certs, sizeof(char *) * share->all_link_count, + &tmp_tgt_ssl_ciphers, sizeof(char *) * share->all_link_count, + &tmp_tgt_ssl_keys, sizeof(char *) * share->all_link_count, + &tmp_tgt_default_files, sizeof(char *) * share->all_link_count, + &tmp_tgt_default_groups, sizeof(char *) * share->all_link_count, + + &tmp_server_names_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_table_names_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_dbs_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_hosts_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_usernames_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_passwords_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_sockets_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_wrappers_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_ssl_cas_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_ssl_capaths_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_ssl_certs_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_ssl_ciphers_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_ssl_keys_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_default_files_lengths, sizeof(uint) * share->all_link_count, + &tmp_tgt_default_groups_lengths, sizeof(uint) * share->all_link_count, + + &tmp_tgt_ports, sizeof(long) * share->all_link_count, + &tmp_tgt_ssl_vscs, sizeof(long) * share->all_link_count, + &tmp_link_statuses, sizeof(long) * share->all_link_count, + + &tmp_server_names_char, sizeof(char) * + (share_alter->tmp_server_names_charlen + 1), + &tmp_tgt_table_names_char, sizeof(char) * + (share_alter->tmp_tgt_table_names_charlen + 1), + &tmp_tgt_dbs_char, sizeof(char) * + (share_alter->tmp_tgt_dbs_charlen + 1), + &tmp_tgt_hosts_char, sizeof(char) * + (share_alter->tmp_tgt_hosts_charlen + 1), + &tmp_tgt_usernames_char, sizeof(char) * + (share_alter->tmp_tgt_usernames_charlen + 1), + &tmp_tgt_passwords_char, sizeof(char) * + (share_alter->tmp_tgt_passwords_charlen + 1), + &tmp_tgt_sockets_char, sizeof(char) * + (share_alter->tmp_tgt_sockets_charlen + 1), + &tmp_tgt_wrappers_char, sizeof(char) * + (share_alter->tmp_tgt_wrappers_charlen + 1), + &tmp_tgt_ssl_cas_char, sizeof(char) * + (share_alter->tmp_tgt_ssl_cas_charlen + 1), + &tmp_tgt_ssl_capaths_char, sizeof(char) * + (share_alter->tmp_tgt_ssl_capaths_charlen + 1), + &tmp_tgt_ssl_certs_char, sizeof(char) * + (share_alter->tmp_tgt_ssl_certs_charlen + 1), + &tmp_tgt_ssl_ciphers_char, sizeof(char) * + (share_alter->tmp_tgt_ssl_ciphers_charlen + 1), + &tmp_tgt_ssl_keys_char, sizeof(char) * + (share_alter->tmp_tgt_ssl_keys_charlen + 1), + &tmp_tgt_default_files_char, sizeof(char) * + (share_alter->tmp_tgt_default_files_charlen + 1), + &tmp_tgt_default_groups_char, sizeof(char) * + (share_alter->tmp_tgt_default_groups_charlen + 1), + NullS)) + ) { + error_num = HA_ERR_OUT_OF_MEM; + goto error_alloc_alter_table; + } + alter_table->now_create = now_create; + alter_table->table_name = tmp_name; + memcpy(alter_table->table_name, share->table_name, share->table_name_length); + alter_table->table_name_length = share->table_name_length; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + DBUG_PRINT("info",("spider table_name_hash_value=%u", + share->table_name_hash_value)); + alter_table->table_name_hash_value = share->table_name_hash_value; +#endif + alter_table->tmp_priority = share->priority; + alter_table->link_count = share->link_count; + alter_table->all_link_count = share->all_link_count; + + alter_table->tmp_server_names = tmp_server_names; + alter_table->tmp_tgt_table_names = tmp_tgt_table_names; + alter_table->tmp_tgt_dbs = tmp_tgt_dbs; + alter_table->tmp_tgt_hosts = tmp_tgt_hosts; + alter_table->tmp_tgt_usernames = tmp_tgt_usernames; + alter_table->tmp_tgt_passwords = tmp_tgt_passwords; + alter_table->tmp_tgt_sockets = tmp_tgt_sockets; + alter_table->tmp_tgt_wrappers = tmp_tgt_wrappers; + alter_table->tmp_tgt_ssl_cas = tmp_tgt_ssl_cas; + alter_table->tmp_tgt_ssl_capaths = tmp_tgt_ssl_capaths; + alter_table->tmp_tgt_ssl_certs = tmp_tgt_ssl_certs; + alter_table->tmp_tgt_ssl_ciphers = tmp_tgt_ssl_ciphers; + alter_table->tmp_tgt_ssl_keys = tmp_tgt_ssl_keys; + alter_table->tmp_tgt_default_files = tmp_tgt_default_files; + alter_table->tmp_tgt_default_groups = tmp_tgt_default_groups; + + alter_table->tmp_tgt_ports = tmp_tgt_ports; + alter_table->tmp_tgt_ssl_vscs = tmp_tgt_ssl_vscs; + alter_table->tmp_link_statuses = tmp_link_statuses; + + alter_table->tmp_server_names_lengths = tmp_server_names_lengths; + alter_table->tmp_tgt_table_names_lengths = tmp_tgt_table_names_lengths; + alter_table->tmp_tgt_dbs_lengths = tmp_tgt_dbs_lengths; + alter_table->tmp_tgt_hosts_lengths = tmp_tgt_hosts_lengths; + alter_table->tmp_tgt_usernames_lengths = tmp_tgt_usernames_lengths; + alter_table->tmp_tgt_passwords_lengths = tmp_tgt_passwords_lengths; + alter_table->tmp_tgt_sockets_lengths = tmp_tgt_sockets_lengths; + alter_table->tmp_tgt_wrappers_lengths = tmp_tgt_wrappers_lengths; + alter_table->tmp_tgt_ssl_cas_lengths = tmp_tgt_ssl_cas_lengths; + alter_table->tmp_tgt_ssl_capaths_lengths = tmp_tgt_ssl_capaths_lengths; + alter_table->tmp_tgt_ssl_certs_lengths = tmp_tgt_ssl_certs_lengths; + alter_table->tmp_tgt_ssl_ciphers_lengths = tmp_tgt_ssl_ciphers_lengths; + alter_table->tmp_tgt_ssl_keys_lengths = tmp_tgt_ssl_keys_lengths; + alter_table->tmp_tgt_default_files_lengths = tmp_tgt_default_files_lengths; + alter_table->tmp_tgt_default_groups_lengths = tmp_tgt_default_groups_lengths; + + for(roop_count = 0; roop_count < (int) share->all_link_count; roop_count++) + { + tmp_server_names[roop_count] = tmp_server_names_char; + memcpy(tmp_server_names_char, + share_alter->tmp_server_names[roop_count], + sizeof(char) * share_alter->tmp_server_names_lengths[roop_count]); + tmp_server_names_char += + share_alter->tmp_server_names_lengths[roop_count] + 1; + + tmp_tgt_table_names[roop_count] = tmp_tgt_table_names_char; + memcpy(tmp_tgt_table_names_char, + share_alter->tmp_tgt_table_names[roop_count], + sizeof(char) * share_alter->tmp_tgt_table_names_lengths[roop_count]); + tmp_tgt_table_names_char += + share_alter->tmp_tgt_table_names_lengths[roop_count] + 1; + + tmp_tgt_dbs[roop_count] = tmp_tgt_dbs_char; + memcpy(tmp_tgt_dbs_char, share_alter->tmp_tgt_dbs[roop_count], + sizeof(char) * share_alter->tmp_tgt_dbs_lengths[roop_count]); + tmp_tgt_dbs_char += + share_alter->tmp_tgt_dbs_lengths[roop_count] + 1; + + tmp_tgt_hosts[roop_count] = tmp_tgt_hosts_char; + memcpy(tmp_tgt_hosts_char, share_alter->tmp_tgt_hosts[roop_count], + sizeof(char) * share_alter->tmp_tgt_hosts_lengths[roop_count]); + tmp_tgt_hosts_char += + share_alter->tmp_tgt_hosts_lengths[roop_count] + 1; + + tmp_tgt_usernames[roop_count] = tmp_tgt_usernames_char; + memcpy(tmp_tgt_usernames_char, share_alter->tmp_tgt_usernames[roop_count], + sizeof(char) * share_alter->tmp_tgt_usernames_lengths[roop_count]); + tmp_tgt_usernames_char += + share_alter->tmp_tgt_usernames_lengths[roop_count] + 1; + + tmp_tgt_passwords[roop_count] = tmp_tgt_passwords_char; + memcpy(tmp_tgt_passwords_char, share_alter->tmp_tgt_passwords[roop_count], + sizeof(char) * share_alter->tmp_tgt_passwords_lengths[roop_count]); + tmp_tgt_passwords_char += + share_alter->tmp_tgt_passwords_lengths[roop_count] + 1; + + tmp_tgt_sockets[roop_count] = tmp_tgt_sockets_char; + memcpy(tmp_tgt_sockets_char, share_alter->tmp_tgt_sockets[roop_count], + sizeof(char) * share_alter->tmp_tgt_sockets_lengths[roop_count]); + tmp_tgt_sockets_char += + share_alter->tmp_tgt_sockets_lengths[roop_count] + 1; + + tmp_tgt_wrappers[roop_count] = tmp_tgt_wrappers_char; + memcpy(tmp_tgt_wrappers_char, share_alter->tmp_tgt_wrappers[roop_count], + sizeof(char) * share_alter->tmp_tgt_wrappers_lengths[roop_count]); + tmp_tgt_wrappers_char += + share_alter->tmp_tgt_wrappers_lengths[roop_count] + 1; + + tmp_tgt_ssl_cas[roop_count] = tmp_tgt_ssl_cas_char; + memcpy(tmp_tgt_ssl_cas_char, share_alter->tmp_tgt_ssl_cas[roop_count], + sizeof(char) * share_alter->tmp_tgt_ssl_cas_lengths[roop_count]); + tmp_tgt_ssl_cas_char += + share_alter->tmp_tgt_ssl_cas_lengths[roop_count] + 1; + + tmp_tgt_ssl_capaths[roop_count] = tmp_tgt_ssl_capaths_char; + memcpy(tmp_tgt_ssl_capaths_char, + share_alter->tmp_tgt_ssl_capaths[roop_count], + sizeof(char) * share_alter->tmp_tgt_ssl_capaths_lengths[roop_count]); + tmp_tgt_ssl_capaths_char += + share_alter->tmp_tgt_ssl_capaths_lengths[roop_count] + 1; + + tmp_tgt_ssl_certs[roop_count] = tmp_tgt_ssl_certs_char; + memcpy(tmp_tgt_ssl_certs_char, share_alter->tmp_tgt_ssl_certs[roop_count], + sizeof(char) * share_alter->tmp_tgt_ssl_certs_lengths[roop_count]); + tmp_tgt_ssl_certs_char += + share_alter->tmp_tgt_ssl_certs_lengths[roop_count] + 1; + + tmp_tgt_ssl_ciphers[roop_count] = tmp_tgt_ssl_ciphers_char; + memcpy(tmp_tgt_ssl_ciphers_char, + share_alter->tmp_tgt_ssl_ciphers[roop_count], + sizeof(char) * share_alter->tmp_tgt_ssl_ciphers_lengths[roop_count]); + tmp_tgt_ssl_ciphers_char += + share_alter->tmp_tgt_ssl_ciphers_lengths[roop_count] + 1; + + tmp_tgt_ssl_keys[roop_count] = tmp_tgt_ssl_keys_char; + memcpy(tmp_tgt_ssl_keys_char, share_alter->tmp_tgt_ssl_keys[roop_count], + sizeof(char) * share_alter->tmp_tgt_ssl_keys_lengths[roop_count]); + tmp_tgt_ssl_keys_char += + share_alter->tmp_tgt_ssl_keys_lengths[roop_count] + 1; + + tmp_tgt_default_files[roop_count] = tmp_tgt_default_files_char; + memcpy(tmp_tgt_default_files_char, + share_alter->tmp_tgt_default_files[roop_count], + sizeof(char) * share_alter->tmp_tgt_default_files_lengths[roop_count]); + tmp_tgt_default_files_char += + share_alter->tmp_tgt_default_files_lengths[roop_count] + 1; + + tmp_tgt_default_groups[roop_count] = tmp_tgt_default_groups_char; + memcpy(tmp_tgt_default_groups_char, + share_alter->tmp_tgt_default_groups[roop_count], + sizeof(char) * share_alter->tmp_tgt_default_groups_lengths[roop_count]); + tmp_tgt_default_groups_char += + share_alter->tmp_tgt_default_groups_lengths[roop_count] + 1; + } + + memcpy(tmp_tgt_ports, share_alter->tmp_tgt_ports, + sizeof(long) * share->all_link_count); + memcpy(tmp_tgt_ssl_vscs, share_alter->tmp_tgt_ssl_vscs, + sizeof(long) * share->all_link_count); + memcpy(tmp_link_statuses, share_alter->tmp_link_statuses, + sizeof(long) * share->all_link_count); + + memcpy(tmp_server_names_lengths, share_alter->tmp_server_names_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_table_names_lengths, share_alter->tmp_tgt_table_names_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_dbs_lengths, share_alter->tmp_tgt_dbs_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_hosts_lengths, share_alter->tmp_tgt_hosts_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_usernames_lengths, share_alter->tmp_tgt_usernames_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_passwords_lengths, share_alter->tmp_tgt_passwords_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_sockets_lengths, share_alter->tmp_tgt_sockets_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_wrappers_lengths, share_alter->tmp_tgt_wrappers_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_ssl_cas_lengths, share_alter->tmp_tgt_ssl_cas_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_ssl_capaths_lengths, share_alter->tmp_tgt_ssl_capaths_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_ssl_certs_lengths, share_alter->tmp_tgt_ssl_certs_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_ssl_ciphers_lengths, share_alter->tmp_tgt_ssl_ciphers_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_ssl_keys_lengths, share_alter->tmp_tgt_ssl_keys_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_default_files_lengths, + share_alter->tmp_tgt_default_files_lengths, + sizeof(uint) * share->all_link_count); + memcpy(tmp_tgt_default_groups_lengths, + share_alter->tmp_tgt_default_groups_lengths, + sizeof(uint) * share->all_link_count); + + alter_table->tmp_server_names_length = + share_alter->tmp_server_names_length; + alter_table->tmp_tgt_table_names_length = + share_alter->tmp_tgt_table_names_length; + alter_table->tmp_tgt_dbs_length = + share_alter->tmp_tgt_dbs_length; + alter_table->tmp_tgt_hosts_length = + share_alter->tmp_tgt_hosts_length; + alter_table->tmp_tgt_usernames_length = + share_alter->tmp_tgt_usernames_length; + alter_table->tmp_tgt_passwords_length = + share_alter->tmp_tgt_passwords_length; + alter_table->tmp_tgt_sockets_length = + share_alter->tmp_tgt_sockets_length; + alter_table->tmp_tgt_wrappers_length = + share_alter->tmp_tgt_wrappers_length; + alter_table->tmp_tgt_ssl_cas_length = + share_alter->tmp_tgt_ssl_cas_length; + alter_table->tmp_tgt_ssl_capaths_length = + share_alter->tmp_tgt_ssl_capaths_length; + alter_table->tmp_tgt_ssl_certs_length = + share_alter->tmp_tgt_ssl_certs_length; + alter_table->tmp_tgt_ssl_ciphers_length = + share_alter->tmp_tgt_ssl_ciphers_length; + alter_table->tmp_tgt_ssl_keys_length = + share_alter->tmp_tgt_ssl_keys_length; + alter_table->tmp_tgt_default_files_length = + share_alter->tmp_tgt_default_files_length; + alter_table->tmp_tgt_default_groups_length = + share_alter->tmp_tgt_default_groups_length; + alter_table->tmp_tgt_ports_length = + share_alter->tmp_tgt_ports_length; + alter_table->tmp_tgt_ssl_vscs_length = + share_alter->tmp_tgt_ssl_vscs_length; + alter_table->tmp_link_statuses_length = + share_alter->tmp_link_statuses_length; + + old_elements = trx->trx_alter_table_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_alter_table_hash, + alter_table->table_name_hash_value, (uchar*) alter_table)) +#else + if (my_hash_insert(&trx->trx_alter_table_hash, (uchar*) alter_table)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (trx->trx_alter_table_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_alter_table_hash, + (trx->trx_alter_table_hash.array.max_element - old_elements) * + trx->trx_alter_table_hash.array.size_of_element); + } + DBUG_RETURN(0); + +error: + spider_free(trx, alter_table, MYF(0)); +error_alloc_alter_table: + DBUG_RETURN(error_num); +} + +bool spider_cmp_trx_alter_table( + SPIDER_ALTER_TABLE *cmp1, + SPIDER_ALTER_TABLE *cmp2 +) { + int roop_count; + DBUG_ENTER("spider_cmp_trx_alter_table"); + if ( + cmp1->tmp_priority != cmp2->tmp_priority || + cmp1->link_count != cmp2->link_count || + cmp1->all_link_count != cmp2->all_link_count + ) + DBUG_RETURN(TRUE); + + for (roop_count = 0; roop_count < (int) cmp1->all_link_count; roop_count++) + { + if ( + ( + cmp1->tmp_server_names[roop_count] != + cmp2->tmp_server_names[roop_count] && + ( + !cmp1->tmp_server_names[roop_count] || + !cmp2->tmp_server_names[roop_count] || + strcmp(cmp1->tmp_server_names[roop_count], + cmp2->tmp_server_names[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_table_names[roop_count] != + cmp2->tmp_tgt_table_names[roop_count] && + ( + !cmp1->tmp_tgt_table_names[roop_count] || + !cmp2->tmp_tgt_table_names[roop_count] || + strcmp(cmp1->tmp_tgt_table_names[roop_count], + cmp2->tmp_tgt_table_names[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_dbs[roop_count] != + cmp2->tmp_tgt_dbs[roop_count] && + ( + !cmp1->tmp_tgt_dbs[roop_count] || + !cmp2->tmp_tgt_dbs[roop_count] || + strcmp(cmp1->tmp_tgt_dbs[roop_count], + cmp2->tmp_tgt_dbs[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_hosts[roop_count] != + cmp2->tmp_tgt_hosts[roop_count] && + ( + !cmp1->tmp_tgt_hosts[roop_count] || + !cmp2->tmp_tgt_hosts[roop_count] || + strcmp(cmp1->tmp_tgt_hosts[roop_count], + cmp2->tmp_tgt_hosts[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_usernames[roop_count] != + cmp2->tmp_tgt_usernames[roop_count] && + ( + !cmp1->tmp_tgt_usernames[roop_count] || + !cmp2->tmp_tgt_usernames[roop_count] || + strcmp(cmp1->tmp_tgt_usernames[roop_count], + cmp2->tmp_tgt_usernames[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_passwords[roop_count] != + cmp2->tmp_tgt_passwords[roop_count] && + ( + !cmp1->tmp_tgt_passwords[roop_count] || + !cmp2->tmp_tgt_passwords[roop_count] || + strcmp(cmp1->tmp_tgt_passwords[roop_count], + cmp2->tmp_tgt_passwords[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_sockets[roop_count] != + cmp2->tmp_tgt_sockets[roop_count] && + ( + !cmp1->tmp_tgt_sockets[roop_count] || + !cmp2->tmp_tgt_sockets[roop_count] || + strcmp(cmp1->tmp_tgt_sockets[roop_count], + cmp2->tmp_tgt_sockets[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_wrappers[roop_count] != + cmp2->tmp_tgt_wrappers[roop_count] && + ( + !cmp1->tmp_tgt_wrappers[roop_count] || + !cmp2->tmp_tgt_wrappers[roop_count] || + strcmp(cmp1->tmp_tgt_wrappers[roop_count], + cmp2->tmp_tgt_wrappers[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_ssl_cas[roop_count] != + cmp2->tmp_tgt_ssl_cas[roop_count] && + ( + !cmp1->tmp_tgt_ssl_cas[roop_count] || + !cmp2->tmp_tgt_ssl_cas[roop_count] || + strcmp(cmp1->tmp_tgt_ssl_cas[roop_count], + cmp2->tmp_tgt_ssl_cas[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_ssl_capaths[roop_count] != + cmp2->tmp_tgt_ssl_capaths[roop_count] && + ( + !cmp1->tmp_tgt_ssl_capaths[roop_count] || + !cmp2->tmp_tgt_ssl_capaths[roop_count] || + strcmp(cmp1->tmp_tgt_ssl_capaths[roop_count], + cmp2->tmp_tgt_ssl_capaths[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_ssl_certs[roop_count] != + cmp2->tmp_tgt_ssl_certs[roop_count] && + ( + !cmp1->tmp_tgt_ssl_certs[roop_count] || + !cmp2->tmp_tgt_ssl_certs[roop_count] || + strcmp(cmp1->tmp_tgt_ssl_certs[roop_count], + cmp2->tmp_tgt_ssl_certs[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_ssl_ciphers[roop_count] != + cmp2->tmp_tgt_ssl_ciphers[roop_count] && + ( + !cmp1->tmp_tgt_ssl_ciphers[roop_count] || + !cmp2->tmp_tgt_ssl_ciphers[roop_count] || + strcmp(cmp1->tmp_tgt_ssl_ciphers[roop_count], + cmp2->tmp_tgt_ssl_ciphers[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_ssl_keys[roop_count] != + cmp2->tmp_tgt_ssl_keys[roop_count] && + ( + !cmp1->tmp_tgt_ssl_keys[roop_count] || + !cmp2->tmp_tgt_ssl_keys[roop_count] || + strcmp(cmp1->tmp_tgt_ssl_keys[roop_count], + cmp2->tmp_tgt_ssl_keys[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_default_files[roop_count] != + cmp2->tmp_tgt_default_files[roop_count] && + ( + !cmp1->tmp_tgt_default_files[roop_count] || + !cmp2->tmp_tgt_default_files[roop_count] || + strcmp(cmp1->tmp_tgt_default_files[roop_count], + cmp2->tmp_tgt_default_files[roop_count]) + ) + ) || + ( + cmp1->tmp_tgt_default_groups[roop_count] != + cmp2->tmp_tgt_default_groups[roop_count] && + ( + !cmp1->tmp_tgt_default_groups[roop_count] || + !cmp2->tmp_tgt_default_groups[roop_count] || + strcmp(cmp1->tmp_tgt_default_groups[roop_count], + cmp2->tmp_tgt_default_groups[roop_count]) + ) + ) || + cmp1->tmp_tgt_ports[roop_count] != cmp2->tmp_tgt_ports[roop_count] || + cmp1->tmp_tgt_ssl_vscs[roop_count] != + cmp2->tmp_tgt_ssl_vscs[roop_count] || + cmp1->tmp_link_statuses[roop_count] != + cmp2->tmp_link_statuses[roop_count] + ) + DBUG_RETURN(TRUE); + } + DBUG_RETURN(FALSE); +} + +int spider_free_trx_alloc( + SPIDER_TRX *trx +) { + int roop_count; + DBUG_ENTER("spider_free_trx_alloc"); + spider_db_udf_free_set_names(trx); + for (roop_count = spider_param_udf_table_lock_mutex_count() - 1; + roop_count >= 0; roop_count--) + pthread_mutex_destroy(&trx->udf_table_mutexes[roop_count]); + spider_free_trx_ha(trx); + spider_free_trx_conn(trx, TRUE); + spider_free_trx_alter_table(trx); + spider_free_mem_calc(spider_current_trx, + trx->trx_conn_hash_id, + trx->trx_conn_hash.array.max_element * + trx->trx_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_conn_hash); + spider_free_mem_calc(spider_current_trx, + trx->trx_another_conn_hash_id, + trx->trx_another_conn_hash.array.max_element * + trx->trx_another_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_another_conn_hash); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider_free_mem_calc(spider_current_trx, + trx->trx_direct_hs_r_conn_hash_id, + trx->trx_direct_hs_r_conn_hash.array.max_element * + trx->trx_direct_hs_r_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_direct_hs_r_conn_hash); + spider_free_mem_calc(spider_current_trx, + trx->trx_direct_hs_w_conn_hash_id, + trx->trx_direct_hs_w_conn_hash.array.max_element * + trx->trx_direct_hs_w_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_direct_hs_w_conn_hash); +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider_free_mem_calc(spider_current_trx, + trx->trx_hs_r_conn_hash_id, + trx->trx_hs_r_conn_hash.array.max_element * + trx->trx_hs_r_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_hs_r_conn_hash); + spider_free_mem_calc(spider_current_trx, + trx->trx_hs_w_conn_hash_id, + trx->trx_hs_w_conn_hash.array.max_element * + trx->trx_hs_w_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_hs_w_conn_hash); +#endif + spider_free_mem_calc(spider_current_trx, + trx->trx_ha_hash_id, + trx->trx_ha_hash.array.max_element * + trx->trx_ha_hash.array.size_of_element); + my_hash_free(&trx->trx_ha_hash); + spider_free_mem_calc(spider_current_trx, + trx->trx_alter_table_hash_id, + trx->trx_alter_table_hash.array.max_element * + trx->trx_alter_table_hash.array.size_of_element); + my_hash_free(&trx->trx_alter_table_hash); + DBUG_RETURN(0); +} + +SPIDER_TRX *spider_get_trx( + THD *thd, + bool regist_allocated_thds, + int *error_num +) { + int roop_count = 0; + SPIDER_TRX *trx; + pthread_mutex_t *udf_table_mutexes; + DBUG_ENTER("spider_get_trx"); + + if ( + !thd || + !(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr)) + ) { + DBUG_PRINT("info",("spider create new trx")); + if (!(trx = (SPIDER_TRX *) + spider_bulk_malloc(NULL, 56, MYF(MY_WME | MY_ZEROFILL), + &trx, sizeof(*trx), + &udf_table_mutexes, sizeof(pthread_mutex_t) * + spider_param_udf_table_lock_mutex_count(), + NullS)) + ) + goto error_alloc_trx; + + trx->udf_table_mutexes = udf_table_mutexes; + + for (roop_count = 0; + roop_count < (int) spider_param_udf_table_lock_mutex_count(); + roop_count++) + { +#if MYSQL_VERSION_ID < 50500 + if (pthread_mutex_init(&trx->udf_table_mutexes[roop_count], + MY_MUTEX_INIT_FAST)) +#else + if (mysql_mutex_init(spd_key_mutex_udf_table, + &trx->udf_table_mutexes[roop_count], MY_MUTEX_INIT_FAST)) +#endif + goto error_init_udf_table_mutex; + } + + if ( + my_hash_init(&trx->trx_conn_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_conn_get_key, 0, 0) + ) + goto error_init_hash; + spider_alloc_calc_mem_init(trx->trx_conn_hash, 151); + spider_alloc_calc_mem( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_conn_hash, + trx->trx_conn_hash.array.max_element * + trx->trx_conn_hash.array.size_of_element); + + if ( + my_hash_init(&trx->trx_another_conn_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_conn_get_key, 0, 0) + ) + goto error_init_another_hash; + spider_alloc_calc_mem_init(trx->trx_another_conn_hash, 152); + spider_alloc_calc_mem( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_another_conn_hash, + trx->trx_another_conn_hash.array.max_element * + trx->trx_another_conn_hash.array.size_of_element); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ( + my_hash_init(&trx->trx_hs_r_conn_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_conn_get_key, 0, 0) + ) + goto error_hs_r_init_hash; + spider_alloc_calc_mem_init(trx->trx_hs_r_conn_hash, 153); + spider_alloc_calc_mem( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_hs_r_conn_hash, + trx->trx_hs_r_conn_hash.array.max_element * + trx->trx_hs_r_conn_hash.array.size_of_element); + + if ( + my_hash_init(&trx->trx_hs_w_conn_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_conn_get_key, 0, 0) + ) + goto error_hs_w_init_hash; + spider_alloc_calc_mem_init(trx->trx_hs_w_conn_hash, 154); + spider_alloc_calc_mem( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_hs_w_conn_hash, + trx->trx_hs_w_conn_hash.array.max_element * + trx->trx_hs_w_conn_hash.array.size_of_element); +#endif + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ( + my_hash_init(&trx->trx_direct_hs_r_conn_hash, spd_charset_utf8_bin, 32, + 0, 0, (my_hash_get_key) spider_conn_get_key, 0, 0) + ) + goto error_direct_hs_r_init_hash; + spider_alloc_calc_mem_init(trx->trx_direct_hs_r_conn_hash, 155); + spider_alloc_calc_mem( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_direct_hs_r_conn_hash, + trx->trx_direct_hs_r_conn_hash.array.max_element * + trx->trx_direct_hs_r_conn_hash.array.size_of_element); + + if ( + my_hash_init(&trx->trx_direct_hs_w_conn_hash, spd_charset_utf8_bin, 32, + 0, 0, (my_hash_get_key) spider_conn_get_key, 0, 0) + ) + goto error_direct_hs_w_init_hash; + spider_alloc_calc_mem_init(trx->trx_direct_hs_w_conn_hash, 156); + spider_alloc_calc_mem( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_direct_hs_w_conn_hash, + trx->trx_direct_hs_w_conn_hash.array.max_element * + trx->trx_direct_hs_w_conn_hash.array.size_of_element); +#endif + + if ( + my_hash_init(&trx->trx_alter_table_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_alter_tbl_get_key, 0, 0) + ) + goto error_init_alter_hash; + spider_alloc_calc_mem_init(trx->trx_alter_table_hash, 157); + spider_alloc_calc_mem( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_alter_table_hash, + trx->trx_alter_table_hash.array.max_element * + trx->trx_alter_table_hash.array.size_of_element); + + if ( + my_hash_init(&trx->trx_ha_hash, spd_charset_utf8_bin, 32, 0, 0, + (my_hash_get_key) spider_trx_ha_get_key, 0, 0) + ) + goto error_init_trx_ha_hash; + spider_alloc_calc_mem_init(trx->trx_ha_hash, 158); + spider_alloc_calc_mem( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_ha_hash, + trx->trx_ha_hash.array.max_element * + trx->trx_ha_hash.array.size_of_element); + + trx->thd = (THD*) thd; +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (thd) + trx->thd_hash_value = my_calc_hash(&spider_allocated_thds, + (uchar*) thd, sizeof(THD *)); + else + trx->thd_hash_value = 0; +#endif + pthread_mutex_lock(&spider_thread_id_mutex); + trx->spider_thread_id = spider_thread_id; + ++spider_thread_id; + pthread_mutex_unlock(&spider_thread_id_mutex); + trx->trx_conn_adjustment = 1; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + trx->trx_hs_r_conn_adjustment = 1; + trx->trx_hs_w_conn_adjustment = 1; +#endif + + if (thd) + { + if (regist_allocated_thds) + { + pthread_mutex_lock(&spider_allocated_thds_mutex); + uint old_elements = spider_allocated_thds.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&spider_allocated_thds, + trx->thd_hash_value, (uchar*) thd)) +#else + if (my_hash_insert(&spider_allocated_thds, (uchar*) thd)) +#endif + { + pthread_mutex_unlock(&spider_allocated_thds_mutex); + goto error_allocated_thds_insert; + } + if (spider_allocated_thds.array.max_element > old_elements) + { + spider_alloc_calc_mem(trx, + spider_allocated_thds, + (spider_allocated_thds.array.max_element - old_elements) * + spider_allocated_thds.array.size_of_element); + } + pthread_mutex_unlock(&spider_allocated_thds_mutex); + trx->registed_allocated_thds = TRUE; + } + *thd_ha_data(thd, spider_hton_ptr) = (void *) trx; + } + } + + DBUG_PRINT("info",("spider trx=%p", trx)); + DBUG_RETURN(trx); + +error_allocated_thds_insert: + spider_free_mem_calc(trx, + trx->trx_ha_hash_id, + trx->trx_ha_hash.array.max_element * + trx->trx_ha_hash.array.size_of_element); + my_hash_free(&trx->trx_ha_hash); +error_init_trx_ha_hash: + spider_free_mem_calc( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_alter_table_hash_id, + trx->trx_alter_table_hash.array.max_element * + trx->trx_alter_table_hash.array.size_of_element); + my_hash_free(&trx->trx_alter_table_hash); +error_init_alter_hash: +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider_free_mem_calc( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_direct_hs_w_conn_hash_id, + trx->trx_direct_hs_w_conn_hash.array.max_element * + trx->trx_direct_hs_w_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_direct_hs_w_conn_hash); +error_direct_hs_w_init_hash: + spider_free_mem_calc( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_direct_hs_r_conn_hash_id, + trx->trx_direct_hs_r_conn_hash.array.max_element * + trx->trx_direct_hs_r_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_direct_hs_r_conn_hash); +error_direct_hs_r_init_hash: +#endif +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider_free_mem_calc( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_hs_w_conn_hash_id, + trx->trx_hs_w_conn_hash.array.max_element * + trx->trx_hs_w_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_hs_w_conn_hash); +error_hs_w_init_hash: + spider_free_mem_calc( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_hs_r_conn_hash_id, + trx->trx_hs_r_conn_hash.array.max_element * + trx->trx_hs_r_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_hs_r_conn_hash); +error_hs_r_init_hash: +#endif + spider_free_mem_calc( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_another_conn_hash_id, + trx->trx_another_conn_hash.array.max_element * + trx->trx_another_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_another_conn_hash); +error_init_another_hash: + spider_free_mem_calc( + thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + trx->trx_conn_hash_id, + trx->trx_conn_hash.array.max_element * + trx->trx_conn_hash.array.size_of_element); + my_hash_free(&trx->trx_conn_hash); +error_init_hash: + if (roop_count > 0) + { + for (roop_count--; roop_count >= 0; roop_count--) + pthread_mutex_destroy(&trx->udf_table_mutexes[roop_count]); + } +error_init_udf_table_mutex: + spider_free(NULL, trx, MYF(0)); +error_alloc_trx: + *error_num = HA_ERR_OUT_OF_MEM; + DBUG_RETURN(NULL); +} + +int spider_free_trx( + SPIDER_TRX *trx, + bool need_lock +) { + DBUG_ENTER("spider_free_trx"); + if (trx->thd) + { + if (trx->registed_allocated_thds) + { + if (need_lock) + pthread_mutex_lock(&spider_allocated_thds_mutex); +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&spider_allocated_thds, + trx->thd_hash_value, (uchar*) trx->thd); +#else + my_hash_delete(&spider_allocated_thds, (uchar*) trx->thd); +#endif + if (need_lock) + pthread_mutex_unlock(&spider_allocated_thds_mutex); + } + *thd_ha_data(trx->thd, spider_hton_ptr) = (void *) NULL; + } + spider_free_trx_alloc(trx); + spider_merge_mem_calc(trx, TRUE); + spider_free(NULL, trx, MYF(0)); + DBUG_RETURN(0); +} + +int spider_check_and_set_trx_isolation( + SPIDER_CONN *conn, + int *need_mon +) { + int trx_isolation; + DBUG_ENTER("spider_check_and_set_trx_isolation"); + + trx_isolation = thd_tx_isolation(conn->thd); + DBUG_PRINT("info",("spider local trx_isolation=%d", trx_isolation)); +/* + DBUG_PRINT("info",("spider conn->trx_isolation=%d", conn->trx_isolation)); + if (conn->trx_isolation != trx_isolation) + { +*/ + spider_conn_queue_trx_isolation(conn, trx_isolation); +/* + conn->trx_isolation = trx_isolation; + } +*/ + DBUG_RETURN(0); +} + +int spider_check_and_set_autocommit( + THD *thd, + SPIDER_CONN *conn, + int *need_mon +) { + bool autocommit; + DBUG_ENTER("spider_check_and_set_autocommit"); + + autocommit = !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT); + if (autocommit) + { + spider_conn_queue_autocommit(conn, TRUE); + } else { + spider_conn_queue_autocommit(conn, FALSE); + } +/* + if (autocommit && conn->autocommit != 1) + { + spider_conn_queue_autocommit(conn, TRUE); + conn->autocommit = 1; + } else if (!autocommit && conn->autocommit != 0) + { + spider_conn_queue_autocommit(conn, FALSE); + conn->autocommit = 0; + } +*/ + DBUG_RETURN(0); +} + +int spider_check_and_set_sql_log_off( + THD *thd, + SPIDER_CONN *conn, + int *need_mon +) { + bool internal_sql_log_off; + DBUG_ENTER("spider_check_and_set_sql_log_off"); + + internal_sql_log_off = spider_param_internal_sql_log_off(thd); + if (internal_sql_log_off) + { + spider_conn_queue_sql_log_off(conn, TRUE); + } else { + spider_conn_queue_sql_log_off(conn, FALSE); + } +/* + if (internal_sql_log_off && conn->sql_log_off != 1) + { + spider_conn_queue_sql_log_off(conn, TRUE); + conn->sql_log_off = 1; + } else if (!internal_sql_log_off && conn->sql_log_off != 0) + { + spider_conn_queue_sql_log_off(conn, FALSE); + conn->sql_log_off = 0; + } +*/ + DBUG_RETURN(0); +} + +int spider_check_and_set_time_zone( + THD *thd, + SPIDER_CONN *conn, + int *need_mon +) { + Time_zone *time_zone; + DBUG_ENTER("spider_check_and_set_time_zone"); + + time_zone = thd->variables.time_zone; + DBUG_PRINT("info",("spider local time_zone=%p", time_zone)); +/* + DBUG_PRINT("info",("spider conn->time_zone=%p", conn->time_zone)); + if (time_zone != conn->time_zone) + { +*/ + spider_conn_queue_time_zone(conn, time_zone); +/* + conn->time_zone = time_zone; + } +*/ + DBUG_RETURN(0); +} + +int spider_xa_lock( + XID_STATE *xid_state +) { + int error_num; + DBUG_ENTER("spider_xa_lock"); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache, + (uchar*) xid_state->xid.key(), xid_state->xid.key_length()); +#endif + pthread_mutex_lock(spd_db_att_LOCK_xid_cache); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if (my_hash_search_using_hash_value(spd_db_att_xid_cache, hash_value, + xid_state->xid.key(), xid_state->xid.key_length())) +#else + if (my_hash_search(spd_db_att_xid_cache, + xid_state->xid.key(), xid_state->xid.key_length())) +#endif + { + error_num = ER_SPIDER_XA_LOCKED_NUM; + goto error; + } +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(spd_db_att_xid_cache, hash_value, + (uchar*)xid_state)) +#else + if (my_hash_insert(spd_db_att_xid_cache, (uchar*)xid_state)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + pthread_mutex_unlock(spd_db_att_LOCK_xid_cache); + DBUG_RETURN(0); + +error: + pthread_mutex_unlock(spd_db_att_LOCK_xid_cache); + DBUG_RETURN(error_num); +} + +int spider_xa_unlock( + XID_STATE *xid_state +) { + DBUG_ENTER("spider_xa_unlock"); +#if defined(SPIDER_HAS_HASH_VALUE_TYPE) && defined(HASH_UPDATE_WITH_HASH_VALUE) + my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache, + (uchar*) xid_state->xid.key(), xid_state->xid.key_length()); +#endif + pthread_mutex_lock(spd_db_att_LOCK_xid_cache); +#if defined(SPIDER_HAS_HASH_VALUE_TYPE) && defined(HASH_UPDATE_WITH_HASH_VALUE) + my_hash_delete_with_hash_value(spd_db_att_xid_cache, hash_value, (uchar *)xid_state); +#else + my_hash_delete(spd_db_att_xid_cache, (uchar *)xid_state); +#endif + pthread_mutex_unlock(spd_db_att_LOCK_xid_cache); + DBUG_RETURN(0); +} + +int spider_start_internal_consistent_snapshot( + SPIDER_TRX *trx, + SPIDER_CONN *conn, + int *need_mon +) { + DBUG_ENTER("spider_start_internal_consistent_snapshot"); + if (trx->trx_consistent_snapshot) + DBUG_RETURN(spider_db_consistent_snapshot(conn, need_mon)); + DBUG_RETURN(0); +} + +int spider_internal_start_trx( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +) { + int error_num; + SPIDER_TRX *trx = spider->trx; + bool sync_autocommit = spider_param_sync_autocommit(trx->thd); + bool sync_time_zone = spider_param_sync_time_zone(trx->thd); + double ping_interval_at_trx_start = + spider_param_ping_interval_at_trx_start(trx->thd); + bool xa_lock = FALSE; + time_t tmp_time = (time_t) time((time_t*) 0); + DBUG_ENTER("spider_internal_start_trx"); + + if ( + conn->server_lost || + difftime(tmp_time, conn->ping_time) >= ping_interval_at_trx_start + ) { + spider_conn_queue_ping(spider, conn, link_idx); + } + conn->disable_reconnect = TRUE; + if (!trx->trx_start) + { + if (!trx->trx_consistent_snapshot) + { + trx->use_consistent_snapshot = + spider_param_use_consistent_snapshot(trx->thd); + trx->internal_xa = spider_param_internal_xa(trx->thd); + trx->internal_xa_snapshot = spider_param_internal_xa_snapshot(trx->thd); + } + } + if ( + (error_num = spider_check_and_set_sql_log_off(trx->thd, conn, + &spider->need_mons[link_idx])) || + (sync_time_zone && + (error_num = spider_check_and_set_time_zone(trx->thd, conn, + &spider->need_mons[link_idx]))) || + (sync_autocommit && + (error_num = spider_check_and_set_autocommit(trx->thd, conn, + &spider->need_mons[link_idx]))) + ) + goto error; + if (trx->trx_consistent_snapshot) + { + if (trx->internal_xa && trx->internal_xa_snapshot < 2) + { + error_num = ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_NUM; + my_message(error_num, ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_STR, + MYF(0)); + goto error; + } else if (!trx->internal_xa || trx->internal_xa_snapshot == 2) + { + if ((error_num = spider_start_internal_consistent_snapshot(trx, conn, + &spider->need_mons[link_idx]))) + goto error; + } + } + if (!trx->trx_start) + { + if ( + trx->thd->transaction.xid_state.xa_state == XA_ACTIVE && + spider_param_support_xa() + ) { + trx->trx_xa = TRUE; + thd_get_xid(trx->thd, (MYSQL_XID*) &trx->xid); + } + + if (!trx->trx_xa && trx->internal_xa) + { + if (!trx->trx_consistent_snapshot || trx->internal_xa_snapshot == 3) + { + trx->trx_xa = TRUE; + trx->xid.formatID = 1; + trx->xid.gtrid_length + = my_sprintf(trx->xid.data, + (trx->xid.data, "%lx", thd_get_thread_id(trx->thd))); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 + trx->xid.bqual_length + = my_sprintf(trx->xid.data + trx->xid.gtrid_length, + (trx->xid.data + trx->xid.gtrid_length, "%lx", + trx->thd->variables.server_id)); +#else + trx->xid.bqual_length + = my_sprintf(trx->xid.data + trx->xid.gtrid_length, + (trx->xid.data + trx->xid.gtrid_length, "%x", + trx->thd->server_id)); +#endif + + trx->internal_xid_state.xa_state = XA_ACTIVE; + trx->internal_xid_state.xid.set(&trx->xid); + trx->internal_xid_state.in_thd = 1; + while ((error_num = spider_xa_lock(&trx->internal_xid_state))) + { + if (error_num != ER_SPIDER_XA_LOCKED_NUM) + goto error; + else if (trx->xid.formatID == 0) + { + my_message(error_num, ER_SPIDER_XA_LOCKED_STR, MYF(0)); + goto error; + } + /* retry */ + trx->xid.formatID++; + trx->internal_xid_state.xid.set(&trx->xid); + } + xa_lock = TRUE; + } + } + + if (!trx->trx_consistent_snapshot) + { + trans_register_ha(trx->thd, FALSE, spider_hton_ptr); + if (thd_test_options(trx->thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + trans_register_ha(trx->thd, TRUE, spider_hton_ptr); + } + trx->trx_start = TRUE; + } + + DBUG_PRINT("info",("spider sync_autocommit = %d", sync_autocommit)); + DBUG_PRINT("info",("spider conn->semi_trx_chk = %d", conn->semi_trx_chk)); + DBUG_PRINT("info",("spider conn->table_lock = %d", conn->table_lock)); + DBUG_PRINT("info",("spider conn->autocommit = %d", conn->autocommit)); + DBUG_PRINT("info",("spider semi_trx = %d", spider_param_semi_trx(trx->thd))); + conn->semi_trx = FALSE; + if (conn->table_lock == 3) + { + DBUG_PRINT("info",("spider conn->table_lock == 3")); + conn->disable_xa = TRUE; + } else if (trx->trx_xa) + { + DBUG_PRINT("info",("spider trx->trx_xa")); + if ( + sync_autocommit && + conn->semi_trx_chk && + !conn->table_lock && + ( + (!conn->queued_autocommit && conn->autocommit == 1) || + (conn->queued_autocommit && conn->queued_autocommit_val == TRUE) + ) && + spider_param_semi_trx(trx->thd) + ) { + DBUG_PRINT("info",("spider semi_trx is set")); + conn->semi_trx = TRUE; + } + spider_conn_queue_xa_start(conn, &trx->xid); + conn->disable_xa = FALSE; + } else if ( + !trx->trx_consistent_snapshot && + !thd_test_options(trx->thd, OPTION_BEGIN) && + sync_autocommit && + conn->semi_trx_chk && + !conn->table_lock && + ( + (!conn->queued_autocommit && conn->autocommit == 1) || + (conn->queued_autocommit && conn->queued_autocommit_val == TRUE) + ) && + spider_param_semi_trx(trx->thd) + ) { + DBUG_PRINT("info",("spider semi_trx is set")); + spider_conn_queue_start_transaction(conn); + conn->semi_trx = TRUE; + } else if ( + !trx->trx_consistent_snapshot && + thd_test_options(trx->thd, OPTION_BEGIN) + ) { + DBUG_PRINT("info",("spider start transaction")); + spider_conn_queue_start_transaction(conn); + } + + conn->join_trx = 1; + if (trx->join_trx_top) + spider_tree_insert(trx->join_trx_top, conn); + else { + conn->p_small = NULL; + conn->p_big = NULL; + conn->c_small = NULL; + conn->c_big = NULL; + trx->join_trx_top = conn; + } + DBUG_RETURN(0); + +error: + if (xa_lock) + spider_xa_unlock(&trx->internal_xid_state); + DBUG_RETURN(error_num); +} + +int spider_internal_xa_commit( + THD* thd, + SPIDER_TRX *trx, + XID* xid, + TABLE *table_xa, + TABLE *table_xa_member +) { + int error_num, tmp_error_num; + char xa_key[MAX_KEY_LENGTH]; + SPIDER_CONN *conn; + uint force_commit = spider_param_force_commit(thd); + MEM_ROOT mem_root; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + bool table_xa_opened = FALSE; + bool table_xa_member_opened = FALSE; + DBUG_ENTER("spider_internal_xa_commit"); + + /* + select + status + from + mysql.spider_xa + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + spider_store_xa_pk(table_xa, &trx->xid); + if ( + (error_num = spider_check_sys_table(table_xa, xa_key)) + ) { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table_xa->file->print_error(error_num, MYF(0)); + goto error; + } + my_message(ER_SPIDER_XA_NOT_EXISTS_NUM, ER_SPIDER_XA_NOT_EXISTS_STR, + MYF(0)); + error_num = ER_SPIDER_XA_NOT_EXISTS_NUM; + goto error; + } + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + if ( + force_commit != 2 && + (error_num = spider_check_sys_xa_status( + table_xa, + SPIDER_SYS_XA_PREPARED_STR, + SPIDER_SYS_XA_COMMIT_STR, + NULL, + ER_SPIDER_XA_NOT_PREPARED_NUM, + &mem_root)) + ) { + free_root(&mem_root, MYF(0)); + if (error_num == ER_SPIDER_XA_NOT_PREPARED_NUM) + my_message(error_num, ER_SPIDER_XA_NOT_PREPARED_STR, MYF(0)); + goto error; + } + free_root(&mem_root, MYF(0)); + + /* + update + mysql.spider_xa + set + status = 'COMMIT' + where + format_id = trx->xid.format_id and + gtrid_length = trx->xid.gtrid_length and + data = trx->xid.data + */ + if ( + (error_num = spider_update_xa( + table_xa, &trx->xid, SPIDER_SYS_XA_COMMIT_STR)) + ) + goto error; + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + + SPIDER_BACKUP_DASTATUS; + if ((conn = spider_tree_first(trx->join_trx_top))) + { + do { + if (conn->join_trx) + { + if ((tmp_error_num = spider_db_xa_commit(conn, &trx->xid))) + { + if (force_commit == 0 || + (force_commit == 1 && tmp_error_num != ER_XAER_NOTA)) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (!error_num && tmp_error_num) + error_num = tmp_error_num; + } + } + if ((tmp_error_num = spider_end_trx(trx, conn))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (!error_num && tmp_error_num) + error_num = tmp_error_num; + } + conn->join_trx = 0; + } + } while ((conn = spider_tree_next(conn))); + trx->join_trx_top = NULL; + } + if (error_num) + goto error_in_commit; + + /* + delete from + mysql.spider_xa_member + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa_member = spider_open_sys_table( + thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR, + SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE, + &error_num)) + ) + goto error_open_table; + table_xa_member_opened = TRUE; + if ((error_num = spider_delete_xa_member(table_xa_member, &trx->xid))) + goto error; + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); + table_xa_member_opened = FALSE; + + /* + delete from + mysql.spider_xa + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + if ((error_num = spider_delete_xa(table_xa, &trx->xid))) + goto error; + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + spider_xa_unlock(&trx->internal_xid_state); + trx->internal_xid_state.xa_state = XA_NOTR; + DBUG_RETURN(0); + +error: + if (table_xa_opened) + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + if (table_xa_member_opened) + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); +error_in_commit: +error_open_table: + spider_xa_unlock(&trx->internal_xid_state); + trx->internal_xid_state.xa_state = XA_NOTR; + DBUG_RETURN(error_num); +} + +int spider_internal_xa_rollback( + THD* thd, + SPIDER_TRX *trx +) { + int error_num = 0, tmp_error_num; + TABLE *table_xa, *table_xa_member; + char xa_key[MAX_KEY_LENGTH]; + SPIDER_CONN *conn; + uint force_commit = spider_param_force_commit(thd); + MEM_ROOT mem_root; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + bool server_lost = FALSE; + bool prepared = (thd->transaction.xid_state.xa_state == XA_PREPARED); + bool table_xa_opened = FALSE; + bool table_xa_member_opened = FALSE; + DBUG_ENTER("spider_internal_xa_rollback"); + + if (prepared) + { + /* + select + status + from + mysql.spider_xa + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + spider_store_xa_pk(table_xa, &trx->xid); + if ( + (error_num = spider_check_sys_table(table_xa, xa_key)) + ) { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table_xa->file->print_error(error_num, MYF(0)); + goto error; + } + my_message(ER_SPIDER_XA_NOT_EXISTS_NUM, ER_SPIDER_XA_NOT_EXISTS_STR, + MYF(0)); + error_num = ER_SPIDER_XA_NOT_EXISTS_NUM; + goto error; + } + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + if ( + force_commit != 2 && + (error_num = spider_check_sys_xa_status( + table_xa, + SPIDER_SYS_XA_PREPARED_STR, + SPIDER_SYS_XA_ROLLBACK_STR, + NULL, + ER_SPIDER_XA_NOT_PREPARED_NUM, + &mem_root)) + ) { + free_root(&mem_root, MYF(0)); + if (error_num == ER_SPIDER_XA_NOT_PREPARED_NUM) + my_message(error_num, ER_SPIDER_XA_NOT_PREPARED_STR, MYF(0)); + goto error; + } + free_root(&mem_root, MYF(0)); + + /* + update + mysql.spider_xa + set + status = 'COMMIT' + where + format_id = trx->xid.format_id and + gtrid_length = trx->xid.gtrid_length and + data = trx->xid.data + */ + if ( + (error_num = spider_update_xa( + table_xa, &trx->xid, SPIDER_SYS_XA_ROLLBACK_STR)) + ) + goto error; + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + } + + SPIDER_BACKUP_DASTATUS; + if ((conn = spider_tree_first(trx->join_trx_top))) + { + do { + if (conn->join_trx) + { + if (conn->disable_xa) + { + if (conn->table_lock != 3 && !prepared) + { + if ( + !conn->server_lost && + (tmp_error_num = spider_db_rollback(conn)) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (!error_num && tmp_error_num) + error_num = tmp_error_num; + } + } + } else { + if (!conn->server_lost) + { + if ( + !prepared && + (tmp_error_num = spider_db_xa_end(conn, &trx->xid)) + ) { + if ( + force_commit == 0 || + (force_commit == 1 && + ( + tmp_error_num != ER_XAER_NOTA && + tmp_error_num != ER_XA_RBTIMEOUT && + tmp_error_num != ER_XA_RBDEADLOCK + ) + ) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (!error_num && tmp_error_num) + error_num = tmp_error_num; + } + } + if ((tmp_error_num = spider_db_xa_rollback(conn, &trx->xid))) + { + if ( + force_commit == 0 || + (force_commit == 1 && + ( + tmp_error_num != ER_XAER_NOTA && + tmp_error_num != ER_XA_RBTIMEOUT && + tmp_error_num != ER_XA_RBDEADLOCK + ) + ) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (!error_num && tmp_error_num) + error_num = tmp_error_num; + } + } + } + } + if ((tmp_error_num = spider_end_trx(trx, conn))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (!error_num && tmp_error_num) + error_num = tmp_error_num; + } + conn->join_trx = 0; + if (conn->server_lost) + server_lost = TRUE; + } + } while ((conn = spider_tree_next(conn))); + trx->join_trx_top = NULL; + } + if (error_num) + goto error_in_rollback; + + if ( + prepared && + !server_lost + ) { + /* + delete from + mysql.spider_xa_member + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa_member = spider_open_sys_table( + thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR, + SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE, + &error_num)) + ) + goto error_open_table; + table_xa_member_opened = TRUE; + if ((error_num = spider_delete_xa_member(table_xa_member, &trx->xid))) + goto error; + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); + table_xa_member_opened = FALSE; + + /* + delete from + mysql.spider_xa + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + if ((error_num = spider_delete_xa(table_xa, &trx->xid))) + goto error; + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + } + spider_xa_unlock(&trx->internal_xid_state); + trx->internal_xid_state.xa_state = XA_NOTR; + DBUG_RETURN(0); + +error: + if (table_xa_opened) + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + if (table_xa_member_opened) + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); +error_in_rollback: +error_open_table: + spider_xa_unlock(&trx->internal_xid_state); + trx->internal_xid_state.xa_state = XA_NOTR; + DBUG_RETURN(error_num); +} + +int spider_internal_xa_prepare( + THD* thd, + SPIDER_TRX *trx, + TABLE *table_xa, + TABLE *table_xa_member, + bool internal_xa +) { + int error_num; + SPIDER_CONN *conn; + uint force_commit = spider_param_force_commit(thd); +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + bool table_xa_opened = FALSE; + bool table_xa_member_opened = FALSE; + DBUG_ENTER("spider_internal_xa_prepare"); + /* + insert into mysql.spider_xa + (format_id, gtrid_length, bqual_length, data, status) values + (trx->xid.format_id, trx->xid.gtrid_length, trx->xid.bqual_length, + trx->xid.data, 'NOT YET') + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + if ( + (error_num = spider_insert_xa( + table_xa, &trx->xid, SPIDER_SYS_XA_NOT_YET_STR)) + ) + goto error; + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + + if ( + !(table_xa_member = spider_open_sys_table( + thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR, + SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE, + &error_num)) + ) + goto error_open_table; + table_xa_member_opened = TRUE; + SPIDER_BACKUP_DASTATUS; + if ((conn = spider_tree_first(trx->join_trx_top))) + { + do { + if (conn->disable_xa) + { + if (conn->table_lock != 3) + { + if ((error_num = spider_db_rollback(conn))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + goto error; + } + } + if ((error_num = spider_end_trx(trx, conn))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + goto error; + } + conn->join_trx = 0; + } else { + /* + insert into mysql.spider_xa_member + (format_id, gtrid_length, bqual_length, data, + scheme, host, port, socket, username, password) values + (trx->xid.format_id, trx->xid.gtrid_length, + trx->xid.bqual_length, trx->xid.data, + conn->tgt_wrapper, + conn->tgt_host, + conn->tgt_port, + conn->tgt_socket, + conn->tgt_username, + conn->tgt_password) + */ + if ( + (error_num = spider_insert_xa_member( + table_xa_member, &trx->xid, conn)) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + goto error; + } + + if ((error_num = spider_db_xa_end(conn, &trx->xid))) + { + if (force_commit == 0 || + (force_commit == 1 && error_num != ER_XAER_NOTA)) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + goto error; + } + } + if ((error_num = spider_db_xa_prepare(conn, &trx->xid))) + { + if (force_commit == 0 || + (force_commit == 1 && error_num != ER_XAER_NOTA)) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + goto error; + } + } +/* + if (!internal_xa) + { + if ((error_num = spider_end_trx(trx, conn))) + DBUG_RETURN(error_num); + conn->join_trx = 0; + } +*/ + } + } while ((conn = spider_tree_next(conn))); +/* + if (!internal_xa) + trx->join_trx_top = NULL; +*/ + } + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); + table_xa_member_opened = FALSE; + + /* + update + mysql.spider_xa + set + status = 'PREPARED' + where + format_id = trx->xid.format_id and + gtrid_length = trx->xid.gtrid_length and + data = trx->xid.data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + if ( + (error_num = spider_update_xa( + table_xa, &trx->xid, SPIDER_SYS_XA_PREPARED_STR)) + ) + goto error; + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + if (internal_xa) + trx->internal_xid_state.xa_state = XA_PREPARED; + DBUG_RETURN(0); + +error: + if (table_xa_opened) + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + if (table_xa_member_opened) + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); +error_open_table: + DBUG_RETURN(error_num); +} + +int spider_internal_xa_recover( + THD* thd, + XID* xid_list, + uint len +) { + TABLE *table_xa; + int cnt = 0; + char xa_key[MAX_KEY_LENGTH]; + MEM_ROOT mem_root; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + DBUG_ENTER("spider_internal_xa_recover"); + /* + select + format_id, + gtrid_length, + bqual_length, + data + from + mysql.spider_xa + where + status = 'PREPARED' + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + FALSE, &open_tables_backup, TRUE, &my_errno)) + ) + goto error_open_table; + spider_store_xa_status(table_xa, SPIDER_SYS_XA_PREPARED_STR); + if ( + (my_errno = spider_get_sys_table_by_idx(table_xa, xa_key, 1, + SPIDER_SYS_XA_IDX1_COL_CNT)) + ) { + spider_sys_index_end(table_xa); + if (my_errno != HA_ERR_KEY_NOT_FOUND && my_errno != HA_ERR_END_OF_FILE) + { + table_xa->file->print_error(my_errno, MYF(0)); + goto error; + } + goto error; + } + + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + do { + spider_get_sys_xid(table_xa, &xid_list[cnt], &mem_root); + cnt++; + my_errno = spider_sys_index_next_same(table_xa, xa_key); + } while (my_errno == 0 && cnt < (int) len); + free_root(&mem_root, MYF(0)); + spider_sys_index_end(table_xa); + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + DBUG_RETURN(cnt); + +error: + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); +error_open_table: + DBUG_RETURN(0); +} + +int spider_initinal_xa_recover( + XID* xid_list, + uint len +) { + int error_num; + static THD *thd = NULL; + static TABLE *table_xa = NULL; + static READ_RECORD *read_record = NULL; +#if MYSQL_VERSION_ID < 50500 + static Open_tables_state *open_tables_backup = NULL; +#else + static Open_tables_backup *open_tables_backup = NULL; +#endif + int cnt = 0; + MEM_ROOT mem_root; + DBUG_ENTER("spider_initinal_xa_recover"); + if (!open_tables_backup) + { +#if MYSQL_VERSION_ID < 50500 + if (!(open_tables_backup = new Open_tables_state)) +#else + if (!(open_tables_backup = new Open_tables_backup)) +#endif + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_create_state; + } + } + if (!read_record) + { + if (!(read_record = new READ_RECORD)) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_create_read_record; + } + } + + if (!thd) + { + if (!(thd = spider_create_tmp_thd())) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_create_thd; + } + } + + /* + select + format_id, + gtrid_length, + bqual_length, + data + from + mysql.spider_xa + */ + if (!table_xa) + { + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + FALSE, open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + init_read_record(read_record, thd, table_xa, NULL, TRUE, FALSE, FALSE); + } + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + while ((!(read_record->read_record(read_record))) && cnt < (int) len) + { + spider_get_sys_xid(table_xa, &xid_list[cnt], &mem_root); + cnt++; + } + free_root(&mem_root, MYF(0)); + + if (cnt < (int) len) + { + end_read_record(read_record); + spider_close_sys_table(thd, table_xa, open_tables_backup, TRUE); + table_xa = NULL; + spider_free_tmp_thd(thd); + thd = NULL; + delete read_record; + read_record = NULL; + delete open_tables_backup; + open_tables_backup = NULL; + } + DBUG_RETURN(cnt); + +/* +error: + end_read_record(&read_record_info); + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa = NULL; +*/ +error_open_table: + spider_free_tmp_thd(thd); + thd = NULL; +error_create_thd: + delete read_record; + read_record = NULL; +error_create_read_record: + delete open_tables_backup; + open_tables_backup = NULL; +error_create_state: + DBUG_RETURN(0); +} + +int spider_internal_xa_commit_by_xid( + THD* thd, + SPIDER_TRX *trx, + XID* xid +) { + TABLE *table_xa, *table_xa_member; + int error_num; + char xa_key[MAX_KEY_LENGTH]; + char xa_member_key[MAX_KEY_LENGTH]; + SPIDER_SHARE tmp_share; + char *tmp_connect_info[8]; + uint tmp_connect_info_length[8]; + long tmp_tgt_port, tmp_link_statuses; + SPIDER_CONN *conn; + uint force_commit = spider_param_force_commit(thd); + MEM_ROOT mem_root; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + bool table_xa_opened = FALSE; + bool table_xa_member_opened = FALSE; + DBUG_ENTER("spider_internal_xa_commit_by_xid"); + /* + select + status + from + mysql.spider_xa + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + spider_store_xa_pk(table_xa, xid); + if ( + (error_num = spider_check_sys_table(table_xa, xa_key)) + ) { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table_xa->file->print_error(error_num, MYF(0)); + goto error; + } + my_message(ER_SPIDER_XA_NOT_EXISTS_NUM, ER_SPIDER_XA_NOT_EXISTS_STR, + MYF(0)); + error_num = ER_SPIDER_XA_NOT_EXISTS_NUM; + goto error; + } + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + if ( + force_commit != 2 && + (error_num = spider_check_sys_xa_status( + table_xa, + SPIDER_SYS_XA_PREPARED_STR, + SPIDER_SYS_XA_COMMIT_STR, + NULL, + ER_SPIDER_XA_NOT_PREPARED_NUM, + &mem_root)) + ) { + free_root(&mem_root, MYF(0)); + if (error_num == ER_SPIDER_XA_NOT_PREPARED_NUM) + my_message(error_num, ER_SPIDER_XA_NOT_PREPARED_STR, MYF(0)); + goto error; + } + + /* + update + mysql.spider_xa + set + status = 'COMMIT' + where + format_id = trx->xid.format_id and + gtrid_length = trx->xid.gtrid_length and + data = trx->xid.data + */ + if ( + (error_num = spider_update_xa( + table_xa, xid, SPIDER_SYS_XA_COMMIT_STR)) + ) { + free_root(&mem_root, MYF(0)); + goto error; + } + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + + /* + select + scheme tmp_share.tgt_wrappers, + host tmp_share.tgt_hosts, + port tmp_share.tgt_ports, + socket tmp_share.tgt_sockets, + username tmp_share.tgt_usernames, + password tmp_share.tgt_passwords + from + mysql.spider_xa_member + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa_member = spider_open_sys_table( + thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR, + SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE, + &error_num)) + ) { + free_root(&mem_root, MYF(0)); + goto error_open_table; + } + table_xa_member_opened = TRUE; + spider_store_xa_pk(table_xa_member, xid); + if ( + (error_num = spider_get_sys_table_by_idx(table_xa_member, xa_member_key, 0, + SPIDER_SYS_XA_PK_COL_CNT)) + ) { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + free_root(&mem_root, MYF(0)); + table_xa_member->file->print_error(error_num, MYF(0)); + goto error; + } else { + free_root(&mem_root, MYF(0)); + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); + table_xa_member_opened = FALSE; + goto xa_delete; + } + } + + memset(&tmp_share, 0, sizeof(SPIDER_SHARE)); + tmp_share.link_count = 1; + tmp_share.all_link_count = 1; + tmp_share.server_names = &tmp_connect_info[0]; + tmp_share.tgt_table_names = &tmp_connect_info[1]; + tmp_share.tgt_dbs = &tmp_connect_info[2]; + tmp_share.tgt_hosts = &tmp_connect_info[3]; + tmp_share.tgt_usernames = &tmp_connect_info[4]; + tmp_share.tgt_passwords = &tmp_connect_info[5]; + tmp_share.tgt_sockets = &tmp_connect_info[6]; + tmp_share.tgt_wrappers = &tmp_connect_info[7]; + tmp_share.tgt_ports = &tmp_tgt_port; + tmp_share.link_statuses = &tmp_link_statuses; + tmp_share.server_names_lengths = &tmp_connect_info_length[0]; + tmp_share.tgt_table_names_lengths = &tmp_connect_info_length[1]; + tmp_share.tgt_dbs_lengths = &tmp_connect_info_length[2]; + tmp_share.tgt_hosts_lengths = &tmp_connect_info_length[3]; + tmp_share.tgt_usernames_lengths = &tmp_connect_info_length[4]; + tmp_share.tgt_passwords_lengths = &tmp_connect_info_length[5]; + tmp_share.tgt_sockets_lengths = &tmp_connect_info_length[6]; + tmp_share.tgt_wrappers_lengths = &tmp_connect_info_length[7]; + tmp_share.server_names_length = 1; + tmp_share.tgt_table_names_length = 1; + tmp_share.tgt_dbs_length = 1; + tmp_share.tgt_hosts_length = 1; + tmp_share.tgt_usernames_length = 1; + tmp_share.tgt_passwords_length = 1; + tmp_share.tgt_sockets_length = 1; + tmp_share.tgt_wrappers_length = 1; + tmp_share.tgt_ports_length = 1; + tmp_share.link_statuses_length = 1; + do { + SPIDER_BACKUP_DASTATUS; + spider_get_sys_server_info(table_xa_member, &tmp_share, 0, &mem_root); + if ((error_num = spider_create_conn_keys(&tmp_share))) + { + spider_sys_index_end(table_xa_member); + free_root(&mem_root, MYF(0)); + goto error; + } + + if ( + !(conn = spider_get_conn( + &tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE, + SPIDER_CONN_KIND_MYSQL, &error_num)) && + (force_commit == 0 || + (force_commit == 1 && error_num != ER_XAER_NOTA)) + ) { + spider_sys_index_end(table_xa_member); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + goto error; + } + conn->error_mode &= spider_param_error_read_mode(thd, 0); + conn->error_mode &= spider_param_error_write_mode(thd, 0); + if ( + (error_num = spider_db_xa_commit(conn, xid)) && + (force_commit == 0 || + (force_commit == 1 && error_num != ER_XAER_NOTA)) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + { + spider_sys_index_end(table_xa_member); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + goto error; + } + } + spider_free_tmp_share_alloc(&tmp_share); + error_num = spider_sys_index_next_same(table_xa_member, xa_member_key); + } while (error_num == 0); + if ((error_num = spider_sys_index_end(table_xa_member))) + { + free_root(&mem_root, MYF(0)); + goto error; + } + free_root(&mem_root, MYF(0)); + spider_reuse_trx_ha(trx); + spider_free_trx_conn(trx, FALSE); + + /* + delete from + mysql.spider_xa_member + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ((error_num = spider_delete_xa_member(table_xa_member, xid))) + goto error; + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); + table_xa_member_opened = FALSE; + +xa_delete: + /* + delete from + mysql.spider_xa + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + if ((error_num = spider_delete_xa(table_xa, xid))) + goto error; + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + DBUG_RETURN(0); + +error: + if (table_xa_opened) + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + if (table_xa_member_opened) + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); +error_open_table: + DBUG_RETURN(error_num); +} + +int spider_internal_xa_rollback_by_xid( + THD* thd, + SPIDER_TRX *trx, + XID* xid +) { + TABLE *table_xa, *table_xa_member; + int error_num; + char xa_key[MAX_KEY_LENGTH]; + char xa_member_key[MAX_KEY_LENGTH]; + SPIDER_SHARE tmp_share; + char *tmp_connect_info[8]; + uint tmp_connect_info_length[8]; + long tmp_tgt_port, tmp_link_statuses; + SPIDER_CONN *conn; + uint force_commit = spider_param_force_commit(thd); + MEM_ROOT mem_root; +#if MYSQL_VERSION_ID < 50500 + Open_tables_state open_tables_backup; +#else + Open_tables_backup open_tables_backup; +#endif + bool table_xa_opened = FALSE; + bool table_xa_member_opened = FALSE; + DBUG_ENTER("spider_internal_xa_rollback_by_xid"); + /* + select + status + from + mysql.spider_xa + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + spider_store_xa_pk(table_xa, xid); + if ( + (error_num = spider_check_sys_table(table_xa, xa_key)) + ) { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + table_xa->file->print_error(error_num, MYF(0)); + goto error; + } + error_num = ER_SPIDER_XA_NOT_EXISTS_NUM; + goto error; + } + SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); + if ( + force_commit != 2 && + (error_num = spider_check_sys_xa_status( + table_xa, + SPIDER_SYS_XA_NOT_YET_STR, + SPIDER_SYS_XA_PREPARED_STR, + SPIDER_SYS_XA_ROLLBACK_STR, + ER_SPIDER_XA_PREPARED_NUM, + &mem_root)) + ) { + free_root(&mem_root, MYF(0)); + if (error_num == ER_SPIDER_XA_PREPARED_NUM) + my_message(error_num, ER_SPIDER_XA_PREPARED_STR, MYF(0)); + goto error; + } + + /* + update + mysql.spider_xa + set + status = 'ROLLBACK' + where + format_id = trx->xid.format_id and + gtrid_length = trx->xid.gtrid_length and + data = trx->xid.data + */ + if ( + (error_num = spider_update_xa( + table_xa, xid, SPIDER_SYS_XA_ROLLBACK_STR)) + ) { + free_root(&mem_root, MYF(0)); + goto error; + } + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + + /* + select + scheme tmp_share.tgt_wrappers, + host tmp_share.tgt_hosts, + port tmp_share.tgt_ports, + socket tmp_share.tgt_sockets, + username tmp_share.tgt_usernames, + password tmp_share.tgt_passwords + from + mysql.spider_xa_member + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa_member = spider_open_sys_table( + thd, SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR, + SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE, + &error_num)) + ) { + free_root(&mem_root, MYF(0)); + goto error_open_table; + } + table_xa_member_opened = TRUE; + spider_store_xa_pk(table_xa_member, xid); + if ( + (error_num = spider_get_sys_table_by_idx(table_xa_member, xa_member_key, 0, + SPIDER_SYS_XA_PK_COL_CNT)) + ) { + if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE) + { + free_root(&mem_root, MYF(0)); + table_xa_member->file->print_error(error_num, MYF(0)); + goto error; + } else { + free_root(&mem_root, MYF(0)); + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); + table_xa_member_opened = FALSE; + goto xa_delete; + } + } + + memset(&tmp_share, 0, sizeof(SPIDER_SHARE)); + tmp_share.link_count = 1; + tmp_share.all_link_count = 1; + tmp_share.server_names = &tmp_connect_info[0]; + tmp_share.tgt_table_names = &tmp_connect_info[1]; + tmp_share.tgt_dbs = &tmp_connect_info[2]; + tmp_share.tgt_hosts = &tmp_connect_info[3]; + tmp_share.tgt_usernames = &tmp_connect_info[4]; + tmp_share.tgt_passwords = &tmp_connect_info[5]; + tmp_share.tgt_sockets = &tmp_connect_info[6]; + tmp_share.tgt_wrappers = &tmp_connect_info[7]; + tmp_share.tgt_ports = &tmp_tgt_port; + tmp_share.link_statuses = &tmp_link_statuses; + tmp_share.server_names_lengths = &tmp_connect_info_length[0]; + tmp_share.tgt_table_names_lengths = &tmp_connect_info_length[1]; + tmp_share.tgt_dbs_lengths = &tmp_connect_info_length[2]; + tmp_share.tgt_hosts_lengths = &tmp_connect_info_length[3]; + tmp_share.tgt_usernames_lengths = &tmp_connect_info_length[4]; + tmp_share.tgt_passwords_lengths = &tmp_connect_info_length[5]; + tmp_share.tgt_sockets_lengths = &tmp_connect_info_length[6]; + tmp_share.tgt_wrappers_lengths = &tmp_connect_info_length[7]; + tmp_share.server_names_length = 1; + tmp_share.tgt_table_names_length = 1; + tmp_share.tgt_dbs_length = 1; + tmp_share.tgt_hosts_length = 1; + tmp_share.tgt_usernames_length = 1; + tmp_share.tgt_passwords_length = 1; + tmp_share.tgt_sockets_length = 1; + tmp_share.tgt_wrappers_length = 1; + tmp_share.tgt_ports_length = 1; + tmp_share.link_statuses_length = 1; + do { + SPIDER_BACKUP_DASTATUS; + spider_get_sys_server_info(table_xa_member, &tmp_share, 0, &mem_root); + if ((error_num = spider_create_conn_keys(&tmp_share))) + { + spider_sys_index_end(table_xa_member); + free_root(&mem_root, MYF(0)); + goto error; + } + + if ( + !(conn = spider_get_conn( + &tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE, + SPIDER_CONN_KIND_MYSQL, &error_num)) && + (force_commit == 0 || + (force_commit == 1 && error_num != ER_XAER_NOTA)) + ) { + spider_sys_index_end(table_xa_member); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + goto error; + } + conn->error_mode &= spider_param_error_read_mode(thd, 0); + conn->error_mode &= spider_param_error_write_mode(thd, 0); + if ( + (error_num = spider_db_xa_rollback(conn, xid)) && + (force_commit == 0 || + (force_commit == 1 && error_num != ER_XAER_NOTA)) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_ERROR_NUM; + if (error_num) + { + spider_sys_index_end(table_xa_member); + spider_free_tmp_share_alloc(&tmp_share); + free_root(&mem_root, MYF(0)); + goto error; + } + } + spider_free_tmp_share_alloc(&tmp_share); + error_num = spider_sys_index_next_same(table_xa_member, xa_member_key); + } while (error_num == 0); + if ((error_num = spider_sys_index_end(table_xa_member))) + { + free_root(&mem_root, MYF(0)); + goto error; + } + free_root(&mem_root, MYF(0)); + spider_reuse_trx_ha(trx); + spider_free_trx_conn(trx, FALSE); + + /* + delete from + mysql.spider_xa_member + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ((error_num = spider_delete_xa_member(table_xa_member, xid))) + goto error; + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); + table_xa_member_opened = FALSE; + +xa_delete: + /* + delete from + mysql.spider_xa + where + format_id = xid->format_id and + gtrid_length = xid->gtrid_length and + data = xid->data + */ + if ( + !(table_xa = spider_open_sys_table( + thd, SPIDER_SYS_XA_TABLE_NAME_STR, SPIDER_SYS_XA_TABLE_NAME_LEN, + TRUE, &open_tables_backup, TRUE, &error_num)) + ) + goto error_open_table; + table_xa_opened = TRUE; + if ((error_num = spider_delete_xa(table_xa, xid))) + goto error; + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + table_xa_opened = FALSE; + DBUG_RETURN(0); + +error: + if (table_xa_opened) + spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE); + if (table_xa_member_opened) + spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE); +error_open_table: + DBUG_RETURN(error_num); +} + +int spider_start_consistent_snapshot( + handlerton *hton, + THD* thd +) { + int error_num; + SPIDER_TRX *trx; + DBUG_ENTER("spider_start_consistent_snapshot"); + + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + DBUG_RETURN(error_num); + if (spider_param_use_consistent_snapshot(trx->thd)) + { + if (spider_param_internal_xa(trx->thd) && + spider_param_internal_xa_snapshot(trx->thd) == 1) + { + error_num = ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_NUM; + my_message(error_num, ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_STR, + MYF(0)); + goto error; + } else { + trx->trx_consistent_snapshot = TRUE; + trx->use_consistent_snapshot = TRUE; + trx->internal_xa_snapshot = spider_param_internal_xa_snapshot(trx->thd); + trans_register_ha(trx->thd, FALSE, spider_hton_ptr); + trans_register_ha(trx->thd, TRUE, spider_hton_ptr); + if (spider_param_use_all_conns_snapshot(trx->thd)) + { + trx->internal_xa = FALSE; + if ((error_num = spider_open_all_tables(trx, TRUE))) + goto error_open_all_tables; + if ( + spider_param_use_snapshot_with_flush_tables(trx->thd) == 1 && + (error_num = spider_trx_all_flush_tables(trx)) + ) + goto error_trx_all_flush_tables; + if (spider_param_use_snapshot_with_flush_tables(trx->thd) == 2) + { + if ((error_num = spider_trx_another_lock_tables(trx))) + goto error_trx_another_lock_tables; + if ((error_num = spider_trx_another_flush_tables(trx))) + goto error_trx_another_flush_tables; + } + if ((error_num = spider_trx_all_start_trx(trx))) + goto error_trx_all_start_trx; + if (spider_param_use_snapshot_with_flush_tables(trx->thd) == 1) + { + if ( + spider_param_use_flash_logs(trx->thd) && + (error_num = spider_trx_all_flush_logs(trx)) + ) + goto error_trx_all_flush_logs; + if ((error_num = spider_trx_all_unlock_tables(trx))) + goto error_trx_all_unlock_tables; + } + if (spider_param_use_snapshot_with_flush_tables(trx->thd) == 2) + { + if ( + spider_param_use_flash_logs(trx->thd) && + (error_num = spider_trx_all_flush_logs(trx)) + ) + goto error_trx_all_flush_logs2; + if ((error_num = spider_free_trx_another_conn(trx, TRUE))) + goto error_free_trx_another_conn; + } + } else + trx->internal_xa = spider_param_internal_xa(trx->thd); + } + } + + DBUG_RETURN(0); + +error_trx_all_flush_logs: +error_trx_all_start_trx: +error_trx_another_flush_tables: +error_trx_another_lock_tables: +error_trx_all_flush_tables: + if (spider_param_use_snapshot_with_flush_tables(trx->thd) == 1) + spider_trx_all_unlock_tables(trx); +error_trx_all_flush_logs2: +error_trx_all_unlock_tables: +error_open_all_tables: + if (spider_param_use_snapshot_with_flush_tables(trx->thd) == 2) + spider_free_trx_another_conn(trx, TRUE); +error_free_trx_another_conn: +error: + DBUG_RETURN(error_num); +} + +int spider_commit( + handlerton *hton, + THD *thd, + bool all +) { + SPIDER_TRX *trx; + TABLE *table_xa = NULL; + TABLE *table_xa_member = NULL; + int error_num = 0; + SPIDER_CONN *conn; + DBUG_ENTER("spider_commit"); + + if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr))) + DBUG_RETURN(0); /* transaction is not started */ + +#ifdef HA_CAN_BULK_ACCESS + DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", + trx->bulk_access_conn_first)); + trx->bulk_access_conn_first = NULL; +#endif + + if (all || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) + { + if (trx->trx_start) + { + if (trx->trx_xa) + { + if ( + trx->internal_xa && + (error_num = spider_internal_xa_prepare( + thd, trx, table_xa, table_xa_member, TRUE)) + ) { +/* + if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + { +*/ + /* rollback for semi_trx */ + spider_rollback(hton, thd, all); +/* + } +*/ + DBUG_RETURN(error_num); + } + if ( + (error_num = spider_internal_xa_commit( + thd, trx, &trx->xid, table_xa, table_xa_member)) + ) { + DBUG_RETURN(error_num); + } + trx->trx_xa = FALSE; + } else { + if ((conn = spider_tree_first(trx->join_trx_top))) + { + SPIDER_BACKUP_DASTATUS; + int tmp_error_num; + do { + if ( + (conn->autocommit != 1 || conn->trx_start) && + (tmp_error_num = spider_db_commit(conn)) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (tmp_error_num) + error_num = tmp_error_num; + } + if ((tmp_error_num = spider_end_trx(trx, conn))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (tmp_error_num) + error_num = tmp_error_num; + } + conn->join_trx = 0; + } while ((conn = spider_tree_next(conn))); + trx->join_trx_top = NULL; + } + } + trx->trx_start = FALSE; + } + spider_reuse_trx_ha(trx); + spider_free_trx_conn(trx, FALSE); + trx->trx_consistent_snapshot = FALSE; + } + spider_merge_mem_calc(trx, FALSE); + DBUG_RETURN(error_num); +} + +int spider_rollback( + handlerton *hton, + THD *thd, + bool all +) { + SPIDER_TRX *trx; + int error_num = 0; + SPIDER_CONN *conn; + DBUG_ENTER("spider_rollback"); + + if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr))) + DBUG_RETURN(0); /* transaction is not started */ + +#ifdef HA_CAN_BULK_ACCESS + DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", + trx->bulk_access_conn_first)); + trx->bulk_access_conn_first = NULL; +#endif + + if (all || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) + { + if (trx->trx_start) + { + if (trx->trx_xa) + { + if ( + (error_num = spider_internal_xa_rollback(thd, trx)) + ) + DBUG_RETURN(error_num); + trx->trx_xa = FALSE; + } else { + if ((conn = spider_tree_first(trx->join_trx_top))) + { + SPIDER_BACKUP_DASTATUS; + int tmp_error_num; + do { + if ( + !conn->server_lost && + (conn->autocommit != 1 || conn->trx_start) && + (tmp_error_num = spider_db_rollback(conn)) + ) { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (tmp_error_num) + error_num = tmp_error_num; + } + if ((tmp_error_num = spider_end_trx(trx, conn))) + { + SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM; + if (tmp_error_num) + error_num = tmp_error_num; + } + conn->join_trx = 0; + } while ((conn = spider_tree_next(conn))); + trx->join_trx_top = NULL; + } + } + trx->trx_start = FALSE; + } + spider_reuse_trx_ha(trx); + spider_free_trx_conn(trx, FALSE); + trx->trx_consistent_snapshot = FALSE; + } + + spider_merge_mem_calc(trx, FALSE); + DBUG_RETURN(error_num); +} + +int spider_xa_prepare( + handlerton *hton, + THD* thd, + bool all +) { + int error_num; + SPIDER_TRX *trx; + TABLE *table_xa = NULL; + TABLE *table_xa_member = NULL; + DBUG_ENTER("spider_xa_prepare"); + + if (all || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) + { + if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr))) + DBUG_RETURN(0); /* transaction is not started */ + + DBUG_PRINT("info",("spider trx_start=%s", + trx->trx_start ? "TRUE" : "FALSE")); + DBUG_PRINT("info",("spider trx_xa=%s", + trx->trx_xa ? "TRUE" : "FALSE")); + if (trx->trx_start && trx->trx_xa) + { + if ((error_num = spider_internal_xa_prepare( + thd, trx, table_xa, table_xa_member, FALSE))) + goto error; + } + } + + DBUG_RETURN(0); + +error: + DBUG_RETURN(error_num); +} + +int spider_xa_recover( + handlerton *hton, + XID* xid_list, + uint len +) { + THD* thd = current_thd; + DBUG_ENTER("spider_xa_recover"); + if (len == 0 || xid_list == NULL) + DBUG_RETURN(0); + + if (thd) + DBUG_RETURN(spider_internal_xa_recover(thd, xid_list, len)); + else + DBUG_RETURN(spider_initinal_xa_recover(xid_list, len)); +} + +int spider_xa_commit_by_xid( + handlerton *hton, + XID* xid +) { + SPIDER_TRX *trx; + int error_num; + THD* thd = current_thd; + DBUG_ENTER("spider_xa_commit_by_xid"); + + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + goto error_get_trx; + + if ((error_num = spider_internal_xa_commit_by_xid(thd, trx, xid))) + goto error; + + DBUG_RETURN(0); + +error: +error_get_trx: + DBUG_RETURN(error_num); +} + +int spider_xa_rollback_by_xid( + handlerton *hton, + XID* xid +) { + SPIDER_TRX *trx; + int error_num; + THD* thd = current_thd; + DBUG_ENTER("spider_xa_rollback_by_xid"); + + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + goto error_get_trx; + + if ((error_num = spider_internal_xa_rollback_by_xid(thd, trx, xid))) + goto error; + + DBUG_RETURN(0); + +error: +error_get_trx: + DBUG_RETURN(error_num); +} + +int spider_end_trx( + SPIDER_TRX *trx, + SPIDER_CONN *conn +) { + int error_num = 0, need_mon = 0; + ha_spider tmp_spider; + DBUG_ENTER("spider_end_trx"); + tmp_spider.conns = &conn; + if (conn->table_lock == 3) + { + conn->table_lock = 0; + conn->disable_reconnect = FALSE; + tmp_spider.trx = trx; + if ( + !conn->server_lost && + (error_num = spider_db_unlock_tables(&tmp_spider, 0)) + ) { + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) + error_num = 0; + } + } else if (!conn->table_lock) + conn->disable_reconnect = FALSE; + if ( + conn->semi_trx_isolation >= 0 && + conn->trx_isolation != conn->semi_trx_isolation + ) { + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider conn->trx_isolation=%d", conn->trx_isolation)); + if ( + !conn->server_lost && + !conn->queued_semi_trx_isolation && + (error_num = spider_db_set_trx_isolation( + conn, conn->trx_isolation, &need_mon)) + ) { + if ( + !conn->disable_reconnect && + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM + ) + error_num = 0; + } + } + conn->semi_trx_isolation = -2; + conn->semi_trx_isolation_chk = FALSE; + conn->semi_trx_chk = FALSE; + DBUG_RETURN(error_num); +} + +int spider_check_trx_and_get_conn( + THD *thd, + ha_spider *spider, + bool use_conn_kind +) { + int error_num, roop_count, search_link_idx; + SPIDER_TRX *trx; + SPIDER_SHARE *share = spider->share; + SPIDER_CONN *conn; + char first_byte, first_byte_bak; + int semi_table_lock_conn = spider_param_semi_table_lock_connection(thd, + share->semi_table_lock_conn); + DBUG_ENTER("spider_check_trx_and_get_conn"); + if (!(trx = spider_get_trx(thd, TRUE, &error_num))) + { + DBUG_PRINT("info",("spider get trx error")); + DBUG_RETURN(error_num); + } + spider->trx = trx; + spider->set_error_mode(); + if ( + spider->sql_command != SQLCOM_DROP_TABLE && + spider->sql_command != SQLCOM_ALTER_TABLE + ) { + SPIDER_TRX_HA *trx_ha = spider_check_trx_ha(trx, spider); + if (!trx_ha || trx_ha->wait_for_reusing) + spider_trx_set_link_idx_for_all(spider); + +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if (use_conn_kind) + { + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + if ( +/* + spider->conn_kind[roop_count] != SPIDER_CONN_KIND_MYSQL && +*/ + share->hs_dbton_ids[spider->conn_link_idx[roop_count]] == + SPIDER_DBTON_SIZE + ) { + /* can't use hs interface */ + spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; + spider_clear_bit(spider->do_hs_direct_update, roop_count); + } + } + } +#endif +#endif + + if (semi_table_lock_conn) + first_byte = '0' + + spider_param_semi_table_lock(thd, share->semi_table_lock); + else + first_byte = '0'; + DBUG_PRINT("info",("spider semi_table_lock_conn = %d", + semi_table_lock_conn)); + DBUG_PRINT("info",("spider semi_table_lock = %d", + spider_param_semi_table_lock(thd, share->semi_table_lock))); + DBUG_PRINT("info",("spider first_byte = %d", first_byte)); + DBUG_PRINT("info",("spider link_status = %ld", + share->link_statuses[spider->conn_link_idx[spider->search_link_idx]])); + if ( + !trx_ha || + trx_ha->wait_for_reusing || + trx->spider_thread_id != spider->spider_thread_id || + trx->trx_conn_adjustment != spider->trx_conn_adjustment || +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + (use_conn_kind && + ( + trx->trx_hs_r_conn_adjustment != spider->trx_hs_r_conn_adjustment || + trx->trx_hs_w_conn_adjustment != spider->trx_hs_w_conn_adjustment + ) + ) || +#endif + first_byte != *spider->conn_keys[0] || + share->link_statuses[spider->conn_link_idx[spider->search_link_idx]] == + SPIDER_LINK_STATUS_NG + ) { + DBUG_PRINT("info",(first_byte != *spider->conn_keys[0] ? + "spider change conn type" : trx != spider->trx ? "spider change thd" : + "spider next trx")); + spider->trx = trx; + spider->trx_conn_adjustment = trx->trx_conn_adjustment; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (use_conn_kind) + { + spider->trx_hs_r_conn_adjustment = trx->trx_hs_r_conn_adjustment; + spider->trx_hs_w_conn_adjustment = trx->trx_hs_w_conn_adjustment; + } +#endif + if ( + spider->spider_thread_id != trx->spider_thread_id || + spider->search_link_query_id != thd->query_id + ) { + search_link_idx = spider_conn_first_link_idx(thd, + share->link_statuses, share->access_balances, spider->conn_link_idx, + share->link_count, SPIDER_LINK_STATUS_OK); + if (search_link_idx == -1) + { + TABLE *table = spider->get_table(); + TABLE_SHARE *table_share = table->s; +#ifdef _MSC_VER + char *db, *table_name; + if (!(db = (char *) + spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME), + &db, table_share->db.length + 1, + &table_name, table_share->table_name.length + 1, + NullS)) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } +#else + char db[table_share->db.length + 1], + table_name[table_share->table_name.length + 1]; +#endif + memcpy(db, table_share->db.str, table_share->db.length); + db[table_share->db.length] = '\0'; + memcpy(table_name, table_share->table_name.str, + table_share->table_name.length); + table_name[table_share->table_name.length] = '\0'; + my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM, + ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name); +#ifdef _MSC_VER + spider_free(trx, db, MYF(MY_WME)); +#endif + DBUG_RETURN(ER_SPIDER_ALL_LINKS_FAILED_NUM); + } + spider->search_link_idx = search_link_idx; + spider->search_link_query_id = thd->query_id; + } + spider->spider_thread_id = trx->spider_thread_id; + + first_byte_bak = *spider->conn_keys[0]; + *spider->conn_keys[0] = first_byte; + for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) + { + if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_MYSQL)) + spider->conns[roop_count] = NULL; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_READ)) + spider->hs_r_conns[roop_count] = NULL; + if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_WRITE)) + spider->hs_w_conns[roop_count] = NULL; +#endif + } + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { + uint tgt_conn_kind = (use_conn_kind ? spider->conn_kind[roop_count] : + SPIDER_CONN_KIND_MYSQL); + if ( +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ( +#endif + tgt_conn_kind == SPIDER_CONN_KIND_MYSQL && + !spider->conns[roop_count] +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + ) || + (tgt_conn_kind == SPIDER_CONN_KIND_HS_READ && + !spider->hs_r_conns[roop_count]) || + (tgt_conn_kind == SPIDER_CONN_KIND_HS_WRITE && + !spider->hs_w_conns[roop_count]) +#endif + ) { + *spider->conn_keys[roop_count] = first_byte; + if ( + !(conn = + spider_get_conn(share, roop_count, + spider->conn_keys[roop_count], trx, + spider, FALSE, TRUE, + use_conn_kind ? spider->conn_kind[roop_count] : + SPIDER_CONN_KIND_MYSQL, + &error_num)) + ) { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_PRINT("info",("spider get conn error")); + *spider->conn_keys[0] = first_byte_bak; + spider->spider_thread_id = 0; + DBUG_RETURN(error_num); + } + conn->error_mode &= spider->error_mode; + } +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if ( + spider->do_direct_update && + spider_bit_is_set(spider->do_hs_direct_update, roop_count) && + !spider->hs_w_conns[roop_count] + ) { + if ( + !(conn = + spider_get_conn(share, roop_count, + spider->conn_keys[roop_count], trx, + spider, FALSE, TRUE, + SPIDER_CONN_KIND_HS_WRITE, + &error_num)) + ) { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_PRINT("info",("spider get conn error")); + *spider->conn_keys[0] = first_byte_bak; + spider->spider_thread_id = 0; + DBUG_RETURN(error_num); + } + conn->error_mode &= spider->error_mode; + } +#endif +#endif + } + } else { + for ( + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, -1, share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + roop_count < (int) share->link_count; + roop_count = spider_conn_link_idx_next(share->link_statuses, + spider->conn_link_idx, roop_count, share->link_count, + SPIDER_LINK_STATUS_RECOVERY) + ) { +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + if ( + !use_conn_kind || + spider->conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL + ) { +#endif + conn = spider->conns[roop_count]; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + } else if (spider->conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) + { + conn = spider->hs_r_conns[roop_count]; + } else { + conn = spider->hs_w_conns[roop_count]; + } +#endif + + if (!conn) + { + DBUG_PRINT("info",("spider get conn %d", roop_count)); + if ( + !(conn = + spider_get_conn(share, roop_count, + spider->conn_keys[roop_count], trx, + spider, FALSE, TRUE, + use_conn_kind ? spider->conn_kind[roop_count] : + SPIDER_CONN_KIND_MYSQL, + &error_num)) + ) { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_PRINT("info",("spider get conn error")); + DBUG_RETURN(error_num); + } + } + conn->error_mode &= spider->error_mode; +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) +#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS + if ( + spider->do_direct_update && + spider_bit_is_set(spider->do_hs_direct_update, roop_count) + ) { + conn = spider->hs_w_conns[roop_count]; + if (!conn) + { + DBUG_PRINT("info",("spider get hs_w_conn %d", roop_count)); + if ( + !(conn = + spider_get_conn(share, roop_count, + spider->conn_keys[roop_count], trx, + spider, FALSE, TRUE, + SPIDER_CONN_KIND_HS_WRITE, + &error_num)) + ) { + if ( + share->monitoring_kind[roop_count] && + spider->need_mons[roop_count] + ) { + error_num = spider_ping_table_mon_from_table( + trx, + trx->thd, + share, + (uint32) share->monitoring_sid[roop_count], + share->table_name, + share->table_name_length, + spider->conn_link_idx[roop_count], + NULL, + 0, + share->monitoring_kind[roop_count], + share->monitoring_limit[roop_count], + TRUE + ); + } + DBUG_PRINT("info",("spider get conn error")); + DBUG_RETURN(error_num); + } + } + } + conn->error_mode &= spider->error_mode; +#endif +#endif + } + } + spider->set_first_link_idx(); + DBUG_RETURN(spider_create_trx_ha(trx, spider, trx_ha)); + } + spider->spider_thread_id = trx->spider_thread_id; + DBUG_RETURN(0); +} + +THD *spider_create_tmp_thd() +{ + THD *thd; + DBUG_ENTER("spider_create_tmp_thd"); + if (!(thd = new THD)) + DBUG_RETURN(NULL); +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 + thd->killed = NOT_KILLED; +#else + thd->killed = THD::NOT_KILLED; +#endif +#if MYSQL_VERSION_ID < 50500 + thd->locked_tables = FALSE; +#endif + thd->proc_info = ""; + thd->thread_id = thd->variables.pseudo_thread_id = 0; + thd->thread_stack = (char*) &thd; + if (thd->store_globals()) + DBUG_RETURN(NULL); + lex_start(thd); + DBUG_RETURN(thd); +} + +void spider_free_tmp_thd( + THD *thd +) { + DBUG_ENTER("spider_free_tmp_thd"); + thd->cleanup(); + delete thd; + DBUG_VOID_RETURN; +} + +int spider_create_trx_ha( + SPIDER_TRX *trx, + ha_spider *spider, + SPIDER_TRX_HA *trx_ha +) { + bool need_create; + char *tmp_name; + uint *conn_link_idx; + uchar *conn_can_fo; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_create_trx_ha"); + if (!trx_ha) + { + DBUG_PRINT("info",("spider need create")); + need_create = TRUE; + } else if ( + trx_ha->share != share || + trx_ha->link_count != share->link_count || + trx_ha->link_bitmap_size != share->link_bitmap_size + ) { + DBUG_PRINT("info",("spider need recreate")); + need_create = TRUE; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + my_hash_delete_with_hash_value(&trx->trx_ha_hash, + share->table_name_hash_value, (uchar*) trx_ha); +#else + my_hash_delete(&trx->trx_ha_hash, (uchar*) trx_ha); +#endif + spider_free(trx, trx_ha, MYF(0)); + } else { + DBUG_PRINT("info",("spider use this")); + trx_ha->wait_for_reusing = FALSE; + need_create = FALSE; + } + if (need_create) + { + if (!(trx_ha = (SPIDER_TRX_HA *) + spider_bulk_malloc(spider_current_trx, 58, MYF(MY_WME), + &trx_ha, sizeof(SPIDER_TRX_HA), + &tmp_name, sizeof(char *) * (share->table_name_length + 1), + &conn_link_idx, sizeof(uint) * share->link_count, + &conn_can_fo, sizeof(uchar) * share->link_bitmap_size, + NullS)) + ) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + trx_ha->table_name = tmp_name; + memcpy(trx_ha->table_name, share->table_name, share->table_name_length); + trx_ha->table_name[share->table_name_length] = '\0'; + trx_ha->table_name_length = share->table_name_length; + trx_ha->trx = trx; + trx_ha->share = share; + trx_ha->link_count = share->link_count; + trx_ha->link_bitmap_size = share->link_bitmap_size; + trx_ha->conn_link_idx = conn_link_idx; + trx_ha->conn_can_fo = conn_can_fo; + trx_ha->wait_for_reusing = FALSE; + uint old_elements = trx->trx_ha_hash.array.max_element; +#ifdef HASH_UPDATE_WITH_HASH_VALUE + if (my_hash_insert_with_hash_value(&trx->trx_ha_hash, + share->table_name_hash_value, (uchar*) trx_ha)) +#else + if (my_hash_insert(&trx->trx_ha_hash, (uchar*) trx_ha)) +#endif + { + spider_free(trx, trx_ha, MYF(0)); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (trx->trx_ha_hash.array.max_element > old_elements) + { + spider_alloc_calc_mem(spider_current_trx, + trx->trx_ha_hash, + (trx->trx_ha_hash.array.max_element - old_elements) * + trx->trx_ha_hash.array.size_of_element); + } + } + memcpy(trx_ha->conn_link_idx, spider->conn_link_idx, + sizeof(uint) * share->link_count); + memcpy(trx_ha->conn_can_fo, spider->conn_can_fo, + sizeof(uint) * share->link_bitmap_size); + DBUG_RETURN(0); +} + +SPIDER_TRX_HA *spider_check_trx_ha( + SPIDER_TRX *trx, + ha_spider *spider +) { + SPIDER_TRX_HA *trx_ha; + SPIDER_SHARE *share = spider->share; + DBUG_ENTER("spider_check_trx_ha"); +#ifdef SPIDER_HAS_HASH_VALUE_TYPE + if ((trx_ha = (SPIDER_TRX_HA *) my_hash_search_using_hash_value( + &trx->trx_ha_hash, share->table_name_hash_value, + (uchar*) share->table_name, share->table_name_length))) +#else + if ((trx_ha = (SPIDER_TRX_HA *) my_hash_search(&trx->trx_ha_hash, + (uchar*) share->table_name, share->table_name_length))) +#endif + { + memcpy(spider->conn_link_idx, trx_ha->conn_link_idx, + sizeof(uint) * share->link_count); + memcpy(spider->conn_can_fo, trx_ha->conn_can_fo, + sizeof(uint) * share->link_bitmap_size); + DBUG_RETURN(trx_ha); + } + DBUG_RETURN(NULL); +} + +void spider_free_trx_ha( + SPIDER_TRX *trx +) { + ulong roop_count; + SPIDER_TRX_HA *trx_ha; + DBUG_ENTER("spider_free_trx_ha"); + for (roop_count = 0; roop_count < trx->trx_ha_hash.records; roop_count++) + { + trx_ha = (SPIDER_TRX_HA *) my_hash_element(&trx->trx_ha_hash, roop_count); + spider_free(spider_current_trx, trx_ha, MYF(0)); + } + my_hash_reset(&trx->trx_ha_hash); + DBUG_VOID_RETURN; +} + +void spider_reuse_trx_ha( + SPIDER_TRX *trx +) { + ulong roop_count; + SPIDER_TRX_HA *trx_ha; + DBUG_ENTER("spider_reuse_trx_ha"); + if (trx->trx_ha_reuse_count < 10000) + { + trx->trx_ha_reuse_count++; + for (roop_count = 0; roop_count < trx->trx_ha_hash.records; roop_count++) + { + trx_ha = (SPIDER_TRX_HA *) my_hash_element(&trx->trx_ha_hash, + roop_count); + trx_ha->wait_for_reusing = TRUE; + } + } else { + trx->trx_ha_reuse_count = 0; + spider_free_trx_ha(trx); + } + DBUG_VOID_RETURN; +} + +void spider_trx_set_link_idx_for_all( + ha_spider *spider +) { + int roop_count, roop_count2; + SPIDER_SHARE *share = spider->share; + long *link_statuses = share->link_statuses; + uint *conn_link_idx = spider->conn_link_idx; + int link_count = share->link_count; + int all_link_count = share->all_link_count; + uchar *conn_can_fo = spider->conn_can_fo; + DBUG_ENTER("spider_trx_set_link_idx_for_all"); + DBUG_PRINT("info",("spider set link_count=%d", link_count)); + DBUG_PRINT("info",("spider set all_link_count=%d", all_link_count)); + memset(conn_can_fo, 0, sizeof(uchar) * share->link_bitmap_size); + for (roop_count = 0; roop_count < link_count; roop_count++) + { + for (roop_count2 = roop_count; roop_count2 < all_link_count; + roop_count2 += link_count) + { + if (link_statuses[roop_count2] <= SPIDER_LINK_STATUS_RECOVERY) + break; + } + if (roop_count2 < all_link_count) + { + conn_link_idx[roop_count] = roop_count2; + if (roop_count2 + link_count < all_link_count) + spider_set_bit(conn_can_fo, roop_count); + DBUG_PRINT("info",("spider set conn_link_idx[%d]=%d", + roop_count, roop_count2)); + } else { + conn_link_idx[roop_count] = roop_count; + DBUG_PRINT("info",("spider set2 conn_link_idx[%d]=%d", + roop_count, roop_count)); + } + spider->conn_keys[roop_count] = + ADD_TO_PTR(spider->conn_keys_first_ptr, + PTR_BYTE_DIFF(share->conn_keys[conn_link_idx[roop_count]], + share->conn_keys[0]), char*); + DBUG_PRINT("info",("spider conn_keys[%d]=%s", + roop_count, spider->conn_keys[roop_count])); +#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) + spider->hs_r_conn_keys[roop_count] = + ADD_TO_PTR(spider->conn_keys_first_ptr, + PTR_BYTE_DIFF(share->hs_read_conn_keys[conn_link_idx[roop_count]], + share->conn_keys[0]), char*); + DBUG_PRINT("info",("spider hs_r_conn_keys[%d]=%s", + roop_count, spider->hs_r_conn_keys[roop_count])); + spider->hs_w_conn_keys[roop_count] = + ADD_TO_PTR(spider->conn_keys_first_ptr, + PTR_BYTE_DIFF(share->hs_write_conn_keys[conn_link_idx[roop_count]], + share->conn_keys[0]), char*); + DBUG_PRINT("info",("spider hs_w_conn_keys[%d]=%s", + roop_count, spider->hs_w_conn_keys[roop_count])); +#endif + } + DBUG_VOID_RETURN; +} + +int spider_trx_check_link_idx_failed( + ha_spider *spider +) { + int roop_count; + SPIDER_SHARE *share = spider->share; + long *link_statuses = share->link_statuses; + uint *conn_link_idx = spider->conn_link_idx; + int link_count = share->link_count; + uchar *conn_can_fo = spider->conn_can_fo; + DBUG_ENTER("spider_trx_set_link_idx_for_all"); + for (roop_count = 0; roop_count < link_count; roop_count++) + { + if ( + link_statuses[conn_link_idx[roop_count]] == SPIDER_LINK_STATUS_NG && + spider_bit_is_set(conn_can_fo, roop_count) + ) { + my_message(ER_SPIDER_LINK_IS_FAILOVER_NUM, + ER_SPIDER_LINK_IS_FAILOVER_STR, MYF(0)); + DBUG_RETURN(ER_SPIDER_LINK_IS_FAILOVER_NUM); + } + } + DBUG_RETURN(0); +} + +#ifdef HA_CAN_BULK_ACCESS +void spider_trx_add_bulk_access_conn( + SPIDER_TRX *trx, + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_trx_add_bulk_access_conn"); + DBUG_PRINT("info",("spider trx=%p", trx)); + DBUG_PRINT("info",("spider conn=%p", conn)); + DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", + conn->bulk_access_requests)); + DBUG_PRINT("info",("spider conn->bulk_access_sended=%u", + conn->bulk_access_sended)); + DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", + trx->bulk_access_conn_first)); + if (!conn->bulk_access_requests && !conn->bulk_access_sended) + { + if (!trx->bulk_access_conn_first) + { + trx->bulk_access_conn_first = conn; + } else { + trx->bulk_access_conn_last->bulk_access_next = conn; + } + trx->bulk_access_conn_last = conn; + conn->bulk_access_next = NULL; + } + conn->bulk_access_requests++; + DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", + conn->bulk_access_requests)); + DBUG_VOID_RETURN; +} +#endif diff --git a/storage/spider/spd_trx.h b/storage/spider/spd_trx.h new file mode 100644 index 00000000000..95814a4b95c --- /dev/null +++ b/storage/spider/spd_trx.h @@ -0,0 +1,260 @@ +/* Copyright (C) 2008-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +int spider_free_trx_conn( + SPIDER_TRX *trx, + bool trx_free +); + +int spider_free_trx_another_conn( + SPIDER_TRX *trx, + bool lock +); + +int spider_trx_another_lock_tables( + SPIDER_TRX *trx +); + +int spider_trx_another_flush_tables( + SPIDER_TRX *trx +); + +int spider_trx_all_flush_tables( + SPIDER_TRX *trx +); + +int spider_trx_all_unlock_tables( + SPIDER_TRX *trx +); + +int spider_trx_all_start_trx( + SPIDER_TRX *trx +); + +int spider_trx_all_flush_logs( + SPIDER_TRX *trx +); + +int spider_free_trx_alloc( + SPIDER_TRX *trx +); + +void spider_free_trx_alter_table_alloc( + SPIDER_TRX *trx, + SPIDER_ALTER_TABLE *alter_table +); + +int spider_free_trx_alter_table( + SPIDER_TRX *trx +); + +int spider_create_trx_alter_table( + SPIDER_TRX *trx, + SPIDER_SHARE *share, + bool now_create +); + +bool spider_cmp_trx_alter_table( + SPIDER_ALTER_TABLE *cmp1, + SPIDER_ALTER_TABLE *cmp2 +); + +SPIDER_TRX *spider_get_trx( + THD *thd, + bool regist_allocated_thds, + int *error_num +); + +int spider_free_trx( + SPIDER_TRX *trx, + bool need_lock +); + +int spider_check_and_set_trx_isolation( + SPIDER_CONN *conn, + int *need_mon +); + +int spider_check_and_set_autocommit( + THD *thd, + SPIDER_CONN *conn, + int *need_mon +); + +int spider_check_and_set_sql_log_off( + THD *thd, + SPIDER_CONN *conn, + int *need_mon +); + +int spider_check_and_set_time_zone( + THD *thd, + SPIDER_CONN *conn, + int *need_mon +); + +int spider_xa_lock( + XID_STATE *xid_state +); + +int spider_xa_unlock( + XID_STATE *xid_state +); + +int spider_start_internal_consistent_snapshot( + SPIDER_TRX *trx, + SPIDER_CONN *conn, + int *need_mon +); + +int spider_internal_start_trx( + ha_spider *spider, + SPIDER_CONN *conn, + int link_idx +); + +int spider_internal_xa_commit( + THD* thd, + SPIDER_TRX *trx, + XID* xid, + TABLE *table_xa, + TABLE *table_xa_member +); + +int spider_internal_xa_rollback( + THD* thd, + SPIDER_TRX *trx +); + +int spider_internal_xa_prepare( + THD* thd, + SPIDER_TRX *trx, + TABLE *table_xa, + TABLE *table_xa_member, + bool internal_xa +); + +int spider_internal_xa_recover( + THD* thd, + XID* xid_list, + uint len +); + +int spider_initinal_xa_recover( + XID* xid_list, + uint len +); + +int spider_internal_xa_commit_by_xid( + THD* thd, + SPIDER_TRX *trx, + XID* xid +); + +int spider_internal_xa_rollback_by_xid( + THD* thd, + SPIDER_TRX *trx, + XID* xid +); + +int spider_start_consistent_snapshot( + handlerton *hton, + THD* thd +); + +int spider_commit( + handlerton *hton, + THD *thd, + bool all +); + +int spider_rollback( + handlerton *hton, + THD *thd, + bool all +); + +int spider_xa_prepare( + handlerton *hton, + THD* thd, + bool all +); + +int spider_xa_recover( + handlerton *hton, + XID* xid_list, + uint len +); + +int spider_xa_commit_by_xid( + handlerton *hton, + XID* xid +); + +int spider_xa_rollback_by_xid( + handlerton *hton, + XID* xid +); + +int spider_end_trx( + SPIDER_TRX *trx, + SPIDER_CONN *conn +); + +int spider_check_trx_and_get_conn( + THD *thd, + ha_spider *spider, + bool use_conn_kind +); + +THD *spider_create_tmp_thd(); + +void spider_free_tmp_thd( + THD *thd +); + +int spider_create_trx_ha( + SPIDER_TRX *trx, + ha_spider *spider, + SPIDER_TRX_HA *trx_ha +); + +SPIDER_TRX_HA *spider_check_trx_ha( + SPIDER_TRX *trx, + ha_spider *spider +); + +void spider_free_trx_ha( + SPIDER_TRX *trx +); + +void spider_reuse_trx_ha( + SPIDER_TRX *trx +); + +void spider_trx_set_link_idx_for_all( + ha_spider *spider +); + +int spider_trx_check_link_idx_failed( + ha_spider *spider +); + +#ifdef HA_CAN_BULK_ACCESS +void spider_trx_add_bulk_access_conn( + SPIDER_TRX *trx, + SPIDER_CONN *conn +); +#endif diff --git a/storage/spider/spd_udf.cc b/storage/spider/spd_udf.cc new file mode 100644 index 00000000000..c116bd13805 --- /dev/null +++ b/storage/spider/spd_udf.cc @@ -0,0 +1,154 @@ +/* Copyright (C) 2009-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include +#include "mysql.h" +#include "spd_udf.h" + +extern "C" { +long long spider_direct_sql( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +) { + return spider_direct_sql_body(initid, args, is_null, error, FALSE); +} + +my_bool spider_direct_sql_init( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +) { + return spider_direct_sql_init_body(initid, args, message, FALSE); +} + +void spider_direct_sql_deinit( + UDF_INIT *initid +) { + spider_direct_sql_deinit_body(initid); +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +long long spider_bg_direct_sql( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +) { + return spider_direct_sql_bg_end(initid); +} + +my_bool spider_bg_direct_sql_init( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +) { + return spider_direct_sql_init_body(initid, args, message, TRUE); +} + +void spider_bg_direct_sql_deinit( + UDF_INIT *initid +) { + spider_direct_sql_deinit_body(initid); +} + +void spider_bg_direct_sql_clear( + UDF_INIT *initid, + char *is_null, + char *error +) { + spider_direct_sql_bg_start(initid); +} + +void spider_bg_direct_sql_add( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +) { + spider_direct_sql_body(initid, args, is_null, error, TRUE); +} +#endif + +long long spider_ping_table( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +) { + return spider_ping_table_body(initid, args, is_null, error); +} + +my_bool spider_ping_table_init( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +) { + return spider_ping_table_init_body(initid, args, message); +} + +void spider_ping_table_deinit( + UDF_INIT *initid +) { + spider_ping_table_deinit_body(initid); +} + +long long spider_flush_table_mon_cache( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +) { + return spider_flush_table_mon_cache_body(); +} + +my_bool spider_flush_table_mon_cache_init( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +) { + return FALSE; +} + +void spider_flush_table_mon_cache_deinit( + UDF_INIT *initid +) { +} + +long long spider_copy_tables( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +) { + return spider_copy_tables_body(initid, args, is_null, error); +} + +my_bool spider_copy_tables_init( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +) { + return spider_copy_tables_init_body(initid, args, message); +} + +void spider_copy_tables_deinit( + UDF_INIT *initid +) { + spider_copy_tables_deinit_body(initid); +} +} diff --git a/storage/spider/spd_udf.def b/storage/spider/spd_udf.def new file mode 100644 index 00000000000..d0d7d53e3fe --- /dev/null +++ b/storage/spider/spd_udf.def @@ -0,0 +1,20 @@ +LIBRARY ha_spider +VERSION 1.0 +EXPORTS + spider_direct_sql + spider_direct_sql_init + spider_direct_sql_deinit + spider_bg_direct_sql + spider_bg_direct_sql_init + spider_bg_direct_sql_deinit + spider_bg_direct_sql_clear + spider_bg_direct_sql_add + spider_ping_table + spider_ping_table_init + spider_ping_table_deinit + spider_flush_table_mon_cache + spider_flush_table_mon_cache_init + spider_flush_table_mon_cache_deinit + spider_copy_tables + spider_copy_tables_init + spider_copy_tables_deinit diff --git a/storage/spider/spd_udf.h b/storage/spider/spd_udf.h new file mode 100644 index 00000000000..eb70055247c --- /dev/null +++ b/storage/spider/spd_udf.h @@ -0,0 +1,79 @@ +/* Copyright (C) 2009-2013 Kentoku Shiba + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +long long spider_direct_sql_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error, + my_bool bg +); + +my_bool spider_direct_sql_init_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *message, + my_bool bg +); + +void spider_direct_sql_deinit_body( + UDF_INIT *initid +); + +#ifndef WITHOUT_SPIDER_BG_SEARCH +void spider_direct_sql_bg_start( + UDF_INIT *initid +); + +long long spider_direct_sql_bg_end( + UDF_INIT *initid +); +#endif + +long long spider_ping_table_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +); + +my_bool spider_ping_table_init_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +); + +void spider_ping_table_deinit_body( + UDF_INIT *initid +); + +long long spider_flush_table_mon_cache_body(); + +long long spider_copy_tables_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *is_null, + char *error +); + +my_bool spider_copy_tables_init_body( + UDF_INIT *initid, + UDF_ARGS *args, + char *message +); + +void spider_copy_tables_deinit_body( + UDF_INIT *initid +); From 9508e913e726f23cfdaeccbce12619e5e4e72bfc Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 28 Jun 2013 14:22:32 +0200 Subject: [PATCH 243/273] - Release memory allocated by inihandl in connect_done_func. modified: storage/connect/ha_connect.cc - Remove unuseful last change modified: storage/connect/block.h --- storage/connect/block.h | 3 --- storage/connect/ha_connect.cc | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/connect/block.h b/storage/connect/block.h index fae4dffa68f..963cfa42f32 100644 --- a/storage/connect/block.h +++ b/storage/connect/block.h @@ -52,9 +52,6 @@ if (debug != NULL) // Avoid warning C4291 by defining a matching dummy delete operator void operator delete(void *, PGLOBAL, void *) {} #endif - - protected: - ~BLOCK(void) {} }; // end of class BLOCK #endif // !BLOCK_DEFINED diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 897827474a6..a75bcf86b22 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -394,6 +394,10 @@ static int connect_done_func(void *p) XmlCleanupParserLib(); #endif // LIBXML2_SUPPORT +#if !defined(WIN32) + PROFILE_Close(connectini); +#endif // !WIN32 + for (pc= user_connect::to_users; pc; pc= pn) { if (pc->g) PlugCleanup(pc->g, true); From b8d6f97380c7f3e3e9278afb9dd21c133c0d051e Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 29 Jun 2013 01:10:31 +0200 Subject: [PATCH 244/273] - Add the PROFILE_End function in inihandl. Called by connect_done_func to release the cache memory allocated by the PROFILE perocessing. (also add some break at the end of switch's to avoid warnings) modified: storage/connect/filamvct.cpp storage/connect/ha_connect.cc storage/connect/inihandl.c storage/connect/inihandl.h --- storage/connect/filamvct.cpp | 8 ++++---- storage/connect/ha_connect.cc | 24 +++++++++++++++++++++--- storage/connect/inihandl.c | 25 +++++++++++++++++++++++++ storage/connect/inihandl.h | 1 + 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index 47ac07c6554..914d671637c 100755 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -10,15 +10,15 @@ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ /* This program are the VCT file access method classes. */ -/* Added in version 2: F */ +/* Added in version 2: F */ /* - Split Vec format. */ /* - Partial delete. */ -/* - Use of tempfile for update. */ +/* - Use of tempfile for update. */ /* */ /***********************************************************************/ /***********************************************************************/ -/* Include relevant MariaDB header file. */ +/* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" #if defined(WIN32) @@ -1823,7 +1823,7 @@ bool VECFAM::OpenTableFile(PGLOBAL g) { char opmode[4]; int i; - bool b; + bool b= false; PCOLDEF cdp; PVCTCOL cp; MODE mode = Tdbp->GetMode(); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index a75bcf86b22..62641c2234f 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -360,6 +360,9 @@ static int connect_init_func(void *p) trace= xtrace; } // endif xtrace +#if !defined(WIN32) + PROFILE_Close(connectini); +#endif // !WIN32 init_connect_psi_keys(); @@ -395,7 +398,7 @@ static int connect_done_func(void *p) #endif // LIBXML2_SUPPORT #if !defined(WIN32) - PROFILE_Close(connectini); + PROFILE_End(); #endif // !WIN32 for (pc= user_connect::to_users; pc; pc= pn) { @@ -903,6 +906,7 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VAR_STRING: pcf->Flags |= U_VAR; + /* no break */ case MYSQL_TYPE_STRING: pcf->Type= TYPE_STRING; @@ -966,6 +970,7 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) break; default: pcf->Type=TYPE_ERROR; + break; } // endswitch type // This is used to skip null bit @@ -1327,6 +1332,7 @@ int ha_connect::MakeRecord(char *buf) break; default: fmt= "%Y-%m-%d %H:%M:%S"; + break; } // endswitch type // Get date in the format required by MySQL fields @@ -1340,6 +1346,7 @@ int ha_connect::MakeRecord(char *buf) // Passthru default: p= value->GetCharString(val); + break; } // endswitch Type if (p) { @@ -1459,6 +1466,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) attribute.charset(), charset, &cnv_errors); value->SetValue_psz(data_charset_value.c_ptr_safe()); } + break; } // endswitch Type #ifdef NEWCHANGE @@ -1566,6 +1574,7 @@ const char *ha_connect::GetValStr(OPVAL vop, bool neg) break; default: val= " ? "; + break; } /* endswitch */ return val; @@ -2168,6 +2177,7 @@ int ha_connect::ReadIndexed(uchar *buf, OPVAL op, const uchar *key, uint key_len DBUG_PRINT("ReadIndexed", ("%s", xp->g->Message)); printf("ReadIndexed: %s\n", xp->g->Message); rc= HA_ERR_INTERNAL_ERROR; + break; } // endswitch RC if (xtrace > 1) @@ -2210,7 +2220,7 @@ int ha_connect::index_read(uchar * buf, const uchar * key, uint key_len, case HA_READ_KEY_EXACT: op= OP_EQ; break; case HA_READ_AFTER_KEY: op= OP_GT; break; case HA_READ_KEY_OR_NEXT: op= OP_GE; break; - default: DBUG_RETURN(-1); + default: DBUG_RETURN(-1); break; } // endswitch find_flag if (xtrace > 1) @@ -2833,6 +2843,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) case F_UNLCK: default: newmode= MODE_ANY; + break; } // endswitch mode if (newmode == MODE_ANY) { @@ -2990,6 +3001,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) printf("Unsupported sql_command=%d", thd_sql_command(thd)); sprintf(g->Message, "Unsupported sql_command=%d", thd_sql_command(thd)); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); + break; } // endswitch newmode } else if (newmode == MODE_READ) { @@ -3027,6 +3039,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) printf("Unsupported sql_command=%d", thd_sql_command(thd)); sprintf(g->Message, "Unsupported sql_command=%d", thd_sql_command(thd)); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); + break; } // endswitch newmode } // endif's newmode @@ -3583,6 +3596,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, break; default: sprintf(g->Message, "Cannot get column info for table type %s", topt->type); + break; } // endif ttp // Check for supported catalog function @@ -3643,6 +3657,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, break; default: sprintf(g->Message, "invalid catfunc %s", fncn); + break; } // endswitch info break; @@ -3979,7 +3994,8 @@ int ha_connect::create(const char *name, TABLE *table_arg, } // endif tabname default: /* do nothing */; - } // endswitch ttp + break; + } // endswitch ttp if (type == TAB_XML) { bool dom; // True: MS-DOM, False libxml2 @@ -4001,6 +4017,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, break; default: dom= false; + break; } // endswitch xsup #if !defined(DOMDOC_SUPPORT) @@ -4086,6 +4103,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, "Unsupported type for column '%s'", MYF(0), fp->field_name); DBUG_RETURN(rc); + break; } // endswitch type if ((fp)->real_maybe_null() && !IsTypeNullable(type)) { diff --git a/storage/connect/inihandl.c b/storage/connect/inihandl.c index 60b72bd2604..0dc7a53faf3 100644 --- a/storage/connect/inihandl.c +++ b/storage/connect/inihandl.c @@ -608,6 +608,31 @@ void PROFILE_Close(LPCSTR filename) } // end of PROFILE_Close +/*********************************************************************** + * PROFILE_End + * + * Terminate and release the cache. + ***********************************************************************/ +void PROFILE_End(void) +{ + int i; + + if (trace) + htrc("PROFILE_End: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES); + + /* Close all opened files and free the cache structure */ + for (i = 0; i < N_CACHED_PROFILES; i++) { + if (trace) + htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i); + + CurProfile = MRUProfile[i]; + PROFILE_ReleaseFile(); + free(MRUProfile[i]); + } // endfor i + +} // end of PROFILE_End + + /*********************************************************************** * PROFILE_DeleteSection * diff --git a/storage/connect/inihandl.h b/storage/connect/inihandl.h index 7f6fcb1f582..f0b7c9afe5c 100644 --- a/storage/connect/inihandl.h +++ b/storage/connect/inihandl.h @@ -8,6 +8,7 @@ extern "C" { #endif void PROFILE_Close(LPCSTR filename); +void PROFILE_End(void); int GetPrivateProfileString( LPCTSTR lpAppName, // section name From 639ce0650cdfc271b2ccf08c4bb294daa28824fa Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 29 Jun 2013 22:53:21 +0200 Subject: [PATCH 245/273] - Release storage allocated by flex modified: storage/connect/fmdlex.c --- storage/connect/fmdlex.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index 9ab8f2e03c5..669104b4425 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -20,11 +20,9 @@ */ #define FLEX_SCANNER - #if WIN32 #define __STDC__ 1 #endif - #include @@ -47,7 +45,7 @@ /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST -#else /* ! __cplusplus */ +#else /* ! __cplusplus */ #ifdef __STDC__ @@ -131,7 +129,7 @@ extern "C" { * int a single C statement (which needs a semi-colon terminator). This * avoids problems with code like: * - * if ( condition_holds ) + * if ( condition_holds ) * yyless( 5 ); * else * do_something_else(); @@ -161,7 +159,7 @@ struct yy_buffer_state FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ + char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. @@ -220,7 +218,7 @@ int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ +static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches @@ -520,10 +518,7 @@ YY_DECL if (pp->InFmt) {*pp->InFmt = '\0'; pp->InFmt[pp->Outsize -1] = '\0'; } if (pp->OutFmt) {*pp->OutFmt = '\0'; pp->OutFmt[pp->Outsize -1] = '\0'; } pp->Curp = pp->Format; - if (!yy_init) { /* Restart that stupid Flex otherwise parsing last input */ - yy_init_buffer( yy_current_buffer, yyin ); - yy_load_buffer_state(); - } // endif yy_init + yy_init = 1; /* This is a new input */ if ( yy_init ) @@ -533,7 +528,7 @@ YY_DECL #endif if ( ! yy_start ) - yy_start = 1; /* first start state */ + yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; @@ -552,7 +547,7 @@ YY_DECL yy_init = 0; } - while ( 1 ) /* loops until end-of-file is reached */ + while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yy_c_buf_p; @@ -1114,7 +1109,7 @@ static int input() } c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ + *yy_c_buf_p = '\0'; /* preserve yytext */ yy_hold_char = *++yy_c_buf_p; return c; @@ -1520,6 +1515,10 @@ void Quotout(char *text) int yywrap(void) { + /* Avoid memory leak */ + if (yy_current_buffer) + yy_delete_buffer(yy_current_buffer); + return 1; } /* end of yywrap */ From b98360a42f2aec08fb7799c23a4b7c7566fb66ec Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 30 Jun 2013 12:43:30 +0200 Subject: [PATCH 246/273] - Trying to get rid of some valgrind warnings modified: storage/connect/mycat.cc storage/connect/valblk.cpp storage/connect/value.cpp --- storage/connect/mycat.cc | 2 ++ storage/connect/valblk.cpp | 7 +++-- storage/connect/value.cpp | 64 ++++++++++++++++++++++++++------------ 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index e243a706f01..3dd203949b6 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -426,6 +426,8 @@ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp) PCOLDEF cdp, lcdp= NULL, tocols= NULL; PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO)); + memset(pcf, 0, sizeof(COLINFO)); + // Get a unique char identifier for type tc= (defp->Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX; diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index 575d88a56fc..cee4571bc0d 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -654,8 +654,11 @@ void CHRBLK::SetValues(PVBLK pv, int k, int n) /***********************************************************************/ void CHRBLK::Move(int i, int j) { - memcpy(Chrp + j * Long, Chrp + i * Long, Long); - MoveNull(i, j); + if (i != j) { + memcpy(Chrp + j * Long, Chrp + i * Long, Long); + MoveNull(i, j); + } // endif i + } // end of Move /***********************************************************************/ diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index e60f3889ef5..196724ea6c0 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -578,19 +578,25 @@ void TYPVAL::SetValue_char(char *p, int n) template <> void TYPVAL::SetValue_char(char *p, int n) { - char *p2, buf[32]; + if (p) { + char *p2, buf[32]; - for (p2 = p + n; p < p2 && *p == ' '; p++) ; + for (p2 = p + n; p < p2 && *p == ' '; p++) ; - n = min(p2 - p, 31); - memcpy(buf, p, n); - buf[n] = '\0'; - Tval = atof(buf); + n = min(p2 - p, 31); + memcpy(buf, p, n); + buf[n] = '\0'; + Tval = atof(buf); - if (trace > 1) - htrc(" setting double: '%s' -> %lf\n", buf, Tval); + if (trace > 1) + htrc(" setting double: '%s' -> %lf\n", buf, Tval); + + Null = false; + } else { + Reset(); + Null = Nullable; + } // endif p - Null = false; } // end of SetValue /***********************************************************************/ @@ -599,8 +605,14 @@ void TYPVAL::SetValue_char(char *p, int n) template void TYPVAL::SetValue_psz(PSZ s) { - Tval = GetTypedValue(s); - Null = false; + if (s) { + Tval = GetTypedValue(s); + Null = false; + } else { + Reset(); + Null = Nullable; + } // endif p + } // end of SetValue template <> @@ -895,17 +907,23 @@ bool TYPVAL::SetValue_pval(PVAL valp, bool chktype) /***********************************************************************/ void TYPVAL::SetValue_char(char *p, int n) { - n = min(n, Len); - strncpy(Strp, p, n); + if (p) { + n = min(n, Len); + strncpy(Strp, p, n); - for (p = Strp + n - 1; (*p == ' ' || *p == '\0') && p >= Strp; p--) ; + for (p = Strp + n - 1; (*p == ' ' || *p == '\0') && p >= Strp; p--) ; - *(++p) = '\0'; + *(++p) = '\0'; - if (trace > 1) - htrc(" Setting string to: '%s'\n", Strp); + if (trace > 1) + htrc(" Setting string to: '%s'\n", Strp); + + Null = false; + } else { + Reset(); + Null = Nullable; + } // endif p - Null = false; } // end of SetValue_char /***********************************************************************/ @@ -913,8 +931,14 @@ void TYPVAL::SetValue_char(char *p, int n) /***********************************************************************/ void TYPVAL::SetValue_psz(PSZ s) { - strncpy(Strp, s, Len); - Null = false; + if (s) { + strncpy(Strp, s, Len); + Null = false; + } else { + Reset(); + Null = Nullable; + } // endif s + } // end of SetValue_psz /***********************************************************************/ From 29f10f0ff19f245a7e00e8ece8a477c1d8bf4a01 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 30 Jun 2013 19:08:09 +0200 Subject: [PATCH 247/273] - Working on eliminating valgrind warning/errors modified: storage/connect/tabdos.cpp storage/connect/tabfix.cpp storage/connect/value.cpp --- storage/connect/tabdos.cpp | 2 +- storage/connect/tabfix.cpp | 2 +- storage/connect/value.cpp | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index 288396276bc..b828c44d648 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -1047,7 +1047,7 @@ bool DOSCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) /***********************************************************************/ void DOSCOL::ReadColumn(PGLOBAL g) { - char *p; + char *p = NULL; int i, rc; int field; double dval; diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp index 801de79aad9..4cad405452e 100644 --- a/storage/connect/tabfix.cpp +++ b/storage/connect/tabfix.cpp @@ -327,7 +327,7 @@ BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp) /***********************************************************************/ void BINCOL::ReadColumn(PGLOBAL g) { - char *p; + char *p = NULL; int rc; PTDBFIX tdbp = (PTDBFIX)To_Tdb; diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 196724ea6c0..e75a6e41557 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -1034,7 +1034,6 @@ void TYPVAL::SetValue(char c) void TYPVAL::SetBinValue(void *p) { SetValue_char((char *)p, Len); - Null = false; } // end of SetBinValue /***********************************************************************/ From 37fce46f6605160734ba3a5d69fb653b0cdd28c5 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 2 Jul 2013 00:07:48 +0200 Subject: [PATCH 248/273] - Fix memory leak in libdoc.cpp in LIBXMLDOC::GetNodeList replacing xmlXPathFreeNodeSetList(Xop); // Caused memory leak, by xmlXPathFreeObject(Xop); modified: storage/connect/libdoc.cpp --- storage/connect/libdoc.cpp | 153 +++++++++++++++++++++++++++++++++---- 1 file changed, 138 insertions(+), 15 deletions(-) diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 95b98931680..2a786ef0eef 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -30,6 +30,53 @@ extern char version[]; extern int trace; } // "C" +#if defined(_DEBUG) +static xmlFreeFunc Free; +static xmlMallocFunc Malloc; +static xmlMallocFunc MallocA; +static xmlReallocFunc Realloc; +static xmlStrdupFunc Strdup; + +void xmlMyFree(void *mem) +{ + if (trace) + htrc("Freeing at %p\n", mem); + Free(mem); +} // end of xmlMyFree + +void *xmlMyMalloc(size_t size) +{ + void *p = Malloc(size); + if (trace) + htrc("Allocating %.5d at %p\n", size, p); + return p; +} // end of xmlMyMalloc + +void *xmlMyMallocAtomic(size_t size) +{ + void *p = MallocA(size); + if (trace) + htrc("Atom alloc %.5d at %p\n", size, p); + return p; +} // end of xmlMyMallocAtomic + +void *xmlMyRealloc(void *mem, size_t size) +{ + void *p = Realloc(mem, size); + if (trace) + htrc("ReAlloc %.5d to %p from %p\n", size, p, mem); + return p; +} // end of xmlMyRealloc + +char *xmlMyStrdup(const char *str) +{ + char *p = Strdup(str); + if (trace) + htrc("Duplicating to %p from %p %s\n", p, str, str); + return p; +} // end of xmlMyStrdup +#endif // _DEBUG + /******************************************************************/ /* Return a LIBXMLDOC as a XMLDOC. */ /******************************************************************/ @@ -44,6 +91,17 @@ PXDOC GetLibxmlDoc(PGLOBAL g, char *nsl, char *nsdf, /******************************************************************/ void XmlInitParserLib(void) { +#if defined(_DEBUG) +int rc = xmlGcMemGet(&Free, &Malloc, &MallocA, &Realloc, &Strdup); + +if (!rc) + rc = xmlGcMemSetup(xmlMyFree, + xmlMyMalloc, + xmlMyMallocAtomic, + xmlMyRealloc, + xmlMyStrdup); + +#endif // _DEBUG xmlInitParser(); } // end of XmlInitParserLib @@ -63,6 +121,9 @@ void CloseXML2File(PGLOBAL g, PFBLOCK fp, bool all) { PX2BLOCK xp = (PX2BLOCK)fp; + if (trace) + htrc("CloseXML2File: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0); + if (xp && xp->Count > 1 && !all) { xp->Count--; } else if (xp && xp->Count > 0) { @@ -101,6 +162,9 @@ bool LIBXMLDOC::Initialize(PGLOBAL g) /******************************************************************/ bool LIBXMLDOC::ParseFile(char *fn) { + if (trace) + htrc("ParseFile\n"); + if ((Docp = xmlParseFile(fn))) { if (Docp->encoding) Encoding = (char*)Docp->encoding; @@ -149,6 +213,9 @@ bool LIBXMLDOC::NewDoc(PGLOBAL g, char *ver) /******************************************************************/ void LIBXMLDOC::AddComment(PGLOBAL g, char *txtp) { + if (trace) + htrc("AddComment: %s\n", txtp); + xmlNodePtr cp = xmlNewDocComment(Docp, BAD_CAST txtp); xmlAddChild((xmlNodePtr)Docp, cp); } // end of AddText @@ -158,6 +225,9 @@ void LIBXMLDOC::AddComment(PGLOBAL g, char *txtp) /******************************************************************/ PXNODE LIBXMLDOC::GetRoot(PGLOBAL g) { + if (trace) + htrc("GetRoot\n"); + xmlNodePtr root = xmlDocGetRootElement(Docp); if (!root) @@ -171,6 +241,9 @@ PXNODE LIBXMLDOC::GetRoot(PGLOBAL g) /******************************************************************/ PXNODE LIBXMLDOC::NewRoot(PGLOBAL g, char *name) { + if (trace) + htrc("NewRoot: %s\n", name); + xmlNodePtr root = xmlNewDocNode(Docp, NULL, BAD_CAST name, NULL); if (root) { @@ -186,6 +259,9 @@ PXNODE LIBXMLDOC::NewRoot(PGLOBAL g, char *name) /******************************************************************/ PXNODE LIBXMLDOC::NewPnode(PGLOBAL g, char *name) { + if (trace) + htrc("NewNode: %s\n", name); + xmlNodePtr nop; if (name) { @@ -224,6 +300,9 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn) int rc = 0; FILE *of; + if (trace) + htrc("DumpDoc: %s\n", ofn); + if (!(of= global_fopen(g, MSGID_CANNOT_OPEN, ofn, "w"))) return -1; @@ -264,6 +343,9 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn) /******************************************************************/ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp) { + if (trace) + htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0); + if (xp && xp->Count == 1) { if (Xop) xmlXPathFreeObject(Xop); @@ -284,12 +366,18 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) xmlNodeSetPtr nl; if (trace) - htrc("GetNodeList %s np=%p\n", xp, np); + htrc("GetNodeList: %s np=%p\n", xp, np); if (!Ctxp) { // Init Xpath + if (trace) + htrc("Calling xmlPathInit\n"); + xmlXPathInit(); + if (trace) + htrc("Calling xmlXPathNewContext Docp=%p\n", Docp); + // Create xpath evaluation context if (!(Ctxp = xmlXPathNewContext(Docp))) { strcpy(g->Message, MSG(XPATH_CNTX_ERR)); @@ -301,7 +389,11 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) } // endif xpathCtx // Register namespaces from list (if any) - for (PNS nsp = Namespaces; nsp; nsp = nsp->Next) + for (PNS nsp = Namespaces; nsp; nsp = nsp->Next) { + if (trace) + htrc("Calling xmlXPathRegisterNs Prefix=%s Uri=%s\n", + nsp->Prefix, nsp->Uri); + if (xmlXPathRegisterNs(Ctxp, BAD_CAST nsp->Prefix, BAD_CAST nsp->Uri)) { sprintf(g->Message, MSG(REGISTER_ERR), nsp->Prefix, nsp->Uri); @@ -312,12 +404,22 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) return NULL; } // endif Registering - } else - xmlXPathFreeNodeSetList(Xop); // To be checked + } // endfor nsp + + } else { + if (trace) + htrc("Calling xmlXPathFreeNodeSetList Xop=%p\n", Xop); + + xmlXPathFreeObject(Xop); +// xmlXPathFreeNodeSetList(Xop); // Caused memory leak + } // endif Ctxp // Set the context to the calling node Ctxp->node = np; + if (trace) + htrc("Calling xmlXPathEval %s Ctxp=%p\n", xp, Ctxp); + // Evaluate table xpath if (!(Xop = xmlXPathEval(BAD_CAST xp, Ctxp))) { sprintf(g->Message, MSG(XPATH_EVAL_ERR), xp); @@ -439,6 +541,9 @@ int XML2NODE::GetType(void) /******************************************************************/ PXNODE XML2NODE::GetNext(PGLOBAL g) { + if (trace) + htrc("GetNext\n"); + if (!Nodep->next) Next = NULL; else if (!Next) @@ -452,6 +557,9 @@ PXNODE XML2NODE::GetNext(PGLOBAL g) /******************************************************************/ PXNODE XML2NODE::GetChild(PGLOBAL g) { + if (trace) + htrc("GetChild\n"); + if (!Nodep->children) Children = NULL; else if (!Children) @@ -467,6 +575,9 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) { RCODE rc = RC_OK; + if (trace) + htrc("GetContent\n"); + if (Content) xmlFree(Content); @@ -505,18 +616,24 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) } else *buf = '\0'; + if (trace) + htrc("GetContent: %s\n", buf); + return rc; - } // end of GetText + } // end of GetContent /******************************************************************/ /* Set the content of a node. */ /******************************************************************/ bool XML2NODE::SetContent(PGLOBAL g, char *txtp, int len) { + if (trace) + htrc("SetContent: %s\n", txtp); + xmlChar *buf = xmlEncodeEntitiesReentrant(Docp, BAD_CAST txtp); if (trace) - htrc("SetContent %s -> %s\n", txtp, buf); + htrc("SetContent: %s -> %s\n", txtp, buf); xmlNodeSetContent(Nodep, buf); xmlFree(buf); @@ -528,6 +645,9 @@ bool XML2NODE::SetContent(PGLOBAL g, char *txtp, int len) /******************************************************************/ PXNODE XML2NODE::Clone(PGLOBAL g, PXNODE np) { + if (trace) + htrc("Clone: np=%p\n", np); + if (np) { ((PNODE2)np)->Nodep = Nodep; return np; @@ -542,7 +662,7 @@ PXNODE XML2NODE::Clone(PGLOBAL g, PXNODE np) PXLIST XML2NODE::GetChildElements(PGLOBAL g, char *xp, PXLIST lp) { if (trace) - htrc("GetChildElements %s\n", xp); + htrc("GetChildElements: %s\n", xp); return SelectNodes(g, (xp) ? xp : (char*)"*", lp); } // end of GetChildElements @@ -553,7 +673,7 @@ PXLIST XML2NODE::GetChildElements(PGLOBAL g, char *xp, PXLIST lp) PXLIST XML2NODE::SelectNodes(PGLOBAL g, char *xp, PXLIST lp) { if (trace) - htrc("SelectNodes %s\n", xp); + htrc("SelectNodes: %s\n", xp); xmlNodeSetPtr nl = ((PXDOC2)Doc)->GetNodeList(g, Nodep, xp); @@ -571,7 +691,7 @@ PXLIST XML2NODE::SelectNodes(PGLOBAL g, char *xp, PXLIST lp) PXNODE XML2NODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np) { if (trace) - htrc("SelectSingleNode %s\n", xp); + htrc("SelectSingleNode: %s\n", xp); xmlNodeSetPtr nl = ((PXDOC2)Doc)->GetNodeList(g, Nodep, xp); @@ -593,7 +713,7 @@ PXNODE XML2NODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np) PXATTR XML2NODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap) { if (trace) - htrc("GetAttribute %s\n", name); + htrc("GetAttribute: %s\n", name); xmlAttrPtr atp = xmlHasProp(Nodep, BAD_CAST name); @@ -618,7 +738,7 @@ PXNODE XML2NODE::AddChildNode(PGLOBAL g, char *name, PXNODE np) char *p, *pn, *pf = NULL; if (trace) - htrc("AddChildNode %s\n", name); + htrc("AddChildNode: %s\n", name); // Is a prefix specified if ((pn = strchr(name, ':'))) { @@ -669,7 +789,7 @@ PXNODE XML2NODE::AddChildNode(PGLOBAL g, char *name, PXNODE np) PXATTR XML2NODE::AddProperty(PGLOBAL g, char *name, PXATTR ap) { if (trace) - htrc("AddProperty %s\n", name); + htrc("AddProperty: %s\n", name); xmlAttrPtr atp = xmlNewProp(Nodep, BAD_CAST name, NULL); @@ -692,7 +812,7 @@ PXATTR XML2NODE::AddProperty(PGLOBAL g, char *name, PXATTR ap) void XML2NODE::AddText(PGLOBAL g, char *txtp) { if (trace) - htrc("AddText %s\n", txtp); + htrc("AddText: %s\n", txtp); // This is to avoid a blank line when inserting a new line xmlNodePtr np = xmlGetLastChild(Nodep); @@ -711,6 +831,9 @@ void XML2NODE::AddText(PGLOBAL g, char *txtp) /******************************************************************/ void XML2NODE::DeleteChild(PGLOBAL g, PXNODE dnp) { + if (trace) + htrc("DeleteChild: node=%p\n", dnp); + xmlNodePtr np = ((PNODE2)dnp)->Nodep; xmlNodePtr text = np->next; @@ -750,7 +873,7 @@ int XML2NODELIST::GetLength(void) PXNODE XML2NODELIST::GetItem(PGLOBAL g, int n, PXNODE np) { if (trace) - htrc("GetItem %d\n", n); + htrc("GetItem: %d\n", n); if (!Listp || Listp->nodeNr <= n) return NULL; @@ -781,7 +904,7 @@ XML2ATTR::XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np) bool XML2ATTR::SetText(PGLOBAL g, char *txtp, int len) { if (trace) - htrc("SetText %s %d\n", txtp, len); + htrc("SetText: %s %d\n", txtp, len); xmlSetProp(Parent, Atrp->name, BAD_CAST txtp); return false; From 59b3833c41273375a05b8a87f04a8271253da3e7 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 3 Jul 2013 12:06:49 +0200 Subject: [PATCH 249/273] - Make sure result are ordered the same on all platforms modified: storage/connect/mysql-test/connect/r/mul.result storage/connect/mysql-test/connect/t/mul.test --- storage/connect/mysql-test/connect/r/mul.result | 2 +- storage/connect/mysql-test/connect/t/mul.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/connect/mysql-test/connect/r/mul.result b/storage/connect/mysql-test/connect/r/mul.result index 46500f6e3ca..d362da13739 100644 --- a/storage/connect/mysql-test/connect/r/mul.result +++ b/storage/connect/mysql-test/connect/r/mul.result @@ -25,7 +25,7 @@ CREATE TABLE `t_all` ( `a` char(10) DEFAULT NULL, `b` char(10) DEFAULT NULL ) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `file_name`='t*.csv' `sep_char`=';' `multiple`=1; -SELECT * FROM t_all; +SELECT * FROM t_all order by `a`; a b test1 bla test2 blub diff --git a/storage/connect/mysql-test/connect/t/mul.test b/storage/connect/mysql-test/connect/t/mul.test index c28e2d140fc..451b38799ad 100644 --- a/storage/connect/mysql-test/connect/t/mul.test +++ b/storage/connect/mysql-test/connect/t/mul.test @@ -19,7 +19,7 @@ CREATE TABLE `t_all` ( `a` char(10) DEFAULT NULL, `b` char(10) DEFAULT NULL ) ENGINE=CONNECT DEFAULT CHARSET=latin1 `table_type`=CSV `file_name`='t*.csv' `sep_char`=';' `multiple`=1; -SELECT * FROM t_all; +SELECT * FROM t_all order by `a`; --echo # --echo # Testing multiple 2 From ffedc6b8910914e3b03bea99b64fa6dd1d2ca235 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 3 Jul 2013 23:58:22 +0200 Subject: [PATCH 250/273] - Makes memory check conditionally modified: storage/connect/libdoc.cpp --- storage/connect/libdoc.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 2a786ef0eef..02b931e2dc2 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -30,11 +30,11 @@ extern char version[]; extern int trace; } // "C" -#if defined(_DEBUG) -static xmlFreeFunc Free; -static xmlMallocFunc Malloc; -static xmlMallocFunc MallocA; -static xmlReallocFunc Realloc; +#if defined(MEMORY_TRACE) +static xmlFreeFunc Free; +static xmlMallocFunc Malloc; +static xmlMallocFunc MallocA; +static xmlReallocFunc Realloc; static xmlStrdupFunc Strdup; void xmlMyFree(void *mem) @@ -75,7 +75,7 @@ char *xmlMyStrdup(const char *str) htrc("Duplicating to %p from %p %s\n", p, str, str); return p; } // end of xmlMyStrdup -#endif // _DEBUG +#endif // MEMORY_TRACE /******************************************************************/ /* Return a LIBXMLDOC as a XMLDOC. */ @@ -91,17 +91,17 @@ PXDOC GetLibxmlDoc(PGLOBAL g, char *nsl, char *nsdf, /******************************************************************/ void XmlInitParserLib(void) { -#if defined(_DEBUG) +#if defined(MEMORY_TRACE) int rc = xmlGcMemGet(&Free, &Malloc, &MallocA, &Realloc, &Strdup); if (!rc) - rc = xmlGcMemSetup(xmlMyFree, - xmlMyMalloc, - xmlMyMallocAtomic, - xmlMyRealloc, - xmlMyStrdup); + rc = xmlGcMemSetup(xmlMyFree, + xmlMyMalloc, + xmlMyMallocAtomic, + xmlMyRealloc, + xmlMyStrdup); -#endif // _DEBUG +#endif // MEMORY_TRACE xmlInitParser(); } // end of XmlInitParserLib From 29ec49b0678b4714070a84770f3a7b71b75c9c50 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 4 Jul 2013 20:09:50 +0200 Subject: [PATCH 251/273] - Make sure Remark is initialised in ha_connect::GetColumnOption modified: storage/connect/ha_connect.cc --- storage/connect/ha_connect.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 62641c2234f..14b2118884f 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -982,7 +982,8 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) pcf->Flags |= U_VIRTUAL; pcf->Key= 0; // Not used when called from MySQL - pcf->Remark= fp->comment.str; + pcf->Remark= (fp->comment.str && fp->comment.length) ? + fp->comment.str : NULL; return fldp; } // end of GetColumnOption From 923eddcfe12d015c43ee6422f32e000aadc714b8 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 4 Jul 2013 23:13:07 +0200 Subject: [PATCH 252/273] - Make sure Remark is initialised modified: storage/connect/ha_connect.cc --- storage/connect/ha_connect.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 14b2118884f..f60a9d0d8f6 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -982,6 +982,8 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) pcf->Flags |= U_VIRTUAL; pcf->Key= 0; // Not used when called from MySQL + + // To make valgring happy pcf->Remark= (fp->comment.str && fp->comment.length) ? fp->comment.str : NULL; return fldp; From ce1b9cb4ba8917af1f2d16b20ab69a46af8fc5e4 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 5 Jul 2013 13:13:45 +0200 Subject: [PATCH 253/273] - Try to fix a uninitialised valgrind warning modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/mycat.cc - Fix a regression error on XML libdoc wrong Nlist freing modified: storage/connect/domdoc.h storage/connect/libdoc.cpp storage/connect/libdoc.h storage/connect/plgxml.h storage/connect/tabxml.cpp --- storage/connect/domdoc.h | 1 + storage/connect/ha_connect.cc | 13 +++++++++---- storage/connect/ha_connect.h | 2 +- storage/connect/libdoc.cpp | 14 ++++++++++++-- storage/connect/libdoc.h | 2 ++ storage/connect/mycat.cc | 2 +- storage/connect/plgxml.h | 1 + storage/connect/tabxml.cpp | 1 + 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/storage/connect/domdoc.h b/storage/connect/domdoc.h index fc157950df8..0fd0a58ffdb 100644 --- a/storage/connect/domdoc.h +++ b/storage/connect/domdoc.h @@ -35,6 +35,7 @@ class DOMDOC : public XMLDOCUMENT { // Properties virtual short GetDocType(void) {return TYPE_FB_XML;} virtual void *GetDocPtr(void) {return Docp;} + virtual void SetNofree(bool b) {} // Only libxml2 // Methods virtual bool Initialize(PGLOBAL g); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index f60a9d0d8f6..35cb0f03c3c 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -851,7 +851,7 @@ PFOS ha_connect::GetFieldOptionStruct(Field *fdp) /****************************************************************************/ /* Returns the column description structure used to make the column. */ /****************************************************************************/ -void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) +void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) { const char *cp; ha_field_option_struct *fop; @@ -983,9 +983,14 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) pcf->Key= 0; // Not used when called from MySQL - // To make valgring happy - pcf->Remark= (fp->comment.str && fp->comment.length) ? - fp->comment.str : NULL; + // Get the comment if any + if (fp->comment.str && fp->comment.length) { + pcf->Remark= (char*)PlugSubAlloc(g, NULL, fp->comment.length + 1); + memcpy(pcf->Remark, fp->comment.str, fp->comment.length); + pcf->Remark[fp->comment.length] = 0; + } else + pcf->Remark= NULL; + return fldp; } // end of GetColumnOption diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index 0d6354ca078..abf82b2d1a8 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -154,7 +154,7 @@ public: int GetIntegerOption(char *opname); bool SetIntegerOption(char *opname, int n); PFOS GetFieldOptionStruct(Field *fp); - void *GetColumnOption(void *field, PCOLINFO pcf); + void *GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf); PIXDEF GetIndexInfo(void); const char *GetDBName(const char *name); const char *GetTableName(void); diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 02b931e2dc2..6e69322425e 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -146,6 +146,8 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp) Nlist = NULL; Ctxp = NULL; Xop = NULL; + Buf = NULL; + Nofreelist = false; } // end of LIBXMLDOC constructor /******************************************************************/ @@ -347,6 +349,9 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp) htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0); if (xp && xp->Count == 1) { + if (Nlist) + xmlXPathFreeNodeSet(Nlist); + if (Xop) xmlXPathFreeObject(Xop); @@ -410,8 +415,13 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) if (trace) htrc("Calling xmlXPathFreeNodeSetList Xop=%p\n", Xop); - xmlXPathFreeObject(Xop); -// xmlXPathFreeNodeSetList(Xop); // Caused memory leak + if (Nofreelist) { + // Making Nlist that must not be freed yet + xmlXPathFreeNodeSetList(Xop); // Caused memory leak + Nofreelist = false; + } else + xmlXPathFreeObject(Xop); // Caused node not found + } // endif Ctxp // Set the context to the calling node diff --git a/storage/connect/libdoc.h b/storage/connect/libdoc.h index 97f97f99ccc..7971f4d1395 100644 --- a/storage/connect/libdoc.h +++ b/storage/connect/libdoc.h @@ -37,6 +37,7 @@ class LIBXMLDOC : public XMLDOCUMENT { // Properties virtual short GetDocType(void) {return TYPE_FB_XML2;} virtual void *GetDocPtr(void) {return Docp;} + virtual void SetNofree(bool b) {Nofreelist = b;} // Methods virtual bool Initialize(PGLOBAL g); @@ -64,6 +65,7 @@ class LIBXMLDOC : public XMLDOCUMENT { xmlXPathContextPtr Ctxp; xmlXPathObjectPtr Xop; char *Buf; // Temporary + bool Nofreelist; }; // end of class LIBXMLDOC /******************************************************************/ diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 3dd203949b6..fe93751d600 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -470,7 +470,7 @@ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp) } // endswitch tc do { - field= Hc->GetColumnOption(field, pcf); + field= Hc->GetColumnOption(g, field, pcf); } while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/)); if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) { diff --git a/storage/connect/plgxml.h b/storage/connect/plgxml.h index 8fc95eabef7..b8352c36c14 100644 --- a/storage/connect/plgxml.h +++ b/storage/connect/plgxml.h @@ -69,6 +69,7 @@ class XMLDOCUMENT : public BLOCK { // Properties virtual short GetDocType(void) = 0; virtual void *GetDocPtr(void) = 0; + virtual void SetNofree(bool b) = 0; // Methods virtual bool Initialize(PGLOBAL) = 0; diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index 9b8db7abbab..69ad6711638 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -547,6 +547,7 @@ bool TDBXML::Initialize(PGLOBAL g) else Nlist = TabNode->GetChildElements(g); + Docp->SetNofree(true); // For libxml2 #if defined(WIN32) } catch(_com_error e) { // We come here if a DOM command threw an error From 63446440437fea4e8f6800b4676105d6617e49a1 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 6 Jul 2013 10:58:22 +0200 Subject: [PATCH 254/273] - Remove unuseful option causing valgrind error or warning modified: storage/connect/myconn.cpp --- storage/connect/myconn.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index d49b3cfcf04..4cad68a9a1e 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -320,10 +320,8 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, return RC_FX; } // endif m_DB - // Notice that the client and server use separate group names. - // This is critical, because the server will not accept the - // client's options, and vice versa. - mysql_options(m_DB, MYSQL_READ_DEFAULT_GROUP, "PlugDB_CLIENT"); + // Removed to do like FEDERATED do +//mysql_options(m_DB, MYSQL_READ_DEFAULT_GROUP, "client-mariadb"); mysql_options(m_DB, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL); mysql_options(m_DB, MYSQL_OPT_CONNECT_TIMEOUT, &cto); mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt); From 66c1665e8991fcc0eda64b63350b46e424e32861 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 10:20:53 +0400 Subject: [PATCH 255/273] Fixing numerous "variable is set but never used" warnings. modified: storage/connect/filamfix.cpp storage/connect/filamtxt.cpp storage/connect/filamvct.cpp storage/connect/odbconn.cpp storage/connect/tabodbc.cpp storage/connect/xindex.cpp --- storage/connect/filamfix.cpp | 4 ++-- storage/connect/filamtxt.cpp | 4 ++-- storage/connect/filamvct.cpp | 28 +++++++++++++--------------- storage/connect/odbconn.cpp | 18 +++++++++--------- storage/connect/tabodbc.cpp | 6 +++--- storage/connect/xindex.cpp | 3 +-- 6 files changed, 30 insertions(+), 33 deletions(-) diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp index b7cbc76a553..d493a2f2568 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -425,9 +425,9 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc) /* for compatibility with Text files and other OS's. */ /*****************************************************************/ char filename[_MAX_PATH]; - int rc, h; + int h; - rc = PlugCloseFile(g, To_Fb); + /*rc= */PlugCloseFile(g, To_Fb); PlugSetPath(filename, To_File, Tdbp->GetPath()); if ((h= global_open(g, MSGID_OPEN_STRERROR, filename, O_WRONLY)) <= 0) diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp index ed4467b6392..2291f2c2b00 100644 --- a/storage/connect/filamtxt.cpp +++ b/storage/connect/filamtxt.cpp @@ -786,10 +786,10 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) /* for compatibility with Text files and other OS's. */ /*****************************************************************/ char filename[_MAX_PATH]; - int h, rc; // File handle, return code + int h; // File handle, return code PlugSetPath(filename, To_File, Tdbp->GetPath()); - rc = PlugCloseFile(g, To_Fb); + /*rc=*/ PlugCloseFile(g, To_Fb); if ((h= global_open(g, MSGID_OPEN_STRERROR, filename, O_WRONLY)) <= 0) return RC_FX; diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index 914d671637c..e97408f48bd 100755 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -204,7 +204,6 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g) { char filename[_MAX_PATH]; bool rc = false; - int k; size_t n; VECHEADER vh; FILE *s; @@ -216,7 +215,7 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g) s = Stream; if (Header == 1) - k = fseek(s, 0, SEEK_SET); + /*k =*/ fseek(s, 0, SEEK_SET); } else s= global_fopen(g, MSGID_CANNOT_OPEN, filename, "r+b"); @@ -230,7 +229,7 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g) sprintf(g->Message, "Error opening header file %s", filename); return true; } else if (Header == 3) - k = fseek(s, -(int)sizeof(VECHEADER), SEEK_END); + /*k =*/ fseek(s, -(int)sizeof(VECHEADER), SEEK_END); vh.MaxRec = MaxBlk * Bsize; vh.NumRec = (Block - 1) * Nrec + Last; @@ -775,10 +774,10 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc) /* checked for compatibility with Text files and other OS's. */ /***************************************************************/ char filename[_MAX_PATH]; - int rc, h; + int h; - rc = CleanUnusedSpace(g); // Clean last block - rc = PlugCloseFile(g, To_Fb); + /*rc =*/ CleanUnusedSpace(g); // Clean last block + /*rc =*/ PlugCloseFile(g, To_Fb); Stream = NULL; // For SetBlockInfo PlugSetPath(filename, To_File, Tdbp->GetPath()); @@ -1705,7 +1704,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ void VCMFAM::CloseTableFile(PGLOBAL g) { - int rc = 0, wrc = RC_OK; + int wrc = RC_OK; MODE mode = Tdbp->GetMode(); if (mode == MODE_INSERT) { @@ -1728,7 +1727,7 @@ void VCMFAM::CloseTableFile(PGLOBAL g) PlugCloseFile(g, To_Fb); if (wrc != RC_FX) - rc = ResetTableSize(g, Block, Last); + /*rc =*/ ResetTableSize(g, Block, Last); } else if (mode != MODE_DELETE) PlugCloseFile(g, To_Fb); @@ -2205,11 +2204,11 @@ int VECFAM::DeleteRecords(PGLOBAL g, int irc) /* for compatibility with other OS's. */ /*****************************************************************/ char filename[_MAX_PATH]; - int h, rc; // File handle, return code + int h; // File handle, return code for (int i = 0; i < Ncol; i++) { sprintf(filename, Colfn, i + 1); - rc = PlugCloseFile(g, To_Fbs[i]); + /*rc =*/ PlugCloseFile(g, To_Fbs[i]); if ((h= global_open(g, MSGID_OPEN_STRERROR, filename, O_WRONLY)) <= 0) return RC_FX; @@ -3118,7 +3117,6 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) { char filename[_MAX_PATH]; int n; - bool b; VECHEADER vh; HANDLE h; @@ -3162,7 +3160,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) return n; } else if (Header == 3) - b = BigSeek(g, h, -(BIGINT)sizeof(vh), true); + /*b = */ BigSeek(g, h, -(BIGINT)sizeof(vh), true); if (BigRead(g, h, &vh, sizeof(vh))) { sprintf(g->Message, "Error reading header file %s", filename); @@ -3190,7 +3188,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) bool BGVFAM::SetBlockInfo(PGLOBAL g) { char filename[_MAX_PATH]; - bool bk, b = false, rc = false; + bool b = false, rc = false; VECHEADER vh; HANDLE h = INVALID_HANDLE_VALUE; @@ -3201,7 +3199,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g) h = Hfile; if (Header == 1) - bk = BigSeek(g, h, (BIGINT)0); + /*bk =*/ BigSeek(g, h, (BIGINT)0); } else b = true; @@ -3230,7 +3228,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g) } // endif h if (Header == 3) - bk = BigSeek(g, h, -(BIGINT)sizeof(vh), true); + /*bk =*/ BigSeek(g, h, -(BIGINT)sizeof(vh), true); vh.MaxRec = MaxBlk * Bsize; vh.NumRec = (Block - 1) * Nrec + Last; diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index b39f1c9ba5b..967d68a360c 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -954,17 +954,17 @@ int ODBConn::Open(PSZ ConnectString, DWORD options) // Allocate the HDBC and make connection try { - PSZ ver; + /*PSZ ver;*/ AllocConnect(options); - ver = GetStringInfo(SQL_ODBC_VER); + /*ver = GetStringInfo(SQL_ODBC_VER);*/ if (Connect(options)) { strcpy(g->Message, MSG(CONNECT_CANCEL)); return 0; } // endif - ver = GetStringInfo(SQL_DRIVER_ODBC_VER); + /*ver = GetStringInfo(SQL_DRIVER_ODBC_VER);*/ } catch(DBX *xp) { // strcpy(g->Message, xp->m_ErrMsg[0]); strcpy(g->Message, xp->GetErrorMessage(0)); @@ -1213,13 +1213,13 @@ int ODBConn::ExecDirectSQL(char *sql, ODBCCOL *tocols) b = false; if (m_hstmt) { - RETCODE rc; + /*RETCODE rc;*/ // All this did not seems to make sense and was been commented out // if (IsOpen()) // Close(SQL_CLOSE); - rc = SQLFreeStmt(m_hstmt, SQL_CLOSE); + /*rc =*/ SQLFreeStmt(m_hstmt, SQL_CLOSE); hstmt = m_hstmt; m_hstmt = NULL; ThrowDBX(MSG(SEQUENCE_ERROR)); @@ -1831,7 +1831,7 @@ int ODBConn::GetCatInfo(CATPARM *cap) /***********************************************************************/ void ODBConn::Close() { - RETCODE rc; + /*RETCODE rc;*/ #if 0 // Close any open recordsets @@ -1856,13 +1856,13 @@ void ODBConn::Close() if (m_hstmt) { // Is required for multiple tables - rc = SQLFreeStmt(m_hstmt, SQL_DROP); + /*rc =*/ SQLFreeStmt(m_hstmt, SQL_DROP); m_hstmt = NULL; } // endif m_hstmt if (m_hdbc != SQL_NULL_HDBC) { - rc = SQLDisconnect(m_hdbc); - rc = SQLFreeConnect(m_hdbc); + /*rc =*/ SQLDisconnect(m_hdbc); + /*rc =*/ SQLFreeConnect(m_hdbc); m_hdbc = SQL_NULL_HDBC; // AfxLockGlobals(CRIT_ODBC); diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index 599f9c7e80f..ae6817344b8 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -324,7 +324,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) { char *colist, *tabname, *sql, buf[64]; LPCSTR ownp = NULL, qualp = NULL; - int rc, len, ncol = 0; + int len, ncol = 0; bool first = true; PTABLE tablep = To_Table; PCOL colp; @@ -341,7 +341,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) for (colp = Columns; colp; colp = colp->GetNext()) if (!colp->IsSpecial()) { // Column name can be in UTF-8 encoding - rc= Decode(colp->GetName(), buf, sizeof(buf)); + /*rc=*/ Decode(colp->GetName(), buf, sizeof(buf)); if (Quote) { if (first) { @@ -376,7 +376,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) } // endif cnt // Table name can be encoded in UTF-8 - rc = Decode(TableName, buf, sizeof(buf)); + /*rc = */Decode(TableName, buf, sizeof(buf)); // Put table name between identifier quotes in case in contains blanks tabname = (char*)PlugSubAlloc(g, NULL, strlen(buf) + 3); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 68a6bba47ec..4a0067e30be 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -2368,7 +2368,6 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) } // endif Mode #else // UNIX - int rc = 0; int oflag = O_LARGEFILE; // Enable file size > 2G mode_t pmod = 0; @@ -2394,7 +2393,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) Hfile= global_open(g, MSGID_OPEN_ERROR_AND_STRERROR, filename, oflag, pmod); if (Hfile == INVALID_HANDLE_VALUE) { - rc = errno; + /*rc = errno;*/ #if defined(TRACE) printf("Open: %s\n", g->Message); #endif // TRACE From e2461d47cbb62c8b804ce72dfc521f963786997a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 10:37:09 +0400 Subject: [PATCH 256/273] =?UTF-8?q?Fixing=20the=20"no=20previous=20declara?= =?UTF-8?q?tion=20for=20=E2=80=98=5Fstrerror'"=20warning.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: storage/connect/filamvct.cpp storage/connect/osutil.c storage/connect/tabvct.cpp --- storage/connect/filamvct.cpp | 1 - storage/connect/osutil.c | 8 -------- storage/connect/tabvct.cpp | 1 - 3 files changed, 10 deletions(-) diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index e97408f48bd..2b66437d127 100755 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -35,7 +35,6 @@ #include #include #include -//#define strerror(X) _strerror(X) #define NO_ERROR 0 #else // !UNIX #include diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c index 1b7332357e6..9a7575b3258 100644 --- a/storage/connect/osutil.c +++ b/storage/connect/osutil.c @@ -202,14 +202,6 @@ BOOL MessageBeep(uint i) return TRUE; } /* end of MessageBeep */ -LPSTR _strerror(int errn) - { - static char buff[256]; - - sprintf(buff,"error: %d", errn); - return buff; - } /* end of _strerror */ - int _isatty(int fileNo) { return isatty(fileNo); diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp index 7a16d2baf0c..8c2474d61a2 100644 --- a/storage/connect/tabvct.cpp +++ b/storage/connect/tabvct.cpp @@ -49,7 +49,6 @@ #include #include #include -//#define strerror(X) _strerror(X) #define NO_ERROR 0 #else #include From 269fd01bc13c14ccec9ceed5ff324d5a67adf7ad Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 10:46:15 +0400 Subject: [PATCH 257/273] =?UTF-8?q?fixing=20warnings:=20-=20no=20previous?= =?UTF-8?q?=20declaration=20for=20=E2=80=98=5Fisatty=E2=80=99=20-=20implic?= =?UTF-8?q?it=20declaration=20of=20function=20=E2=80=98=5Fisatty=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: storage/connect/fmdlex.c storage/connect/osutil.c --- storage/connect/fmdlex.c | 4 +++- storage/connect/osutil.c | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index 669104b4425..d55b4661426 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -24,6 +24,9 @@ #define __STDC__ 1 #endif #include +#ifndef defined(WIN32) +#include +#endif /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ @@ -392,7 +395,6 @@ char *yytext; #include #include "preparse.h" -#define isatty _isatty #define fileno _fileno #undef YY_DECL #define YY_DECL int yylex YY_PROTO((PDTP ppp)) diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c index 9a7575b3258..4cdd7c560f0 100644 --- a/storage/connect/osutil.c +++ b/storage/connect/osutil.c @@ -202,11 +202,6 @@ BOOL MessageBeep(uint i) return TRUE; } /* end of MessageBeep */ -int _isatty(int fileNo) - { - return isatty(fileNo); - } /* end of _isatty */ - #if 0 /* This function is ridiculous and should be revisited */ DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, From f2d2c1ea325f97ffcaa883d4a07f148c168983aa Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 10:49:50 +0400 Subject: [PATCH 258/273] Fixing a typo in the previous push modified: storage/connect/fmdlex.c --- storage/connect/fmdlex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index d55b4661426..7a3053f0d38 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -24,7 +24,7 @@ #define __STDC__ 1 #endif #include -#ifndef defined(WIN32) +#ifndef WIN32 #include #endif From f9ba8073548a26d03cfd28b723425574c884b1b1 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 10:52:20 +0400 Subject: [PATCH 259/273] =?UTF-8?q?fixing=20warnings:=20-=20no=20previous?= =?UTF-8?q?=20declaration=20for=20=E2=80=98ddwrap=E2=80=99=20-=20implicit?= =?UTF-8?q?=20declaration=20of=20function=20=E2=80=98ddwrap=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: storage/connect/fmdlex.c --- storage/connect/fmdlex.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index 7a3053f0d38..a7213b1ed57 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -406,6 +406,8 @@ char *yytext; #undef yywrap #define yywrap ddwrap #endif /* UNIX */ +int yywrap(void); + static PDTP pp; static void MakeParm(int n); static void MakeMMDD(int n); From e46f8f3d0aa59e71c40e0f2bd7d67414b2b8628b Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 11:05:59 +0400 Subject: [PATCH 260/273] Fixing warnings: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - no previous declaration for ‘void XmlCleanupParserLib()’ - no previous declaration for ‘void CloseXML2File’ - no previous declaration for ‘void XmlInitParserLib()’ modified: storage/connect/ha_connect.cc storage/connect/libdoc.cpp storage/connect/libdoc.h storage/connect/plgdbutl.cpp --- storage/connect/ha_connect.cc | 3 +- storage/connect/libdoc.cpp | 149 +++++++++++++++++++++++++++++++++ storage/connect/libdoc.h | 152 ++-------------------------------- storage/connect/plgdbutl.cpp | 2 +- 4 files changed, 157 insertions(+), 149 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 35cb0f03c3c..861d1edb12c 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -146,8 +146,7 @@ #define my_stricmp(a,b) my_strcasecmp(default_charset_info, (a), (b)) #ifdef LIBXML2_SUPPORT -void XmlInitParserLib(void); -void XmlCleanupParserLib(void); +#include "libdoc.h" #endif // LIBXML2_SUPPORT /***********************************************************************/ diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 6e69322425e..45f379350f5 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -25,6 +25,155 @@ #include "sql_string.h" +/******************************************************************/ +/* Declaration of XML document processing using libxml2 */ +/* Author: Olivier Bertrand 2007-2012 */ +/******************************************************************/ +#include "plgxml.h" + +typedef class LIBXMLDOC *PXDOC2; +typedef class XML2NODE *PNODE2; +typedef class XML2ATTR *PATTR2; +typedef class XML2NODELIST *PLIST2; + +/******************************************************************/ +/* XML2 block. Must have the same layout than FBLOCK up to Type. */ +/******************************************************************/ +typedef struct _x2block { /* Loaded XML file block */ + struct _x2block *Next; + LPCSTR Fname; /* Point on file name */ + size_t Length; /* Used to tell if read mode */ + short Count; /* Nb of times file is used */ + short Type; /* TYPE_FB_XML */ + int Retcode; /* Return code from Load */ + xmlDocPtr Docp; /* Document interface pointer */ +// xmlXPathContextPtr Ctxp; +// xmlXPathObjectPtr Xop; + } X2BLOCK, *PX2BLOCK; + +/******************************************************************/ +/* Declaration of libxml2 document. */ +/******************************************************************/ +class LIBXMLDOC : public XMLDOCUMENT { + friend class XML2NODE; + friend class XML2ATTR; + public: + // Constructor + LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp); + + // Properties + virtual short GetDocType(void) {return TYPE_FB_XML2;} + virtual void *GetDocPtr(void) {return Docp;} + virtual void SetNofree(bool b) {Nofreelist = b;} + + // Methods + virtual bool Initialize(PGLOBAL g); + virtual bool ParseFile(char *fn); + virtual bool NewDoc(PGLOBAL g, char *ver); + virtual void AddComment(PGLOBAL g, char *com); + virtual PXNODE GetRoot(PGLOBAL g); + virtual PXNODE NewRoot(PGLOBAL g, char *name); + virtual PXNODE NewPnode(PGLOBAL g, char *name); + virtual PXATTR NewPattr(PGLOBAL g); + virtual PXLIST NewPlist(PGLOBAL g); + virtual int DumpDoc(PGLOBAL g, char *ofn); + virtual void CloseDoc(PGLOBAL g, PFBLOCK xp); + virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn); + + protected: +// bool CheckDocument(FILE *of, xmlNodePtr np); + xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp); + int Decode(xmlChar *cnt, char *buf, int n); + xmlChar *Encode(PGLOBAL g, char *txt); + + // Members + xmlDocPtr Docp; + xmlNodeSetPtr Nlist; + xmlXPathContextPtr Ctxp; + xmlXPathObjectPtr Xop; + char *Buf; // Temporary + bool Nofreelist; +}; // end of class LIBXMLDOC + +/******************************************************************/ +/* Declaration of libxml2 node. */ +/******************************************************************/ +class XML2NODE : public XMLNODE { + friend class LIBXMLDOC; + friend class XML2NODELIST; + public: + // Properties + virtual char *GetName(PGLOBAL g) {return (char*)Nodep->name;} + virtual int GetType(void); + virtual PXNODE GetNext(PGLOBAL g); + virtual PXNODE GetChild(PGLOBAL g); + + // Methods + virtual RCODE GetContent(PGLOBAL g, char *buf, int len); + virtual bool SetContent(PGLOBAL g, char *txtp, int len); + virtual PXNODE Clone(PGLOBAL g, PXNODE np); + virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp); + virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp); + virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np); + virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap); + virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np); + virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap); + virtual void AddText(PGLOBAL g, char *txtp); + virtual void DeleteChild(PGLOBAL g, PXNODE dnp); + + protected: + // Constructor + XML2NODE(PXDOC dp, xmlNodePtr np); + + // Members + xmlDocPtr Docp; + xmlChar *Content; + xmlNodePtr Nodep; +}; // end of class XML2NODE + +/******************************************************************/ +/* Declaration of libxml2 node list. */ +/******************************************************************/ +class XML2NODELIST : public XMLNODELIST { + friend class LIBXMLDOC; + friend class XML2NODE; + public: + // Methods + virtual int GetLength(void); + virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np); + + protected: + // Constructor + XML2NODELIST(PXDOC dp, xmlNodeSetPtr lp); + + // Members + xmlNodeSetPtr Listp; +}; // end of class XML2NODELIST + +/******************************************************************/ +/* Declaration of libxml2 attribute. */ +/******************************************************************/ +class XML2ATTR : public XMLATTRIBUTE { + friend class LIBXMLDOC; + friend class XML2NODE; + public: + // Properties +//virtual char *GetText(void); + + // Methods + virtual bool SetText(PGLOBAL g, char *txtp, int len); + + protected: + // Constructor + XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np); + + // Members + xmlAttrPtr Atrp; + xmlNodePtr Parent; +}; // end of class XML2ATTR + + + extern "C" { extern char version[]; extern int trace; diff --git a/storage/connect/libdoc.h b/storage/connect/libdoc.h index 7971f4d1395..a0cead4e904 100644 --- a/storage/connect/libdoc.h +++ b/storage/connect/libdoc.h @@ -1,146 +1,6 @@ -/******************************************************************/ -/* Declaration of XML document processing using libxml2 */ -/* Author: Olivier Bertrand 2007-2012 */ -/******************************************************************/ -#include "plgxml.h" - -typedef class LIBXMLDOC *PXDOC2; -typedef class XML2NODE *PNODE2; -typedef class XML2ATTR *PATTR2; -typedef class XML2NODELIST *PLIST2; - -/******************************************************************/ -/* XML2 block. Must have the same layout than FBLOCK up to Type. */ -/******************************************************************/ -typedef struct _x2block { /* Loaded XML file block */ - struct _x2block *Next; - LPCSTR Fname; /* Point on file name */ - size_t Length; /* Used to tell if read mode */ - short Count; /* Nb of times file is used */ - short Type; /* TYPE_FB_XML */ - int Retcode; /* Return code from Load */ - xmlDocPtr Docp; /* Document interface pointer */ -// xmlXPathContextPtr Ctxp; -// xmlXPathObjectPtr Xop; - } X2BLOCK, *PX2BLOCK; - -/******************************************************************/ -/* Declaration of libxml2 document. */ -/******************************************************************/ -class LIBXMLDOC : public XMLDOCUMENT { - friend class XML2NODE; - friend class XML2ATTR; - public: - // Constructor - LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp); - - // Properties - virtual short GetDocType(void) {return TYPE_FB_XML2;} - virtual void *GetDocPtr(void) {return Docp;} - virtual void SetNofree(bool b) {Nofreelist = b;} - - // Methods - virtual bool Initialize(PGLOBAL g); - virtual bool ParseFile(char *fn); - virtual bool NewDoc(PGLOBAL g, char *ver); - virtual void AddComment(PGLOBAL g, char *com); - virtual PXNODE GetRoot(PGLOBAL g); - virtual PXNODE NewRoot(PGLOBAL g, char *name); - virtual PXNODE NewPnode(PGLOBAL g, char *name); - virtual PXATTR NewPattr(PGLOBAL g); - virtual PXLIST NewPlist(PGLOBAL g); - virtual int DumpDoc(PGLOBAL g, char *ofn); - virtual void CloseDoc(PGLOBAL g, PFBLOCK xp); - virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn); - - protected: -// bool CheckDocument(FILE *of, xmlNodePtr np); - xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp); - int Decode(xmlChar *cnt, char *buf, int n); - xmlChar *Encode(PGLOBAL g, char *txt); - - // Members - xmlDocPtr Docp; - xmlNodeSetPtr Nlist; - xmlXPathContextPtr Ctxp; - xmlXPathObjectPtr Xop; - char *Buf; // Temporary - bool Nofreelist; -}; // end of class LIBXMLDOC - -/******************************************************************/ -/* Declaration of libxml2 node. */ -/******************************************************************/ -class XML2NODE : public XMLNODE { - friend class LIBXMLDOC; - friend class XML2NODELIST; - public: - // Properties - virtual char *GetName(PGLOBAL g) {return (char*)Nodep->name;} - virtual int GetType(void); - virtual PXNODE GetNext(PGLOBAL g); - virtual PXNODE GetChild(PGLOBAL g); - - // Methods - virtual RCODE GetContent(PGLOBAL g, char *buf, int len); - virtual bool SetContent(PGLOBAL g, char *txtp, int len); - virtual PXNODE Clone(PGLOBAL g, PXNODE np); - virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp); - virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp); - virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np); - virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap); - virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np); - virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap); - virtual void AddText(PGLOBAL g, char *txtp); - virtual void DeleteChild(PGLOBAL g, PXNODE dnp); - - protected: - // Constructor - XML2NODE(PXDOC dp, xmlNodePtr np); - - // Members - xmlDocPtr Docp; - xmlChar *Content; - xmlNodePtr Nodep; -}; // end of class XML2NODE - -/******************************************************************/ -/* Declaration of libxml2 node list. */ -/******************************************************************/ -class XML2NODELIST : public XMLNODELIST { - friend class LIBXMLDOC; - friend class XML2NODE; - public: - // Methods - virtual int GetLength(void); - virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np); - - protected: - // Constructor - XML2NODELIST(PXDOC dp, xmlNodeSetPtr lp); - - // Members - xmlNodeSetPtr Listp; -}; // end of class XML2NODELIST - -/******************************************************************/ -/* Declaration of libxml2 attribute. */ -/******************************************************************/ -class XML2ATTR : public XMLATTRIBUTE { - friend class LIBXMLDOC; - friend class XML2NODE; - public: - // Properties -//virtual char *GetText(void); - - // Methods - virtual bool SetText(PGLOBAL g, char *txtp, int len); - - protected: - // Constructor - XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np); - - // Members - xmlAttrPtr Atrp; - xmlNodePtr Parent; -}; // end of class XML2ATTR +#ifndef LIBDOC_H_INCLUDED +#define LIBDOC_H_INCLUDED +void XmlInitParserLib(void); +void XmlCleanupParserLib(void); +void CloseXML2File(PGLOBAL, PFBLOCK, bool); +#endif diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 73b468c9209..6884930a3b1 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -127,7 +127,7 @@ void CloseXMLFile(PGLOBAL, PFBLOCK, bool); #endif // DOMDOC_SUPPORT #ifdef LIBXML2_SUPPORT -void CloseXML2File(PGLOBAL, PFBLOCK, bool); +#include "libdoc.h" #endif // LIBXML2_SUPPORT From 63522ed38eb2a4905cac12b0fd7ded8a43bedc4e Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 11:11:53 +0400 Subject: [PATCH 261/273] =?UTF-8?q?Fixing=20warnings:=20-=20no=20previous?= =?UTF-8?q?=20declaration=20for=20=E2=80=98char*=20GetIni(int)=E2=80=99=20?= =?UTF-8?q?-=20no=20previous=20declaration=20for=20=E2=80=98void=20SetTrc(?= =?UTF-8?q?)=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp --- storage/connect/plgdbsem.h | 3 ++- storage/connect/plgdbutl.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 919f3452a4d..44ad8605747 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -565,7 +565,8 @@ DllExport void PlgDBfree(MBLOCK&); //lExport int GetIniSize(char *, char *, char *, char *); //lExport bool WritePrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR); DllExport void NewPointer(PTABS, void *, void *); - +DllExport char *GetIni(int n= 0); +DllExport void SetTrc(void); #define MSGID_NONE 0 #define MSGID_CANNOT_OPEN 1 diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 6884930a3b1..5ea8457f25e 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -222,7 +222,7 @@ int global_open(GLOBAL *g, int msgid, const char *path, int flags, int mode) /**************************************************************************/ /* Utility for external callers (such as XDB) */ /**************************************************************************/ -DllExport char *GetIni(int n = 0) +DllExport char *GetIni(int n) { switch (n) { case 1: return plgxini; break; From c5b631cefa3aa4b0a6b7588c306b3502b80bcabb Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 11:16:16 +0400 Subject: [PATCH 262/273] =?UTF-8?q?Fixing=20a=20warning:=20-=20no=20previo?= =?UTF-8?q?us=20declaration=20for=20=E2=80=98int=20PrepareColist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: storage/connect/taboccur.cpp --- storage/connect/taboccur.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 065da269caa..478edb14f9e 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -56,7 +56,7 @@ extern "C" int trace; /***********************************************************************/ /* Prepare and count columns in the column list. */ /***********************************************************************/ -int PrepareColist(char *colist) +static int PrepareColist(char *colist) { char *p, *pn; int n = 0; From a3c4f8729dc26b2432e67cda6e822d3fa55cfeda Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 11:22:32 +0400 Subject: [PATCH 263/273] =?UTF-8?q?Fixing=20warnings:=20-=20no=20previous?= =?UTF-8?q?=20declaration=20for=20=E2=80=98bool=20OcrSrcCol'=20-=20no=20pr?= =?UTF-8?q?evious=20declaration=20for=20=E2=80=98bool=20OcrColumns'=20-=20?= =?UTF-8?q?no=20previous=20declaration=20for=20=E2=80=98=5Fqryres*=20Pivot?= =?UTF-8?q?Columns'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: storage/connect/ha_connect.cc storage/connect/taboccur.h storage/connect/tabpivot.h --- storage/connect/ha_connect.cc | 14 ++++---------- storage/connect/taboccur.h | 6 ++++++ storage/connect/tabpivot.h | 6 ++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 861d1edb12c..786997cc76d 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -149,6 +149,10 @@ #include "libdoc.h" #endif // LIBXML2_SUPPORT +#include "taboccur.h" +#include "tabpivot.h" + + /***********************************************************************/ /* DB static variables. */ /***********************************************************************/ @@ -166,16 +170,6 @@ extern "C" { int trace= 0; // The general trace value } // extern "C" -bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col, - const char *ocr, const char *rank); -bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col, - const char *ocr, const char *rank); -PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src, - const char *picol, const char *fncol, - const char *host, const char *db, - const char *user, const char *pwd, - int port); - /****************************************************************************/ /* Initialize the ha_connect static members. */ /****************************************************************************/ diff --git a/storage/connect/taboccur.h b/storage/connect/taboccur.h index 10f94329703..6cfece5634e 100644 --- a/storage/connect/taboccur.h +++ b/storage/connect/taboccur.h @@ -137,3 +137,9 @@ class XCOLDEF: public COLDEF { friend class TDBOCCUR; }; // end of class XCOLDEF + +bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col, + const char *ocr, const char *rank); + +bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col, + const char *ocr, const char *rank); diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h index 170c6b67ea4..0b5bf50d13b 100644 --- a/storage/connect/tabpivot.h +++ b/storage/connect/tabpivot.h @@ -188,3 +188,9 @@ class SRCCOL : public PRXCOL { // Members }; // end of class SRCCOL + +PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src, + const char *picol, const char *fncol, + const char *host, const char *db, + const char *user, const char *pwd, + int port); From 6dbc562b5d31a683f772cbbaef5c18aaa22f85a5 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 11:26:24 +0400 Subject: [PATCH 264/273] =?UTF-8?q?Fixing=20a=20warning:=20-=20no=20previo?= =?UTF-8?q?us=20declaration=20for=20=E2=80=98void*=20ThreadOpen(void*)?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: storage/connect/tabtbl.h --- storage/connect/tabtbl.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index 7cc2ff0b92c..6b29e8eed6e 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -163,3 +163,6 @@ class DllExport TDBTBM : public TDBTBL { int Nrc; // Number of remote connections int Nlc; // Number of local connections }; // end of class TDBTBM + + +pthread_handler_t ThreadOpen(void *p); From 309f59a5c8098d19a378f08e414b9dc94fc55085 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 11:28:07 +0400 Subject: [PATCH 265/273] =?UTF-8?q?Fixing=20warnings:=20-=20no=20previous?= =?UTF-8?q?=20declaration=20for=20=E2=80=98const=20char*=20PLGtoMYSQLtype?= =?UTF-8?q?=20-=20no=20previous=20declaration=20for=20=E2=80=98int=20MYSQL?= =?UTF-8?q?toPLG(int)=E2=80=99=20-=20no=20previous=20declaration=20for=20?= =?UTF-8?q?=E2=80=98char*=20MyDateFmt(int)=E2=80=99=20-=20no=20previous=20?= =?UTF-8?q?declaration=20for=20=E2=80=98char*=20MyDateFmt(char*)=E2=80=99?= =?UTF-8?q?=20-=20no=20previous=20declaration=20for=20=E2=80=98int=20MYSQL?= =?UTF-8?q?toPLG(char*)=E2=80=99=20-=20no=20previous=20declaration=20for?= =?UTF-8?q?=20=E2=80=98enum=5Ffield=5Ftypes=20PLGtoMYSQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: storage/connect/myutil.cpp --- storage/connect/myutil.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp index 19c478ecbd8..b266b7b79c1 100644 --- a/storage/connect/myutil.cpp +++ b/storage/connect/myutil.cpp @@ -23,6 +23,7 @@ #include "plgdbsem.h" //#include "value.h" //#include "valblk.h" +#include "myutil.h" #define DLL_EXPORT // Items are exported from this DLL /************************************************************************/ From a8fb8e141e2ff69d6fe74a5b89c99e4dfef4bc41 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 11:43:45 +0400 Subject: [PATCH 266/273] Fixing a warning: - cast to pointer from integer of different size modified: storage/connect/odbconn.cpp --- storage/connect/odbconn.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 967d68a360c..59dd337ef5c 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -1673,8 +1673,10 @@ int ODBConn::GetCatInfo(CATPARM *cap) // Attempt to set rowset size. // In case of failure reset it to 0 to use Fetch. if (m_Catver == 3) // ODBC Ver 3 - rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, - (SQLPOINTER)m_RowsetSize, 0); + { + SQLULEN tmp= m_RowsetSize; + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, &tmp, 0); + } else rc = SQLSetStmtOption(hstmt, SQL_ROWSET_SIZE, m_RowsetSize); From d7283bc59a26693dda35b0d8adc02d4b5c6dc4f6 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 13:11:40 +0400 Subject: [PATCH 267/273] Fixing some of the memory leaks in ODBCColumns(). modified: storage/connect/odbconn.cpp --- storage/connect/odbconn.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 59dd337ef5c..5808bf266bd 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -304,6 +304,9 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table, } else qrp = NULL; + /* Cleanup */ + ocp->Close(); + /************************************************************************/ /* Return the result pointer for use by GetData routines. */ /************************************************************************/ From ba0abd77172b651a2618eecb212d7baaf7fb8bee Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 13:39:45 +0400 Subject: [PATCH 268/273] Adding instructions on how to install sqlite3 ODBC driver for test purposes. modified: storage/connect/mysql-test/connect/t/odbc_sqlite3.test --- .../mysql-test/connect/t/odbc_sqlite3.test | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/storage/connect/mysql-test/connect/t/odbc_sqlite3.test b/storage/connect/mysql-test/connect/t/odbc_sqlite3.test index f32196e3f04..2705b4f47fb 100644 --- a/storage/connect/mysql-test/connect/t/odbc_sqlite3.test +++ b/storage/connect/mysql-test/connect/t/odbc_sqlite3.test @@ -3,21 +3,40 @@ # # To run this test, install SQLite3 ODBC Driver from # http://www.ch-werner.de/sqliteodbc/ -# The installer file is sqliteodbc.exe +# +# Note, the test does not need a DSN to be created +# (only the driver is required) +# +# +# On Windows: +# ----------- +# Download and run the installer file sqliteodbc.exe # Version sqliteodbc-0.991 is known to Work. +# After running the installer the test should start working automatically. # -# On Windows the test should start working automatically +# On Linux: +# -------- +# 1. Download the source tarball, e.g.: sqliteodbc-0.993.tar.gz +# 2. Unpack the sources: +# tar -zxf sqliteodbc-0.993.tar.gz +# 3. Compile the source and install: +# cd sqliteodbc-0.993 +# ./configure --prefix=/opt/sqliteodbc +# make +# sudo make install # -# On Linux add these lines into /etc/odbcinst.ini +# (you can use a different --prefix, according to your preferences) +# +# 4. Add these lines into /etc/odbcinst.ini # #[SQLite3 ODBC Driver] #Description=SQLite3 ODBC Driver #Driver=/opt/sqliteodbc/libsqlite3odbc.so #Setup=/opt/sqliteodbc/libsqlite3odbc.so # -# (adjust the directory "/opt/sqliteodbc/" according to your OS settings) +# Adjust the directory "/opt/sqliteodbc/" according to --prefix +# that you chose on step #3. # -# Note, the test does not need a DSN to be created. # SET NAMES utf8; From f3078f01b24bed421c015aec2c1646fa25934c13 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 8 Jul 2013 12:20:12 +0200 Subject: [PATCH 269/273] - Suppressing wrong code (INI tables are not indexables) modified: storage/connect/tabsys.cpp --- storage/connect/tabsys.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp index 6434e011882..c5186f42666 100644 --- a/storage/connect/tabsys.cpp +++ b/storage/connect/tabsys.cpp @@ -223,12 +223,13 @@ bool TDBINI::OpenDB(PGLOBAL g) PINICOL colp; if (Use == USE_OPEN) { +#if 0 if (To_Kindex) /*****************************************************************/ /* Table is to be accessed through a sorted index table. */ /*****************************************************************/ To_Kindex->Reset(); - +#endif // 0 Section = NULL; N = 0; return false; @@ -262,6 +263,7 @@ int TDBINI::ReadDB(PGLOBAL g) /*********************************************************************/ /* Now start the pseudo reading process. */ /*********************************************************************/ +#if 0 // INI tables are not indexable if (To_Kindex) { /*******************************************************************/ /* Reading is by an index table. */ @@ -276,10 +278,11 @@ int TDBINI::ReadDB(PGLOBAL g) case -3: // Same record as last non null one return RC_OK; default: - Section = (char*)recpos; + Section = (char*)recpos; // No good on 64 bit machines } // endswitch recpos } else { +#endif // 0 if (!Section) Section = Seclist; else @@ -289,7 +292,7 @@ int TDBINI::ReadDB(PGLOBAL g) htrc("INI ReadDB: section=%s N=%d\n", Section, N); N++; - } // endif To_Kindex +//} // endif To_Kindex return (*Section) ? RC_OK : RC_EF; } // end of ReadDB @@ -655,6 +658,7 @@ int TDBXIN::ReadDB(PGLOBAL g) /*********************************************************************/ /* Now start the pseudo reading process. */ /*********************************************************************/ +#if 0 // XIN tables are not indexable if (To_Kindex) { /*******************************************************************/ /* Reading is by an index table. */ @@ -673,6 +677,7 @@ int TDBXIN::ReadDB(PGLOBAL g) } // endswitch recpos } else { +#endif // 0 do { if (!Keycur || !*Keycur) { if (!Section) @@ -691,7 +696,7 @@ int TDBXIN::ReadDB(PGLOBAL g) } while (!*Keycur); N++; - } // endif To_Kindex +//} // endif To_Kindex return RC_OK; } // end of ReadDB From 7adf46f66208f1334f7d063d2fcf8097b0d8c082 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Jul 2013 17:26:27 +0400 Subject: [PATCH 270/273] Re-enabling connect tests in 10.0-connect (still disabled in 10.0 due to valgrind failures) modified: mysql-test/mysql-test-run.pl --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 90988c73c66..3be67db3371 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -377,7 +377,7 @@ sub main { # directly before it executes them, like "make test-force-pl" in RPM builds. mtr_report("Logging: $0 ", join(" ", @ARGV)); - $DEFAULT_SUITES.=",sequence,sql_discovery,spider,spider/bg" if $source_dist; + $DEFAULT_SUITES.=",sequence,sql_discovery,connect,spider,spider/bg" if $source_dist; command_line_setup(); From b3ad9a97e984864c7809f0c2a2847ab35305488c Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 8 Jul 2013 19:03:15 +0200 Subject: [PATCH 271/273] - Suppress some ubuntu compiler warnings modified: storage/connect/connect.cc storage/connect/ha_connect.cc storage/connect/mycat.cc storage/connect/odbconn.cpp storage/connect/osutil.c storage/connect/tabutil.cpp --- storage/connect/connect.cc | 2 +- storage/connect/ha_connect.cc | 5 +++-- storage/connect/mycat.cc | 5 ++--- storage/connect/odbconn.cpp | 6 +++--- storage/connect/osutil.c | 2 +- storage/connect/tabutil.cpp | 10 ++++++---- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 41fb061bd7f..e0c722bc01f 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -816,7 +816,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, p+= valp->GetClen(); - if (len[i] == p - kp) { + if (len[i] == (unsigned)(p - kp)) { n++; break; } else if (len[i] < (unsigned)(p - kp)) { diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 786997cc76d..3325d39f1d8 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3433,7 +3433,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL); bool bif, ok= false, dbf= false; TABTYPE ttp= TAB_UNDEF; - PQRYRES qrp; + PQRYRES qrp= NULL; PCOLRES crp; PGLOBAL g= GetPlug(thd, NULL); PTOS topt= table_s->option_struct; @@ -3709,7 +3709,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, if (fnc != FNC_NO || src || ttp == TAB_PIVOT) { // Catalog like table - for (crp=qrp->Colresp; !b && crp; crp= crp->Next) { + for (crp= qrp->Colresp; !b && crp; crp= crp->Next) { cnm= encode(g, crp->Name); type= PLGtoMYSQLtype(crp->Type, dbf); len= crp->Length; @@ -3726,6 +3726,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, rem= NULL; typ= len= dec= 0; tm= NOT_NULL_FLAG; + cnm= (char*)"noname"; for (crp= qrp->Colresp; crp; crp= crp->Next) switch (crp->Fld) { diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index fe93751d600..3c75c0b63b3 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -383,7 +383,7 @@ int MYCAT::GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size) /***********************************************************************/ char *MYCAT::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) { - char *sval, *s= Hc->GetStringOption(what, sdef); + char *sval= NULL, *s= Hc->GetStringOption(what, sdef); if (s) { sval= (char*)PlugSubAlloc(g, NULL, strlen(s) + 1); @@ -408,8 +408,7 @@ char *MYCAT::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) } // endif FileType - } else - sval = NULL; + } // endif s return sval; } // end of GetStringCatInfo diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 5808bf266bd..69fddb2d9f8 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -242,7 +242,7 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table, int maxres; PQRYRES qrp; CATPARM *cap; - ODBConn *ocp; + ODBConn *ocp = NULL; /************************************************************************/ /* Do an evaluation of the result size. */ @@ -497,7 +497,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info) int maxres; PQRYRES qrp; CATPARM *cap; - ODBConn *ocp; + ODBConn *ocp = NULL; /************************************************************************/ /* Do an evaluation of the result size. */ @@ -1654,7 +1654,7 @@ int ODBConn::GetCatInfo(CATPARM *cap) PCOLRES crp; RETCODE rc; HSTMT hstmt = NULL; - SQLLEN *vl, *vlen; + SQLLEN *vl, *vlen = NULL; PVAL *pval = NULL; try { diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c index 4cdd7c560f0..ad92caefe95 100644 --- a/storage/connect/osutil.c +++ b/storage/connect/osutil.c @@ -181,7 +181,7 @@ char *_fullpath(char *absPath, const char *relPath, size_t maxLength) } else { char buff[2*_MAX_PATH]; - getcwd(buff, _MAX_PATH); + assert(getcwd(buff, _MAX_PATH) != NULL); strcat(buff,"/"); strcat(buff, relPath); strncpy(absPath, buff, maxLength); diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 21dee4e1856..6e5f6784d3a 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -133,7 +133,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, int i, n, ncol = sizeof(buftyp) / sizeof(int); int len, type, prec; bool mysql; - TABLE_SHARE *s; + TABLE_SHARE *s = NULL; Field* *field; Field *fp; PQRYRES qrp; @@ -243,7 +243,9 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, /**********************************************************************/ /* Return the result pointer for use by GetData routines. */ /**********************************************************************/ - free_table_share(s); + if (s) + free_table_share(s); + return qrp; } // end of TabColumns @@ -315,12 +317,12 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp) /***********************************************************************/ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) { - const char *sp; + const char *sp = NULL; char *db, *name; bool mysql = true; PTDB tdbp = NULL; TABLE_SHARE *s = NULL; - Field* *fp; + Field* *fp = NULL; PCATLG cat = To_Def->GetCat(); PHC hc = ((MYCAT*)cat)->GetHandler(); LPCSTR cdb, curdb = hc->GetDBName(NULL); From 5b0774ee1c5a32ef694ce18413fa003bc6646c48 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 10 Jul 2013 11:49:17 +0400 Subject: [PATCH 272/273] Adding support for MySQL-5.6 temporal column types: TIME, DATETIME, TIMESTAMP added: mysql-test/r/type_temporal_mysql56.result mysql-test/std_data/mysql56datetime.MYD mysql-test/std_data/mysql56datetime.MYI mysql-test/std_data/mysql56datetime.frm mysql-test/std_data/mysql56time.MYD mysql-test/std_data/mysql56time.MYI mysql-test/std_data/mysql56time.frm mysql-test/std_data/mysql56timestamp.MYD mysql-test/std_data/mysql56timestamp.MYI mysql-test/std_data/mysql56timestamp.frm mysql-test/suite/rpl/r/rpl_temporal_mysql56.result mysql-test/suite/rpl/t/rpl_temporal_mysql56.test mysql-test/t/type_temporal_mysql56.test sql/compat56.cc sql/compat56.h modified: client/mysqlbinlog.cc include/my_time.h include/mysql.h.pp include/mysql_com.h mysql-test/r/statistics.result mysql-test/r/strict.result mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result sql-common/my_time.c sql/CMakeLists.txt sql/field.cc sql/field.h sql/item.cc sql/item_strfunc.cc sql/item_sum.cc sql/item_timefunc.cc sql/log_event.cc sql/opt_range.cc sql/opt_table_elimination.cc sql/protocol.cc sql/rpl_utility.cc sql/rpl_utility.h sql/sql_partition.cc sql/sql_prepare.cc sql/sql_select.cc sql/sql_table.cc sql/table.cc storage/perfschema/pfs_engine_table.cc --- client/mysqlbinlog.cc | 2 + include/my_time.h | 21 +- include/mysql.h.pp | 3 + include/mysql_com.h | 10 + mysql-test/r/statistics.result | 4 +- mysql-test/r/strict.result | 2 +- mysql-test/r/type_temporal_mysql56.result | 89 +++ mysql-test/std_data/mysql56datetime.MYD | Bin 0 -> 96 bytes mysql-test/std_data/mysql56datetime.MYI | Bin 0 -> 1024 bytes mysql-test/std_data/mysql56datetime.frm | Bin 0 -> 8726 bytes mysql-test/std_data/mysql56time.MYD | Bin 0 -> 102 bytes mysql-test/std_data/mysql56time.MYI | Bin 0 -> 1024 bytes mysql-test/std_data/mysql56time.frm | Bin 0 -> 8712 bytes mysql-test/std_data/mysql56timestamp.MYD | Bin 0 -> 82 bytes mysql-test/std_data/mysql56timestamp.MYI | Bin 0 -> 1024 bytes mysql-test/std_data/mysql56timestamp.frm | Bin 0 -> 8726 bytes .../r/binlog_mysqlbinlog_row_innodb.result | 8 +- .../r/binlog_mysqlbinlog_row_myisam.result | 8 +- .../suite/rpl/r/rpl_temporal_mysql56.result | 84 ++ .../suite/rpl/t/rpl_temporal_mysql56.test | 48 ++ mysql-test/t/type_temporal_mysql56.test | 23 + sql-common/my_time.c | 55 +- sql/CMakeLists.txt | 2 +- sql/compat56.cc | 445 +++++++++++ sql/compat56.h | 46 ++ sql/field.cc | 731 +++++++++--------- sql/field.h | 610 +++++++++++---- sql/item.cc | 19 +- sql/item_strfunc.cc | 3 + sql/item_sum.cc | 6 +- sql/item_timefunc.cc | 7 +- sql/log_event.cc | 48 +- sql/opt_range.cc | 6 +- sql/opt_table_elimination.cc | 2 +- sql/protocol.cc | 4 +- sql/rpl_utility.cc | 44 +- sql/rpl_utility.h | 10 +- sql/sql_partition.cc | 9 +- sql/sql_prepare.cc | 4 +- sql/sql_select.cc | 4 +- sql/sql_table.cc | 11 +- sql/table.cc | 2 +- storage/perfschema/pfs_engine_table.cc | 2 +- 43 files changed, 1813 insertions(+), 559 deletions(-) create mode 100644 mysql-test/r/type_temporal_mysql56.result create mode 100644 mysql-test/std_data/mysql56datetime.MYD create mode 100644 mysql-test/std_data/mysql56datetime.MYI create mode 100644 mysql-test/std_data/mysql56datetime.frm create mode 100644 mysql-test/std_data/mysql56time.MYD create mode 100644 mysql-test/std_data/mysql56time.MYI create mode 100644 mysql-test/std_data/mysql56time.frm create mode 100644 mysql-test/std_data/mysql56timestamp.MYD create mode 100644 mysql-test/std_data/mysql56timestamp.MYI create mode 100644 mysql-test/std_data/mysql56timestamp.frm create mode 100644 mysql-test/suite/rpl/r/rpl_temporal_mysql56.result create mode 100644 mysql-test/suite/rpl/t/rpl_temporal_mysql56.test create mode 100644 mysql-test/t/type_temporal_mysql56.test create mode 100644 sql/compat56.cc create mode 100644 sql/compat56.h diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index c099459f61e..58785c48781 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -37,6 +37,7 @@ /* That one is necessary for defines of OPTION_NO_FOREIGN_KEY_CHECKS etc */ #include "sql_priv.h" #include "log_event.h" +#include "compat56.h" #include "sql_common.h" #include "my_dir.h" #include // ORACLE_WELCOME_COPYRIGHT_NOTICE @@ -2562,3 +2563,4 @@ void *sql_alloc(size_t size) #include "sql_string.cc" #include "sql_list.cc" #include "rpl_filter.cc" +#include "compat56.cc" diff --git a/include/my_time.h b/include/my_time.h index 046b5c94923..d8a8d0b5ed3 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -111,6 +111,8 @@ longlong pack_time(MYSQL_TIME *my_time); MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time); int check_time_range(struct st_mysql_time *my_time, uint dec, int *warning); +my_bool check_datetime_range(const MYSQL_TIME *ltime); + long calc_daynr(uint year,uint month,uint day); uint calc_days_in_year(uint year); @@ -163,6 +165,8 @@ int my_date_to_str(const MYSQL_TIME *l_time, char *to); int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, uint digits); int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, uint digits); +int my_timeval_to_str(const struct timeval *tm, char *to, uint dec); + static inline longlong sec_part_shift(longlong second_part, uint digits) { return second_part / (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; @@ -171,11 +175,22 @@ static inline longlong sec_part_unshift(longlong second_part, uint digits) { return second_part * (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; } -static inline ulong sec_part_truncate(ulong second_part, uint digits) + +/* Date/time rounding and truncation functions */ +static inline long my_time_fraction_remainder(long nr, uint decimals) { - /* the cast here should be unnecessary! */ - return second_part - second_part % (ulong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; + DBUG_ASSERT(decimals <= TIME_SECOND_PART_DIGITS); + return nr % (long) log_10_int[TIME_SECOND_PART_DIGITS - decimals]; } +static inline void my_time_trunc(MYSQL_TIME *ltime, uint decimals) +{ + ltime->second_part-= my_time_fraction_remainder(ltime->second_part, decimals); +} +static inline void my_timeval_trunc(struct timeval *tv, uint decimals) +{ + tv->tv_usec-= my_time_fraction_remainder(tv->tv_usec, decimals); +} + #define hrtime_to_my_time(X) ((my_time_t)hrtime_to_time(X)) diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 02eb62655df..4b0edf56a72 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -49,6 +49,9 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_BIT, + MYSQL_TYPE_TIMESTAMP2, + MYSQL_TYPE_DATETIME2, + MYSQL_TYPE_TIME2, MYSQL_TYPE_NEWDECIMAL=246, MYSQL_TYPE_ENUM=247, MYSQL_TYPE_SET=248, diff --git a/include/mysql_com.h b/include/mysql_com.h index 0573bbe5f80..6e8350b0d75 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -400,6 +400,16 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_BIT, + /* + mysql-5.6 compatibility temporal types. + They're only used internally for reading RBR + mysql-5.6 binary log events and mysql-5.6 frm files. + They're never sent to the client. + */ + MYSQL_TYPE_TIMESTAMP2, + MYSQL_TYPE_DATETIME2, + MYSQL_TYPE_TIME2, + MYSQL_TYPE_NEWDECIMAL=246, MYSQL_TYPE_ENUM=247, MYSQL_TYPE_SET=248, diff --git a/mysql-test/r/statistics.result b/mysql-test/r/statistics.result index 640a2f649d6..ad12c60cce5 100644 --- a/mysql-test/r/statistics.result +++ b/mysql-test/r/statistics.result @@ -220,7 +220,7 @@ db_name table_name column_name min_value max_value nulls_ratio avg_frequency his test t1 a 0 49 0.0000 1.0000 4 SINGLE_PREC_HB 2E62A1D0 test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 SINGLE_PREC_HB 003FBFFF test t1 c aaaa dddddddd 0.1250 7.0000 4 SINGLE_PREC_HB 0055AAFF -test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 SINGLE_PREC_HB 009393FF +test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 SINGLE_PREC_HB 001919FF test t1 e 0.01 0.112 0.2250 6.2000 4 SINGLE_PREC_HB 000564E1 test t1 f 1 5 0.2000 6.4000 4 SINGLE_PREC_HB 3F7FBFBF DELETE FROM mysql.column_stats; @@ -238,7 +238,7 @@ db_name table_name column_name min_value max_value nulls_ratio avg_frequency his test t1 a 0 49 0.0000 1.0000 8 DOUBLE_PREC_HB 052F4363F4A1F9D0 test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 DOUBLE_PREC_HB 0000FF3FFFBFFFFF test t1 c aaaa dddddddd 0.1250 7.0000 8 DOUBLE_PREC_HB 00005555AAAAFFFF -test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 DOUBLE_PREC_HB 000026942694FFFF +test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 DOUBLE_PREC_HB 0000031A031AFFFF test t1 e 0.01 0.112 0.2250 6.2000 8 DOUBLE_PREC_HB 000005056464E1E1 test t1 f 1 5 0.2000 6.4000 8 DOUBLE_PREC_HB FF3FFF7FFFBFFFBF DELETE FROM mysql.column_stats; diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index b1e4cb669ed..139994445f9 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -1135,7 +1135,7 @@ create table t1 (col1 date, col2 datetime, col3 timestamp); insert into t1 values (0,0,0); ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1 insert into t1 values (0.0,0.0,0.0); -ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1 +ERROR 22007: Incorrect date value: '0.0' for column 'col1' at row 1 insert into t1 (col1) values (convert('0000-00-00',date)); ERROR 22007: Incorrect datetime value: '0000-00-00' insert into t1 (col1) values (cast('0000-00-00' as date)); diff --git a/mysql-test/r/type_temporal_mysql56.result b/mysql-test/r/type_temporal_mysql56.result new file mode 100644 index 00000000000..b0c81844781 --- /dev/null +++ b/mysql-test/r/type_temporal_mysql56.result @@ -0,0 +1,89 @@ +SHOW CREATE TABLE mysql56time; +Table Create Table +mysql56time CREATE TABLE `mysql56time` ( + `t0` time DEFAULT NULL, + `t1` time(1) DEFAULT NULL, + `t2` time(2) DEFAULT NULL, + `t3` time(3) DEFAULT NULL, + `t4` time(4) DEFAULT NULL, + `t5` time(5) DEFAULT NULL, + `t6` time(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * FROM mysql56time; +t0 838:59:59 +t1 838:59:59.0 +t2 838:59:59.00 +t3 838:59:59.000 +t4 838:59:59.0000 +t5 838:59:59.00000 +t6 838:59:59.000000 +t0 00:00:00 +t1 00:00:00.0 +t2 00:00:00.00 +t3 00:00:00.000 +t4 00:00:00.0000 +t5 00:00:00.00000 +t6 00:00:00.000000 +t0 -838:59:59 +t1 -838:59:59.0 +t2 -838:59:59.00 +t3 -838:59:59.000 +t4 -838:59:59.0000 +t5 -838:59:59.00000 +t6 -838:59:59.000000 +DROP TABLE mysql56time; +SHOW CREATE TABLE mysql56datetime; +Table Create Table +mysql56datetime CREATE TABLE `mysql56datetime` ( + `dt0` datetime DEFAULT NULL, + `dt1` datetime(1) DEFAULT NULL, + `dt2` datetime(2) DEFAULT NULL, + `dt3` datetime(3) DEFAULT NULL, + `dt4` datetime(4) DEFAULT NULL, + `dt5` datetime(5) DEFAULT NULL, + `dt6` datetime(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * FROM mysql56datetime; +dt0 0000-00-00 00:00:00 +dt1 0000-00-00 00:00:00.0 +dt2 0000-00-00 00:00:00.00 +dt3 0000-00-00 00:00:00.000 +dt4 0000-00-00 00:00:00.0000 +dt5 0000-00-00 00:00:00.00000 +dt6 0000-00-00 00:00:00.000000 +dt0 9999-12-31 23:59:59 +dt1 9999-12-31 23:59:59.9 +dt2 9999-12-31 23:59:59.99 +dt3 9999-12-31 23:59:59.999 +dt4 9999-12-31 23:59:59.9999 +dt5 9999-12-31 23:59:59.99999 +dt6 9999-12-31 23:59:59.999999 +DROP TABLE mysql56datetime; +SET TIME_ZONE='+00:00'; +SHOW CREATE TABLE mysql56timestamp; +Table Create Table +mysql56timestamp CREATE TABLE `mysql56timestamp` ( + `ts0` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `ts1` timestamp(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `ts2` timestamp(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `ts3` timestamp(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `ts4` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `ts5` timestamp(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `ts6` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * FROM mysql56timestamp; +ts0 1970-01-01 00:00:01 +ts1 1970-01-01 00:00:01.0 +ts2 1970-01-01 00:00:01.00 +ts3 1970-01-01 00:00:01.000 +ts4 1970-01-01 00:00:01.0000 +ts5 1970-01-01 00:00:01.00000 +ts6 1970-01-01 00:00:01.000000 +ts0 2038-01-19 03:14:07 +ts1 2038-01-19 03:14:07.9 +ts2 2038-01-19 03:14:07.99 +ts3 2038-01-19 03:14:07.999 +ts4 2038-01-19 03:14:07.9999 +ts5 2038-01-19 03:14:07.99999 +ts6 2038-01-19 03:14:07.999999 +DROP TABLE mysql56timestamp; diff --git a/mysql-test/std_data/mysql56datetime.MYD b/mysql-test/std_data/mysql56datetime.MYD new file mode 100644 index 0000000000000000000000000000000000000000..5c398fe9f7a830d124458e4e612f7ee3859bb398 GIT binary patch literal 96 tcmZQsD?l+i-0+Y#LQk@M#@q;OTCo?E*4*+$~B$)sJ literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mysql56datetime.MYI b/mysql-test/std_data/mysql56datetime.MYI new file mode 100644 index 0000000000000000000000000000000000000000..d1b19d18093c96bdc1a2a9eef9d36b9b9eda92f2 GIT binary patch literal 1024 zcmezOkDZZ$fzgLy149ZBg8>Jal>86jF)%@C7{&A-3LpY3F!2N!12%EQeK zJeXX8tOuQsEC*r3?ZlKq6)^yEk+BGn5B44#Gh89WyKpX;0SprmV1>Am4PqY~L?ycb XSdLu*OmR3ss0J`KN{oiUkO~0+leQG1 literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mysql56datetime.frm b/mysql-test/std_data/mysql56datetime.frm new file mode 100644 index 0000000000000000000000000000000000000000..5b215ae340005474fad9ffbacbe7bd0092f94514 GIT binary patch literal 8726 zcmeI2Jx;?w5QU$YA+{qSML2O17buje;{5iM6p@fPK_reqLzg3P1n$5YxEAIO#MaVL zM&gY$^E^+oclB-M)qEy-egO;;pr&|fBV@>cOK+(^F`&GE0JBq%#Ug52Qz`-?AOa#F z0wN#+A|L`HAOa#F0wQpB1Ol3FPtDOEzss+BYFg zl6NDN6+cB;bBcnpLGH3e-(?50qCfy%k6i8A2QF+h^2Ix&XJv`2$VhEGMiCjAO(v)! fBe&@kw~^7es=_=n8t#(0WUiQN=7zat?izdnt@bn< literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mysql56time.MYD b/mysql-test/std_data/mysql56time.MYD new file mode 100644 index 0000000000000000000000000000000000000000..29ac794e9dba64911b3c2f3e8b12b735c2752f9c GIT binary patch literal 102 tcmZSFlJ^^k7+@I8fDllUv4MdBh~OB^fDllU(R(5*5HY|om;oW6Bmhra7v literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mysql56time.MYI b/mysql-test/std_data/mysql56time.MYI new file mode 100644 index 0000000000000000000000000000000000000000..0cdac671d933c31d91cd9279797ded272c23b46d GIT binary patch literal 1024 zcmezOkDZZ$fzgLy149ZBg8>Jal>86jF)%}E7{&Y_3LpY3F!3}P12|=oh466WG WkW~Rpu{l7f1~4^BjE2CF3IPDv+!SK~ literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mysql56time.frm b/mysql-test/std_data/mysql56time.frm new file mode 100644 index 0000000000000000000000000000000000000000..318f2080b5edf8fc9b1ba431b911d3695adfd4ce GIT binary patch literal 8712 zcmeI&J5Iwu5C-7iJ0X53P8>i`Aw}t^;yimwibzOw>A1r*bU6n1;0#=gVHStQC1oW3 zkv-!bY1j5w+WVQ6r2tI^v|cbricp{cF5=j07mb(q4`6m0W3lKBewwTlpa2CZKmiI+ zfC3bt00k&O0ScU*K!BxZvLoO}I=?TvbjrXG``5?khkZ9GeiC3%fC3bt00k&O0SZun z0u-PC1t@UN0!8qj{{J{K@`Yh dn)n`RjY_6d-1Qo!t?ANqWx6)qm~KsXhA*a*Ev^6n literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mysql56timestamp.MYD b/mysql-test/std_data/mysql56timestamp.MYD new file mode 100644 index 0000000000000000000000000000000000000000..9d0cb49737ccd3862f771416723da7f32c30e854 GIT binary patch literal 82 rcmey*z`(!=#b5@6Kq0}L|Mma>gK-pykqjc#*}x<}h~#%NgHZMW(}5hJ literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mysql56timestamp.MYI b/mysql-test/std_data/mysql56timestamp.MYI new file mode 100644 index 0000000000000000000000000000000000000000..fb47f4a5c6a20376bb7eb057bb03c59a73157296 GIT binary patch literal 1024 zcmezOkDZZ$fzgLy149ZBg8>Jal>86jF)%@C7{&A-3LpY3F!3N512125*+bL0wr!c4hQ6IeMFjs>vHzTfWe-h7Mz-(ED^h`_z23H zQxud9GM6p-E<2bFhX_E00=V*l3mc7iBPxz$G)8QBj!PO`)fkBtg}=3mgBy*J+IZ|I ouB2cV)4oloxTC?18>8kanM>x1xn^#dTjs9DC;nV5#Q*>R literal 0 HcmV?d00001 diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result index a209ec141fe..0c44061c4e9 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result @@ -2404,7 +2404,7 @@ BEGIN ### @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */ ### @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */ ### @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */ -### @31='839:12:57' /* TIME meta=0 nullable=1 is_null=0 */ +### @31='-838:59:59' /* TIME meta=0 nullable=1 is_null=0 */ ### @32=1901 /* YEAR meta=0 nullable=1 is_null=0 */ ### @33='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ ### @34='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ @@ -2766,7 +2766,7 @@ BEGIN ### @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */ ### @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */ ### @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */ -### @31='839:12:57' /* TIME meta=0 nullable=1 is_null=0 */ +### @31='-838:59:59' /* TIME meta=0 nullable=1 is_null=0 */ ### @32=1901 /* YEAR meta=0 nullable=1 is_null=0 */ ### @33='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ ### @34='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ @@ -3019,7 +3019,7 @@ BEGIN ### @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */ ### @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */ ### @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */ -### @31='839:12:57' /* TIME meta=0 nullable=1 is_null=0 */ +### @31='-838:59:59' /* TIME meta=0 nullable=1 is_null=0 */ ### @32=1901 /* YEAR meta=0 nullable=1 is_null=0 */ ### @33='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ ### @34='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ @@ -3551,7 +3551,7 @@ BEGIN ### @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */ ### @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */ ### @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */ -### @31='839:12:57' /* TIME meta=0 nullable=1 is_null=0 */ +### @31='-838:59:59' /* TIME meta=0 nullable=1 is_null=0 */ ### @32=1901 /* YEAR meta=0 nullable=1 is_null=0 */ ### @33='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ ### @34='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result index ff4f26b93e5..e54e33283fd 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result @@ -2404,7 +2404,7 @@ BEGIN ### @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */ ### @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */ ### @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */ -### @31='839:12:57' /* TIME meta=0 nullable=1 is_null=0 */ +### @31='-838:59:59' /* TIME meta=0 nullable=1 is_null=0 */ ### @32=1901 /* YEAR meta=0 nullable=1 is_null=0 */ ### @33='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ ### @34='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ @@ -2773,7 +2773,7 @@ BEGIN ### @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */ ### @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */ ### @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */ -### @31='839:12:57' /* TIME meta=0 nullable=1 is_null=0 */ +### @31='-838:59:59' /* TIME meta=0 nullable=1 is_null=0 */ ### @32=1901 /* YEAR meta=0 nullable=1 is_null=0 */ ### @33='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ ### @34='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ @@ -3028,7 +3028,7 @@ BEGIN ### @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */ ### @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */ ### @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */ -### @31='839:12:57' /* TIME meta=0 nullable=1 is_null=0 */ +### @31='-838:59:59' /* TIME meta=0 nullable=1 is_null=0 */ ### @32=1901 /* YEAR meta=0 nullable=1 is_null=0 */ ### @33='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ ### @34='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ @@ -3568,7 +3568,7 @@ BEGIN ### @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */ ### @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */ ### @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */ -### @31='839:12:57' /* TIME meta=0 nullable=1 is_null=0 */ +### @31='-838:59:59' /* TIME meta=0 nullable=1 is_null=0 */ ### @32=1901 /* YEAR meta=0 nullable=1 is_null=0 */ ### @33='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ ### @34='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ diff --git a/mysql-test/suite/rpl/r/rpl_temporal_mysql56.result b/mysql-test/suite/rpl/r/rpl_temporal_mysql56.result new file mode 100644 index 00000000000..99f81abb166 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_temporal_mysql56.result @@ -0,0 +1,84 @@ +include/master-slave.inc +[connection master] +SET TIME_ZONE='+00:00'; +SET TIME_ZONE='+00:00'; +INSERT INTO mysql56time VALUES ('01:01:01','01:01:01.1','01:01:01.11','01:01:01.111','01:01:01.1111','01:01:01.11111','01:01:01.111111'); +INSERT INTO mysql56datetime VALUES ('2001-01-01 01:01:01','2001-01-01 01:01:01.1','2001-01-01 01:01:01.11','2001-01-01 01:01:01.111','2001-01-01 01:01:01.1111','2001-01-01 01:01:01.11111','2001-01-01 01:01:01.111111'); +INSERT INTO mysql56timestamp VALUES ('2001-01-01 01:01:01','2001-01-01 01:01:01.1','2001-01-01 01:01:01.11','2001-01-01 01:01:01.111','2001-01-01 01:01:01.1111','2001-01-01 01:01:01.11111','2001-01-01 01:01:01.111111'); +SELECT * FROM mysql56time; +t0 838:59:59 +t1 838:59:59.0 +t2 838:59:59.00 +t3 838:59:59.000 +t4 838:59:59.0000 +t5 838:59:59.00000 +t6 838:59:59.000000 +t0 00:00:00 +t1 00:00:00.0 +t2 00:00:00.00 +t3 00:00:00.000 +t4 00:00:00.0000 +t5 00:00:00.00000 +t6 00:00:00.000000 +t0 -838:59:59 +t1 -838:59:59.0 +t2 -838:59:59.00 +t3 -838:59:59.000 +t4 -838:59:59.0000 +t5 -838:59:59.00000 +t6 -838:59:59.000000 +t0 01:01:01 +t1 01:01:01.1 +t2 01:01:01.11 +t3 01:01:01.111 +t4 01:01:01.1111 +t5 01:01:01.11111 +t6 01:01:01.111111 +SELECT * FROM mysql56datetime; +dt0 0000-00-00 00:00:00 +dt1 0000-00-00 00:00:00.0 +dt2 0000-00-00 00:00:00.00 +dt3 0000-00-00 00:00:00.000 +dt4 0000-00-00 00:00:00.0000 +dt5 0000-00-00 00:00:00.00000 +dt6 0000-00-00 00:00:00.000000 +dt0 9999-12-31 23:59:59 +dt1 9999-12-31 23:59:59.9 +dt2 9999-12-31 23:59:59.99 +dt3 9999-12-31 23:59:59.999 +dt4 9999-12-31 23:59:59.9999 +dt5 9999-12-31 23:59:59.99999 +dt6 9999-12-31 23:59:59.999999 +dt0 2001-01-01 01:01:01 +dt1 2001-01-01 01:01:01.1 +dt2 2001-01-01 01:01:01.11 +dt3 2001-01-01 01:01:01.111 +dt4 2001-01-01 01:01:01.1111 +dt5 2001-01-01 01:01:01.11111 +dt6 2001-01-01 01:01:01.111111 +SELECT * FROM mysql56timestamp; +ts0 1970-01-01 00:00:01 +ts1 1970-01-01 00:00:01.0 +ts2 1970-01-01 00:00:01.00 +ts3 1970-01-01 00:00:01.000 +ts4 1970-01-01 00:00:01.0000 +ts5 1970-01-01 00:00:01.00000 +ts6 1970-01-01 00:00:01.000000 +ts0 2038-01-19 03:14:07 +ts1 2038-01-19 03:14:07.9 +ts2 2038-01-19 03:14:07.99 +ts3 2038-01-19 03:14:07.999 +ts4 2038-01-19 03:14:07.9999 +ts5 2038-01-19 03:14:07.99999 +ts6 2038-01-19 03:14:07.999999 +ts0 2001-01-01 01:01:01 +ts1 2001-01-01 01:01:01.1 +ts2 2001-01-01 01:01:01.11 +ts3 2001-01-01 01:01:01.111 +ts4 2001-01-01 01:01:01.1111 +ts5 2001-01-01 01:01:01.11111 +ts6 2001-01-01 01:01:01.111111 +DROP TABLE mysql56time; +DROP TABLE mysql56datetime; +DROP TABLE mysql56timestamp; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_temporal_mysql56.test b/mysql-test/suite/rpl/t/rpl_temporal_mysql56.test new file mode 100644 index 00000000000..f21f125ba30 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_temporal_mysql56.test @@ -0,0 +1,48 @@ +--source include/master-slave.inc + +connection master; +SET TIME_ZONE='+00:00'; +let $MYSQLD_MASTER_DATADIR= `select @@datadir`; + +connection slave; +SET TIME_ZONE='+00:00'; +let $MYSQLD_SLAVE_DATADIR= `select @@datadir`; + +--copy_file std_data/mysql56time.frm $MYSQLD_MASTER_DATADIR/test/mysql56time.frm +--copy_file std_data/mysql56time.MYD $MYSQLD_MASTER_DATADIR/test/mysql56time.MYD +--copy_file std_data/mysql56time.MYI $MYSQLD_MASTER_DATADIR/test/mysql56time.MYI +--copy_file std_data/mysql56time.frm $MYSQLD_SLAVE_DATADIR/test/mysql56time.frm +--copy_file std_data/mysql56time.MYD $MYSQLD_SLAVE_DATADIR/test/mysql56time.MYD +--copy_file std_data/mysql56time.MYI $MYSQLD_SLAVE_DATADIR/test/mysql56time.MYI + +--copy_file std_data/mysql56datetime.frm $MYSQLD_MASTER_DATADIR/test/mysql56datetime.frm +--copy_file std_data/mysql56datetime.MYD $MYSQLD_MASTER_DATADIR/test/mysql56datetime.MYD +--copy_file std_data/mysql56datetime.MYI $MYSQLD_MASTER_DATADIR/test/mysql56datetime.MYI +--copy_file std_data/mysql56datetime.frm $MYSQLD_SLAVE_DATADIR/test/mysql56datetime.frm +--copy_file std_data/mysql56datetime.MYD $MYSQLD_SLAVE_DATADIR/test/mysql56datetime.MYD +--copy_file std_data/mysql56datetime.MYI $MYSQLD_SLAVE_DATADIR/test/mysql56datetime.MYI + +--copy_file std_data/mysql56timestamp.frm $MYSQLD_MASTER_DATADIR/test/mysql56timestamp.frm +--copy_file std_data/mysql56timestamp.MYD $MYSQLD_MASTER_DATADIR/test/mysql56timestamp.MYD +--copy_file std_data/mysql56timestamp.MYI $MYSQLD_MASTER_DATADIR/test/mysql56timestamp.MYI +--copy_file std_data/mysql56timestamp.frm $MYSQLD_SLAVE_DATADIR/test/mysql56timestamp.frm +--copy_file std_data/mysql56timestamp.MYD $MYSQLD_SLAVE_DATADIR/test/mysql56timestamp.MYD +--copy_file std_data/mysql56timestamp.MYI $MYSQLD_SLAVE_DATADIR/test/mysql56timestamp.MYI + +connection master; +INSERT INTO mysql56time VALUES ('01:01:01','01:01:01.1','01:01:01.11','01:01:01.111','01:01:01.1111','01:01:01.11111','01:01:01.111111'); +INSERT INTO mysql56datetime VALUES ('2001-01-01 01:01:01','2001-01-01 01:01:01.1','2001-01-01 01:01:01.11','2001-01-01 01:01:01.111','2001-01-01 01:01:01.1111','2001-01-01 01:01:01.11111','2001-01-01 01:01:01.111111'); +INSERT INTO mysql56timestamp VALUES ('2001-01-01 01:01:01','2001-01-01 01:01:01.1','2001-01-01 01:01:01.11','2001-01-01 01:01:01.111','2001-01-01 01:01:01.1111','2001-01-01 01:01:01.11111','2001-01-01 01:01:01.111111'); +sync_slave_with_master; + +connection slave; +--query_vertical SELECT * FROM mysql56time +--query_vertical SELECT * FROM mysql56datetime +--query_vertical SELECT * FROM mysql56timestamp + +connection master; +DROP TABLE mysql56time; +DROP TABLE mysql56datetime; +DROP TABLE mysql56timestamp; + +--source include/rpl_end.inc diff --git a/mysql-test/t/type_temporal_mysql56.test b/mysql-test/t/type_temporal_mysql56.test new file mode 100644 index 00000000000..98529bfe1c1 --- /dev/null +++ b/mysql-test/t/type_temporal_mysql56.test @@ -0,0 +1,23 @@ + +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file std_data/mysql56time.frm $MYSQLD_DATADIR/test/mysql56time.frm +--copy_file std_data/mysql56time.MYD $MYSQLD_DATADIR/test/mysql56time.MYD +--copy_file std_data/mysql56time.MYI $MYSQLD_DATADIR/test/mysql56time.MYI +SHOW CREATE TABLE mysql56time; +--query_vertical SELECT * FROM mysql56time +DROP TABLE mysql56time; + +--copy_file std_data/mysql56datetime.frm $MYSQLD_DATADIR/test/mysql56datetime.frm +--copy_file std_data/mysql56datetime.MYD $MYSQLD_DATADIR/test/mysql56datetime.MYD +--copy_file std_data/mysql56datetime.MYI $MYSQLD_DATADIR/test/mysql56datetime.MYI +SHOW CREATE TABLE mysql56datetime; +--query_vertical SELECT * FROM mysql56datetime +DROP TABLE mysql56datetime; + +--copy_file std_data/mysql56timestamp.frm $MYSQLD_DATADIR/test/mysql56timestamp.frm +--copy_file std_data/mysql56timestamp.MYD $MYSQLD_DATADIR/test/mysql56timestamp.MYD +--copy_file std_data/mysql56timestamp.MYI $MYSQLD_DATADIR/test/mysql56timestamp.MYI +SET TIME_ZONE='+00:00'; +SHOW CREATE TABLE mysql56timestamp; +--query_vertical SELECT * FROM mysql56timestamp +DROP TABLE mysql56timestamp; diff --git a/sql-common/my_time.c b/sql-common/my_time.c index d4093bb4df9..343bb0ec614 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -203,6 +203,29 @@ static uint skip_digits(const char **str, const char *end) return s - start; } + +/** + Check datetime, date, or normalized time (i.e. time without days) range. + @param ltime Datetime value. + @returns + @retval FALSE on success + @retval TRUE on error +*/ +my_bool check_datetime_range(const MYSQL_TIME *ltime) +{ + /* + In case of MYSQL_TIMESTAMP_TIME hour value can be up to TIME_MAX_HOUR. + In case of MYSQL_TIMESTAMP_DATETIME it cannot be bigger than 23. + */ + return + ltime->year > 9999 || ltime->month > 12 || ltime->day > 31 || + ltime->minute > 59 || ltime->second > 59 || + ltime->second_part > TIME_MAX_SECOND_PART || + (ltime->hour > + (ltime->time_type == MYSQL_TIMESTAMP_TIME ? TIME_MAX_HOUR : 23)); +} + + /* Convert a timestamp string to a MYSQL_TIME value. @@ -332,9 +355,14 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, uint second_part; const char *start= ++str; *was_cut= get_digits(&second_part, &number_of_fields, &str, end, 6); - if (str - start < 6) - second_part*= log_10_int[6 - (str - start)]; - l_time->second_part= second_part; + if (number_of_fields == 7) + { + if (str - start < 6) + second_part*= log_10_int[6 - (str - start)]; + l_time->second_part= second_part; + } + else + l_time->second_part= 0; if (skip_digits(&str, end)) *was_cut= 1; } @@ -1101,6 +1129,27 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, uint digits) } +/** + Print a timestamp with an optional fractional part: XXXXX[.YYYYY] + + @param tm The timestamp value to print. + @param OUT to The string pointer to print at. + @param dec Precision, in the range 0..6. + @return The length of the result string. +*/ +int my_timeval_to_str(const struct timeval *tm, char *to, uint dec) +{ + char *pos= longlong10_to_str((longlong) tm->tv_sec, to, 10); + if (dec) + { + *pos++= '.'; + pos= fmt_number((uint) sec_part_shift(tm->tv_usec, dec), pos, dec); + } + *pos= '\0'; + return (int) (pos - to); +} + + /* Convert datetime value specified as number to broken-down TIME representation and form value of DATETIME type as side-effect. diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index bf1d0bfdc9a..dc6ba20811d 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -37,7 +37,7 @@ IF(SSL_DEFINES) ENDIF() SET (SQL_SOURCE - ../sql-common/client.c derror.cc des_key_file.cc + ../sql-common/client.c compat56.cc derror.cc des_key_file.cc discover.cc ../libmysql/errmsg.c field.cc field_conv.cc filesort_utils.cc filesort.cc gstream.cc sha2.cc diff --git a/sql/compat56.cc b/sql/compat56.cc new file mode 100644 index 00000000000..3bd6b21a154 --- /dev/null +++ b/sql/compat56.cc @@ -0,0 +1,445 @@ +/* + Copyright (c) 2004, 2012, Oracle and/or its affiliates. + Copyright (c) 2013, MariaDB Foundation. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "my_global.h" +#include "compat56.h" +#include "myisampack.h" +#include "my_time.h" + +/*** MySQL56 TIME low-level memory and disk representation routines ***/ + +/* + In-memory format: + + 1 bit sign (Used for sign, when on disk) + 1 bit unused (Reserved for wider hour range, e.g. for intervals) + 10 bit hour (0-836) + 6 bit minute (0-59) + 6 bit second (0-59) + 24 bits microseconds (0-999999) + + Total: 48 bits = 6 bytes + Suhhhhhh.hhhhmmmm.mmssssss.ffffffff.ffffffff.ffffffff +*/ + + +/** + Convert time value to MySQL56 numeric packed representation. + + @param ltime The value to convert. + @return Numeric packed representation. +*/ +longlong TIME_to_longlong_time_packed(const MYSQL_TIME *ltime) +{ + /* If month is 0, we mix day with hours: "1 00:10:10" -> "24:00:10" */ + long hms= (((ltime->month ? 0 : ltime->day * 24) + ltime->hour) << 12) | + (ltime->minute << 6) | ltime->second; + longlong tmp= MY_PACKED_TIME_MAKE(hms, ltime->second_part); + return ltime->neg ? -tmp : tmp; +} + + + +/** + Convert MySQL56 time packed numeric representation to time. + + @param OUT ltime The MYSQL_TIME variable to set. + @param tmp The packed numeric representation. +*/ +void TIME_from_longlong_time_packed(MYSQL_TIME *ltime, longlong tmp) +{ + long hms; + if ((ltime->neg= (tmp < 0))) + tmp= -tmp; + hms= MY_PACKED_TIME_GET_INT_PART(tmp); + ltime->year= (uint) 0; + ltime->month= (uint) 0; + ltime->day= (uint) 0; + ltime->hour= (uint) (hms >> 12) % (1 << 10); /* 10 bits starting at 12th */ + ltime->minute= (uint) (hms >> 6) % (1 << 6); /* 6 bits starting at 6th */ + ltime->second= (uint) hms % (1 << 6); /* 6 bits starting at 0th */ + ltime->second_part= MY_PACKED_TIME_GET_FRAC_PART(tmp); + ltime->time_type= MYSQL_TIMESTAMP_TIME; +} + + +/** + Calculate binary size of MySQL56 packed numeric time representation. + + @param dec Precision. +*/ +uint my_time_binary_length(uint dec) +{ + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + return 3 + (dec + 1) / 2; +} + + +/* + On disk we convert from signed representation to unsigned + representation using TIMEF_OFS, so all values become binary comparable. +*/ +#define TIMEF_OFS 0x800000000000LL +#define TIMEF_INT_OFS 0x800000LL + + +/** + Convert MySQL56 in-memory numeric time representation to on-disk representation + + @param nr Value in packed numeric time format. + @param OUT ptr The buffer to put value at. + @param dec Precision. +*/ +void my_time_packed_to_binary(longlong nr, uchar *ptr, uint dec) +{ + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + /* Make sure the stored value was previously properly rounded or truncated */ + DBUG_ASSERT((MY_PACKED_TIME_GET_FRAC_PART(nr) % + (int) log_10_int[TIME_SECOND_PART_DIGITS - dec]) == 0); + + switch (dec) + { + case 0: + default: + mi_int3store(ptr, TIMEF_INT_OFS + MY_PACKED_TIME_GET_INT_PART(nr)); + break; + + case 1: + case 2: + mi_int3store(ptr, TIMEF_INT_OFS + MY_PACKED_TIME_GET_INT_PART(nr)); + ptr[3]= (unsigned char) (char) (MY_PACKED_TIME_GET_FRAC_PART(nr) / 10000); + break; + + case 4: + case 3: + mi_int3store(ptr, TIMEF_INT_OFS + MY_PACKED_TIME_GET_INT_PART(nr)); + mi_int2store(ptr + 3, MY_PACKED_TIME_GET_FRAC_PART(nr) / 100); + break; + + case 5: + case 6: + mi_int6store(ptr, nr + TIMEF_OFS); + break; + } +} + + +/** + Convert MySQL56 on-disk time representation to in-memory packed numeric + representation. + + @param ptr The pointer to read the value at. + @param dec Precision. + @return Packed numeric time representation. +*/ +longlong my_time_packed_from_binary(const uchar *ptr, uint dec) +{ + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + + switch (dec) + { + case 0: + default: + { + longlong intpart= mi_uint3korr(ptr) - TIMEF_INT_OFS; + return MY_PACKED_TIME_MAKE_INT(intpart); + } + case 1: + case 2: + { + longlong intpart= mi_uint3korr(ptr) - TIMEF_INT_OFS; + int frac= (uint) ptr[3]; + if (intpart < 0 && frac) + { + /* + Negative values are stored with reverse fractional part order, + for binary sort compatibility. + + Disk value intpart frac Time value Memory value + 800000.00 0 0 00:00:00.00 0000000000.000000 + 7FFFFF.FF -1 255 -00:00:00.01 FFFFFFFFFF.FFD8F0 + 7FFFFF.9D -1 99 -00:00:00.99 FFFFFFFFFF.F0E4D0 + 7FFFFF.00 -1 0 -00:00:01.00 FFFFFFFFFF.000000 + 7FFFFE.FF -1 255 -00:00:01.01 FFFFFFFFFE.FFD8F0 + 7FFFFE.F6 -2 246 -00:00:01.10 FFFFFFFFFE.FE7960 + + Formula to convert fractional part from disk format + (now stored in "frac" variable) to absolute value: "0x100 - frac". + To reconstruct in-memory value, we shift + to the next integer value and then substruct fractional part. + */ + intpart++; /* Shift to the next integer value */ + frac-= 0x100; /* -(0x100 - frac) */ + } + return MY_PACKED_TIME_MAKE(intpart, frac * 10000); + } + + case 3: + case 4: + { + longlong intpart= mi_uint3korr(ptr) - TIMEF_INT_OFS; + int frac= mi_uint2korr(ptr + 3); + if (intpart < 0 && frac) + { + /* + Fix reverse fractional part order: "0x10000 - frac". + See comments for FSP=1 and FSP=2 above. + */ + intpart++; /* Shift to the next integer value */ + frac-= 0x10000; /* -(0x10000-frac) */ + } + return MY_PACKED_TIME_MAKE(intpart, frac * 100); + } + + case 5: + case 6: + return ((longlong) mi_uint6korr(ptr)) - TIMEF_OFS; + } +} + + +/*** MySQL56 DATETIME low-level memory and disk representation routines ***/ + +/* + 1 bit sign (used when on disk) + 17 bits year*13+month (year 0-9999, month 0-12) + 5 bits day (0-31) + 5 bits hour (0-23) + 6 bits minute (0-59) + 6 bits second (0-59) + 24 bits microseconds (0-999999) + + Total: 64 bits = 8 bytes + + SYYYYYYY.YYYYYYYY.YYdddddh.hhhhmmmm.mmssssss.ffffffff.ffffffff.ffffffff +*/ + +/** + Convert datetime to MySQL56 packed numeric datetime representation. + @param ltime The value to convert. + @return Packed numeric representation of ltime. +*/ +longlong TIME_to_longlong_datetime_packed(const MYSQL_TIME *ltime) +{ + longlong ymd= ((ltime->year * 13 + ltime->month) << 5) | ltime->day; + longlong hms= (ltime->hour << 12) | (ltime->minute << 6) | ltime->second; + longlong tmp= MY_PACKED_TIME_MAKE(((ymd << 17) | hms), ltime->second_part); + DBUG_ASSERT(!check_datetime_range(ltime)); /* Make sure no overflow */ + return ltime->neg ? -tmp : tmp; +} + + +/** + Convert MySQL56 packed numeric datetime representation to MYSQL_TIME. + @param OUT ltime The datetime variable to convert to. + @param tmp The packed numeric datetime value. +*/ +void TIME_from_longlong_datetime_packed(MYSQL_TIME *ltime, longlong tmp) +{ + longlong ymd, hms; + longlong ymdhms, ym; + if ((ltime->neg= (tmp < 0))) + tmp= -tmp; + + ltime->second_part= MY_PACKED_TIME_GET_FRAC_PART(tmp); + ymdhms= MY_PACKED_TIME_GET_INT_PART(tmp); + + ymd= ymdhms >> 17; + ym= ymd >> 5; + hms= ymdhms % (1 << 17); + + ltime->day= ymd % (1 << 5); + ltime->month= ym % 13; + ltime->year= ym / 13; + + ltime->second= hms % (1 << 6); + ltime->minute= (hms >> 6) % (1 << 6); + ltime->hour= (hms >> 12); + + ltime->time_type= MYSQL_TIMESTAMP_DATETIME; +} + + +/** + Calculate binary size of MySQL56 packed datetime representation. + @param dec Precision. +*/ +uint my_datetime_binary_length(uint dec) +{ + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + return 5 + (dec + 1) / 2; +} + + +/* + On disk we store as unsigned number with DATETIMEF_INT_OFS offset, + for HA_KETYPE_BINARY compatibilty purposes. +*/ +#define DATETIMEF_INT_OFS 0x8000000000LL + + +/** + Convert MySQL56 on-disk datetime representation + to in-memory packed numeric representation. + + @param ptr The pointer to read value at. + @param dec Precision. + @return In-memory packed numeric datetime representation. +*/ +longlong my_datetime_packed_from_binary(const uchar *ptr, uint dec) +{ + longlong intpart= mi_uint5korr(ptr) - DATETIMEF_INT_OFS; + int frac; + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + switch (dec) + { + case 0: + default: + return MY_PACKED_TIME_MAKE_INT(intpart); + case 1: + case 2: + frac= ((int) (signed char) ptr[5]) * 10000; + break; + case 3: + case 4: + frac= mi_sint2korr(ptr + 5) * 100; + break; + case 5: + case 6: + frac= mi_sint3korr(ptr + 5); + break; + } + return MY_PACKED_TIME_MAKE(intpart, frac); +} + + +/** + Store MySQL56 in-memory numeric packed datetime representation to disk. + + @param nr In-memory numeric packed datetime representation. + @param OUT ptr The pointer to store at. + @param dec Precision, 1-6. +*/ +void my_datetime_packed_to_binary(longlong nr, uchar *ptr, uint dec) +{ + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + /* The value being stored must have been properly rounded or truncated */ + DBUG_ASSERT((MY_PACKED_TIME_GET_FRAC_PART(nr) % + (int) log_10_int[TIME_SECOND_PART_DIGITS - dec]) == 0); + + mi_int5store(ptr, MY_PACKED_TIME_GET_INT_PART(nr) + DATETIMEF_INT_OFS); + switch (dec) + { + case 0: + default: + break; + case 1: + case 2: + ptr[5]= (unsigned char) (char) (MY_PACKED_TIME_GET_FRAC_PART(nr) / 10000); + break; + case 3: + case 4: + mi_int2store(ptr + 5, MY_PACKED_TIME_GET_FRAC_PART(nr) / 100); + break; + case 5: + case 6: + mi_int3store(ptr + 5, MY_PACKED_TIME_GET_FRAC_PART(nr)); + } +} + + +/*** MySQL56 TIMESTAMP low-level memory and disk representation routines ***/ + +/** + Calculate on-disk size of a timestamp value. + + @param dec Precision. +*/ +uint my_timestamp_binary_length(uint dec) +{ + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + return 4 + (dec + 1) / 2; +} + + +/** + Convert MySQL56 binary timestamp representation to in-memory representation. + + @param OUT tm The variable to convert to. + @param ptr The pointer to read the value from. + @param dec Precision. +*/ +void my_timestamp_from_binary(struct timeval *tm, const uchar *ptr, uint dec) +{ + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + tm->tv_sec= mi_uint4korr(ptr); + switch (dec) + { + case 0: + default: + tm->tv_usec= 0; + break; + case 1: + case 2: + tm->tv_usec= ((int) ptr[4]) * 10000; + break; + case 3: + case 4: + tm->tv_usec= mi_sint2korr(ptr + 4) * 100; + break; + case 5: + case 6: + tm->tv_usec= mi_sint3korr(ptr + 4); + } +} + + +/** + Convert MySQL56 in-memory timestamp representation to on-disk representation. + + @param tm The value to convert. + @param OUT ptr The pointer to store the value to. + @param dec Precision. +*/ +void my_timestamp_to_binary(const struct timeval *tm, uchar *ptr, uint dec) +{ + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + /* Stored value must have been previously properly rounded or truncated */ + DBUG_ASSERT((tm->tv_usec % + (int) log_10_int[TIME_SECOND_PART_DIGITS - dec]) == 0); + mi_int4store(ptr, tm->tv_sec); + switch (dec) + { + case 0: + default: + break; + case 1: + case 2: + ptr[4]= (unsigned char) (char) (tm->tv_usec / 10000); + break; + case 3: + case 4: + mi_int2store(ptr + 4, tm->tv_usec / 100); + break; + /* Impossible second precision. Fall through */ + case 5: + case 6: + mi_int3store(ptr + 4, tm->tv_usec); + } +} + +/****************************************/ diff --git a/sql/compat56.h b/sql/compat56.h new file mode 100644 index 00000000000..bb5e2670f7d --- /dev/null +++ b/sql/compat56.h @@ -0,0 +1,46 @@ +#ifndef COMPAT56_H_INCLUDED +#define COMPAT56_H_INCLUDED +/* + Copyright (c) 2004, 2012, Oracle and/or its affiliates. + Copyright (c) 2013 MariaDB Foundation. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + + +/** MySQL56 routines and macros **/ +#define MY_PACKED_TIME_GET_INT_PART(x) ((x) >> 24) +#define MY_PACKED_TIME_GET_FRAC_PART(x) ((x) % (1LL << 24)) +#define MY_PACKED_TIME_MAKE(i, f) ((((longlong) (i)) << 24) + (f)) +#define MY_PACKED_TIME_MAKE_INT(i) ((((longlong) (i)) << 24)) + +longlong TIME_to_longlong_datetime_packed(const MYSQL_TIME *); +longlong TIME_to_longlong_time_packed(const MYSQL_TIME *); + +void TIME_from_longlong_datetime_packed(MYSQL_TIME *ltime, longlong nr); +void TIME_from_longlong_time_packed(MYSQL_TIME *ltime, longlong nr); + +void my_datetime_packed_to_binary(longlong nr, uchar *ptr, uint dec); +longlong my_datetime_packed_from_binary(const uchar *ptr, uint dec); +uint my_datetime_binary_length(uint dec); + +void my_time_packed_to_binary(longlong nr, uchar *ptr, uint dec); +longlong my_time_packed_from_binary(const uchar *ptr, uint dec); +uint my_time_binary_length(uint dec); + +void my_timestamp_to_binary(const struct timeval *tm, uchar *ptr, uint dec); +void my_timestamp_from_binary(struct timeval *tm, const uchar *ptr, uint dec); +uint my_timestamp_binary_length(uint dec); +/** End of MySQL routines and macros **/ + +#endif /* COMPAT56_H_INCLUDED */ diff --git a/sql/field.cc b/sql/field.cc index e85903d76c6..c51a04ba140 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -87,6 +87,7 @@ const char field_separator=','; #define FIELDTYPE_NUM (FIELDTYPE_TEAR_FROM + (255 - FIELDTYPE_TEAR_TO)) static inline int field_type2index (enum_field_types field_type) { + field_type= real_type_to_type(field_type); return (field_type < FIELDTYPE_TEAR_FROM ? field_type : ((int)FIELDTYPE_TEAR_FROM) + (field_type - FIELDTYPE_TEAR_TO) - 1); @@ -947,8 +948,10 @@ static enum_field_types field_types_merge_rules [FIELDTYPE_NUM][FIELDTYPE_NUM]= enum_field_types Field::field_type_merge(enum_field_types a, enum_field_types b) { - DBUG_ASSERT(a < FIELDTYPE_TEAR_FROM || a > FIELDTYPE_TEAR_TO); - DBUG_ASSERT(b < FIELDTYPE_TEAR_FROM || b > FIELDTYPE_TEAR_TO); + DBUG_ASSERT(real_type_to_type(a) < FIELDTYPE_TEAR_FROM || + real_type_to_type(a) > FIELDTYPE_TEAR_TO); + DBUG_ASSERT(real_type_to_type(b) < FIELDTYPE_TEAR_FROM || + real_type_to_type(b) > FIELDTYPE_TEAR_TO); return field_types_merge_rules[field_type2index(a)] [field_type2index(b)]; } @@ -1042,8 +1045,8 @@ CPP_UNNAMED_NS_END Item_result Field::result_merge_type(enum_field_types field_type) { - DBUG_ASSERT(field_type < FIELDTYPE_TEAR_FROM || field_type - > FIELDTYPE_TEAR_TO); + DBUG_ASSERT(real_type_to_type(field_type) < FIELDTYPE_TEAR_FROM || + real_type_to_type(field_type) > FIELDTYPE_TEAR_TO); return field_types_result_type[field_type2index(field_type)]; } @@ -1129,6 +1132,111 @@ void Field::make_sort_key(uchar *buff,uint length) } +/** + @brief + Determine the relative position of the field value in a numeric interval + + @details + The function returns a double number between 0.0 and 1.0 as the relative + position of the value of the this field in the numeric interval of [min,max]. + If the value is not in the interval the the function returns 0.0 when + the value is less than min, and, 1.0 when the value is greater than max. + + @param min value of the left end of the interval + @param max value of the right end of the interval + + @return + relative position of the field value in the numeric interval [min,max] +*/ + +double Field::pos_in_interval_val_real(Field *min, Field *max) +{ + double n, d; + n= val_real() - min->val_real(); + if (n < 0) + return 0.0; + d= max->val_real() - min->val_real(); + if (d <= 0) + return 1.0; + return min(n/d, 1.0); +} + + +static +inline ulonglong char_prefix_to_ulonglong(uchar *src) +{ + uint sz= sizeof(ulonglong); + for (uint i= 0; i < sz/2; i++) + { + uchar tmp= src[i]; + src[i]= src[sz-1-i]; + src[sz-1-i]= tmp; + } + return uint8korr(src); +} + + +/** + @brief + Determine the relative position of the field value in a string interval + + @details + The function returns a double number between 0.0 and 1.0 as the relative + position of the value of the this field in the string interval of [min,max]. + If the value is not in the interval the the function returns 0.0 when + the value is less than min, and, 1.0 when the value is greater than max. + + @note + To calculate the relative position of the string value v in the interval + [min, max] the function first converts the beginning of these three + strings v, min, max into the strings that are used for byte comparison. + For each string not more sizeof(ulonglong) first bytes are taken + from the result of conversion. Then these bytes are interpreted as the + big-endian representation of an ulonglong integer. The values of these + integer numbers obtained for the strings v, min, max are used to calculate + the position of v in [min,max] in the same way is it's done for numeric + fields (see Field::pos_in_interval_val_real). + + @todo + Improve the procedure for the case when min and max have the same + beginning + + @param min value of the left end of the interval + @param max value of the right end of the interval + + @return + relative position of the field value in the string interval [min,max] +*/ + +double Field::pos_in_interval_val_str(Field *min, Field *max, uint data_offset) +{ + uchar mp_prefix[sizeof(ulonglong)]; + uchar minp_prefix[sizeof(ulonglong)]; + uchar maxp_prefix[sizeof(ulonglong)]; + ulonglong mp, minp, maxp; + my_strnxfrm(charset(), mp_prefix, sizeof(mp), + ptr + data_offset, + data_length()); + my_strnxfrm(charset(), minp_prefix, sizeof(minp), + min->ptr + data_offset, + min->data_length()); + my_strnxfrm(charset(), maxp_prefix, sizeof(maxp), + max->ptr + data_offset, + max->data_length()); + mp= char_prefix_to_ulonglong(mp_prefix); + minp= char_prefix_to_ulonglong(minp_prefix); + maxp= char_prefix_to_ulonglong(maxp_prefix); + double n, d; + n= mp - minp; + if (n < 0) + return 0.0; + d= maxp - minp; + if (d <= 0) + return 1.0; + return min(n/d, 1.0); +} + + /** Numeric fields base class constructor. */ @@ -1274,36 +1382,6 @@ out_of_range: } -/** - @brief - Determine the relative position of the field value in a numeric interval - - @details - The function returns a double number between 0.0 and 1.0 as the relative - position of the value of the this field in the numeric interval of [min,max]. - If the value is not in the interval the the function returns 0.0 when - the value is less than min, and, 1.0 when the value is greater than max. - - @param min value of the left end of the interval - @param max value of the right end of the interval - - @return - relative position of the field value in the numeric interval [min,max] -*/ - -double Field_num::pos_in_interval(Field *min, Field *max) -{ - double n, d; - n= val_real() - min->val_real(); - if (n < 0) - return 0.0; - d= max->val_real() - min->val_real(); - if (d <= 0) - return 1.0; - return min(n/d, 1.0); -} - - /** Process decimal library return codes and issue warnings for overflow and truncation. @@ -4485,13 +4563,12 @@ Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, - TABLE_SHARE *share, - CHARSET_INFO *cs) - :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, cs) + TABLE_SHARE *share) + :Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg) { /* For 4.0 MYD and 4.0 InnoDB compatibility */ - flags|= UNSIGNED_FLAG | BINARY_FLAG; + flags|= UNSIGNED_FLAG; if (unireg_check != NONE) { /* @@ -4636,6 +4713,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) { MYSQL_TIME ltime; uint32 temp, temp2; + uint dec; char *to; val_buffer->alloc(field_length+1); @@ -4690,6 +4768,16 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) *to++= (char) ('0'+(char) (temp)); *to= 0; val_buffer->set_charset(&my_charset_numeric); + + if ((dec= decimals())) + { + ulong sec_part= (ulong) sec_part_shift(ltime.second_part, dec); + char *buf= const_cast(val_buffer->ptr() + MAX_DATETIME_WIDTH); + for (int i= dec; i > 0; i--, sec_part/= 10) + buf[i]= (char)(sec_part % 10) + '0'; + buf[0]= '.'; + buf[dec + 1]= 0; + } return val_buffer; } @@ -4743,7 +4831,14 @@ void Field_timestamp::sort_string(uchar *to,uint length __attribute__((unused))) void Field_timestamp::sql_type(String &res) const { - res.set_ascii(STRING_WITH_LEN("timestamp")); + if (!decimals()) + { + res.set_ascii(STRING_WITH_LEN("timestamp")); + return; + } + CHARSET_INFO *cs=res.charset(); + res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(), + "timestamp(%u)", decimals())); } @@ -4783,13 +4878,6 @@ void Field_timestamp::set_explicit_default(Item *value) set_has_explicit_value(); } -void Field_timestamp_hires::sql_type(String &res) const -{ - CHARSET_INFO *cs=res.charset(); - res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(), - "timestamp(%u)", dec)); -} - #ifdef NOT_USED static void store_native(ulonglong num, uchar *to, uint bytes) { @@ -4883,7 +4971,7 @@ my_time_t Field_timestamp_hires::get_timestamp(ulong *sec_part) const return mi_uint4korr(ptr); } -double Field_timestamp_hires::val_real(void) +double Field_timestamp_with_dec::val_real(void) { MYSQL_TIME ltime; if (get_date(<ime, TIME_NO_ZERO_DATE)) @@ -4894,31 +4982,14 @@ double Field_timestamp_hires::val_real(void) ltime.minute * 1e2 + ltime.second + ltime.second_part*1e-6; } -String *Field_timestamp_hires::val_str(String *val_buffer, String *val_ptr) -{ - String *tmp= Field_timestamp::val_str(val_buffer, val_ptr); - ulong sec_part= (ulong)read_bigendian(ptr+4, sec_part_bytes[dec]); - - if (tmp->ptr() == zero_timestamp) - return tmp; - - char *buf= const_cast(tmp->ptr() + MAX_DATETIME_WIDTH); - for (int i=dec; i>0; i--, sec_part/=10) - buf[i]= (char)(sec_part % 10) + '0'; - buf[0]= '.'; - buf[dec+1]= 0; - return tmp; -} - - -my_decimal *Field_timestamp_hires::val_decimal(my_decimal *d) +my_decimal *Field_timestamp_with_dec::val_decimal(my_decimal *d) { MYSQL_TIME ltime; get_date(<ime, 0); return TIME_to_my_decimal(<ime, d); } -int Field_timestamp_hires::store_decimal(const my_decimal *d) +int Field_timestamp::store_decimal(const my_decimal *d) { ulonglong nr; ulong sec_part; @@ -4941,7 +5012,7 @@ int Field_timestamp_hires::store_decimal(const my_decimal *d) return store_TIME_with_warning(thd, <ime, &str, error, tmp != -1); } -int Field_timestamp_hires::set_time() +int Field_timestamp_with_dec::set_time() { THD *thd= get_thd(); set_notnull(); @@ -4949,7 +5020,7 @@ int Field_timestamp_hires::set_time() return 0; } -bool Field_timestamp_hires::send_binary(Protocol *protocol) +bool Field_timestamp_with_dec::send_binary(Protocol *protocol) { MYSQL_TIME ltime; Field_timestamp::get_date(<ime, 0); @@ -4970,71 +5041,53 @@ int Field_timestamp_hires::cmp(const uchar *a_ptr, const uchar *b_ptr) } -void Field_timestamp_hires::sort_string(uchar *to,uint length) -{ - DBUG_ASSERT(length == Field_timestamp_hires::pack_length()); - memcpy(to, ptr, length); -} - uint32 Field_timestamp_hires::pack_length() const { return 4 + sec_part_bytes[dec]; } -void Field_timestamp_hires::make_field(Send_field *field) +void Field_timestamp_with_dec::make_field(Send_field *field) { Field::make_field(field); field->decimals= dec; } -/* - Store string into a date/time field - RETURN - 0 ok - 1 Value was cut during conversion - 2 value was out of range - 3 Datetime value that was cut (warning level NOTE) - This is used by opt_range.cc:get_mm_leaf(). -*/ -int Field_temporal::store_TIME_with_warning(MYSQL_TIME *ltime, - const ErrConv *str, - int was_cut, int have_smth_to_conv) +/************************************************************* +** MySQL-5.6 compatible TIMESTAMP(N) +**************************************************************/ + +void Field_timestampf::store_TIME(my_time_t timestamp, ulong sec_part) { - MYSQL_ERROR::enum_warning_level trunc_level= MYSQL_ERROR::WARN_LEVEL_WARN; - int ret= 2; - - ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; + struct timeval tm; + tm.tv_sec= timestamp; + tm.tv_usec= sec_part; + my_timeval_trunc(&tm, dec); + my_timestamp_to_binary(&tm, ptr, dec); +} - if (was_cut == 0 && - have_smth_to_conv == 0 && - mysql_type_to_time_type(type()) != MYSQL_TIMESTAMP_TIME) // special case: zero date - was_cut= MYSQL_TIME_WARN_OUT_OF_RANGE; - else - if (!have_smth_to_conv) - { - bzero(ltime, sizeof(*ltime)); - was_cut= MYSQL_TIME_WARN_TRUNCATED; - ret= 1; - } - else if (!(was_cut & MYSQL_TIME_WARN_TRUNCATED) && - mysql_type_to_time_type(type()) == MYSQL_TIMESTAMP_DATE && - (ltime->hour || ltime->minute || ltime->second || ltime->second_part)) - { - trunc_level= MYSQL_ERROR::WARN_LEVEL_NOTE; - was_cut|= MYSQL_TIME_WARN_TRUNCATED; - ret= 3; - } - else if (!(was_cut & MYSQL_TIME_WARN_TRUNCATED) && - mysql_type_to_time_type(type()) == MYSQL_TIMESTAMP_TIME && - (ltime->year || ltime->month)) - { - ltime->year= ltime->month= ltime->day= 0; - trunc_level= MYSQL_ERROR::WARN_LEVEL_NOTE; - was_cut|= MYSQL_TIME_WARN_TRUNCATED; - ret= 3; - } +my_time_t Field_timestampf::get_timestamp(ulong *sec_part) const +{ + struct timeval tm; + my_timestamp_from_binary(&tm, ptr, dec); + *sec_part= tm.tv_usec; + return tm.tv_sec; +} + + +/*************************************************************/ +uint Field_temporal::is_equal(Create_field *new_field) +{ + return new_field->sql_type == real_type() && + new_field->length == max_display_length(); +} + + +void Field_temporal::set_warnings(MYSQL_ERROR::enum_warning_level trunc_level, + const ErrConv *str, int was_cut, + timestamp_type ts_type) +{ /* error code logic: MYSQL_TIME_WARN_TRUNCATED means that the value was not a date/time at all. @@ -5051,13 +5104,54 @@ int Field_temporal::store_TIME_with_warning(MYSQL_TIME *ltime, if (was_cut & MYSQL_TIME_WARN_OUT_OF_RANGE) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, str, mysql_type_to_time_type(type()), 1); +} + +/* + Store string into a date/time field + + RETURN + 0 ok + 1 Value was cut during conversion + 2 value was out of range + 3 Datetime value that was cut (warning level NOTE) + This is used by opt_range.cc:get_mm_leaf(). +*/ +int Field_temporal_with_date::store_TIME_with_warning(MYSQL_TIME *ltime, + const ErrConv *str, + int was_cut, + int have_smth_to_conv) +{ + MYSQL_ERROR::enum_warning_level trunc_level= MYSQL_ERROR::WARN_LEVEL_WARN; + int ret= 2; + + ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; + + if (was_cut == 0 && have_smth_to_conv == 0) // special case: zero date + { + was_cut= MYSQL_TIME_WARN_OUT_OF_RANGE; + } + else if (!have_smth_to_conv) + { + bzero(ltime, sizeof(*ltime)); + was_cut= MYSQL_TIME_WARN_TRUNCATED; + ret= 1; + } + else if (!(was_cut & MYSQL_TIME_WARN_TRUNCATED) && + mysql_type_to_time_type(type()) == MYSQL_TIMESTAMP_DATE && + (ltime->hour || ltime->minute || ltime->second || ltime->second_part)) + { + trunc_level= MYSQL_ERROR::WARN_LEVEL_NOTE; + was_cut|= MYSQL_TIME_WARN_TRUNCATED; + ret= 3; + } + set_warnings(trunc_level, str, was_cut, mysql_type_to_time_type(type())); store_TIME(ltime); return was_cut ? ret : 0; } -int Field_temporal::store(const char *from,uint len,CHARSET_INFO *cs) +int Field_temporal_with_date::store(const char *from, uint len, CHARSET_INFO *cs) { MYSQL_TIME ltime; int error; @@ -5075,7 +5169,7 @@ int Field_temporal::store(const char *from,uint len,CHARSET_INFO *cs) } -int Field_temporal::store(double nr) +int Field_temporal_with_date::store(double nr) { int error= 0; MYSQL_TIME ltime; @@ -5092,7 +5186,7 @@ int Field_temporal::store(double nr) } -int Field_temporal::store(longlong nr, bool unsigned_val) +int Field_temporal_with_date::store(longlong nr, bool unsigned_val) { int error; MYSQL_TIME ltime; @@ -5110,7 +5204,7 @@ int Field_temporal::store(longlong nr, bool unsigned_val) } -int Field_temporal::store_time_dec(MYSQL_TIME *ltime, uint dec) +int Field_temporal_with_date::store_time_dec(MYSQL_TIME *ltime, uint dec) { int error = 0, have_smth_to_conv= 1; MYSQL_TIME l_time= *ltime; @@ -5144,6 +5238,35 @@ my_decimal *Field_temporal::val_decimal(my_decimal *d) ** In number context: HHMMSS ** Stored as a 3 byte unsigned int ****************************************************************************/ +int Field_time::store_TIME_with_warning(MYSQL_TIME *ltime, + const ErrConv *str, + int was_cut, + int have_smth_to_conv) +{ + MYSQL_ERROR::enum_warning_level trunc_level= MYSQL_ERROR::WARN_LEVEL_WARN; + int ret= 2; + + ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; + + if (!have_smth_to_conv) + { + bzero(ltime, sizeof(*ltime)); + was_cut= MYSQL_TIME_WARN_TRUNCATED; + ret= 1; + } + else if (!(was_cut & MYSQL_TIME_WARN_TRUNCATED) && + (ltime->year || ltime->month)) + { + ltime->year= ltime->month= ltime->day= 0; + trunc_level= MYSQL_ERROR::WARN_LEVEL_NOTE; + was_cut|= MYSQL_TIME_WARN_TRUNCATED; + ret= 3; + } + set_warnings(trunc_level, str, was_cut, MYSQL_TIMESTAMP_TIME); + store_TIME(ltime); + return was_cut ? ret : 0; +} + void Field_time::store_TIME(MYSQL_TIME *ltime) { @@ -5229,32 +5352,16 @@ longlong Field_time::val_int(void) my_charset_bin */ -String *Field_time::val_str(String *val_buffer, - String *val_ptr __attribute__((unused))) +String *Field_time::val_str(String *str, + String *unused __attribute__((unused))) { ASSERT_COLUMN_MARKED_FOR_READ; MYSQL_TIME ltime; - long tmp=(long) sint3korr(ptr); - ltime.neg= 0; - if (tmp < 0) - { - tmp= -tmp; - ltime.neg= 1; - } - ltime.year= ltime.month= 0; - ltime.day= (uint) 0; - ltime.hour= (uint) (tmp/10000); - ltime.minute= (uint) (tmp/100 % 100); - ltime.second= (uint) (tmp % 100); - ltime.second_part= 0; - - val_buffer->alloc(MAX_DATE_STRING_REP_LENGTH); - uint length= (uint) my_time_to_str(<ime, - const_cast(val_buffer->ptr()), 0); - val_buffer->length(length); - val_buffer->set_charset(&my_charset_numeric); - - return val_buffer; + get_date(<ime, TIME_TIME_ONLY); + str->alloc(field_length + 1); + str->length(my_time_to_str(<ime, const_cast(str->ptr()), decimals())); + str->set_charset(&my_charset_numeric); + return str; } @@ -5297,8 +5404,8 @@ bool Field_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) bool Field_time::send_binary(Protocol *protocol) { MYSQL_TIME ltime; - Field_time::get_date(<ime, TIME_TIME_ONLY); - return protocol->store_time(<ime, 0); + get_date(<ime, TIME_TIME_ONLY); + return protocol->store_time(<ime, decimals()); } @@ -5319,7 +5426,14 @@ void Field_time::sort_string(uchar *to,uint length __attribute__((unused))) void Field_time::sql_type(String &res) const { - res.set_ascii(STRING_WITH_LEN("time")); + if (decimals() == 0) + { + res.set_ascii(STRING_WITH_LEN("time")); + return; + } + const CHARSET_INFO *cs= res.charset(); + res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(), + "time(%d)", decimals())); } int Field_time_hires::reset() @@ -5335,7 +5449,7 @@ void Field_time_hires::store_TIME(MYSQL_TIME *ltime) store_bigendian(packed, ptr, Field_time_hires::pack_length()); } -int Field_time_hires::store_decimal(const my_decimal *d) +int Field_time::store_decimal(const my_decimal *d) { ulonglong nr; ulong sec_part; @@ -5354,35 +5468,23 @@ uint32 Field_time_hires::pack_length() const return time_hires_bytes[dec]; } -longlong Field_time_hires::val_int(void) +longlong Field_time_with_dec::val_int(void) { ASSERT_COLUMN_MARKED_FOR_READ; MYSQL_TIME ltime; - Field_time_hires::get_date(<ime, TIME_TIME_ONLY); + get_date(<ime, TIME_TIME_ONLY); longlong val= TIME_to_ulonglong_time(<ime); return ltime.neg ? -val : val; } -double Field_time_hires::val_real(void) +double Field_time_with_dec::val_real(void) { ASSERT_COLUMN_MARKED_FOR_READ; MYSQL_TIME ltime; - Field_time_hires::get_date(<ime, TIME_TIME_ONLY); + get_date(<ime, TIME_TIME_ONLY); return TIME_to_double(<ime); } -String *Field_time_hires::val_str(String *str, - String *unused __attribute__((unused))) -{ - ASSERT_COLUMN_MARKED_FOR_READ; - MYSQL_TIME ltime; - Field_time_hires::get_date(<ime, TIME_TIME_ONLY); - str->alloc(field_length+1); - str->length(my_time_to_str(<ime, (char*) str->ptr(), dec)); - str->set_charset(&my_charset_bin); - return str; -} - bool Field_time_hires::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) { uint32 len= pack_length(); @@ -5402,14 +5504,6 @@ bool Field_time_hires::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) } -bool Field_time_hires::send_binary(Protocol *protocol) -{ - MYSQL_TIME ltime; - Field_time_hires::get_date(<ime, TIME_TIME_ONLY); - return protocol->store_time(<ime, dec); -} - - int Field_time_hires::cmp(const uchar *a_ptr, const uchar *b_ptr) { ulonglong a=read_bigendian(a_ptr, Field_time_hires::pack_length()); @@ -5424,19 +5518,38 @@ void Field_time_hires::sort_string(uchar *to,uint length __attribute__((unused)) to[0]^= 128; } -void Field_time_hires::sql_type(String &res) const -{ - CHARSET_INFO *cs=res.charset(); - res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(), - "time(%u)", dec)); -} - -void Field_time_hires::make_field(Send_field *field) +void Field_time_with_dec::make_field(Send_field *field) { Field::make_field(field); field->decimals= dec; } +/**************************************************************************** +** time type with fsp (MySQL-5.6 version) +** In string context: HH:MM:SS.FFFFFF +** In number context: HHMMSS.FFFFFF +****************************************************************************/ + +int Field_timef::reset() +{ + my_time_packed_to_binary(0, ptr, dec); + return 0; +} + +void Field_timef::store_TIME(MYSQL_TIME *ltime) +{ + my_time_trunc(ltime, decimals()); + longlong tmp= TIME_to_longlong_time_packed(ltime); + my_time_packed_to_binary(tmp, ptr, dec); +} + +bool Field_timef::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) +{ + longlong tmp= my_time_packed_from_binary(ptr, dec); + TIME_from_longlong_time_packed(ltime, tmp); + return false; +} + /**************************************************************************** ** year type ** Save in a byte the year 0, 1901->2155 @@ -5792,8 +5905,8 @@ bool Field_datetime::send_binary(Protocol *protocol) Field_datetime::get_date(&tm, TIME_FUZZY_DATE); return protocol->store(&tm, 0); } - - + + double Field_datetime::val_real(void) { return (double) Field_datetime::val_int(); @@ -5901,7 +6014,14 @@ void Field_datetime::sort_string(uchar *to,uint length __attribute__((unused))) void Field_datetime::sql_type(String &res) const { - res.set_ascii(STRING_WITH_LEN("datetime")); + if (decimals() == 0) + { + res.set_ascii(STRING_WITH_LEN("datetime")); + return; + } + CHARSET_INFO *cs= res.charset(); + res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(), + "datetime(%u)", decimals())); } @@ -5924,7 +6044,7 @@ void Field_datetime_hires::store_TIME(MYSQL_TIME *ltime) store_bigendian(packed, ptr, Field_datetime_hires::pack_length()); } -int Field_datetime_hires::store_decimal(const my_decimal *d) +int Field_temporal_with_date::store_decimal(const my_decimal *d) { ulonglong nr; ulong sec_part; @@ -5949,38 +6069,38 @@ int Field_datetime_hires::store_decimal(const my_decimal *d) return store_TIME_with_warning(<ime, &str, error, tmp != -1); } -bool Field_datetime_hires::send_binary(Protocol *protocol) +bool Field_datetime_with_dec::send_binary(Protocol *protocol) { MYSQL_TIME ltime; - Field_datetime_hires::get_date(<ime, TIME_FUZZY_DATE); + get_date(<ime, TIME_FUZZY_DATE); return protocol->store(<ime, dec); } -double Field_datetime_hires::val_real(void) +double Field_datetime_with_dec::val_real(void) { MYSQL_TIME ltime; - Field_datetime_hires::get_date(<ime, TIME_FUZZY_DATE); + get_date(<ime, TIME_FUZZY_DATE); return TIME_to_double(<ime); } -longlong Field_datetime_hires::val_int(void) +longlong Field_datetime_with_dec::val_int(void) { MYSQL_TIME ltime; - Field_datetime_hires::get_date(<ime, TIME_FUZZY_DATE); + get_date(<ime, TIME_FUZZY_DATE); return TIME_to_ulonglong_datetime(<ime); } -String *Field_datetime_hires::val_str(String *str, - String *unused __attribute__((unused))) +String *Field_datetime_with_dec::val_str(String *str, + String *unused __attribute__((unused))) { MYSQL_TIME ltime; - Field_datetime_hires::get_date(<ime, TIME_FUZZY_DATE); + get_date(<ime, TIME_FUZZY_DATE); str->alloc(field_length+1); str->length(field_length); my_datetime_to_str(<ime, (char*) str->ptr(), dec); - str->set_charset(&my_charset_bin); + str->set_charset(&my_charset_numeric); return str; } @@ -6007,27 +6127,42 @@ int Field_datetime_hires::cmp(const uchar *a_ptr, const uchar *b_ptr) return a < b ? -1 : a > b ? 1 : 0; } -void Field_datetime_hires::sort_string(uchar *to, - uint length __attribute__((unused))) -{ - DBUG_ASSERT(length == Field_datetime_hires::pack_length()); - memcpy(to, ptr, length); -} - - -void Field_datetime_hires::sql_type(String &res) const -{ - CHARSET_INFO *cs=res.charset(); - res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(), - "datetime(%u)", dec)); -} - -void Field_datetime_hires::make_field(Send_field *field) +void Field_datetime_with_dec::make_field(Send_field *field) { Field::make_field(field); field->decimals= dec; } + +/**************************************************************************** +** MySQL-5.6 compatible DATETIME(N) +** +****************************************************************************/ +int Field_datetimef::reset() +{ + my_datetime_packed_to_binary(0, ptr, dec); + return 0; +} + +void Field_datetimef::store_TIME(MYSQL_TIME *ltime) +{ + my_time_trunc(ltime, decimals()); + longlong tmp= TIME_to_longlong_datetime_packed(ltime); + my_datetime_packed_to_binary(tmp, ptr, dec); +} + +bool Field_datetimef::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) +{ + longlong tmp= my_datetime_packed_from_binary(ptr, dec); + TIME_from_longlong_datetime_packed(ltime, tmp); + if (!tmp) + return fuzzydate & TIME_NO_ZERO_DATE; + if (!ltime->month || !ltime->day) + return !(fuzzydate & TIME_FUZZY_DATE); + return false; +} + + /**************************************************************************** ** string type ** A string may be varchar or binary @@ -6198,80 +6333,6 @@ int Field_str::store(double nr) return store(buff, length, &my_charset_numeric); } -static -inline ulonglong char_prefix_to_ulonglong(uchar *src) -{ - uint sz= sizeof(ulonglong); - for (uint i= 0; i < sz/2; i++) - { - uchar tmp= src[i]; - src[i]= src[sz-1-i]; - src[sz-1-i]= tmp; - } - return uint8korr(src); -} - -/** - @brief - Determine the relative position of the field value in a string interval - - @details - The function returns a double number between 0.0 and 1.0 as the relative - position of the value of the this field in the string interval of [min,max]. - If the value is not in the interval the the function returns 0.0 when - the value is less than min, and, 1.0 when the value is greater than max. - - @note - To calculate the relative position of the string value v in the interval - [min, max] the function first converts the beginning of these three - strings v, min, max into the strings that are used for byte comparison. - For each string not more sizeof(ulonglong) first bytes are taken - from the result of conversion. Then these bytes are interpreted as the - big-endian representation of an ulonglong integer. The values of these - integer numbers obtained for the strings v, min, max are used to calculate - the position of v in [min,max] in the same way is it's done for numeric - fields (see Field_num::pos_in_interval). - - @todo - Improve the procedure for the case when min and max have the same - beginning - - @param min value of the left end of the interval - @param max value of the right end of the interval - - @return - relative position of the field value in the string interval [min,max] -*/ - -double Field_str::pos_in_interval(Field *min, Field *max) -{ - uchar mp_prefix[sizeof(ulonglong)]; - uchar minp_prefix[sizeof(ulonglong)]; - uchar maxp_prefix[sizeof(ulonglong)]; - ulonglong mp, minp, maxp; - my_strnxfrm(charset(), mp_prefix, sizeof(mp), - ptr + length_size(), - data_length()); - my_strnxfrm(charset(), minp_prefix, sizeof(minp), - min->ptr + length_size(), - min->data_length()); - my_strnxfrm(charset(), maxp_prefix, sizeof(maxp), - max->ptr + length_size(), - max->data_length()); - mp= char_prefix_to_ulonglong(mp_prefix); - minp= char_prefix_to_ulonglong(minp_prefix); - maxp= char_prefix_to_ulonglong(maxp_prefix); - double n, d; - n= mp - minp; - if (n < 0) - return 0.0; - d= maxp - minp; - if (d <= 0) - return 1.0; - return min(n/d, 1.0); -} - - uint Field::is_equal(Create_field *new_field) { return (new_field->sql_type == real_type()); @@ -8482,36 +8543,6 @@ my_decimal *Field_bit::val_decimal(my_decimal *deciaml_value) } -/** - @brief - Determine the relative position of the field value in a bit interval - - @details - The function returns a double number between 0.0 and 1.0 as the relative - position of the value of the this field in the bit interval of [min,max]. - If the value is not in the interval the the function returns 0.0 when - the value is less than min, and, 1.0 when the value is greater than max. - - @param min value of the left end of the interval - @param max value of the right end of the interval - - @return - relative position of the field value in the bit interval [min,max] -*/ - -double Field_bit::pos_in_interval(Field *min, Field *max) -{ - double n, d; - n= val_real() - min->val_real(); - if (n < 0) - return 0.0; - d= max->val_real() - min->val_real(); - if (d <= 0) - return 1.0; - return min(n/d, 1.0); -} - - /* Compare two bit fields using pointers within the record. SYNOPSIS @@ -9144,7 +9175,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP. */ if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) && - (fld_type_modifier & NOT_NULL_FLAG) && fld_type != MYSQL_TYPE_TIMESTAMP) + (fld_type_modifier & NOT_NULL_FLAG) && !is_timestamp_type(fld_type)) flags|= NO_DEFAULT_VALUE_FLAG; if (fld_length != NULL) @@ -9306,6 +9337,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, } break; case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_TIMESTAMP2: if (length > MAX_DATETIME_PRECISION) { my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name, @@ -9323,6 +9355,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, length= MAX_DATE_WIDTH; break; case MYSQL_TYPE_TIME: + case MYSQL_TYPE_TIME2: if (length > MAX_DATETIME_PRECISION) { my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name, @@ -9332,6 +9365,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, length+= MIN_TIME_WIDTH + (length ? 1 : 0); break; case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_DATETIME2: if (length > MAX_DATETIME_PRECISION) { my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name, @@ -9413,17 +9447,6 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, DBUG_RETURN(TRUE); } - switch (fld_type) { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_NEWDATE: - case MYSQL_TYPE_TIME: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: - charset= &my_charset_numeric; - flags|= BINARY_FLAG; - default: break; - } - DBUG_RETURN(FALSE); /* success */ } @@ -9462,10 +9485,16 @@ uint32 calc_pack_length(enum_field_types type,uint32 length) case MYSQL_TYPE_TIME: return length > MIN_TIME_WIDTH ? time_hires_bytes[length - 1 - MIN_TIME_WIDTH] : 3; + case MYSQL_TYPE_TIME2: + return length > MIN_TIME_WIDTH ? + my_time_binary_length(length - MIN_TIME_WIDTH - 1) : 3; case MYSQL_TYPE_TIMESTAMP: return length > MAX_DATETIME_WIDTH ? 4 + sec_part_bytes[length - 1 - MAX_DATETIME_WIDTH] : 4; + case MYSQL_TYPE_TIMESTAMP2: + return length > MAX_DATETIME_WIDTH ? + my_timestamp_binary_length(length - MAX_DATETIME_WIDTH - 1) : 4; case MYSQL_TYPE_DATE: case MYSQL_TYPE_LONG : return 4; case MYSQL_TYPE_FLOAT : return sizeof(float); @@ -9474,6 +9503,9 @@ uint32 calc_pack_length(enum_field_types type,uint32 length) return length > MAX_DATETIME_WIDTH ? datetime_hires_bytes[length - 1 - MAX_DATETIME_WIDTH] : 8; + case MYSQL_TYPE_DATETIME2: + return length > MAX_DATETIME_WIDTH ? + my_datetime_binary_length(length - MAX_DATETIME_WIDTH - 1) : 5; case MYSQL_TYPE_LONGLONG: return 8; /* Don't crash if no longlong */ case MYSQL_TYPE_NULL : return 0; case MYSQL_TYPE_TINY_BLOB: return 1+portable_sizeof_char_ptr; @@ -9538,16 +9570,6 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, null_bit= ((uchar) 1) << null_bit; } - switch (field_type) { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_NEWDATE: - case MYSQL_TYPE_TIME: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: - field_charset= &my_charset_numeric; - default: break; - } - DBUG_PRINT("debug", ("field_type: %d, field_length: %u, interval: %p, pack_flag: %s%s%s%s%s", field_type, field_length, interval, FLAGSTR(pack_flag, FIELDFLAG_BINARY), @@ -9661,30 +9683,51 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, uint dec= field_length > MAX_DATETIME_WIDTH ? field_length - MAX_DATETIME_WIDTH - 1: 0; return new_Field_timestamp(ptr, null_pos, null_bit, unireg_check, - field_name, share, dec, field_charset); + field_name, share, dec); + } + case MYSQL_TYPE_TIMESTAMP2: + { + uint dec= field_length > MAX_DATETIME_WIDTH ? + field_length - MAX_DATETIME_WIDTH - 1: 0; + return new Field_timestampf(ptr, null_pos, null_bit, unireg_check, + field_name, share, dec); } case MYSQL_TYPE_YEAR: return new Field_year(ptr,field_length,null_pos,null_bit, unireg_check, field_name); case MYSQL_TYPE_DATE: return new Field_date(ptr,null_pos,null_bit, - unireg_check, field_name, field_charset); + unireg_check, field_name); case MYSQL_TYPE_NEWDATE: return new Field_newdate(ptr,null_pos,null_bit, - unireg_check, field_name, field_charset); + unireg_check, field_name); case MYSQL_TYPE_TIME: { uint dec= field_length > MIN_TIME_WIDTH ? field_length - MIN_TIME_WIDTH - 1: 0; return new_Field_time(ptr, null_pos, null_bit, unireg_check, - field_name, dec, field_charset); + field_name, dec); + } + case MYSQL_TYPE_TIME2: + { + uint dec= field_length > MIN_TIME_WIDTH ? + field_length - MIN_TIME_WIDTH - 1: 0; + return new Field_timef(ptr, null_pos, null_bit, unireg_check, + field_name, dec); } case MYSQL_TYPE_DATETIME: { uint dec= field_length > MAX_DATETIME_WIDTH ? field_length - MAX_DATETIME_WIDTH - 1: 0; return new_Field_datetime(ptr, null_pos, null_bit, unireg_check, - field_name, dec, field_charset); + field_name, dec); + } + case MYSQL_TYPE_DATETIME2: + { + uint dec= field_length > MAX_DATETIME_WIDTH ? + field_length - MAX_DATETIME_WIDTH - 1: 0; + return new Field_datetimef(ptr, null_pos, null_bit, unireg_check, + field_name, dec); } case MYSQL_TYPE_NULL: return new Field_null(ptr, field_length, unireg_check, field_name, diff --git a/sql/field.h b/sql/field.h index 48d873beb32..feef0cbef08 100644 --- a/sql/field.h +++ b/sql/field.h @@ -30,6 +30,7 @@ #include "sql_string.h" /* String */ #include "my_decimal.h" /* my_decimal */ #include "sql_error.h" /* MYSQL_ERROR */ +#include "compat56.h" class Send_field; class Protocol; @@ -89,6 +90,42 @@ inline uint get_set_pack_length(int elements) return len > 4 ? 8 : len; } + +/** + Recognizer for concrete data type (called real_type for some reason), + returning true if it is one of the TIMESTAMP types. +*/ +inline bool is_timestamp_type(enum_field_types type) +{ + return type == MYSQL_TYPE_TIMESTAMP || type == MYSQL_TYPE_TIMESTAMP2; +} + + +/** + Convert temporal real types as retuned by field->real_type() + to field type as returned by field->type(). + + @param real_type Real type. + @retval Field type. +*/ +inline enum_field_types real_type_to_type(enum_field_types real_type) +{ + switch (real_type) + { + case MYSQL_TYPE_TIME2: + return MYSQL_TYPE_TIME; + case MYSQL_TYPE_DATETIME2: + return MYSQL_TYPE_DATETIME; + case MYSQL_TYPE_TIMESTAMP2: + return MYSQL_TYPE_TIMESTAMP; + case MYSQL_TYPE_NEWDATE: + return MYSQL_TYPE_DATE; + /* Note: NEWDECIMAL is a type, not only a real_type */ + default: return real_type; + } +} + + /* Virtual_column_info is the class to contain additional characteristics that is specific for a virtual/computed @@ -428,6 +465,54 @@ public: virtual uint32 key_length() const { return pack_length(); } virtual enum_field_types type() const =0; virtual enum_field_types real_type() const { return type(); } + virtual enum_field_types binlog_type() const + { + /* + Binlog stores field->type() as type code by default. For example, + it puts MYSQL_TYPE_STRING in case of CHAR, VARCHAR, SET and ENUM, + with extra data type details put into metadata. + + Binlog behaviour slightly differs between various MySQL and MariaDB + versions for the temporal data types TIME, DATETIME and TIMESTAMP. + + MySQL prior to 5.6 uses MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME + and MYSQL_TYPE_TIMESTAMP type codes in binlog and stores no + additional metadata. + + MariaDB-5.3 implements new versions for TIME, DATATIME, TIMESTAMP + with fractional second precision, but uses the old format for the + types TIME(0), DATETIME(0), TIMESTAMP(0), and it still stores + MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME and MYSQL_TYPE_TIMESTAMP in binlog, + with no additional metadata. + So row-based replication between temporal data types of + different precision is not possible in MariaDB. + + MySQL-5.6 also implements a new version of TIME, DATETIME, TIMESTAMP + which support fractional second precision 0..6, and use the new + format even for the types TIME(0), DATETIME(0), TIMESTAMP(0). + For these new data types, MySQL-5.6 stores new type codes + MYSQL_TYPE_TIME2, MYSQL_TYPE_DATETIME2, MYSQL_TYPE_TIMESTAMP2 in binlog, + with fractional precision 0..6 put into metadata. + This makes it in theory possible to do row-based replication between + columns of different fractional precision (e.g. from TIME(1) on master + to TIME(6) on slave). However, it's not currently fully implemented yet. + MySQL-5.6 can only do row-based replication from the old types + TIME, DATETIME, TIMESTAMP (represented by MYSQL_TYPE_TIME, + MYSQL_TYPE_DATETIME and MYSQL_TYPE_TIMESTAMP type codes in binlog) + to the new corresponding types TIME(0), DATETIME(0), TIMESTAMP(0). + + Note: MariaDB starting from the version 10.0 understands the new + MySQL-5.6 type codes MYSQL_TYPE_TIME2, MYSQL_TYPE_DATETIME2, + MYSQL_TYPE_TIMESTAMP2. When started over MySQL-5.6 tables both on + master and on slave, MariaDB-10.0 can also do row-based replication + from the old types TIME, DATETIME, TIMESTAMP to the new MySQL-5.6 + types TIME(0), DATETIME(0), TIMESTAMP(0). + + Note: perhaps binlog should eventually be modified to store + real_type() instead of type() for all column types. + */ + return type(); + } inline int cmp(const uchar *str) { return cmp(ptr,str); } virtual int cmp_max(const uchar *a, const uchar *b, uint max_len) { return cmp(a, b); } @@ -661,6 +746,16 @@ public: { return binary() ? &my_charset_bin : charset(); } virtual CHARSET_INFO *sort_charset(void) const { return charset(); } virtual bool has_charset(void) const { return FALSE; } + /* + match_collation_to_optimize_range() is to distinguish in + range optimizer (see opt_range.cc) between real string types: + CHAR, VARCHAR, TEXT + and the other string-alike types with result_type() == STRING_RESULT: + DATE, TIME, DATETIME, TIMESTAMP + We need it to decide whether to test if collation of the operation + matches collation of the field (needed only for real string types). + */ + virtual bool match_collation_to_optimize_range() const { return false; } virtual void set_charset(CHARSET_INFO *charset_arg) { } virtual enum Derivation derivation(void) const { return DERIVATION_IMPLICIT; } @@ -808,7 +903,8 @@ protected: { return (flags & (BINCMP_FLAG | BINARY_FLAG)) != 0; } - + double pos_in_interval_val_real(Field *min, Field *max); + double pos_in_interval_val_str(Field *min, Field *max, uint data_offset); }; @@ -847,7 +943,10 @@ public: bool get_int(CHARSET_INFO *cs, const char *from, uint len, longlong *rnd, ulonglong unsigned_max, longlong signed_min, longlong signed_max); - double pos_in_interval(Field *min, Field *max); + double pos_in_interval(Field *min, Field *max) + { + return pos_in_interval_val_real(min, max); + } }; @@ -860,23 +959,11 @@ public: uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *charset); Item_result result_type () const { return STRING_RESULT; } - /* - match_collation_to_optimize_range() is to distinguish in - range optimizer (see opt_range.cc) between real string types: - CHAR, VARCHAR, TEXT - and the other string-alike types with result_type() == STRING_RESULT: - DATE, TIME, DATETIME, TIMESTAMP - We need it to decide whether to test if collation of the operation - matches collation of the field (needed only for real string types). - QQ: shouldn't DATE/TIME types have their own XXX_RESULT types eventually? - */ - virtual bool match_collation_to_optimize_range() const=0; uint decimals() const { return NOT_FIXED_DEC; } int store(double nr); int store(longlong nr, bool unsigned_val)=0; int store_decimal(const my_decimal *); int store(const char *to,uint length,CHARSET_INFO *cs)=0; - uint size_of() const { return sizeof(*this); } uint repertoire(void) const { return my_charset_repertoire(field_charset); @@ -894,7 +981,10 @@ public: uint is_equal(Create_field *new_field); bool eq_cmp_as_binary() { return test(flags & BINARY_FLAG); } virtual uint length_size() { return 0; } - double pos_in_interval(Field *min, Field *max); + double pos_in_interval(Field *min, Field *max) + { + return pos_in_interval_val_str(min, max, length_size()); + } }; /* base class for Field_string, Field_varstring and Field_blob */ @@ -914,6 +1004,7 @@ public: int store_decimal(const my_decimal *d); uint32 max_data_length() const; + bool match_collation_to_optimize_range() const { return true; } }; /* base class for float and double and decimal (old one) */ @@ -1323,7 +1414,6 @@ public: unireg_check_arg, field_name_arg, cs) {} enum_field_types type() const { return MYSQL_TYPE_NULL;} - bool match_collation_to_optimize_range() const { return FALSE; } int store(const char *to, uint length, CHARSET_INFO *cs) { null[0]=1; return 0; } int store(double nr) { null[0]=1; return 0; } @@ -1345,7 +1435,67 @@ public: }; -class Field_timestamp :public Field_str { +class Field_temporal: public Field { +public: + Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, + uchar null_bit_arg, utype unireg_check_arg, + const char *field_name_arg) + :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, + field_name_arg) + { flags|= BINARY_FLAG; } + Item_result result_type () const { return STRING_RESULT; } + uint32 max_display_length() { return field_length; } + bool str_needs_quotes() { return TRUE; } + enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } + uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } + CHARSET_INFO *charset(void) const { return &my_charset_numeric; } + const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; } + bool binary() const { return true; } + enum Item_result cmp_type () const { return TIME_RESULT; } + uint is_equal(Create_field *new_field); + bool eq_def(Field *field) + { + return (Field::eq_def(field) && decimals() == field->decimals()); + } + my_decimal *val_decimal(my_decimal*); + void set_warnings(MYSQL_ERROR::enum_warning_level trunc_level, + const ErrConv *str, int was_cut, timestamp_type ts_type); + double pos_in_interval(Field *min, Field *max) + { + return pos_in_interval_val_real(min, max); + } +}; + + +/** + Abstract class for: + - DATE + - DATETIME + - DATETIME(1..6) + - DATETIME(0..6) - MySQL56 version +*/ +class Field_temporal_with_date: public Field_temporal { +protected: + int store_TIME_with_warning(MYSQL_TIME *ltime, const ErrConv *str, + int was_cut, int have_smth_to_conv); + virtual void store_TIME(MYSQL_TIME *ltime) = 0; +public: + Field_temporal_with_date(uchar *ptr_arg, uint32 len_arg, + uchar *null_ptr_arg, uchar null_bit_arg, + utype unireg_check_arg, + const char *field_name_arg) + :Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg) + {} + int store(const char *to, uint length, CHARSET_INFO *charset); + int store(double nr); + int store(longlong nr, bool unsigned_val); + int store_time_dec(MYSQL_TIME *ltime, uint dec); + int store_decimal(const my_decimal *); +}; + + +class Field_timestamp :public Field_temporal { protected: int store_TIME_with_warning(THD *, MYSQL_TIME *, const ErrConv *, bool, bool); @@ -1353,21 +1503,14 @@ public: Field_timestamp(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, - TABLE_SHARE *share, CHARSET_INFO *cs); - Field_timestamp(bool maybe_null_arg, const char *field_name_arg, - CHARSET_INFO *cs); + TABLE_SHARE *share); enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;} - bool match_collation_to_optimize_range() const { return FALSE; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } - enum Item_result cmp_type () const { return TIME_RESULT; } - enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } - uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } - CHARSET_INFO *charset(void) const { return &my_charset_numeric; } - bool binary() const { return 1; } int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); int store_time_dec(MYSQL_TIME *ltime, uint dec); + int store_decimal(const my_decimal *); double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -1377,7 +1520,6 @@ public: uint32 pack_length() const { return 4; } void sql_type(String &str) const; bool zero_pack() const { return 0; } - uint decimals() const { return 0; } virtual int set_time(); virtual void set_default() { @@ -1418,46 +1560,109 @@ public: { return unpack_int32(to, from, from_end); } + uint size_of() const { return sizeof(*this); } }; -class Field_timestamp_hires :public Field_timestamp { +/** + Abstract class for: + - TIMESTAMP(1..6) + - TIMESTAMP(0..6) - MySQL56 version +*/ +class Field_timestamp_with_dec :public Field_timestamp { +protected: uint dec; public: - Field_timestamp_hires(uchar *ptr_arg, - uchar *null_ptr_arg, uchar null_bit_arg, - enum utype unireg_check_arg, const char *field_name_arg, - TABLE_SHARE *share, uint dec_arg, CHARSET_INFO *cs) : - Field_timestamp(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + 1, null_ptr_arg, - null_bit_arg, unireg_check_arg, field_name_arg, share, cs), + Field_timestamp_with_dec(uchar *ptr_arg, + uchar *null_ptr_arg, uchar null_bit_arg, + enum utype unireg_check_arg, + const char *field_name_arg, + TABLE_SHARE *share, uint dec_arg) : + Field_timestamp(ptr_arg, + MAX_DATETIME_WIDTH + dec_arg + test(dec_arg), null_ptr_arg, + null_bit_arg, unireg_check_arg, field_name_arg, share), dec(dec_arg) { - DBUG_ASSERT(dec); DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); } - void sql_type(String &str) const; - my_time_t get_timestamp(ulong *sec_part) const; - void store_TIME(my_time_t timestamp, ulong sec_part); - int store_decimal(const my_decimal *d); - double val_real(void); - String *val_str(String*,String *); - my_decimal* val_decimal(my_decimal*); - bool send_binary(Protocol *protocol); - int cmp(const uchar *,const uchar *); - void sort_string(uchar *buff,uint length); uint decimals() const { return dec; } - int set_time(); enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } - void make_field(Send_field *field); - uint32 pack_length() const; uchar *pack(uchar *to, const uchar *from, uint max_length) { return Field::pack(to, from, max_length); } const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end, uint param_data) { return Field::unpack(to, from, from_end, param_data); } + void make_field(Send_field *field); + void sort_string(uchar *to, uint length) + { + DBUG_ASSERT(length == pack_length()); + memcpy(to, ptr, length); + } + bool send_binary(Protocol *protocol); + double val_real(void); + my_decimal* val_decimal(my_decimal*); + int set_time(); +}; + + +class Field_timestamp_hires :public Field_timestamp_with_dec { +public: + Field_timestamp_hires(uchar *ptr_arg, + uchar *null_ptr_arg, uchar null_bit_arg, + enum utype unireg_check_arg, + const char *field_name_arg, + TABLE_SHARE *share, uint dec_arg) : + Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg, share, dec_arg) + { + DBUG_ASSERT(dec); + } + my_time_t get_timestamp(ulong *sec_part) const; + void store_TIME(my_time_t timestamp, ulong sec_part); + int cmp(const uchar *,const uchar *); + uint32 pack_length() const; + uint size_of() const { return sizeof(*this); } +}; + + +/** + TIMESTAMP(0..6) - MySQL56 version +*/ +class Field_timestampf :public Field_timestamp_with_dec { + int do_save_field_metadata(uchar *metadata_ptr) + { + *metadata_ptr= decimals(); + return 1; + } +public: + Field_timestampf(uchar *ptr_arg, + uchar *null_ptr_arg, uchar null_bit_arg, + enum utype unireg_check_arg, + const char *field_name_arg, + TABLE_SHARE *share, uint dec_arg) : + Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg, share, dec_arg) + {} + enum_field_types real_type() const { return MYSQL_TYPE_TIMESTAMP2; } + enum_field_types binlog_type() const { return MYSQL_TYPE_TIMESTAMP2; } + uint32 pack_length() const + { + return my_timestamp_binary_length(dec); + } + uint row_pack_length() { return pack_length(); } + uint pack_length_from_metadata(uint field_metadata) + { + DBUG_ENTER("Field_timestampf::pack_length_from_metadata"); + uint tmp= my_timestamp_binary_length(field_metadata); + DBUG_RETURN(tmp); + } + int cmp(const uchar *a_ptr,const uchar *b_ptr) + { + return memcmp(a_ptr, b_ptr, pack_length()); + } + void store_TIME(my_time_t timestamp, ulong sec_part); + my_time_t get_timestamp(ulong *sec_part) const; uint size_of() const { return sizeof(*this); } - bool eq_def(Field *field) - { return Field_str::eq_def(field) && dec == field->decimals(); } }; @@ -1484,56 +1689,24 @@ public: }; -class Field_temporal: public Field_str { -protected: - int store_TIME_with_warning(MYSQL_TIME *ltime, const ErrConv *str, - int was_cut, int have_smth_to_conv); - virtual void store_TIME(MYSQL_TIME *ltime) = 0; -public: - Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, - uchar null_bit_arg, utype unireg_check_arg, - const char *field_name_arg, CHARSET_INFO *charset_arg) - :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, - field_name_arg, charset_arg) - { flags|= BINARY_FLAG; } - enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } - uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } - CHARSET_INFO *charset(void) const { return &my_charset_numeric; } - bool binary() const { return 1; } - bool match_collation_to_optimize_range() const { return FALSE; } - enum Item_result cmp_type () const { return TIME_RESULT; } - int store(const char *to,uint length,CHARSET_INFO *charset); - int store(double nr); - int store(longlong nr, bool unsigned_val); - int store_time_dec(MYSQL_TIME *ltime, uint dec); - my_decimal *val_decimal(my_decimal*); - bool eq_def(Field *field) - { - return (Field_str::eq_def(field) && decimals() == field->decimals()); - } -}; - -class Field_date :public Field_temporal { +class Field_date :public Field_temporal_with_date { void store_TIME(MYSQL_TIME *ltime); public: Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, - enum utype unireg_check_arg, const char *field_name_arg, - CHARSET_INFO *cs) - :Field_temporal(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, cs) {} + enum utype unireg_check_arg, const char *field_name_arg) + :Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg) {} enum_field_types type() const { return MYSQL_TYPE_DATE;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); - uint decimals() const { return 0; } bool send_binary(Protocol *protocol); int cmp(const uchar *,const uchar *); void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 4; } void sql_type(String &str) const; - bool zero_pack() const { return 1; } uchar *pack(uchar* to, const uchar *from, uint max_length __attribute__((unused))) { @@ -1544,23 +1717,22 @@ public: { return unpack_int32(to, from, from_end); } + uint size_of() const { return sizeof(*this); } }; -class Field_newdate :public Field_temporal { +class Field_newdate :public Field_temporal_with_date { void store_TIME(MYSQL_TIME *ltime); public: Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, - enum utype unireg_check_arg, const char *field_name_arg, - CHARSET_INFO *cs) - :Field_temporal(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, cs) + enum utype unireg_check_arg, const char *field_name_arg) + :Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg) {} enum_field_types type() const { return MYSQL_TYPE_DATE;} enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; } int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; } - uint decimals() const { return 0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -1569,19 +1741,22 @@ public: void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; - bool zero_pack() const { return 1; } bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); + uint size_of() const { return sizeof(*this); } }; class Field_time :public Field_temporal { - void store_TIME(MYSQL_TIME *ltime); +protected: + virtual void store_TIME(MYSQL_TIME *ltime); + int store_TIME_with_warning(MYSQL_TIME *ltime, const ErrConv *str, + int was_cut, int have_smth_to_conv); public: Field_time(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, - const char *field_name_arg, CHARSET_INFO *cs) + const char *field_name_arg) :Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, cs) + unireg_check_arg, field_name_arg) {} enum_field_types type() const { return MYSQL_TYPE_TIME;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; } @@ -1589,7 +1764,7 @@ public: int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); - uint decimals() const { return 0; } + int store_decimal(const my_decimal *); double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -1599,55 +1774,122 @@ public: void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; - bool zero_pack() const { return 1; } + uint size_of() const { return sizeof(*this); } }; -class Field_time_hires :public Field_time { + +/** + Abstract class for: + - TIME(1..6) + - TIME(0..6) - MySQL56 version +*/ +class Field_time_with_dec :public Field_time { +protected: uint dec; +public: + Field_time_with_dec(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, + enum utype unireg_check_arg, const char *field_name_arg, + uint dec_arg) + :Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + test(dec_arg), null_ptr_arg, + null_bit_arg, unireg_check_arg, field_name_arg), + dec(dec_arg) + { + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + } + uint decimals() const { return dec; } + enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } + longlong val_int(void); + double val_real(void); + void make_field(Send_field *); +}; + + +/** + TIME(1..6) +*/ +class Field_time_hires :public Field_time_with_dec { longlong zero_point; void store_TIME(MYSQL_TIME *ltime); public: Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, - uint dec_arg, CHARSET_INFO *cs) - :Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + 1, null_ptr_arg, - null_bit_arg, unireg_check_arg, field_name_arg, cs), - dec(dec_arg) + uint dec_arg) + :Field_time_with_dec(ptr_arg, null_ptr_arg, + null_bit_arg, unireg_check_arg, field_name_arg, + dec_arg) { DBUG_ASSERT(dec); - DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); zero_point= sec_part_shift( ((TIME_MAX_VALUE_SECONDS+1LL)*TIME_SECOND_PART_FACTOR), dec); } - enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } - uint decimals() const { return dec; } - int store_decimal(const my_decimal *d); - longlong val_int(void); - double val_real(void); - String *val_str(String*,String *); int reset(void); bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); - bool send_binary(Protocol *protocol); int cmp(const uchar *,const uchar *); void sort_string(uchar *buff,uint length); uint32 pack_length() const; - void sql_type(String &str) const; - void make_field(Send_field *); uint size_of() const { return sizeof(*this); } }; -class Field_datetime :public Field_temporal { + +/** + TIME(0..6) - MySQL56 version +*/ +class Field_timef :public Field_time_with_dec { + void store_TIME(MYSQL_TIME *ltime); + int do_save_field_metadata(uchar *metadata_ptr) + { + *metadata_ptr= decimals(); + return 1; + } +public: + Field_timef(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, + enum utype unireg_check_arg, const char *field_name_arg, + uint dec_arg) + :Field_time_with_dec(ptr_arg, null_ptr_arg, + null_bit_arg, unireg_check_arg, field_name_arg, + dec_arg) + { + DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); + } + enum_field_types real_type() const { return MYSQL_TYPE_TIME2; } + enum_field_types binlog_type() const { return MYSQL_TYPE_TIME2; } + uint32 pack_length() const + { + return my_time_binary_length(dec); + } + uint row_pack_length() { return pack_length(); } + uint pack_length_from_metadata(uint field_metadata) + { + DBUG_ENTER("Field_timef::pack_length_from_metadata"); + uint tmp= my_time_binary_length(field_metadata); + DBUG_RETURN(tmp); + } + void sort_string(uchar *to, uint length) + { + DBUG_ASSERT(length == Field_timef::pack_length()); + memcpy(to, ptr, length); + } + int cmp(const uchar *a_ptr, const uchar *b_ptr) + { + return memcmp(a_ptr, b_ptr, pack_length()); + } + int reset(); + bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); + uint size_of() const { return sizeof(*this); } +}; + + +class Field_datetime :public Field_temporal_with_date { void store_TIME(MYSQL_TIME *ltime); public: Field_datetime(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, - const char *field_name_arg, CHARSET_INFO *cs) - :Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, cs) + const char *field_name_arg) + :Field_temporal_with_date(ptr_arg, length_arg, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg) {} enum_field_types type() const { return MYSQL_TYPE_DATETIME;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; } - uint decimals() const { return 0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -1656,7 +1898,6 @@ public: void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 8; } void sql_type(String &str) const; - bool zero_pack() const { return 1; } bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); virtual int set_time(); virtual void set_default() @@ -1690,85 +1931,149 @@ public: { return unpack_int64(to, from, from_end); } + uint size_of() const { return sizeof(*this); } }; -class Field_datetime_hires :public Field_datetime { - void store_TIME(MYSQL_TIME *ltime); +/** + Abstract class for: + - DATETIME(1..6) + - DATETIME(0..6) - MySQL56 version +*/ +class Field_datetime_with_dec :public Field_datetime { +protected: uint dec; public: - Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg, - uchar null_bit_arg, enum utype unireg_check_arg, - const char *field_name_arg, uint dec_arg, - CHARSET_INFO *cs) - :Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + 1, + Field_datetime_with_dec(uchar *ptr_arg, uchar *null_ptr_arg, + uchar null_bit_arg, enum utype unireg_check_arg, + const char *field_name_arg, uint dec_arg) + :Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + test(dec_arg), null_ptr_arg, null_bit_arg, unireg_check_arg, - field_name_arg, cs), dec(dec_arg) + field_name_arg), dec(dec_arg) { - DBUG_ASSERT(dec); DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); } - enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } uint decimals() const { return dec; } + enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } void make_field(Send_field *field); - int store_decimal(const my_decimal *d); - double val_real(void); - longlong val_int(void); - String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const uchar *,const uchar *); - void sort_string(uchar *buff,uint length); - uint32 pack_length() const; - void sql_type(String &str) const; - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); uchar *pack(uchar *to, const uchar *from, uint max_length) { return Field::pack(to, from, max_length); } const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end, uint param_data) { return Field::unpack(to, from, from_end, param_data); } + void sort_string(uchar *to, uint length) + { + DBUG_ASSERT(length == pack_length()); + memcpy(to, ptr, length); + } + double val_real(void); + longlong val_int(void); + String *val_str(String*,String *); +}; + + +/** + DATETIME(1..6) +*/ +class Field_datetime_hires :public Field_datetime_with_dec { + void store_TIME(MYSQL_TIME *ltime); +public: + Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg, + uchar null_bit_arg, enum utype unireg_check_arg, + const char *field_name_arg, uint dec_arg) + :Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg, dec_arg) + { + DBUG_ASSERT(dec); + } + int cmp(const uchar *,const uchar *); + uint32 pack_length() const; + bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); uint size_of() const { return sizeof(*this); } }; + +/** + DATETIME(0..6) - MySQL56 version +*/ +class Field_datetimef :public Field_datetime_with_dec { + void store_TIME(MYSQL_TIME *ltime); + int do_save_field_metadata(uchar *metadata_ptr) + { + *metadata_ptr= decimals(); + return 1; + } +public: + Field_datetimef(uchar *ptr_arg, uchar *null_ptr_arg, + uchar null_bit_arg, enum utype unireg_check_arg, + const char *field_name_arg, uint dec_arg) + :Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg, + unireg_check_arg, field_name_arg, dec_arg) + {} + enum_field_types real_type() const { return MYSQL_TYPE_DATETIME2; } + enum_field_types binlog_type() const { return MYSQL_TYPE_DATETIME2; } + uint32 pack_length() const + { + return my_datetime_binary_length(dec); + } + uint row_pack_length() { return pack_length(); } + uint pack_length_from_metadata(uint field_metadata) + { + DBUG_ENTER("Field_datetimef::pack_length_from_metadata"); + uint tmp= my_datetime_binary_length(field_metadata); + DBUG_RETURN(tmp); + } + int cmp(const uchar *a_ptr, const uchar *b_ptr) + { + return memcmp(a_ptr, b_ptr, pack_length()); + } + int reset(); + bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); + uint size_of() const { return sizeof(*this); } +}; + + static inline Field_timestamp * new_Field_timestamp(uchar *ptr, uchar *null_ptr, uchar null_bit, enum Field::utype unireg_check, const char *field_name, - TABLE_SHARE *share, uint dec, CHARSET_INFO *cs) + TABLE_SHARE *share, uint dec) { if (dec==0) return new Field_timestamp(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit, - unireg_check, field_name, share, cs); + unireg_check, field_name, share); if (dec == NOT_FIXED_DEC) dec= MAX_DATETIME_PRECISION; return new Field_timestamp_hires(ptr, null_ptr, null_bit, unireg_check, - field_name, share, dec, cs); + field_name, share, dec); } static inline Field_time * new_Field_time(uchar *ptr, uchar *null_ptr, uchar null_bit, enum Field::utype unireg_check, const char *field_name, - uint dec, CHARSET_INFO *cs) + uint dec) { if (dec == 0) return new Field_time(ptr, MIN_TIME_WIDTH, null_ptr, null_bit, - unireg_check, field_name, cs); + unireg_check, field_name); if (dec == NOT_FIXED_DEC) dec= MAX_DATETIME_PRECISION; return new Field_time_hires(ptr, null_ptr, null_bit, - unireg_check, field_name, dec, cs); + unireg_check, field_name, dec); } static inline Field_datetime * new_Field_datetime(uchar *ptr, uchar *null_ptr, uchar null_bit, enum Field::utype unireg_check, - const char *field_name, uint dec, CHARSET_INFO *cs) + const char *field_name, uint dec) { if (dec == 0) return new Field_datetime(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit, - unireg_check, field_name, cs); + unireg_check, field_name); if (dec == NOT_FIXED_DEC) dec= MAX_DATETIME_PRECISION; return new Field_datetime_hires(ptr, null_ptr, null_bit, - unireg_check, field_name, dec, cs); + unireg_check, field_name, dec); } class Field_string :public Field_longstr { @@ -1795,7 +2100,6 @@ public: orig_table->s->frm_version < FRM_VER_TRUE_VARCHAR ? MYSQL_TYPE_VAR_STRING : MYSQL_TYPE_STRING); } - bool match_collation_to_optimize_range() const { return TRUE; } enum ha_base_keytype key_type() const { return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; } bool zero_pack() const { return 0; } @@ -1876,7 +2180,6 @@ public: } enum_field_types type() const { return MYSQL_TYPE_VARCHAR; } - bool match_collation_to_optimize_range() const { return TRUE; } enum ha_base_keytype key_type() const; uint row_pack_length() { return field_length; } bool zero_pack() const { return 0; } @@ -1972,7 +2275,6 @@ public: :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info), packlength(packlength_arg) {} enum_field_types type() const { return MYSQL_TYPE_BLOB;} - bool match_collation_to_optimize_range() const { return TRUE; } enum ha_base_keytype key_type() const { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; } int store(const char *to,uint length,CHARSET_INFO *charset); @@ -2118,7 +2420,7 @@ public: { geom_type= geom_type_arg; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY2; } enum_field_types type() const { return MYSQL_TYPE_GEOMETRY; } - bool match_collation_to_optimize_range() const { return FALSE; } + bool match_collation_to_optimize_range() const { return false; } void sql_type(String &str) const; int store(const char *to, uint length, CHARSET_INFO *charset); int store(double nr); @@ -2156,7 +2458,6 @@ public: } Field *new_field(MEM_ROOT *root, TABLE *new_table, bool keep_type); enum_field_types type() const { return MYSQL_TYPE_STRING; } - bool match_collation_to_optimize_range() const { return FALSE; } enum Item_result cmp_type () const { return INT_RESULT; } enum ha_base_keytype key_type() const; int store(const char *to,uint length,CHARSET_INFO *charset); @@ -2309,7 +2610,10 @@ public: { store(*((longlong *)val), TRUE); } - double pos_in_interval(Field *min, Field *max); + double pos_in_interval(Field *min, Field *max) + { + return pos_in_interval_val_real(min, max); + } void get_image(uchar *buff, uint length, CHARSET_INFO *cs) { get_key_image(buff, length, itRAW); } void set_image(const uchar *buff,uint length, CHARSET_INFO *cs) diff --git a/sql/item.cc b/sql/item.cc index a5d5cf61496..f9def19bf6a 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -651,9 +651,12 @@ Item_result Item::cmp_type() const case MYSQL_TYPE_GEOMETRY: return STRING_RESULT; case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_TIMESTAMP2: case MYSQL_TYPE_DATE: case MYSQL_TYPE_TIME: + case MYSQL_TYPE_TIME2: case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_DATETIME2: case MYSQL_TYPE_NEWDATE: return TIME_RESULT; }; @@ -3218,11 +3221,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type, value.time= *tm; value.time.time_type= time_type; - if (value.time.year > 9999 || value.time.month > 12 || - value.time.day > 31 || - (time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23) || - value.time.minute > 59 || value.time.second > 59 || - value.time.second_part > TIME_MAX_SECOND_PART) + if (check_datetime_range(&value.time)) { ErrConvTime str(&value.time); make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, @@ -5678,19 +5677,17 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) break; case MYSQL_TYPE_NEWDATE: case MYSQL_TYPE_DATE: - field= new Field_newdate(0, null_ptr, 0, Field::NONE, name, &my_charset_bin); + field= new Field_newdate(0, null_ptr, 0, Field::NONE, name); break; case MYSQL_TYPE_TIME: - field= new_Field_time(0, null_ptr, 0, Field::NONE, name, - decimals, &my_charset_bin); + field= new_Field_time(0, null_ptr, 0, Field::NONE, name, decimals); break; case MYSQL_TYPE_TIMESTAMP: field= new_Field_timestamp(0, null_ptr, 0, - Field::NONE, name, 0, decimals, &my_charset_bin); + Field::NONE, name, 0, decimals); break; case MYSQL_TYPE_DATETIME: - field= new_Field_datetime(0, null_ptr, 0, Field::NONE, name, - decimals, &my_charset_bin); + field= new_Field_datetime(0, null_ptr, 0, Field::NONE, name, decimals); break; case MYSQL_TYPE_YEAR: field= new Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE, diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5bf53784c26..132515733d6 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3972,7 +3972,9 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg) type= DYN_COL_NULL; break; case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_TIMESTAMP2: case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_DATETIME2: type= DYN_COL_DATETIME; break; case MYSQL_TYPE_DATE: @@ -3980,6 +3982,7 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg) type= DYN_COL_DATE; break; case MYSQL_TYPE_TIME: + case MYSQL_TYPE_TIME2: type= DYN_COL_TIME; break; case MYSQL_TYPE_VARCHAR: diff --git a/sql/item_sum.cc b/sql/item_sum.cc index d441653c82b..92fff032095 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1307,16 +1307,16 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table, switch (args[0]->field_type()) { case MYSQL_TYPE_DATE: field= new Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, - name, collation.collation); + name); break; case MYSQL_TYPE_TIME: field= new_Field_time(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, - name, decimals, collation.collation); + name, decimals); break; case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: field= new_Field_datetime(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, - name, decimals, collation.collation); + name, decimals); break; default: return Item_sum::create_tmp_field(group, table, convert_blob_length); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index f43a4e79431..84510e0f112 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1574,7 +1574,7 @@ static void set_sec_part(ulong sec_part, MYSQL_TIME *ltime, Item *item) { ltime->second_part= sec_part; if (item->decimals < TIME_SECOND_PART_DIGITS) - ltime->second_part= sec_part_truncate(ltime->second_part, item->decimals); + my_time_trunc(ltime, item->decimals); } } @@ -2411,7 +2411,7 @@ bool Item_time_typecast::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) if (get_arg0_time(ltime)) return 1; if (decimals < TIME_SECOND_PART_DIGITS) - ltime->second_part= sec_part_truncate(ltime->second_part, decimals); + my_time_trunc(ltime, decimals); /* MYSQL_TIMESTAMP_TIME value can have non-zero day part, which we should not lose. @@ -2450,8 +2450,7 @@ bool Item_datetime_typecast::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) return 1; if (decimals < TIME_SECOND_PART_DIGITS) - ltime->second_part= sec_part_truncate(ltime->second_part, decimals); - + my_time_trunc(ltime, decimals); /* ltime is valid MYSQL_TYPE_TIME (according to fuzzy_date). diff --git a/sql/log_event.cc b/sql/log_event.cc index 0782e40981e..6f56d1d53b9 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -48,6 +48,7 @@ #include #include "sql_show.h" // append_identifier #include +#include "compat56.h" #endif /* MYSQL_CLIENT */ @@ -2128,6 +2129,17 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr, return 4; } + case MYSQL_TYPE_TIMESTAMP2: + { + char buf[MAX_DATE_STRING_REP_LENGTH]; + struct timeval tm; + my_timestamp_from_binary(&tm, ptr, meta); + int buflen= my_timeval_to_str(&tm, buf, meta); + my_b_write(file, buf, buflen); + my_snprintf(typestr, typestr_length, "TIMESTAMP(%d)", meta); + return my_timestamp_binary_length(meta); + } + case MYSQL_TYPE_DATETIME: { ulong d, t; @@ -2142,15 +2154,41 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr, return 8; } + case MYSQL_TYPE_DATETIME2: + { + char buf[MAX_DATE_STRING_REP_LENGTH]; + MYSQL_TIME ltime; + longlong packed= my_datetime_packed_from_binary(ptr, meta); + TIME_from_longlong_datetime_packed(<ime, packed); + int buflen= my_datetime_to_str(<ime, buf, meta); + my_b_write_quoted(file, (uchar *) buf, buflen); + my_snprintf(typestr, typestr_length, "DATETIME(%d)", meta); + return my_datetime_binary_length(meta); + } + case MYSQL_TYPE_TIME: { - uint32 i32= uint3korr(ptr); - my_b_printf(file, "'%02d:%02d:%02d'", - i32 / 10000, (i32 % 10000) / 100, i32 % 100); + int32 tmp= sint3korr(ptr); + int32 i32= tmp >= 0 ? tmp : - tmp; + const char *sign= tmp < 0 ? "-" : ""; + my_b_printf(file, "'%s%02d:%02d:%02d'", + sign, i32 / 10000, (i32 % 10000) / 100, i32 % 100, i32); my_snprintf(typestr, typestr_length, "TIME"); return 3; } - + + case MYSQL_TYPE_TIME2: + { + char buf[MAX_DATE_STRING_REP_LENGTH]; + MYSQL_TIME ltime; + longlong packed= my_time_packed_from_binary(ptr, meta); + TIME_from_longlong_time_packed(<ime, packed); + int buflen= my_time_to_str(<ime, buf, meta); + my_b_write_quoted(file, (uchar *) buf, buflen); + my_snprintf(typestr, typestr_length, "TIME(%d)", meta); + return my_time_binary_length(meta); + } + case MYSQL_TYPE_NEWDATE: { uint32 tmp= uint3korr(ptr); @@ -9860,7 +9898,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, { m_coltype= reinterpret_cast(m_memory); for (unsigned int i= 0 ; i < m_table->s->fields ; ++i) - m_coltype[i]= m_table->field[i]->type(); + m_coltype[i]= m_table->field[i]->binlog_type(); } /* diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 659e63caf6c..e8213ea8dd6 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8014,10 +8014,10 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field, */ if (field->result_type() == STRING_RESULT && - ((Field_str*) field)->match_collation_to_optimize_range() && + field->match_collation_to_optimize_range() && value->result_type() == STRING_RESULT && key_part->image_type == Field::itRAW && - ((Field_str*)field)->charset() != conf_func->compare_collation() && + field->charset() != conf_func->compare_collation() && !(conf_func->compare_collation()->state & MY_CS_BINSORT && (type == Item_func::EQUAL_FUNC || type == Item_func::EQ_FUNC))) goto end; @@ -12885,7 +12885,7 @@ check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item, */ ((args[1]->result_type() == STRING_RESULT && image_type == Field::itRAW && - ((Field_str*) min_max_arg_item->field)->charset() != + min_max_arg_item->field->charset() != pred->compare_collation()) || /* diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index 33164c1ed12..1542efa7415 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -1482,7 +1482,7 @@ void check_equality(Dep_analysis_context *ctx, Dep_module_expr **eq_mod, collation of the operation differ from the field collation. */ if (field->cmp_type() == STRING_RESULT && - ((Field_str*)field)->charset() != cond->compare_collation()) + field->charset() != cond->compare_collation()) return; } } diff --git a/sql/protocol.cc b/sql/protocol.cc index f6e9e9e62e1..1e257b5a282 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1427,7 +1427,7 @@ bool Protocol_binary::store(MYSQL_TIME *tm, int decimals) DBUG_ASSERT(decimals == AUTO_SEC_PART_DIGITS || (decimals >= 0 && decimals <= TIME_SECOND_PART_DIGITS)); if (decimals != AUTO_SEC_PART_DIGITS) - tm->second_part= sec_part_truncate(tm->second_part, decimals); + my_time_trunc(tm, decimals); int4store(pos+7, tm->second_part); if (tm->second_part) length=11; @@ -1469,7 +1469,7 @@ bool Protocol_binary::store_time(MYSQL_TIME *tm, int decimals) DBUG_ASSERT(decimals == AUTO_SEC_PART_DIGITS || (decimals >= 0 && decimals <= TIME_SECOND_PART_DIGITS)); if (decimals != AUTO_SEC_PART_DIGITS) - tm->second_part= sec_part_truncate(tm->second_part, decimals); + my_time_trunc(tm, decimals); int4store(pos+8, tm->second_part); if (tm->second_part) length=12; diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 6bbe998a624..ac8a8fe356b 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -109,12 +109,15 @@ max_display_length_for_field(enum_field_types sql_type, unsigned int metadata) case MYSQL_TYPE_DATE: case MYSQL_TYPE_TIME: + case MYSQL_TYPE_TIME2: return 3; case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_TIMESTAMP2: return 4; case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_DATETIME2: return 8; case MYSQL_TYPE_BIT: @@ -262,12 +265,21 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const case MYSQL_TYPE_TIME: length= 3; break; + case MYSQL_TYPE_TIME2: + length= my_time_binary_length(m_field_metadata[col]); + break; case MYSQL_TYPE_TIMESTAMP: length= 4; break; + case MYSQL_TYPE_TIMESTAMP2: + length= my_timestamp_binary_length(m_field_metadata[col]); + break; case MYSQL_TYPE_DATETIME: length= 8; break; + case MYSQL_TYPE_DATETIME2: + length= my_datetime_binary_length(m_field_metadata[col]); + break; case MYSQL_TYPE_BIT: { /* @@ -376,6 +388,7 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_ break; case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_TIMESTAMP2: str->set_ascii(STRING_WITH_LEN("timestamp")); break; @@ -393,10 +406,12 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_ break; case MYSQL_TYPE_TIME: + case MYSQL_TYPE_TIME2: str->set_ascii(STRING_WITH_LEN("time")); break; case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_DATETIME2: str->set_ascii(STRING_WITH_LEN("datetime")); break; @@ -615,6 +630,23 @@ can_convert_field_to(Field *field, else DBUG_RETURN(false); } + else if (metadata == 0 && + ((field->real_type() == MYSQL_TYPE_TIMESTAMP2 && + source_type == MYSQL_TYPE_TIMESTAMP) || + (field->real_type() == MYSQL_TYPE_TIME2 && + source_type == MYSQL_TYPE_TIME) || + (field->real_type() == MYSQL_TYPE_DATETIME2 && + source_type == MYSQL_TYPE_DATETIME))) + { + /* + TS-TODO: conversion from FSP1>FSP2. + Can do non-lossy conversion + from old TIME, TIMESTAMP, DATETIME + to MySQL56 TIME(0), TIMESTAMP(0), DATETIME(0). + */ + *order_var= -1; + DBUG_RETURN(true); + } else if (!slave_type_conversions_options) DBUG_RETURN(false); @@ -739,6 +771,9 @@ can_convert_field_to(Field *field, case MYSQL_TYPE_NULL: case MYSQL_TYPE_ENUM: case MYSQL_TYPE_SET: + case MYSQL_TYPE_TIMESTAMP2: + case MYSQL_TYPE_DATETIME2: + case MYSQL_TYPE_TIME2: DBUG_RETURN(false); } DBUG_RETURN(false); // To keep GCC happy @@ -939,7 +974,7 @@ TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE * DBUG_PRINT("debug", ("sql_type: %d, target_field: '%s', max_length: %d, decimals: %d," " maybe_null: %d, unsigned_flag: %d, pack_length: %u", - type(col), target_table->field[col]->field_name, + binlog_type(col), target_table->field[col]->field_name, max_length, decimals, TRUE, FALSE, pack_length)); field_def->init_for_tmp_table(type(col), max_length, @@ -993,7 +1028,7 @@ table_def::table_def(unsigned char *types, ulong size, int index= 0; for (unsigned int i= 0; i < m_size; i++) { - switch (m_type[i]) { + switch (binlog_type(i)) { case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_BLOB: case MYSQL_TYPE_MEDIUM_BLOB: @@ -1042,6 +1077,11 @@ table_def::table_def(unsigned char *types, ulong size, m_field_metadata[i]= x; break; } + case MYSQL_TYPE_TIME2: + case MYSQL_TYPE_DATETIME2: + case MYSQL_TYPE_TIMESTAMP2: + m_field_metadata[i]= field_metadata[index++]; + break; default: m_field_metadata[i]= 0; break; diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h index 79f4517c492..b08721aa8c2 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -65,6 +65,14 @@ public: ulong size() const { return m_size; } + /** + Returns internal binlog type code for one field, + without translation to real types. + */ + enum_field_types binlog_type(ulong index) const + { + return static_cast(m_type[index]); + } /* Return a representation of the type data for one field. @@ -82,7 +90,7 @@ public: either MYSQL_TYPE_STRING, MYSQL_TYPE_ENUM, or MYSQL_TYPE_SET, so we might need to modify the type to get the real type. */ - enum_field_types source_type= static_cast(m_type[index]); + enum_field_types source_type= binlog_type(index); uint16 source_metadata= m_field_metadata[index]; switch (source_type) { diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 2bcefce1212..5bac6643772 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1563,7 +1563,7 @@ bool field_is_partition_charset(Field *field) !(field->type() == MYSQL_TYPE_VARCHAR)) return FALSE; { - CHARSET_INFO *cs= ((Field_str*)field)->charset(); + CHARSET_INFO *cs= field->charset(); if (!(field->type() == MYSQL_TYPE_STRING) || !(cs->state & MY_CS_BINSORT)) return TRUE; @@ -1606,7 +1606,7 @@ bool check_part_func_fields(Field **ptr, bool ok_with_charsets) */ if (field_is_partition_charset(field)) { - CHARSET_INFO *cs= ((Field_str*)field)->charset(); + CHARSET_INFO *cs= field->charset(); if (!ok_with_charsets || cs->mbmaxlen > 1 || cs->strxfrm_multiply > 1) @@ -2090,6 +2090,8 @@ static int check_part_field(enum_field_types sql_type, case MYSQL_TYPE_DATE: case MYSQL_TYPE_TIME: case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_TIME2: + case MYSQL_TYPE_DATETIME2: *result_type= STRING_RESULT; *need_cs_check= TRUE; return FALSE; @@ -2102,6 +2104,7 @@ static int check_part_field(enum_field_types sql_type, case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_TIMESTAMP2: case MYSQL_TYPE_NULL: case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_DOUBLE: @@ -2974,7 +2977,7 @@ static void copy_to_part_field_buffers(Field **ptr, restore_ptr++; if (!field->maybe_null() || !field->is_null()) { - CHARSET_INFO *cs= ((Field_str*)field)->charset(); + CHARSET_INFO *cs= field->charset(); uint max_len= field->pack_length(); uint data_len= field->data_length(); uchar *field_buf= *field_bufs; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 518b86ee301..51c3894ec3e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -4409,7 +4409,7 @@ bool Protocol_local::store(const char *str, size_t length, bool Protocol_local::store(MYSQL_TIME *time, int decimals) { if (decimals != AUTO_SEC_PART_DIGITS) - time->second_part= sec_part_truncate(time->second_part, decimals); + my_time_trunc(time, decimals); return store_column(time, sizeof(MYSQL_TIME)); } @@ -4427,7 +4427,7 @@ bool Protocol_local::store_date(MYSQL_TIME *time) bool Protocol_local::store_time(MYSQL_TIME *time, int decimals) { if (decimals != AUTO_SEC_PART_DIGITS) - time->second_part= sec_part_truncate(time->second_part, decimals); + my_time_trunc(time, decimals); return store_column(time, sizeof(MYSQL_TIME)); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 806017b9ae5..93f8711fb7e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4307,7 +4307,7 @@ add_key_field(JOIN *join, { if ((*value)->cmp_type() != STRING_RESULT) return; - if (((Field_str*)field)->charset() != cond->compare_collation()) + if (field->charset() != cond->compare_collation()) return; } } @@ -11857,7 +11857,7 @@ static bool check_simple_equality(Item *left_item, Item *right_item, if (field_item->cmp_type() == STRING_RESULT) { - CHARSET_INFO *cs= ((Field_str*) field_item->field)->charset(); + CHARSET_INFO *cs= field_item->field->charset(); if (!item) { Item_func_eq *eq_item; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f56eedf4c42..4b3997dec3c 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2790,6 +2790,8 @@ int prepare_create_field(Create_field *sql_field, case MYSQL_TYPE_NEWDATE: case MYSQL_TYPE_TIME: case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_TIME2: + case MYSQL_TYPE_DATETIME2: case MYSQL_TYPE_NULL: sql_field->pack_flag=f_settype((uint) sql_field->sql_type); break; @@ -2808,6 +2810,7 @@ int prepare_create_field(Create_field *sql_field, (sql_field->decimals << FIELDFLAG_DEC_SHIFT)); break; case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_TIMESTAMP2: /* fall-through */ default: sql_field->pack_flag=(FIELDFLAG_NUMBER | @@ -2893,7 +2896,7 @@ void promote_first_timestamp_column(List *column_definitions) while ((column_definition= it++) != NULL) { - if (column_definition->sql_type == MYSQL_TYPE_TIMESTAMP || // TIMESTAMP + if (is_timestamp_type(column_definition->sql_type) || // TIMESTAMP column_definition->unireg_check == Field::TIMESTAMP_OLD_FIELD) // Legacy { if ((column_definition->flags & NOT_NULL_FLAG) != 0 && // NOT NULL, @@ -3854,7 +3857,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, if (thd->variables.sql_mode & MODE_NO_ZERO_DATE && !sql_field->def && - sql_field->sql_type == MYSQL_TYPE_TIMESTAMP && + is_timestamp_type(sql_field->sql_type) && (sql_field->flags & NOT_NULL_FLAG) && (type == Field::NONE || type == Field::TIMESTAMP_UN_FIELD)) { @@ -5950,7 +5953,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, */ if ((def->sql_type == MYSQL_TYPE_DATE || def->sql_type == MYSQL_TYPE_NEWDATE || - def->sql_type == MYSQL_TYPE_DATETIME) && + def->sql_type == MYSQL_TYPE_DATETIME || + def->sql_type == MYSQL_TYPE_DATETIME2) && !alter_info->datetime_field && !(~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) && thd->variables.sql_mode & MODE_NO_ZERO_DATE) @@ -7582,6 +7586,7 @@ err: t_type= MYSQL_TIMESTAMP_DATE; break; case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_DATETIME2: f_val= "0000-00-00 00:00:00"; t_type= MYSQL_TIMESTAMP_DATETIME; break; diff --git a/sql/table.cc b/sql/table.cc index 2f867eb7dc4..32a841ffd46 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3281,7 +3281,7 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res) } if (!(to= strmake_root(mem, str.ptr(), length))) length= 0; // Safety fix - res->set(to, length, ((Field_str*)field)->charset()); + res->set(to, length, field->charset()); return 0; } diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc index 64a4aa81d73..c3f29787951 100644 --- a/storage/perfschema/pfs_engine_table.cc +++ b/storage/perfschema/pfs_engine_table.cc @@ -514,7 +514,7 @@ void PFS_engine_table::set_field_enum(Field *f, ulonglong value) void PFS_engine_table::set_field_timestamp(Field *f, ulonglong value) { - DBUG_ASSERT(f->real_type() == MYSQL_TYPE_TIMESTAMP); + DBUG_ASSERT(is_timestamp_type(f->real_type())); Field_timestamp *f2= (Field_timestamp*) f; f2->store_TIME((long)(value / 1000000), (value % 1000000)); } From d98584f56a5ec46d6258bba6250c6c797a678afd Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 10 Jul 2013 12:12:27 +0400 Subject: [PATCH 273/273] Adding support for the SQL-standard temporal literals. added: mysql-test/r/temporal_literal.result mysql-test/t/temporal_literal.test modified: client/mysqlbinlog.cc include/my_time.h mysql-test/r/cast.result mysql-test/r/partition_innodb.result mysql-test/t/cast.test mysql-test/t/partition_innodb.test sql-common/my_time.c sql/field.cc sql/item.cc sql/item.h sql/item_cmpfunc.cc sql/item_create.cc sql/item_create.h sql/item_strfunc.cc sql/item_timefunc.cc sql/item_timefunc.h sql/sql_select.cc sql/sql_time.cc sql/sql_time.h sql/sql_yacc.yy storage/spider/spd_db_mysql.cc --- client/mysqlbinlog.cc | 7 +- include/my_time.h | 27 +- mysql-test/r/cast.result | 20 +- mysql-test/r/partition_innodb.result | 4 +- mysql-test/r/temporal_literal.result | 418 +++++++++++++++++++++++++++ mysql-test/t/cast.test | 10 +- mysql-test/t/partition_innodb.test | 4 +- mysql-test/t/temporal_literal.test | 217 ++++++++++++++ sql-common/my_time.c | 224 ++++++++------ sql/field.cc | 43 ++- sql/item.cc | 93 +++++- sql/item.h | 113 +++++++- sql/item_cmpfunc.cc | 22 +- sql/item_create.cc | 65 +++++ sql/item_create.h | 5 + sql/item_strfunc.cc | 2 +- sql/item_timefunc.cc | 13 +- sql/item_timefunc.h | 1 - sql/sql_select.cc | 1 + sql/sql_time.cc | 48 +-- sql/sql_time.h | 36 ++- sql/sql_yacc.yy | 79 ++++- storage/spider/spd_db_mysql.cc | 20 +- 23 files changed, 1256 insertions(+), 216 deletions(-) create mode 100644 mysql-test/r/temporal_literal.result create mode 100644 mysql-test/t/temporal_literal.test diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index c099459f61e..f38a88749db 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1541,13 +1541,14 @@ the mysql command line client.\n\n"); static my_time_t convert_str_to_timestamp(const char* str) { - int was_cut; + MYSQL_TIME_STATUS status; MYSQL_TIME l_time; long dummy_my_timezone; uint dummy_in_dst_time_gap; + /* We require a total specification (date AND time) */ - if (str_to_datetime(str, (uint) strlen(str), &l_time, 0, &was_cut) != - MYSQL_TIMESTAMP_DATETIME || was_cut) + if (str_to_datetime(str, (uint) strlen(str), &l_time, 0, &status) || + l_time.time_type != MYSQL_TIMESTAMP_DATETIME || status.warnings) { error("Incorrect date and time argument: %s", str); exit(1); diff --git a/include/my_time.h b/include/my_time.h index 046b5c94923..f7227b168be 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -78,14 +78,27 @@ extern uchar days_in_month[]; #define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \ TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND) +/* + Structure to return status from + str_to_datetime(), str_to_time(). +*/ +typedef struct st_mysql_time_status +{ + int warnings; + uint precision; +} MYSQL_TIME_STATUS; + +static inline void my_time_status_init(MYSQL_TIME_STATUS *status) +{ + status->warnings= status->precision= 0; +} + my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, ulonglong flags, int *was_cut); -enum enum_mysql_timestamp_type -str_to_time(const char *str, uint length, MYSQL_TIME *l_time, - ulonglong flag, int *warning); -enum enum_mysql_timestamp_type -str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, - ulonglong flags, int *was_cut); +my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time, + ulonglong flag, MYSQL_TIME_STATUS *status); +my_bool str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, + ulonglong flags, MYSQL_TIME_STATUS *status); longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res, ulonglong flags, int *was_cut); @@ -107,7 +120,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *); ulonglong TIME_to_ulonglong(const MYSQL_TIME *); double TIME_to_double(const MYSQL_TIME *my_time); -longlong pack_time(MYSQL_TIME *my_time); +longlong pack_time(const MYSQL_TIME *my_time); MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time); int check_time_range(struct st_mysql_time *my_time, uint dec, int *warning); diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 625791a7c4b..ac7be28d736 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -180,24 +180,24 @@ select 10.0+'10'; select 10E+0+'10'; 10E+0+'10' 20 -select CONVERT(DATE "2004-01-22 21:45:33" USING latin1); -CONVERT(DATE "2004-01-22 21:45:33" USING latin1) +select CONVERT(TIMESTAMP "2004-01-22 21:45:33" USING latin1); +CONVERT(TIMESTAMP "2004-01-22 21:45:33" USING latin1) 2004-01-22 21:45:33 -select CONVERT(DATE "2004-01-22 21:45:33",CHAR); -CONVERT(DATE "2004-01-22 21:45:33",CHAR) +select CONVERT(TIMESTAMP "2004-01-22 21:45:33",CHAR); +CONVERT(TIMESTAMP "2004-01-22 21:45:33",CHAR) 2004-01-22 21:45:33 -select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)); -CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)) +select CONVERT(TIMESTAMP "2004-01-22 21:45:33",CHAR(4)); +CONVERT(TIMESTAMP "2004-01-22 21:45:33",CHAR(4)) 2004 Warnings: Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33' -select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)); -CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)) +select CONVERT(TIMESTAMP "2004-01-22 21:45:33",BINARY(4)); +CONVERT(TIMESTAMP "2004-01-22 21:45:33",BINARY(4)) 2004 Warnings: Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33' -select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)); -CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)) +select CAST(TIMESTAMP "2004-01-22 21:45:33" AS BINARY(4)); +CAST(TIMESTAMP "2004-01-22 21:45:33" AS BINARY(4)) 2004 Warnings: Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33' diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index adfe3287459..a1accfa8e3d 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -51,8 +51,8 @@ p200912 0 p201103 1 p201912 0 SELECT count(*) FROM t1 p where c3 in -(select c3 from t1 t where t.c3 < date '2011-04-26 19:19:44' - and t.c3 > date '2011-04-26 19:18:44') ; +(select c3 from t1 t where t.c3 < timestamp '2011-04-26 19:19:44' + and t.c3 > timestamp '2011-04-26 19:18:44') ; count(*) 0 DROP TABLE t1; diff --git a/mysql-test/r/temporal_literal.result b/mysql-test/r/temporal_literal.result new file mode 100644 index 00000000000..c79ed311d16 --- /dev/null +++ b/mysql-test/r/temporal_literal.result @@ -0,0 +1,418 @@ +DROP TABLE IF EXISTS t1, t2; +SET NAMES latin1; +# +# Testing DATE literals +# +SELECT DATE'xxxx'; +ERROR HY000: Incorrect DATE value: 'xxxx' +SELECT DATE'01'; +ERROR HY000: Incorrect DATE value: '01' +SELECT DATE'01-01'; +ERROR HY000: Incorrect DATE value: '01-01' +SELECT DATE'2001'; +ERROR HY000: Incorrect DATE value: '2001' +SELECT DATE'2001-01'; +ERROR HY000: Incorrect DATE value: '2001-01' +SELECT DATE'2001-00-00'; +DATE'2001-00-00' +2001-00-00 +SELECT DATE'2001-01-00'; +DATE'2001-01-00' +2001-01-00 +SELECT DATE'0000-00-00'; +DATE'0000-00-00' +0000-00-00 +SELECT DATE'2001-01-01 00:00:00'; +ERROR HY000: Incorrect DATE value: '2001-01-01 00:00:00' +SELECT DATE'01:01:01'; +DATE'01:01:01' +2001-01-01 +SELECT DATE'01-01-01'; +DATE'01-01-01' +2001-01-01 +SELECT DATE'2010-01-01'; +DATE'2010-01-01' +2010-01-01 +SELECT DATE '2010-01-01'; +DATE '2010-01-01' +2010-01-01 +CREATE TABLE t1 AS SELECT DATE'2010-01-01'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `DATE'2010-01-01'` date NOT NULL DEFAULT '0000-00-00' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +{d'2001-01-01'}, +{ d '2001-01-01' }, +{d'2001-01-01 10:10:10'}; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `{d'2001-01-01'}` date NOT NULL DEFAULT '0000-00-00', + `{ d '2001-01-01' }` date NOT NULL DEFAULT '0000-00-00', + `2001-01-01 10:10:10` varchar(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +EXPLAIN EXTENDED SELECT {d'2010-01-01'}; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select DATE'2010-01-01' AS `{d'2010-01-01'}` +EXPLAIN EXTENDED SELECT DATE'2010-01-01'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select DATE'2010-01-01' AS `DATE'2010-01-01'` +# +# Testing DATE literals in non-default sql_mode +# +SET sql_mode=no_zero_in_date; +SELECT DATE'2001-00-00'; +ERROR HY000: Incorrect DATE value: '2001-00-00' +SELECT DATE'2001-01-00'; +ERROR HY000: Incorrect DATE value: '2001-01-00' +SELECT DATE'0000-00-00'; +DATE'0000-00-00' +0000-00-00 +SET sql_mode=no_zero_date; +SELECT DATE'0000-00-00'; +ERROR HY000: Incorrect DATE value: '0000-00-00' +SET sql_mode=default; +# +# Testing TIME literals +# +SELECT TIME'xxxx'; +ERROR HY000: Incorrect TIME value: 'xxxx' +SELECT TIME'900:00:00'; +ERROR HY000: Incorrect TIME value: '900:00:00' +SELECT TIME'-900:00:00'; +ERROR HY000: Incorrect TIME value: '-900:00:00' +SELECT TIME'1 24:00:00'; +TIME'1 24:00:00' +48:00:00 +SELECT TIME'30 24:00:00'; +TIME'30 24:00:00' +744:00:00 +SELECT TIME'0000-00-00 00:00:00'; +ERROR HY000: Incorrect TIME value: '0000-00-00 00:00:00' +SELECT TIME'40 24:00:00'; +ERROR HY000: Incorrect TIME value: '40 24:00:00' +SELECT TIME'10'; +TIME'10' +00:00:10 +SELECT TIME'10:10'; +TIME'10:10' +10:10:00 +SELECT TIME'10:11.12'; +TIME'10:11.12' +10:11:00.12 +SELECT TIME'10:10:10'; +TIME'10:10:10' +10:10:10 +SELECT TIME'10:10:10.'; +TIME'10:10:10.' +10:10:10 +SELECT TIME'10:10:10.1'; +TIME'10:10:10.1' +10:10:10.1 +SELECT TIME'10:10:10.12'; +TIME'10:10:10.12' +10:10:10.12 +SELECT TIME'10:10:10.123'; +TIME'10:10:10.123' +10:10:10.123 +SELECT TIME'10:10:10.1234'; +TIME'10:10:10.1234' +10:10:10.1234 +SELECT TIME'10:10:10.12345'; +TIME'10:10:10.12345' +10:10:10.12345 +SELECT TIME'10:10:10.123456'; +TIME'10:10:10.123456' +10:10:10.123456 +SELECT TIME'-10:00:00'; +TIME'-10:00:00' +-10:00:00 +SELECT TIME '10:11:12'; +TIME '10:11:12' +10:11:12 +CREATE TABLE t1 AS SELECT +TIME'10:10:10', +TIME'10:10:10.', +TIME'10:10:10.1', +TIME'10:10:10.12', +TIME'10:10:10.123', +TIME'10:10:10.1234', +TIME'10:10:10.12345', +TIME'10:10:10.123456'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `TIME'10:10:10'` time NOT NULL DEFAULT '00:00:00', + `TIME'10:10:10.'` time NOT NULL DEFAULT '00:00:00', + `TIME'10:10:10.1'` time(1) NOT NULL DEFAULT '00:00:00.0', + `TIME'10:10:10.12'` time(2) NOT NULL DEFAULT '00:00:00.00', + `TIME'10:10:10.123'` time(3) NOT NULL DEFAULT '00:00:00.000', + `TIME'10:10:10.1234'` time(4) NOT NULL DEFAULT '00:00:00.0000', + `TIME'10:10:10.12345'` time(5) NOT NULL DEFAULT '00:00:00.00000', + `TIME'10:10:10.123456'` time(6) NOT NULL DEFAULT '00:00:00.000000' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +{t'10:10:10'}, +{ t '10:10:10' }, +{t'10:10:10.'}, +{t'10:10:10.123456'}, +{t'2001-01-01'}; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `{t'10:10:10'}` time NOT NULL DEFAULT '00:00:00', + `{ t '10:10:10' }` time NOT NULL DEFAULT '00:00:00', + `{t'10:10:10.'}` time NOT NULL DEFAULT '00:00:00', + `{t'10:10:10.123456'}` time(6) NOT NULL DEFAULT '00:00:00.000000', + `2001-01-01` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +EXPLAIN EXTENDED SELECT {t'10:01:01'}; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select TIME'10:01:01' AS `{t'10:01:01'}` +EXPLAIN EXTENDED SELECT TIME'10:01:01'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select TIME'10:01:01' AS `TIME'10:01:01'` +# +# Testing TIMESTAMP literals +# +SELECT TIMESTAMP'xxxx'; +ERROR HY000: Incorrect DATETIME value: 'xxxx' +SELECT TIMESTAMP'2010'; +ERROR HY000: Incorrect DATETIME value: '2010' +SELECT TIMESTAMP'2010-01'; +ERROR HY000: Incorrect DATETIME value: '2010-01' +SELECT TIMESTAMP'2010-01-01'; +ERROR HY000: Incorrect DATETIME value: '2010-01-01' +SELECT TIMESTAMP'2010-01-01 00'; +TIMESTAMP'2010-01-01 00' +2010-01-01 00:00:00 +SELECT TIMESTAMP'2010-01-01 00:01'; +TIMESTAMP'2010-01-01 00:01' +2010-01-01 00:01:00 +SELECT TIMESTAMP'2010-01-01 10:10:10'; +TIMESTAMP'2010-01-01 10:10:10' +2010-01-01 10:10:10 +SELECT TIMESTAMP'2010-01-01 10:10:10.'; +TIMESTAMP'2010-01-01 10:10:10.' +2010-01-01 10:10:10 +SELECT TIMESTAMP'2010-01-01 10:10:10.1'; +TIMESTAMP'2010-01-01 10:10:10.1' +2010-01-01 10:10:10.1 +SELECT TIMESTAMP'2010-01-01 10:10:10.12'; +TIMESTAMP'2010-01-01 10:10:10.12' +2010-01-01 10:10:10.12 +SELECT TIMESTAMP'2010-01-01 10:10:10.123'; +TIMESTAMP'2010-01-01 10:10:10.123' +2010-01-01 10:10:10.123 +SELECT TIMESTAMP'2010-01-01 10:10:10.1234'; +TIMESTAMP'2010-01-01 10:10:10.1234' +2010-01-01 10:10:10.1234 +SELECT TIMESTAMP'2010-01-01 10:10:10.12345'; +TIMESTAMP'2010-01-01 10:10:10.12345' +2010-01-01 10:10:10.12345 +SELECT TIMESTAMP'2010-01-01 10:10:10.123456'; +TIMESTAMP'2010-01-01 10:10:10.123456' +2010-01-01 10:10:10.123456 +SELECT TIMESTAMP '2010-01-01 10:20:30'; +TIMESTAMP '2010-01-01 10:20:30' +2010-01-01 10:20:30 +CREATE TABLE t1 AS SELECT +TIMESTAMP'2010-01-01 10:10:10', +TIMESTAMP'2010-01-01 10:10:10.', +TIMESTAMP'2010-01-01 10:10:10.1', +TIMESTAMP'2010-01-01 10:10:10.12', +TIMESTAMP'2010-01-01 10:10:10.123', +TIMESTAMP'2010-01-01 10:10:10.1234', +TIMESTAMP'2010-01-01 10:10:10.12345', +TIMESTAMP'2010-01-01 10:10:10.123456'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `TIMESTAMP'2010-01-01 10:10:10'` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `TIMESTAMP'2010-01-01 10:10:10.'` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `TIMESTAMP'2010-01-01 10:10:10.1'` datetime(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `TIMESTAMP'2010-01-01 10:10:10.12'` datetime(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `TIMESTAMP'2010-01-01 10:10:10.123'` datetime(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `TIMESTAMP'2010-01-01 10:10:10.1234'` datetime(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `TIMESTAMP'2010-01-01 10:10:10.12345'` datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000', + `TIMESTAMP'2010-01-01 10:10:10.123456'` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +{ts'2001-01-01 10:10:10'}, +{ ts '2001-01-01 10:10:10' }, +{ts'2001-01-01 10:10:10.'}, +{ts'2001-01-01 10:10:10.123456'}, +{ts'2001-01-01'}; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `{ts'2001-01-01 10:10:10'}` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `{ ts '2001-01-01 10:10:10' }` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `{ts'2001-01-01 10:10:10.'}` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `{ts'2001-01-01 10:10:10.123456'}` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `2001-01-01` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +EXPLAIN EXTENDED SELECT {ts'2010-01-01 10:10:10'}; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select TIMESTAMP'2010-01-01 10:10:10' AS `{ts'2010-01-01 10:10:10'}` +EXPLAIN EXTENDED SELECT TIMESTAMP'2010-01-01 10:10:10'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select TIMESTAMP'2010-01-01 10:10:10' AS `TIMESTAMP'2010-01-01 10:10:10'` +# +# Testing nanosecond rounding for TIMESTAMP literals with bad dates +# +SELECT TIMESTAMP'2001-00-00 00:00:00.999999'; +TIMESTAMP'2001-00-00 00:00:00.999999' +2001-00-00 00:00:00.999999 +SELECT TIMESTAMP'2001-00-01 00:00:00.999999'; +TIMESTAMP'2001-00-01 00:00:00.999999' +2001-00-01 00:00:00.999999 +SELECT TIMESTAMP'2001-01-00 00:00:00.999999'; +TIMESTAMP'2001-01-00 00:00:00.999999' +2001-01-00 00:00:00.999999 +SELECT TIMESTAMP'2001-00-00 00:00:00.9999999'; +ERROR HY000: Incorrect DATETIME value: '2001-00-00 00:00:00.9999999' +SELECT TIMESTAMP'2001-00-01 00:00:00.9999999'; +ERROR HY000: Incorrect DATETIME value: '2001-00-01 00:00:00.9999999' +SELECT TIMESTAMP'2001-01-00 00:00:00.9999999'; +ERROR HY000: Incorrect DATETIME value: '2001-01-00 00:00:00.9999999' +# +# String literal with bad dates and nanoseconds to DATETIME(N) +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +SELECT * FROM t1; +a +2001-00-00 00:00:00.999999 +2001-00-01 00:00:00.999999 +2001-01-00 00:00:00.999999 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(5)); +INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +SELECT * FROM t1; +a +2001-00-00 00:00:00.99999 +2001-00-01 00:00:00.99999 +2001-01-00 00:00:00.99999 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +SELECT * FROM t1; +a +2001-00-00 00:00:00 +2001-00-01 00:00:00 +2001-01-00 00:00:00 +DROP TABLE t1; +# +# Testing Item_date_literal::eq +# +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01'),('2003-01-01'); +SELECT * FROM t1 WHERE a BETWEEN DATE'2001-01-01' AND DATE'2002-01-01'; +a +2001-01-01 +SELECT DATE'2001-01-01' FROM t1 GROUP BY DATE'2001-01-01'; +DATE'2001-01-01' +2001-01-01 +DROP TABLE t1; +# +# TIME literals in no-zero date context +# +SELECT TO_DAYS(TIME'00:00:00'); +TO_DAYS(TIME'00:00:00') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT TO_SECONDS(TIME'00:00:00'); +TO_SECONDS(TIME'00:00:00') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT DAYOFYEAR(TIME'00:00:00'); +DAYOFYEAR(TIME'00:00:00') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT WEEK(TIME'00:00:00'); +WEEK(TIME'00:00:00') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT YEARWEEK(TIME'00:00:00'); +YEARWEEK(TIME'00:00:00') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT WEEKDAY(TIME'00:00:00'); +WEEKDAY(TIME'00:00:00') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT CONVERT_TZ(TIME'00:00:00','+00:00','+01:00'); +CONVERT_TZ(TIME'00:00:00','+00:00','+01:00') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT DATE_ADD(TIME'00:00:00', INTERVAL 1 HOUR); +DATE_ADD(TIME'00:00:00', INTERVAL 1 HOUR) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT TIMESTAMPDIFF(SECOND,TIME'00:00:00', TIME'00:00:00'); +TIMESTAMPDIFF(SECOND,TIME'00:00:00', TIME'00:00:00') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +# +# Testing Item_func::fix_fields() +# +SELECT 'a' LIKE 'a' ESCAPE DATE'2001-01-01'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT 'a' LIKE 'a' ESCAPE TIMESTAMP'2001-01-01 00:00:00'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT 'a' LIKE 'a' ESCAPE TIME'00:00:00'; +ERROR HY000: Incorrect arguments to ESCAPE diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 64e8225530b..9cbc941402e 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -74,11 +74,11 @@ select 10E+0+'10'; # The following cast creates warnings -select CONVERT(DATE "2004-01-22 21:45:33" USING latin1); -select CONVERT(DATE "2004-01-22 21:45:33",CHAR); -select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)); -select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)); -select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)); +select CONVERT(TIMESTAMP "2004-01-22 21:45:33" USING latin1); +select CONVERT(TIMESTAMP "2004-01-22 21:45:33",CHAR); +select CONVERT(TIMESTAMP "2004-01-22 21:45:33",CHAR(4)); +select CONVERT(TIMESTAMP "2004-01-22 21:45:33",BINARY(4)); +select CAST(TIMESTAMP "2004-01-22 21:45:33" AS BINARY(4)); select CAST(0xb3 as signed); select CAST(0x8fffffffffffffff as signed); select CAST(0xffffffffffffffff as unsigned); diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index a743ad45568..ea8faec0d51 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -60,8 +60,8 @@ insert into t1(c2,c3) values ("Test row",'2010-01-01 00:00:00'); SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; SELECT count(*) FROM t1 p where c3 in -(select c3 from t1 t where t.c3 < date '2011-04-26 19:19:44' - and t.c3 > date '2011-04-26 19:18:44') ; +(select c3 from t1 t where t.c3 < timestamp '2011-04-26 19:19:44' + and t.c3 > timestamp '2011-04-26 19:18:44') ; DROP TABLE t1; diff --git a/mysql-test/t/temporal_literal.test b/mysql-test/t/temporal_literal.test new file mode 100644 index 00000000000..5d67f64a6f5 --- /dev/null +++ b/mysql-test/t/temporal_literal.test @@ -0,0 +1,217 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +SET NAMES latin1; + + +--echo # +--echo # Testing DATE literals +--echo # +--error ER_WRONG_VALUE +SELECT DATE'xxxx'; +--error ER_WRONG_VALUE +SELECT DATE'01'; +--error ER_WRONG_VALUE +SELECT DATE'01-01'; +--error ER_WRONG_VALUE +SELECT DATE'2001'; +--error ER_WRONG_VALUE +SELECT DATE'2001-01'; +SELECT DATE'2001-00-00'; +SELECT DATE'2001-01-00'; +SELECT DATE'0000-00-00'; +--error ER_WRONG_VALUE +SELECT DATE'2001-01-01 00:00:00'; +SELECT DATE'01:01:01'; +SELECT DATE'01-01-01'; +SELECT DATE'2010-01-01'; +SELECT DATE '2010-01-01'; +CREATE TABLE t1 AS SELECT DATE'2010-01-01'; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT + {d'2001-01-01'}, + { d '2001-01-01' }, + {d'2001-01-01 10:10:10'}; +SHOW CREATE TABLE t1; +DROP TABLE t1; +EXPLAIN EXTENDED SELECT {d'2010-01-01'}; +EXPLAIN EXTENDED SELECT DATE'2010-01-01'; + +--echo # +--echo # Testing DATE literals in non-default sql_mode +--echo # +SET sql_mode=no_zero_in_date; +--error ER_WRONG_VALUE +SELECT DATE'2001-00-00'; +--error ER_WRONG_VALUE +SELECT DATE'2001-01-00'; +SELECT DATE'0000-00-00'; + +SET sql_mode=no_zero_date; +--error ER_WRONG_VALUE +SELECT DATE'0000-00-00'; +SET sql_mode=default; + +--echo # +--echo # Testing TIME literals +--echo # +--error ER_WRONG_VALUE +SELECT TIME'xxxx'; +--error ER_WRONG_VALUE +SELECT TIME'900:00:00'; +--error ER_WRONG_VALUE +SELECT TIME'-900:00:00'; +SELECT TIME'1 24:00:00'; +SELECT TIME'30 24:00:00'; +--error ER_WRONG_VALUE +SELECT TIME'0000-00-00 00:00:00'; +--error ER_WRONG_VALUE +SELECT TIME'40 24:00:00'; +SELECT TIME'10'; +SELECT TIME'10:10'; +SELECT TIME'10:11.12'; +SELECT TIME'10:10:10'; +SELECT TIME'10:10:10.'; +SELECT TIME'10:10:10.1'; +SELECT TIME'10:10:10.12'; +SELECT TIME'10:10:10.123'; +SELECT TIME'10:10:10.1234'; +SELECT TIME'10:10:10.12345'; +SELECT TIME'10:10:10.123456'; +SELECT TIME'-10:00:00'; +SELECT TIME '10:11:12'; +CREATE TABLE t1 AS SELECT + TIME'10:10:10', + TIME'10:10:10.', + TIME'10:10:10.1', + TIME'10:10:10.12', + TIME'10:10:10.123', + TIME'10:10:10.1234', + TIME'10:10:10.12345', + TIME'10:10:10.123456'; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT + {t'10:10:10'}, + { t '10:10:10' }, + {t'10:10:10.'}, + {t'10:10:10.123456'}, + {t'2001-01-01'}; +SHOW CREATE TABLE t1; +DROP TABLE t1; +EXPLAIN EXTENDED SELECT {t'10:01:01'}; +EXPLAIN EXTENDED SELECT TIME'10:01:01'; + + +--echo # +--echo # Testing TIMESTAMP literals +--echo # +--error ER_WRONG_VALUE +SELECT TIMESTAMP'xxxx'; +--error ER_WRONG_VALUE +SELECT TIMESTAMP'2010'; +--error ER_WRONG_VALUE +SELECT TIMESTAMP'2010-01'; +--error ER_WRONG_VALUE +SELECT TIMESTAMP'2010-01-01'; +SELECT TIMESTAMP'2010-01-01 00'; +SELECT TIMESTAMP'2010-01-01 00:01'; +SELECT TIMESTAMP'2010-01-01 10:10:10'; +SELECT TIMESTAMP'2010-01-01 10:10:10.'; +SELECT TIMESTAMP'2010-01-01 10:10:10.1'; +SELECT TIMESTAMP'2010-01-01 10:10:10.12'; +SELECT TIMESTAMP'2010-01-01 10:10:10.123'; +SELECT TIMESTAMP'2010-01-01 10:10:10.1234'; +SELECT TIMESTAMP'2010-01-01 10:10:10.12345'; +SELECT TIMESTAMP'2010-01-01 10:10:10.123456'; +SELECT TIMESTAMP '2010-01-01 10:20:30'; +CREATE TABLE t1 AS SELECT + TIMESTAMP'2010-01-01 10:10:10', + TIMESTAMP'2010-01-01 10:10:10.', + TIMESTAMP'2010-01-01 10:10:10.1', + TIMESTAMP'2010-01-01 10:10:10.12', + TIMESTAMP'2010-01-01 10:10:10.123', + TIMESTAMP'2010-01-01 10:10:10.1234', + TIMESTAMP'2010-01-01 10:10:10.12345', + TIMESTAMP'2010-01-01 10:10:10.123456'; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT + {ts'2001-01-01 10:10:10'}, + { ts '2001-01-01 10:10:10' }, + {ts'2001-01-01 10:10:10.'}, + {ts'2001-01-01 10:10:10.123456'}, + {ts'2001-01-01'}; +SHOW CREATE TABLE t1; +DROP TABLE t1; +EXPLAIN EXTENDED SELECT {ts'2010-01-01 10:10:10'}; +EXPLAIN EXTENDED SELECT TIMESTAMP'2010-01-01 10:10:10'; + +--echo # +--echo # Testing nanosecond rounding for TIMESTAMP literals with bad dates +--echo # +SELECT TIMESTAMP'2001-00-00 00:00:00.999999'; +SELECT TIMESTAMP'2001-00-01 00:00:00.999999'; +SELECT TIMESTAMP'2001-01-00 00:00:00.999999'; +--error ER_WRONG_VALUE +SELECT TIMESTAMP'2001-00-00 00:00:00.9999999'; +--error ER_WRONG_VALUE +SELECT TIMESTAMP'2001-00-01 00:00:00.9999999'; +--error ER_WRONG_VALUE +SELECT TIMESTAMP'2001-01-00 00:00:00.9999999'; + +--echo # +--echo # String literal with bad dates and nanoseconds to DATETIME(N) +--echo # +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999'); +INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999'); +INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999'); +SELECT * FROM t1; +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(5)); +INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999'); +INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999'); +INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999'); +SELECT * FROM t1; +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999'); +INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999'); +INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999'); +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # Testing Item_date_literal::eq +--echo # +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01'),('2003-01-01'); +SELECT * FROM t1 WHERE a BETWEEN DATE'2001-01-01' AND DATE'2002-01-01'; +SELECT DATE'2001-01-01' FROM t1 GROUP BY DATE'2001-01-01'; +DROP TABLE t1; + +--echo # +--echo # TIME literals in no-zero date context +--echo # +SELECT TO_DAYS(TIME'00:00:00'); +SELECT TO_SECONDS(TIME'00:00:00'); +SELECT DAYOFYEAR(TIME'00:00:00'); +SELECT WEEK(TIME'00:00:00'); +SELECT YEARWEEK(TIME'00:00:00'); +SELECT WEEKDAY(TIME'00:00:00'); +SELECT CONVERT_TZ(TIME'00:00:00','+00:00','+01:00'); +SELECT DATE_ADD(TIME'00:00:00', INTERVAL 1 HOUR); +SELECT TIMESTAMPDIFF(SECOND,TIME'00:00:00', TIME'00:00:00'); + +--echo # +--echo # Testing Item_func::fix_fields() +--echo # +--error ER_WRONG_ARGUMENTS +SELECT 'a' LIKE 'a' ESCAPE DATE'2001-01-01'; +--error ER_WRONG_ARGUMENTS +SELECT 'a' LIKE 'a' ESCAPE TIMESTAMP'2001-01-01 00:00:00'; +--error ER_WRONG_ARGUMENTS +SELECT 'a' LIKE 'a' ESCAPE TIME'00:00:00'; diff --git a/sql-common/my_time.c b/sql-common/my_time.c index d4093bb4df9..03701f61ae9 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -130,6 +130,7 @@ static int get_digits(uint *val, uint *number_of_fields, const char **str, return get_number(val, number_of_fields, str, min(end, *str + length)); } + static int get_punct(const char **str, const char *end) { if (*str >= end) @@ -203,6 +204,24 @@ static uint skip_digits(const char **str, const char *end) return s - start; } + +static void get_microseconds(ulong *val, MYSQL_TIME_STATUS *status, + uint *number_of_fields, + const char **str, const char *end) +{ + const char *start= *str; + uint tmp= 0; /* For the case '10:10:10.' */ + if (get_digits(&tmp, number_of_fields, str, end, 6)) + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; + if ((status->precision= (*str - start)) < 6) + *val= tmp * log_10_int[6 - (*str - start)]; + else + *val= tmp; + if (skip_digits(str, end)) + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; +} + + /* Convert a timestamp string to a MYSQL_TIME value. @@ -217,9 +236,8 @@ static uint skip_digits(const char **str, const char *end) TIME_NO_ZERO_IN_DATE Don't allow partial dates TIME_NO_ZERO_DATE Don't allow 0000-00-00 date TIME_INVALID_DATES Allow 2000-02-31 - was_cut 0 Value OK - 1 If value was cut during conversion - 2 check_date(date,flags) considers date invalid + status Conversion status + DESCRIPTION At least the following formats are recogniced (based on number of digits) @@ -230,20 +248,29 @@ static uint skip_digits(const char **str, const char *end) The second part may have an optional .###### fraction part. - RETURN VALUES + status->warnings is set to: + 0 Value OK + MYSQL_TIME_WARN_TRUNCATED If value was cut during conversion + MYSQL_TIME_WARN_OUT_OF_RANGE check_date(date,flags) considers date invalid + + l_time->time_type is set as follows: MYSQL_TIMESTAMP_NONE String wasn't a timestamp, like [DD [HH:[MM:[SS]]]].fraction. + l_time is not changed. MYSQL_TIMESTAMP_DATE DATE string (YY MM and DD parts ok) MYSQL_TIMESTAMP_DATETIME Full timestamp MYSQL_TIMESTAMP_ERROR Timestamp with wrong values. All elements in l_time is set to 0 + RETURN VALUES + 0 - Ok + 1 - Error */ #define MAX_DATE_PARTS 8 -enum enum_mysql_timestamp_type +my_bool str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, - ulonglong flags, int *was_cut) + ulonglong flags, MYSQL_TIME_STATUS *status) { const char *end=str+length, *pos; uint number_of_fields= 0, digits, year_length, not_zero_date; @@ -252,19 +279,20 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, if (flags & TIME_TIME_ONLY) { - enum enum_mysql_timestamp_type ret; - ret= str_to_time(str, length, l_time, flags, was_cut); + my_bool ret= str_to_time(str, length, l_time, flags, status); DBUG_RETURN(ret); } - *was_cut= 0; + + my_time_status_init(status); /* Skip space at start */ for (; str != end && my_isspace(&my_charset_latin1, *str) ; str++) ; if (str == end || ! my_isdigit(&my_charset_latin1, *str)) { - *was_cut= 1; - DBUG_RETURN(MYSQL_TIMESTAMP_NONE); + status->warnings= MYSQL_TIME_WARN_TRUNCATED; + l_time->time_type= MYSQL_TIMESTAMP_NONE; + DBUG_RETURN(1); } /* @@ -293,50 +321,49 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, (only numbers like [YY]YYMMDD[T][hhmmss[.uuuuuu]]) */ year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2; - *was_cut= get_digits(&l_time->year, &number_of_fields, &str, end, year_length) - || get_digits(&l_time->month, &number_of_fields, &str, end, 2) - || get_digits(&l_time->day, &number_of_fields, &str, end, 2) - || get_maybe_T(&str, end) - || get_digits(&l_time->hour, &number_of_fields, &str, end, 2) - || get_digits(&l_time->minute, &number_of_fields, &str, end, 2) - || get_digits(&l_time->second, &number_of_fields, &str, end, 2); + if (get_digits(&l_time->year, &number_of_fields, &str, end, year_length) + || get_digits(&l_time->month, &number_of_fields, &str, end, 2) + || get_digits(&l_time->day, &number_of_fields, &str, end, 2) + || get_maybe_T(&str, end) + || get_digits(&l_time->hour, &number_of_fields, &str, end, 2) + || get_digits(&l_time->minute, &number_of_fields, &str, end, 2) + || get_digits(&l_time->second, &number_of_fields, &str, end, 2)) + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; } else { const char *start= str; - *was_cut = get_number(&l_time->year, &number_of_fields, &str, end); + if (get_number(&l_time->year, &number_of_fields, &str, end)) + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; year_length= str - start; - if (!*was_cut) - *was_cut= get_punct(&str, end) - || get_number(&l_time->month, &number_of_fields, &str, end) - || get_punct(&str, end) - || get_number(&l_time->day, &number_of_fields, &str, end) - || get_date_time_separator(&number_of_fields, flags, &str, end) - || get_number(&l_time->hour, &number_of_fields, &str, end) - || get_punct(&str, end) - || get_number(&l_time->minute, &number_of_fields, &str, end) - || get_punct(&str, end) - || get_number(&l_time->second, &number_of_fields, &str, end); + if (!status->warnings && + (get_punct(&str, end) + || get_number(&l_time->month, &number_of_fields, &str, end) + || get_punct(&str, end) + || get_number(&l_time->day, &number_of_fields, &str, end) + || get_date_time_separator(&number_of_fields, flags, &str, end) + || get_number(&l_time->hour, &number_of_fields, &str, end) + || get_punct(&str, end) + || get_number(&l_time->minute, &number_of_fields, &str, end) + || get_punct(&str, end) + || get_number(&l_time->second, &number_of_fields, &str, end))) + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; } - if (number_of_fields < 3) - *was_cut= 1; - /* we're ok if date part is correct. even if the rest is truncated */ - if (*was_cut && number_of_fields < 3) - DBUG_RETURN(MYSQL_TIMESTAMP_NONE); - - if (!*was_cut && str < end && *str == '.') + if (number_of_fields < 3) { - uint second_part; - const char *start= ++str; - *was_cut= get_digits(&second_part, &number_of_fields, &str, end, 6); - if (str - start < 6) - second_part*= log_10_int[6 - (str - start)]; - l_time->second_part= second_part; - if (skip_digits(&str, end)) - *was_cut= 1; + l_time->time_type= MYSQL_TIMESTAMP_NONE; + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; + DBUG_RETURN(TRUE); + } + + if (!status->warnings && str < end && *str == '.') + { + str++; + get_microseconds(&l_time->second_part, status, + &number_of_fields, &str, end); } not_zero_date = l_time->year || l_time->month || l_time->day || @@ -349,11 +376,11 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, if (l_time->year > 9999 || l_time->month > 12 || l_time->day > 31 || l_time->hour > 23 || l_time->minute > 59 || l_time->second > 59) { - *was_cut= 1; + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; goto err; } - if (check_date(l_time, not_zero_date, flags, was_cut)) + if (check_date(l_time, not_zero_date, flags, &status->warnings)) goto err; l_time->time_type= (number_of_fields <= 3 ? @@ -363,16 +390,17 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, { if (!my_isspace(&my_charset_latin1,*str)) { - *was_cut= 1; + status->warnings= MYSQL_TIME_WARN_TRUNCATED; break; } } - DBUG_RETURN(l_time->time_type); + DBUG_RETURN(FALSE); err: bzero((char*) l_time, sizeof(*l_time)); - DBUG_RETURN(MYSQL_TIMESTAMP_ERROR); + l_time->time_type= MYSQL_TIMESTAMP_ERROR; + DBUG_RETURN(TRUE); } @@ -387,23 +415,26 @@ err: There may be an optional [.second_part] after seconds length Length of str l_time Store result here - warning Set MYSQL_TIME_WARN_TRUNCATED flag if the input string - was cut during conversion, and/or - MYSQL_TIME_WARN_OUT_OF_RANGE flag, if the value is - out of range. + status Conversion status + NOTES + Because of the extra days argument, this function can only work with times where the time arguments are in the above order. + status->warnings is set as follows: + MYSQL_TIME_WARN_TRUNCATED if the input string was cut during conversion, + and/or + MYSQL_TIME_WARN_OUT_OF_RANGE flag is set if the value is out of range. + RETURN - MYSQL_TIMESTAMP_TIME - MYSQL_TIMESTAMP_ERROR + FALSE on success + TRUE on error */ -enum enum_mysql_timestamp_type -str_to_time(const char *str, uint length, MYSQL_TIME *l_time, - ulonglong fuzzydate, int *warning) +my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time, + ulonglong fuzzydate, MYSQL_TIME_STATUS *status) { ulong date[5]; ulonglong value; @@ -411,7 +442,7 @@ str_to_time(const char *str, uint length, MYSQL_TIME *l_time, my_bool found_days,found_hours, neg= 0; uint UNINIT_VAR(state); - *warning= 0; + my_time_status_init(status); for (; str != end && my_isspace(&my_charset_latin1,*str) ; str++) length--; if (str != end && *str == '-') @@ -421,22 +452,20 @@ str_to_time(const char *str, uint length, MYSQL_TIME *l_time, length--; } if (str == end) - return MYSQL_TIMESTAMP_ERROR; + { + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; + goto err; + } /* Check first if this is a full TIMESTAMP */ if (length >= 12) { /* Probably full timestamp */ - int was_cut; - enum enum_mysql_timestamp_type - res= str_to_datetime(str, length, l_time, + (void) str_to_datetime(str, length, l_time, (fuzzydate & ~TIME_TIME_ONLY) | TIME_DATETIME_ONLY, - &was_cut); - if ((int) res >= (int) MYSQL_TIMESTAMP_ERROR) - { - if (was_cut) - *warning|= MYSQL_TIME_WARN_TRUNCATED; - return res; - } + status); + if (l_time->time_type >= MYSQL_TIMESTAMP_ERROR) + return l_time->time_type == MYSQL_TIMESTAMP_ERROR; + my_time_status_init(status); } l_time->neg= neg; @@ -504,24 +533,15 @@ str_to_time(const char *str, uint length, MYSQL_TIME *l_time, fractional: /* Get fractional second part */ - if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_latin1,str[1])) + if (!status->warnings && str < end && *str == '.') { - int field_length= 5; - str++; value=(uint) (uchar) (*str - '0'); - while (++str != end && my_isdigit(&my_charset_latin1, *str)) - { - if (field_length-- > 0) - value= value*10 + (uint) (uchar) (*str - '0'); - } - if (field_length > 0) - value*= (long) log_10_int[field_length]; - else if (field_length < 0) - *warning|= MYSQL_TIME_WARN_TRUNCATED; - date[4]= (ulong) value; + uint number_of_fields= 0; + str++; + get_microseconds(&date[4], status, &number_of_fields, &str, end); } else - date[4]=0; - + date[4]= 0; + /* Check for exponent part: E | E */ /* (may occur as result of %g formatting of time value) */ if ((end - str) > 1 && @@ -530,7 +550,10 @@ fractional: ((str[1] == '-' || str[1] == '+') && (end - str) > 2 && my_isdigit(&my_charset_latin1, str[2])))) - return MYSQL_TIMESTAMP_ERROR; + { + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; + goto err; + } if (internal_format_positions[7] != 255) { @@ -553,8 +576,11 @@ fractional: if (date[0] > UINT_MAX || date[1] > UINT_MAX || date[2] > UINT_MAX || date[3] > UINT_MAX || date[4] > UINT_MAX) - return MYSQL_TIMESTAMP_ERROR; - + { + status->warnings|= MYSQL_TIME_WARN_OUT_OF_RANGE; + goto err; + } + l_time->year= 0; /* For protocol::store_time */ l_time->month= 0; l_time->day= date[0]; @@ -565,9 +591,9 @@ fractional: l_time->time_type= MYSQL_TIMESTAMP_TIME; /* Check if the value is valid and fits into MYSQL_TIME range */ - if (check_time_range(l_time, 6, warning)) - return MYSQL_TIMESTAMP_ERROR; - + if (check_time_range(l_time, 6, &status->warnings)) + return TRUE; + /* Check if there is garbage at end of the MYSQL_TIME specification */ if (str != end) { @@ -575,12 +601,17 @@ fractional: { if (!my_isspace(&my_charset_latin1,*str)) { - *warning|= MYSQL_TIME_WARN_TRUNCATED; + status->warnings|= MYSQL_TIME_WARN_TRUNCATED; break; } } while (++str != end); } - return MYSQL_TIMESTAMP_TIME; + return FALSE; + +err: + bzero((char*) l_time, sizeof(*l_time)); + l_time->time_type= MYSQL_TIMESTAMP_ERROR; + return TRUE; } @@ -610,7 +641,10 @@ int check_time_range(struct st_mysql_time *my_time, uint dec, int *warning) 999000, 999900, 999990, 999999}; if (my_time->minute >= 60 || my_time->second >= 60) + { + *warning|= MYSQL_TIME_WARN_TRUNCATED; return 1; + } hour= my_time->hour + (24*my_time->day); @@ -1357,7 +1391,7 @@ double TIME_to_double(const MYSQL_TIME *my_time) return my_time->neg ? -d : d; } -longlong pack_time(MYSQL_TIME *my_time) +longlong pack_time(const MYSQL_TIME *my_time) { return ((((((my_time->year * 13ULL + my_time->month) * 32ULL + diff --git a/sql/field.cc b/sql/field.cc index e85903d76c6..8bf9561b586 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1822,7 +1822,7 @@ bool Field::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) String tmp(buff,sizeof(buff),&my_charset_bin),*res; if (!(res=val_str(&tmp)) || str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(), - ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) + ltime, fuzzydate)) return 1; return 0; } @@ -4570,18 +4570,18 @@ int Field_timestamp::store_time_dec(MYSQL_TIME *ltime, uint dec) int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) { MYSQL_TIME l_time; - int error; - int have_smth_to_conv; + MYSQL_TIME_STATUS status; + bool have_smth_to_conv; ErrConvString str(from, len, cs); THD *thd= get_thd(); /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */ - have_smth_to_conv= (str_to_datetime(cs, from, len, &l_time, + have_smth_to_conv= !str_to_datetime(cs, from, len, &l_time, (thd->variables.sql_mode & MODE_NO_ZERO_DATE) | - MODE_NO_ZERO_IN_DATE, &error) > - MYSQL_TIMESTAMP_ERROR); - return store_TIME_with_warning(thd, &l_time, &str, error, have_smth_to_conv); + MODE_NO_ZERO_IN_DATE, &status); + return store_TIME_with_warning(thd, &l_time, &str, + status.warnings, have_smth_to_conv); } @@ -5060,18 +5060,16 @@ int Field_temporal::store_TIME_with_warning(MYSQL_TIME *ltime, int Field_temporal::store(const char *from,uint len,CHARSET_INFO *cs) { MYSQL_TIME ltime; - int error; - enum enum_mysql_timestamp_type func_res; + MYSQL_TIME_STATUS status; THD *thd= get_thd(); ErrConvString str(from, len, cs); - - func_res= str_to_datetime(cs, from, len, <ime, - (TIME_FUZZY_DATE | - (thd->variables.sql_mode & - (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), - &error); - return store_TIME_with_warning(<ime, &str, error, func_res > MYSQL_TIMESTAMP_ERROR); + bool func_res= !str_to_datetime(cs, from, len, <ime, + (TIME_FUZZY_DATE | + (thd->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | + MODE_INVALID_DATES))), + &status); + return store_TIME_with_warning(<ime, &str, status.warnings, func_res); } @@ -5157,16 +5155,17 @@ void Field_time::store_TIME(MYSQL_TIME *ltime) int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) { MYSQL_TIME ltime; + MYSQL_TIME_STATUS status; ErrConvString str(from, len, cs); - int was_cut; - int have_smth_to_conv= - str_to_time(cs, from, len, <ime, + bool have_smth_to_conv= + !str_to_time(cs, from, len, <ime, get_thd()->variables.sql_mode & (MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE | MODE_INVALID_DATES), - &was_cut) > MYSQL_TIMESTAMP_ERROR; + &status); - return store_TIME_with_warning(<ime, &str, was_cut, have_smth_to_conv); + return store_TIME_with_warning(<ime, &str, + status.warnings, have_smth_to_conv); } diff --git a/sql/item.cc b/sql/item.cc index a5d5cf61496..d1fd2fc82ae 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -377,6 +377,27 @@ my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value) } +longlong Item::val_int_from_date() +{ + DBUG_ASSERT(fixed == 1); + MYSQL_TIME ltime; + if (get_date(<ime, TIME_FUZZY_DATE)) + return 0; + longlong v= TIME_to_ulonglong(<ime); + return ltime.neg ? -v : v; +} + + +double Item::val_real_from_date() +{ + DBUG_ASSERT(fixed == 1); + MYSQL_TIME ltime; + if (get_date(<ime, TIME_FUZZY_DATE)) + return 0; + return TIME_to_double(<ime); +} + + double Item::val_real_from_decimal() { /* Note that fix_fields may not be called for Item_avg_field items */ @@ -1269,7 +1290,7 @@ bool Item::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) String tmp(buff,sizeof(buff), &my_charset_bin),*res; if (!(res=val_str(&tmp)) || str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(), - ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) + ltime, fuzzydate)) goto err; break; } @@ -6286,6 +6307,76 @@ Item_bin_string::Item_bin_string(const char *str, uint str_length) } +bool Item_temporal_literal::eq(const Item *item, bool binary_cmp) const +{ + return + item->basic_const_item() && type() == item->type() && + field_type() == ((Item_temporal_literal *) item)->field_type() && + !my_time_compare(&cached_time, + &((Item_temporal_literal *) item)->cached_time); +} + + +void Item_date_literal::print(String *str, enum_query_type query_type) +{ + str->append("DATE'"); + char buf[MAX_DATE_STRING_REP_LENGTH]; + my_date_to_str(&cached_time, buf); + str->append(buf); + str->append('\''); +} + + +bool Item_date_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) +{ + DBUG_ASSERT(fixed); + *ltime= cached_time; + return (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); +} + + +void Item_datetime_literal::print(String *str, enum_query_type query_type) +{ + str->append("TIMESTAMP'"); + char buf[MAX_DATE_STRING_REP_LENGTH]; + my_datetime_to_str(&cached_time, buf, decimals); + str->append(buf); + str->append('\''); +} + + +bool Item_datetime_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) +{ + DBUG_ASSERT(fixed); + *ltime= cached_time; + return (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); +} + + +void Item_time_literal::print(String *str, enum_query_type query_type) +{ + str->append("TIME'"); + char buf[MAX_DATE_STRING_REP_LENGTH]; + my_time_to_str(&cached_time, buf, decimals); + str->append(buf); + str->append('\''); +} + + +bool Item_time_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) +{ + DBUG_ASSERT(fixed); + *ltime= cached_time; + if (fuzzy_date & TIME_TIME_ONLY) + return (null_value= false); + return (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); +} + + + /** Pack data in buffer for sending. */ diff --git a/sql/item.h b/sql/item.h index 1a373da9ba5..a298f16a93b 100644 --- a/sql/item.h +++ b/sql/item.h @@ -599,7 +599,8 @@ public: SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER, PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM, XPATH_NODESET, XPATH_NODESET_CMP, - VIEW_FIXER_ITEM, EXPR_CACHE_ITEM}; + VIEW_FIXER_ITEM, EXPR_CACHE_ITEM, + DATE_ITEM}; enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; @@ -956,7 +957,9 @@ public: my_decimal *val_decimal_from_date(my_decimal *decimal_value); my_decimal *val_decimal_from_time(my_decimal *decimal_value); longlong val_int_from_decimal(); + longlong val_int_from_date(); double val_real_from_decimal(); + double val_real_from_date(); int save_time_in_field(Field *field); int save_date_in_field(Field *field); @@ -1113,8 +1116,8 @@ public: */ virtual CHARSET_INFO *charset_for_protocol(void) const { - return result_type() == STRING_RESULT ? collation.collation : - &my_charset_bin; + return cmp_type() == STRING_RESULT ? collation.collation : + &my_charset_bin; }; virtual bool walk(Item_processor processor, bool walk_subquery, uchar *arg) @@ -2877,6 +2880,110 @@ public: Item_bin_string(const char *str,uint str_length); }; + +class Item_temporal_literal :public Item_basic_constant +{ + //sql_mode= current_thd->variables.sql_mode & + // (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE); +protected: + MYSQL_TIME cached_time; +public: + /** + Constructor for Item_date_literal. + @param ltime DATE value. + */ + Item_temporal_literal(MYSQL_TIME *ltime) :Item_basic_constant() + { + collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII); + decimals= 0; + cached_time= *ltime; + } + Item_temporal_literal(MYSQL_TIME *ltime, uint dec_arg) :Item_basic_constant() + { + collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII); + decimals= dec_arg; + cached_time= *ltime; + } + bool basic_const_item() const { return true; } + bool const_item() const { return true; } + enum Type type() const { return DATE_ITEM; } + bool eq(const Item *item, bool binary_cmp) const; + enum Item_result result_type () const { return STRING_RESULT; } + Item_result cmp_type() const { return TIME_RESULT; } + + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool check_vcol_func_processor(uchar *arg) { return FALSE;} + + String *val_str(String *str) + { return val_string_from_date(str); } + longlong val_int() + { return val_int_from_date(); } + double val_real() + { return val_real_from_date(); } + my_decimal *val_decimal(my_decimal *decimal_value) + { return val_decimal_from_date(decimal_value); } + Field *tmp_table_field(TABLE *table) + { return tmp_table_field_from_field_type(table, 0); } + int save_in_field(Field *field, bool no_conversions) + { return save_date_in_field(field); } +}; + + +/** + DATE'2010-01-01' +*/ +class Item_date_literal: public Item_temporal_literal +{ +public: + Item_date_literal(MYSQL_TIME *ltime) + :Item_temporal_literal(ltime) + { + max_length= MAX_DATE_WIDTH; + fixed= 1; + } + enum_field_types field_type() const { return MYSQL_TYPE_DATE; } + void print(String *str, enum_query_type query_type); + bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); +}; + + +/** + TIME'10:10:10' +*/ +class Item_time_literal: public Item_temporal_literal +{ +public: + Item_time_literal(MYSQL_TIME *ltime, uint dec_arg) + :Item_temporal_literal(ltime, dec_arg) + { + max_length= MIN_TIME_WIDTH + (decimals ? decimals + 1 : 0); + fixed= 1; + } + enum_field_types field_type() const { return MYSQL_TYPE_TIME; } + void print(String *str, enum_query_type query_type); + bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); +}; + + +/** + TIMESTAMP'2001-01-01 10:20:30' +*/ +class Item_datetime_literal: public Item_temporal_literal +{ +public: + Item_datetime_literal(MYSQL_TIME *ltime, uint dec_arg) + :Item_temporal_literal(ltime, dec_arg) + { + max_length= MAX_DATETIME_WIDTH + (decimals ? decimals + 1 : 0); + fixed= 1; + } + enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } + void print(String *str, enum_query_type query_type); + bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); +}; + + + class Item_result_field :public Item /* Item with result field */ { public: diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 5f62ee946a5..057d75676dc 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -721,31 +721,31 @@ bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type, const char *warn_name, MYSQL_TIME *l_time) { bool value; - int error; - enum_mysql_timestamp_type timestamp_type; + MYSQL_TIME_STATUS status; int flags= TIME_FUZZY_DATE | MODE_INVALID_DATES; ErrConvString err(str); - if (warn_type == MYSQL_TIMESTAMP_TIME) - flags|= TIME_TIME_ONLY; + DBUG_ASSERT(warn_type != MYSQL_TIMESTAMP_TIME); - timestamp_type= - str_to_datetime(str->charset(), str->ptr(), str->length(), - l_time, flags, &error); - - if (timestamp_type > MYSQL_TIMESTAMP_ERROR) + if (!str_to_datetime(str->charset(), str->ptr(), str->length(), + l_time, flags, &status)) + { + DBUG_ASSERT(l_time->time_type == MYSQL_TIMESTAMP_DATETIME || + l_time->time_type == MYSQL_TIMESTAMP_DATE); /* Do not return yet, we may still want to throw a "trailing garbage" warning. */ value= FALSE; + } else { + DBUG_ASSERT(l_time->time_type != MYSQL_TIMESTAMP_TIME); + DBUG_ASSERT(status.warnings != 0); // Must be set by set_to_datetime() value= TRUE; - error= 1; /* force warning */ } - if (error > 0) + if (status.warnings > 0) make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, &err, warn_type, warn_name); diff --git a/sql/item_create.cc b/sql/item_create.cc index ce4dc7ced8f..c6d0f09907b 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -32,6 +32,7 @@ #include "set_var.h" #include "sp_head.h" #include "sp.h" +#include "sql_time.h" /* ============================================================================= @@ -5821,6 +5822,70 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, } +/** + Builder for datetime literals: + TIME'00:00:00', DATE'2001-01-01', TIMESTAMP'2001-01-01 00:00:00'. + @param thd The current thread + @param str Character literal + @param length Length of str + @param type Type of literal (TIME, DATE or DATETIME) + @param send_error Whether to generate an error on failure +*/ + +Item *create_temporal_literal(THD *thd, + const char *str, uint length, + CHARSET_INFO *cs, + enum_field_types type, + bool send_error) +{ + MYSQL_TIME_STATUS status; + MYSQL_TIME ltime; + Item *item= NULL; + ulonglong datetime_flags= thd->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | + MODE_NO_ZERO_DATE | + MODE_INVALID_DATES); + ulonglong flags= TIME_FUZZY_DATE | datetime_flags; + + switch(type) + { + case MYSQL_TYPE_DATE: + case MYSQL_TYPE_NEWDATE: + if (!str_to_datetime(cs, str, length, <ime, flags, &status) && + ltime.time_type == MYSQL_TIMESTAMP_DATE && !status.warnings) + item= new (thd->mem_root) Item_date_literal(<ime); + break; + case MYSQL_TYPE_DATETIME: + if (!str_to_datetime(cs, str, length, <ime, flags, &status) && + ltime.time_type == MYSQL_TIMESTAMP_DATETIME && !status.warnings) + item= new (thd->mem_root) Item_datetime_literal(<ime, + status.precision); + break; + case MYSQL_TYPE_TIME: + if (!str_to_time(cs, str, length, <ime, 0, &status) && + ltime.time_type == MYSQL_TIMESTAMP_TIME && !status.warnings) + item= new (thd->mem_root) Item_time_literal(<ime, + status.precision); + break; + default: + DBUG_ASSERT(0); + } + + if (item) + return item; + + if (send_error) + { + const char *typestr= + (type == MYSQL_TYPE_DATE) ? "DATE" : + (type == MYSQL_TYPE_TIME) ? "TIME" : "DATETIME"; + ErrConvString err(str, length, thd->variables.character_set_client); + my_error(ER_WRONG_VALUE, MYF(0), typestr, err.ptr()); + } + return NULL; +} + + static List *create_func_dyncol_prepare(THD *thd, DYNCALL_CREATE_DEF **dfs, List &list) diff --git a/sql/item_create.h b/sql/item_create.h index 5ecb45e9eae..5f1a8c6006d 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -168,6 +168,11 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, const char *len, const char *dec, CHARSET_INFO *cs); +Item *create_temporal_literal(THD *thd, + const char *str, uint length, + CHARSET_INFO *cs, + enum_field_types type, + bool send_error); int item_create_init(); void item_create_cleanup(); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5bf53784c26..9582c7940f1 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -4722,7 +4722,7 @@ bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) if (str_to_datetime_with_warn(&my_charset_numeric, val.x.string.value.str, val.x.string.value.length, - ltime, fuzzy_date) <= MYSQL_TIMESTAMP_ERROR) + ltime, fuzzy_date)) goto null; return 0; case DYN_COL_DATETIME: diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index f43a4e79431..1f3d7bb6265 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2430,17 +2430,8 @@ bool Item_date_typecast::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; ltime->time_type= MYSQL_TIMESTAMP_DATE; - - int unused; - if (check_date(ltime, ltime->year || ltime->month || ltime->day, - fuzzy_date, &unused)) - { - ErrConvTime str(ltime); - make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - &str, MYSQL_TIMESTAMP_DATE, 0); - return (null_value= 1); - } - return (null_value= 0); + return (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_DATE)); } diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 9b2db9e816e..3f58fe09af1 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -489,7 +489,6 @@ public: Item_temporal_func(Item *a, Item *b) :Item_func(a,b) {} Item_temporal_func(Item *a, Item *b, Item *c) :Item_func(a,b,c) {} enum Item_result result_type () const { return STRING_RESULT; } - CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } Item_result cmp_type() const { return TIME_RESULT; } String *val_str(String *str); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 806017b9ae5..7c7239fd400 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14696,6 +14696,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case Item::REAL_ITEM: case Item::DECIMAL_ITEM: case Item::STRING_ITEM: + case Item::DATE_ITEM: case Item::REF_ITEM: case Item::NULL_ITEM: case Item::VARBIN_ITEM: diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 89c2e3b7086..ff2ec62f815 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -214,6 +214,22 @@ ulong convert_month_to_period(ulong month) } +bool +check_date_with_warn(const MYSQL_TIME *ltime, ulonglong fuzzy_date, + timestamp_type ts_type) +{ + int unused; + if (check_date(ltime, fuzzy_date, &unused)) + { + ErrConvTime str(ltime); + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + &str, ts_type, 0); + return true; + } + return false; +} + + /* Convert a string to 8-bit representation, for use in str_to_time/str_to_date/str_to_date. @@ -249,9 +265,9 @@ to_ascii(CHARSET_INFO *cs, /* Character set-aware version of str_to_time() */ -timestamp_type +bool str_to_time(CHARSET_INFO *cs, const char *str,uint length, - MYSQL_TIME *l_time, ulonglong fuzzydate, int *warning) + MYSQL_TIME *l_time, ulonglong fuzzydate, MYSQL_TIME_STATUS *status) { char cnv[32]; if ((cs->state & MY_CS_NONASCII) != 0) @@ -259,14 +275,14 @@ str_to_time(CHARSET_INFO *cs, const char *str,uint length, length= to_ascii(cs, str, length, cnv, sizeof(cnv)); str= cnv; } - return str_to_time(str, length, l_time, fuzzydate, warning); + return str_to_time(str, length, l_time, fuzzydate, status); } /* Character set-aware version of str_to_datetime() */ -timestamp_type str_to_datetime(CHARSET_INFO *cs, - const char *str, uint length, - MYSQL_TIME *l_time, ulonglong flags, int *was_cut) +bool str_to_datetime(CHARSET_INFO *cs, const char *str, uint length, + MYSQL_TIME *l_time, ulonglong flags, + MYSQL_TIME_STATUS *status) { char cnv[32]; if ((cs->state & MY_CS_NONASCII) != 0) @@ -274,7 +290,7 @@ timestamp_type str_to_datetime(CHARSET_INFO *cs, length= to_ascii(cs, str, length, cnv, sizeof(cnv)); str= cnv; } - return str_to_datetime(str, length, l_time, flags, was_cut); + return str_to_datetime(str, length, l_time, flags, status); } @@ -286,26 +302,24 @@ timestamp_type str_to_datetime(CHARSET_INFO *cs, See description of str_to_datetime() for more information. */ -timestamp_type +bool str_to_datetime_with_warn(CHARSET_INFO *cs, const char *str, uint length, MYSQL_TIME *l_time, ulonglong flags) { - int was_cut; + MYSQL_TIME_STATUS status; THD *thd= current_thd; - timestamp_type ts_type; - - ts_type= str_to_datetime(cs, str, length, l_time, + bool ret_val= str_to_datetime(cs, str, length, l_time, (flags | (sql_mode_for_dates(thd))), - &was_cut); - if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR) + &status); + if (ret_val || status.warnings) make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, str, length, flags & TIME_TIME_ONLY ? - MYSQL_TIMESTAMP_TIME : ts_type, NullS); + MYSQL_TIMESTAMP_TIME : l_time->time_type, NullS); DBUG_EXECUTE_IF("str_to_datetime_warn", push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_YES, str);); - return ts_type; + return ret_val; } @@ -1055,7 +1069,7 @@ calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign, longlong *s */ -int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b) +int my_time_compare(const MYSQL_TIME *a, const MYSQL_TIME *b) { ulonglong a_t= pack_time(a); ulonglong b_t= pack_time(b); diff --git a/sql/sql_time.h b/sql/sql_time.h index c1a75bb2ad3..cf029f143b3 100644 --- a/sql/sql_time.h +++ b/sql/sql_time.h @@ -35,11 +35,9 @@ ulong convert_period_to_month(ulong period); ulong convert_month_to_period(ulong month); bool get_date_from_daynr(long daynr,uint *year, uint *month, uint *day); my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, uint *error_code); -bool str_to_time_with_warn(CHARSET_INFO *cs, const char *str, uint length, - MYSQL_TIME *l_time, ulonglong fuzzydate); -timestamp_type str_to_datetime_with_warn(CHARSET_INFO *cs, const char *str, - uint length, MYSQL_TIME *l_time, - ulonglong flags); +bool str_to_datetime_with_warn(CHARSET_INFO *cs, const char *str, + uint length, MYSQL_TIME *l_time, + ulonglong flags); bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime, ulonglong fuzzydate, const char *name); @@ -76,7 +74,7 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval); bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign, longlong *seconds_out, long *microseconds_out); -int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b); +int my_time_compare(const MYSQL_TIME *a, const MYSQL_TIME *b); void localtime_to_TIME(MYSQL_TIME *to, struct tm *from); void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds); uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year); @@ -86,12 +84,14 @@ bool parse_date_time_format(timestamp_type format_type, const char *format, uint format_length, DATE_TIME_FORMAT *date_time_format); /* Character set-aware version of str_to_time() */ -timestamp_type str_to_time(CHARSET_INFO *cs, const char *str,uint length, - MYSQL_TIME *l_time, ulonglong fuzzydate, int *warning); +bool str_to_time(CHARSET_INFO *cs, const char *str,uint length, + MYSQL_TIME *l_time, ulonglong fuzzydate, + MYSQL_TIME_STATUS *status); /* Character set-aware version of str_to_datetime() */ -timestamp_type str_to_datetime(CHARSET_INFO *cs, - const char *str, uint length, - MYSQL_TIME *l_time, ulonglong flags, int *was_cut); +bool str_to_datetime(CHARSET_INFO *cs, + const char *str, uint length, + MYSQL_TIME *l_time, ulonglong flags, + MYSQL_TIME_STATUS *status); /* convenience wrapper */ inline bool parse_date_time_format(timestamp_type format_type, @@ -110,4 +110,18 @@ extern DATE_TIME_FORMAT global_time_format; extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; extern LEX_STRING interval_type_to_name[]; + +static inline bool +non_zero_date(const MYSQL_TIME *ltime) +{ + return ltime->year || ltime->month || ltime->day; +} +static inline bool +check_date(const MYSQL_TIME *ltime, ulonglong flags, int *was_cut) +{ + return check_date(ltime, non_zero_date(ltime), flags, was_cut); +} +bool check_date_with_warn(const MYSQL_TIME *ltime, ulonglong fuzzy_date, + timestamp_type ts_type); + #endif /* SQL_TIME_INCLUDED */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 83b5692d606..0dc8ed7037e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -32,6 +32,7 @@ #define YYTHD ((THD *)yythd) #define YYLIP (& YYTHD->m_parser_state->m_lip) #define YYPS (& YYTHD->m_parser_state->m_yacc) +#define YYCSCL YYTHD->variables.character_set_client #define MYSQL_YACC #define YYINITDEPTH 100 @@ -899,10 +900,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %pure_parser /* We have threads */ /* - Currently there are 170 shift/reduce conflicts. + Currently there are 167 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 170 +%expect 167 /* Comments for TOKENS. @@ -1628,7 +1629,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); replace_lock_option opt_low_priority insert_lock_option load_data_lock %type - literal text_literal insert_ident order_ident + literal text_literal insert_ident order_ident temporal_literal simple_ident expr opt_expr opt_else sum_expr in_sum_expr variable variable_aux bool_pri predicate bit_expr @@ -8741,7 +8742,48 @@ simple_expr: MYSQL_YYABORT; } | '{' ident expr '}' - { $$= $3; } + { + Item_string *item; + $$= NULL; + /* + If "expr" is reasonably short pure ASCII string literal, + try to parse known ODBC style date, time or timestamp literals, + e.g: + SELECT {d'2001-01-01'}; + SELECT {t'10:20:30'}; + SELECT {ts'2001-01-01 10:20:30'}; + */ + if ($3->type() == Item::STRING_ITEM && + (item= (Item_string *) $3) && + item->collation.repertoire == MY_REPERTOIRE_ASCII && + item->str_value.length() < MAX_DATE_STRING_REP_LENGTH * 4) + { + enum_field_types type= MYSQL_TYPE_STRING; + LEX_STRING *ls= &$2; + if (ls->length == 1) + { + if (ls->str[0] == 'd') /* {d'2001-01-01'} */ + type= MYSQL_TYPE_DATE; + else if (ls->str[0] == 't') /* {t'10:20:30'} */ + type= MYSQL_TYPE_TIME; + } + else if (ls->length == 2) /* {ts'2001-01-01 10:20:30'} */ + { + if (ls->str[0] == 't' && ls->str[1] == 's') + type= MYSQL_TYPE_DATETIME; + } + if (type != MYSQL_TYPE_STRING) + { + $$= create_temporal_literal(YYTHD, + item->str_value.ptr(), + item->str_value.length(), + item->str_value.charset(), + type, false); + } + } + if ($$ == NULL) + $$= $3; + } | MATCH ident_list_arg AGAINST '(' bit_expr fulltext_options ')' { $2->push_front($5); @@ -12730,6 +12772,7 @@ signed_literal: literal: text_literal { $$ = $1; } | NUM_literal { $$ = $1; } + | temporal_literal { $$= $1; } | NULL_SYM { $$ = new (YYTHD->mem_root) Item_null(); @@ -12824,9 +12867,6 @@ literal: $$= item_str; } - | DATE_SYM text_literal { $$ = $2; } - | TIME_SYM text_literal { $$ = $2; } - | TIMESTAMP text_literal { $$ = $2; } ; NUM_literal: @@ -12875,6 +12915,31 @@ NUM_literal: } ; + +temporal_literal: + DATE_SYM TEXT_STRING + { + if (!($$= create_temporal_literal(YYTHD, $2.str, $2.length, YYCSCL, + MYSQL_TYPE_DATE, true))) + MYSQL_YYABORT; + } + | TIME_SYM TEXT_STRING + { + if (!($$= create_temporal_literal(YYTHD, $2.str, $2.length, YYCSCL, + MYSQL_TYPE_TIME, true))) + MYSQL_YYABORT; + } + | TIMESTAMP TEXT_STRING + { + if (!($$= create_temporal_literal(YYTHD, $2.str, $2.length, YYCSCL, + MYSQL_TYPE_DATETIME, true))) + MYSQL_YYABORT; + } + ; + + + + /********************************************************************** ** Creating different items. **********************************************************************/ diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index d17de6cd32e..48d127dac2f 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -567,7 +567,7 @@ int spider_db_mysql_result::fetch_table_status( #else my_bool not_used_my_bool; #endif - int not_used_int; + MYSQL_TIME_STATUS time_status; long not_used_long; DBUG_ENTER("spider_db_mysql_result::fetch_table_status"); DBUG_PRINT("info",("spider this=%p", this)); @@ -628,8 +628,9 @@ int spider_db_mysql_result::fetch_table_status( ("spider auto_increment_value=%lld", auto_increment_value)); if (mysql_row[11]) { + my_time_status_init(&time_status); str_to_datetime(mysql_row[11], strlen(mysql_row[11]), &mysql_time, 0, - ¬_used_int); + &time_status); #ifdef MARIADB_BASE_VERSION create_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -650,8 +651,9 @@ int spider_db_mysql_result::fetch_table_status( #endif if (mysql_row[12]) { + my_time_status_init(&time_status); str_to_datetime(mysql_row[12], strlen(mysql_row[12]), &mysql_time, 0, - ¬_used_int); + &time_status); #ifdef MARIADB_BASE_VERSION update_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -672,8 +674,9 @@ int spider_db_mysql_result::fetch_table_status( #endif if (mysql_row[13]) { + my_time_status_init(&time_status); str_to_datetime(mysql_row[13], strlen(mysql_row[13]), &mysql_time, 0, - ¬_used_int); + &time_status); #ifdef MARIADB_BASE_VERSION check_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -737,8 +740,9 @@ int spider_db_mysql_result::fetch_table_status( ("spider auto_increment_value=%lld", auto_increment_value)); if (mysql_row[6]) { + my_time_status_init(&time_status); str_to_datetime(mysql_row[6], strlen(mysql_row[6]), &mysql_time, 0, - ¬_used_int); + &time_status); #ifdef MARIADB_BASE_VERSION create_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -759,8 +763,9 @@ int spider_db_mysql_result::fetch_table_status( #endif if (mysql_row[7]) { + my_time_status_init(&time_status); str_to_datetime(mysql_row[7], strlen(mysql_row[7]), &mysql_time, 0, - ¬_used_int); + &time_status); #ifdef MARIADB_BASE_VERSION update_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -781,8 +786,9 @@ int spider_db_mysql_result::fetch_table_status( #endif if (mysql_row[8]) { + my_time_status_init(&time_status); str_to_datetime(mysql_row[8], strlen(mysql_row[8]), &mysql_time, 0, - ¬_used_int); + &time_status); #ifdef MARIADB_BASE_VERSION check_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint);