From 48450d8a2b7a4e50d8642c1f6fb9415eac5f2e12 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Dec 2005 18:02:36 +0400 Subject: [PATCH 01/15] Fix for bug #15225 (ANALYZE temporary has no effect) mysql-test/r/analyze.result: test result fixed mysql-test/t/analyze.test: test case added sql/sql_table.cc: we don't need to remove temporary table from the cache, but we need to reload it's info --- mysql-test/r/analyze.result | 9 +++++++++ mysql-test/t/analyze.test | 9 +++++++++ sql/sql_table.cc | 13 +++++++++---- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/analyze.result b/mysql-test/r/analyze.result index 796b382f5d6..bded22c4859 100644 --- a/mysql-test/r/analyze.result +++ b/mysql-test/r/analyze.result @@ -37,3 +37,12 @@ Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_ execute stmt1; Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype deallocate prepare stmt1; +create temporary table t1(a int, index(a)); +insert into t1 values('1'),('2'),('3'),('4'),('5'); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A 5 NULL NULL YES BTREE +drop table t1; diff --git a/mysql-test/t/analyze.test b/mysql-test/t/analyze.test index 5d653b65579..a4694c32d3c 100644 --- a/mysql-test/t/analyze.test +++ b/mysql-test/t/analyze.test @@ -48,4 +48,13 @@ execute stmt1; execute stmt1; deallocate prepare stmt1; +# +# bug#15225 (ANALYZE temporary has no effect) +# +create temporary table t1(a int, index(a)); +insert into t1 values('1'),('2'),('3'),('4'),('5'); +analyze table t1; +show index from t1; +drop table t1; + # End of 4.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 294c59af90f..d582c36a4f4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2140,10 +2140,15 @@ send_result_message: table->table->version=0; // Force close of table else if (open_for_modify) { - pthread_mutex_lock(&LOCK_open); - remove_table_from_cache(thd, table->table->table_cache_key, - table->table->real_name, RTFC_NO_FLAG); - pthread_mutex_unlock(&LOCK_open); + if (table->table->tmp_table) + table->table->file->info(HA_STATUS_CONST); + else + { + pthread_mutex_lock(&LOCK_open); + remove_table_from_cache(thd, table->table->table_cache_key, + table->table->real_name, RTFC_NO_FLAG); + pthread_mutex_unlock(&LOCK_open); + } /* May be something modified consequently we have to invalidate cache */ query_cache_invalidate3(thd, table->table, 0); } From 4de90ee7c13d6991a1df8a3dadb4b8446665634e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Apr 2006 17:41:40 +0500 Subject: [PATCH 02/15] bug $17756 (sp_notembedded.test unstable) mysql-test/r/sp_notembedded.result: result fixed mysql-test/t/sp_notembedded.test: test case fixed so as the previous test won't affect the result of SHOW PROCESSLIST command --- mysql-test/r/sp_notembedded.result | 2 ++ mysql-test/t/sp_notembedded.test | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result index d434f5c32ce..1faf8834980 100644 --- a/mysql-test/r/sp_notembedded.result +++ b/mysql-test/r/sp_notembedded.result @@ -1,3 +1,4 @@ +drop table if exists t1,t3; drop procedure if exists bug4902| create procedure bug4902() begin @@ -204,3 +205,4 @@ drop procedure bug10100pv| drop procedure bug10100pd| drop procedure bug10100pc| drop view v1| +drop table t3; diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index 3854297ec0c..ead33ff9968 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -1,6 +1,10 @@ # Can't test with embedded server -- source include/not_embedded.inc +--sleep 2 +--disable_warnings +drop table if exists t1,t3; +--enable_warnings delimiter |; # @@ -260,3 +264,4 @@ drop procedure bug10100pc| drop view v1| delimiter ;| +drop table t3; From 57ecf2b4b417f9f100d56b65413a7133d405809a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 11 Apr 2006 15:01:21 +0500 Subject: [PATCH 03/15] bug #15442 (mysqltest.test doesn't work with the embedded server) mysql-test/mysql-test-run.pl: no ndbcluster needed here mysql-test/mysql-test-run.sh: no ndbcluster needed here mysql-test/t/mysqltest.test: this test shouldn't work with the embedded server --- mysql-test/mysql-test-run.pl | 1 + mysql-test/mysql-test-run.sh | 1 + mysql-test/t/mysqltest.test | 1 + 3 files changed, 3 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 20bb6e0117a..3fcc5b554d8 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -678,6 +678,7 @@ sub command_line_setup () { $glob_use_embedded_server= 1; push(@glob_test_mode, "embedded"); $opt_skip_rpl= 1; # We never run replication with embedded + $opt_skip_ndbcluster= 1; if ( $opt_extern ) { diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index c8d54d7e86c..e74a5ac82d0 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -279,6 +279,7 @@ while test $# -gt 0; do USE_EMBEDDED_SERVER=1 USE_MANAGER=0 NO_SLAVE=1 USE_RUNNING_SERVER="" + USE_NDBCLUSTER="" TEST_MODE="$TEST_MODE embedded" ;; --purify) USE_PURIFY=1 diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index f5c6a7617c5..a15a143e9f4 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1,3 +1,4 @@ +-- source include/not_embedded.inc # ============================================================================ # From f01b0ac2212a8e8c4192842ddba123198353c591 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Apr 2006 22:05:23 +0500 Subject: [PATCH 04/15] bug #15860 (SPATIAL keys in INNODB) mysql-test/r/innodb.result: result added mysql-test/t/innodb.test: testcase sql/ha_myisam.cc: HA_CAN_RTREEKEYS added to ha_myisam sql/handler.h: HA_CAN_RTREEKEYS defined sql/share/errmsg.txt: error message added sql/sql_table.cc: check that the handler allows SPATIAL keys --- mysql-test/r/innodb.result | 2 ++ mysql-test/t/innodb.test | 7 +++++++ sql/ha_myisam.cc | 2 +- sql/handler.h | 1 + sql/share/errmsg.txt | 2 ++ sql/sql_table.cc | 6 ++++++ 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 9a190557211..1e6793c39db 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -3241,3 +3241,5 @@ where t2.a between t1.a - interval 2 day and t1.a + interval 2 day; a a 2005-10-01 2005-10-01 drop table t1, t2; +create table t1 (g geometry not null, spatial gk(g)) engine=innodb; +ERROR HY000: The used table type doesn't support SPATIAL indexes diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index b0835cd8419..b95a6a25f28 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -2139,3 +2139,10 @@ insert into t2 values('2005-10-01'); select * from t1, t2 where t2.a between t1.a - interval 2 day and t1.a + interval 2 day; drop table t1, t2; + +# +# Bug #15680 (SPATIAL key in innodb) +# +--error 1461 +create table t1 (g geometry not null, spatial gk(g)) engine=innodb; + diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index ff6431fa0f3..128cc191434 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -165,7 +165,7 @@ ha_myisam::ha_myisam(TABLE *table_arg) int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | HA_DUPP_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME | - HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD), + HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS), can_enable_indexes(1) {} diff --git a/sql/handler.h b/sql/handler.h index 977bd77a54e..056b11f2526 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -80,6 +80,7 @@ */ #define HA_CAN_INSERT_DELAYED (1 << 14) #define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15) +#define HA_CAN_RTREEKEYS (1 << 17) #define HA_NOT_DELETE_WITH_CACHE (1 << 18) #define HA_NO_PREFIX_CHAR_KEYS (1 << 20) #define HA_CAN_FULLTEXT (1 << 21) diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 37487c245a9..5de070faeb5 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5611,3 +5611,5 @@ ER_TABLE_NEEDS_UPGRADE eng "Table upgrade required. Please do \"REPAIR TABLE `%-.32s`\" to fix it!" ER_SP_NO_AGGREGATE 42000 eng "AGGREGATE is not supported for stored functions" +ER_TABLE_CANT_HANDLE_SPKEYS + eng "The used table type doesn't support SPATIAL indexes" diff --git a/sql/sql_table.cc b/sql/sql_table.cc index cb556acd5c7..f57fb4715d2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1130,6 +1130,12 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, /* TODO: Add proper checks if handler supports key_type and algorithm */ if (key_info->flags & HA_SPATIAL) { + if (!(file->table_flags() & HA_CAN_RTREEKEYS)) + { + my_message(ER_TABLE_CANT_HANDLE_SPKEYS, ER(ER_TABLE_CANT_HANDLE_SPKEYS), + MYF(0)); + DBUG_RETURN(-1); + } if (key_info->key_parts != 1) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "SPATIAL INDEX"); From 4441e34e38acc430a229844a85756891221068a4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Apr 2006 15:13:50 +0500 Subject: [PATCH 05/15] BUG#18160 - Memory-/HEAP Table endless growing indexes Updating data in HEAP table with BTREE index results in wrong index_length counter value, which keeps growing after each update. When inserting new record into tree counter is incremented by: sizeof(TREE_ELEMENT) + key_size + tree->size_of_element But when deleting element from tree it doesn't decrement counter by key_size: sizeof(TREE_ELEMENT) + tree->size_of_element This fix makes accurate allocated memory counter for tree. That is decrease counter by key_size when deleting tree element. heap/hp_delete.c: Added size of the key to tree_delete() for accurate allocated memory counter. include/my_tree.h: Added size of the key to tree_delete() for accurate allocated memory counter. myisam/myisamlog.c: Added size of the key to tree_delete() for accurate allocated memory counter. mysql-test/r/heap_btree.result: Testcase for BUG#18160. mysql-test/t/heap_btree.test: Testcase for BUG#18160. mysys/tree.c: Added size of the key to tree_delete() for accurate allocated memory counter. Note that this size is optional. If one doesn't need precise counter it is safe to pass 0 as key_size. --- heap/hp_delete.c | 3 ++- include/my_tree.h | 2 +- myisam/myisamlog.c | 2 +- mysql-test/r/heap_btree.result | 10 ++++++++++ mysql-test/t/heap_btree.test | 10 ++++++++++ mysys/tree.c | 5 ++--- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/heap/hp_delete.c b/heap/hp_delete.c index 2d94418a1bf..f37db2588f3 100644 --- a/heap/hp_delete.c +++ b/heap/hp_delete.c @@ -79,7 +79,8 @@ int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos); custom_arg.search_flag= SEARCH_SAME; old_allocated= keyinfo->rb_tree.allocated; - res= tree_delete(&keyinfo->rb_tree, info->recbuf, &custom_arg); + res= tree_delete(&keyinfo->rb_tree, info->recbuf, custom_arg.key_length, + &custom_arg); info->s->index_length-= (old_allocated - keyinfo->rb_tree.allocated); return res; } diff --git a/include/my_tree.h b/include/my_tree.h index 14d8593b6dc..03dc9d5c829 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -84,7 +84,7 @@ TREE_ELEMENT *tree_insert(TREE *tree,void *key, uint key_size, void *tree_search(TREE *tree, void *key, void *custom_arg); int tree_walk(TREE *tree,tree_walk_action action, void *argument, TREE_WALK visit); -int tree_delete(TREE *tree, void *key, void *custom_arg); +int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg); void *tree_search_key(TREE *tree, const void *key, TREE_ELEMENT **parents, TREE_ELEMENT ***last_pos, enum ha_rkey_function flag, void *custom_arg); diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index de55b86252c..17af4ab34a2 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -475,7 +475,7 @@ static int examine_log(my_string file_name, char **table_names) { if (!curr_file_info->closed) files_open--; - VOID(tree_delete(&tree, (gptr) curr_file_info, tree.custom_arg)); + VOID(tree_delete(&tree, (gptr) curr_file_info, 0, tree.custom_arg)); } break; case MI_LOG_EXTRA: diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 374d2c63632..b63eaf7e48c 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -246,3 +246,13 @@ DELETE from t1 where a < 100; SELECT * from t1; a DROP TABLE t1; +CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory; +INSERT INTO t1 VALUES(0); +SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1'; +INDEX_LENGTH +21 +UPDATE t1 SET val=1; +SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1'; +INDEX_LENGTH +21 +DROP TABLE t1; diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 5e493c2643b..eadb1fec8ae 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -164,4 +164,14 @@ DELETE from t1 where a < 100; SELECT * from t1; DROP TABLE t1; +# +# BUG#18160 - Memory-/HEAP Table endless growing indexes +# +CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory; +INSERT INTO t1 VALUES(0); +SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1'; +UPDATE t1 SET val=1; +SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1'; +DROP TABLE t1; + # End of 4.1 tests diff --git a/mysys/tree.c b/mysys/tree.c index 1780913961e..0c9c04919b0 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -271,7 +271,7 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size, return element; } -int tree_delete(TREE *tree, void *key, void *custom_arg) +int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg) { int cmp,remove_colour; TREE_ELEMENT *element,***parent, ***org_parent, *nod; @@ -326,8 +326,7 @@ int tree_delete(TREE *tree, void *key, void *custom_arg) rb_delete_fixup(tree,parent); if (tree->free) (*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg); - /* This doesn't include key_size, but better than nothing */ - tree->allocated-= sizeof(TREE_ELEMENT)+tree->size_of_element; + tree->allocated-= sizeof(TREE_ELEMENT) + tree->size_of_element + key_size; my_free((gptr) element,MYF(0)); tree->elements_in_tree--; return 0; From 651c0c18f04e5c6831402916b66777817dd57c75 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Apr 2006 13:07:53 +0500 Subject: [PATCH 06/15] bug #16892 (mysql_client_test fails in embedded server) mysql-test/t/mysql_client_test.test: test disabled in embedded server --- mysql-test/t/mysql_client_test.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 66b57dd5fb7..1225bf73009 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -1,3 +1,6 @@ +# This test should work in embedded server after we fix mysqltest +-- source include/not_embedded.inc + # We run with different binaries for normal and --embedded-server # # If this test fails with "command "$MYSQL_CLIENT_TEST" failed", From 09ad4efa5dbad83d483ae27191cc5f5a1982b7a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Apr 2006 15:27:28 +0500 Subject: [PATCH 07/15] Fix for bug #7643: ALTER TABLE fails for CSV, EXAMPLE, ARCHIVE engines sql/sql_table.cc: Fix for bug #7643: ALTER TABLE fails for CSV, EXAMPLE, ARCHIVE engines - issue an ER_NOT_SUPPORTED_YET if an engine doesn't support ALTER TABLE. --- sql/sql_table.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 71cbc0be1e3..5749ff9c190 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1654,7 +1654,9 @@ mysql_rename_table(enum db_type base, } } delete file; - if (error) + if (error == HA_ERR_WRONG_COMMAND) + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "ALTER TABLE"); + else if (error) my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error); DBUG_RETURN(error != 0); } From 82e938f681c85043386c72a28f85dd23fe930275 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Apr 2006 15:58:27 +0500 Subject: [PATCH 08/15] bug #18455 (embedded server Win32 build) VC++Files/libmysqld/libmysqld.dsp: my_user.c file added VC++Files/libmysqld/libmysqld.vcproj: my_user.c file added VC++Files/libmysqld/libmysqld_ia64.dsp: my_user.c added --- VC++Files/libmysqld/libmysqld.dsp | 4 +++ VC++Files/libmysqld/libmysqld.vcproj | 36 ++++++++++++++++++++++++++ VC++Files/libmysqld/libmysqld_ia64.dsp | 4 +++ 3 files changed, 44 insertions(+) diff --git a/VC++Files/libmysqld/libmysqld.dsp b/VC++Files/libmysqld/libmysqld.dsp index 87a88333a2a..8c1a5271656 100644 --- a/VC++Files/libmysqld/libmysqld.dsp +++ b/VC++Files/libmysqld/libmysqld.dsp @@ -363,6 +363,10 @@ SOURCE=..\mysys\my_getopt.c SOURCE=..\sql-common\my_time.c # End Source File # Begin Source File + +SOURCE=..\sql-common\my_user.c +# End Source File +# Begin Source File SOURCE=..\sql\net_serv.cpp # End Source File diff --git a/VC++Files/libmysqld/libmysqld.vcproj b/VC++Files/libmysqld/libmysqld.vcproj index 47fb660bb7a..fe791d702a3 100644 --- a/VC++Files/libmysqld/libmysqld.vcproj +++ b/VC++Files/libmysqld/libmysqld.vcproj @@ -2009,6 +2009,42 @@ PreprocessorDefinitions="WIN32;_WINDOWS;USE_SYMDIR;SIGNAL_WITH_VIO_CLOSE;HAVE_DLOPEN;EMBEDDED_LIBRARY;USE_TLS;__WIN__;LICENSE=Commercial;DBUG_OFF;_MBCS;NDEBUG;$(NoInherit)"/> + + + + + + + + + + + + + + Date: Thu, 27 Apr 2006 12:51:33 +0500 Subject: [PATCH 09/15] BUG#17810 - REPAIR says ok, CHECK says broken (repeatable) Write operations on tables created in 4.x with index on variable length column results in index crash. Even REPAIR TABLE wasn't able to fix broken index. Problem was that packed key length size wasn't restored correctly. In 5.0 packed key length size is either 1 or 2. In 4.x this length is always 2, but is saved as 0. This fix ensures that key length size is restored correctly for 4.x tables. myisam/mi_key.c: Ensure that pack_length is either 1 or 2 (compatibility with 4.x). --- myisam/mi_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 5dcc99d41b4..717a5dbd56e 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -127,7 +127,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, } if (keyseg->flag & HA_VAR_LENGTH_PART) { - uint pack_length= keyseg->bit_start; + uint pack_length= (keyseg->bit_start == 1 ? 1 : 2); uint tmp_length= (pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos)); pos+= pack_length; /* Skip VARCHAR length */ From e93b203d08dd7f64b140485993ac85791343e115 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 May 2006 14:33:55 +0200 Subject: [PATCH 10/15] ndb - bug#19201 (4.1), see comment in NdbBlob.cpp ndb/test/ndbapi/testBlobs.cpp: option -fac (fetch across commit) ndb/tools/delete_all.cpp: option --transactional (default remains truncate) mysql-test/r/ndb_blob.result: bug#19201 mysql-test/t/ndb_blob.test: bug#19201 ndb/include/kernel/signaldata/TcKeyReq.hpp: bug#19201 ndb/include/ndbapi/NdbBlob.hpp: bug#19201 ndb/src/ndbapi/NdbBlob.cpp: bug#19201 --- mysql-test/r/ndb_blob.result | 18 +++++++++---- mysql-test/t/ndb_blob.test | 25 ++++++++++++++--- ndb/include/kernel/signaldata/TcKeyReq.hpp | 1 + ndb/include/ndbapi/NdbBlob.hpp | 1 + ndb/src/ndbapi/NdbBlob.cpp | 24 ++++++++++++++++- ndb/test/ndbapi/testBlobs.cpp | 23 +++++++--------- ndb/tools/delete_all.cpp | 31 ++++++++++------------ 7 files changed, 83 insertions(+), 40 deletions(-) diff --git a/mysql-test/r/ndb_blob.result b/mysql-test/r/ndb_blob.result index bcf867a4edd..e3289961fb8 100644 --- a/mysql-test/r/ndb_blob.result +++ b/mysql-test/r/ndb_blob.result @@ -481,14 +481,22 @@ msg text NOT NULL insert into t1 (msg) values( 'Tries to validate (8 byte length + inline bytes) as UTF8 :( Fast fix: removed validation for Text. It is not yet indexable -so bad data will not crash kernel. -Proper fix: Set inline bytes to multiple of mbmaxlen and -validate it (after the 8 byte length).'); +so bad data will not crash kernel.'); select * from t1; id msg 1 Tries to validate (8 byte length + inline bytes) as UTF8 :( Fast fix: removed validation for Text. It is not yet indexable so bad data will not crash kernel. -Proper fix: Set inline bytes to multiple of mbmaxlen and -validate it (after the 8 byte length). +drop table t1; +create table t1 ( +a int primary key not null auto_increment, +b text +) engine=ndbcluster; +select count(*) from t1; +count(*) +500 +truncate t1; +select count(*) from t1; +count(*) +0 drop table t1; diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index f80b7f71281..bf82a793049 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -403,10 +403,29 @@ create table t1 ( insert into t1 (msg) values( 'Tries to validate (8 byte length + inline bytes) as UTF8 :( Fast fix: removed validation for Text. It is not yet indexable -so bad data will not crash kernel. -Proper fix: Set inline bytes to multiple of mbmaxlen and -validate it (after the 8 byte length).'); +so bad data will not crash kernel.'); select * from t1; drop table t1; +# -- bug #19201 +create table t1 ( + a int primary key not null auto_increment, + b text +) engine=ndbcluster; +--disable_query_log +set autocommit=1; +# more rows than batch size (64) +# for this bug no blob parts would be necessary +let $1 = 500; +while ($1) +{ + insert into t1 (b) values (repeat('x',4000)); + dec $1; +} +--enable_query_log +select count(*) from t1; +truncate t1; +select count(*) from t1; +drop table t1; + # End of 4.1 tests diff --git a/ndb/include/kernel/signaldata/TcKeyReq.hpp b/ndb/include/kernel/signaldata/TcKeyReq.hpp index 9e42f2a70d5..820425b97e2 100644 --- a/ndb/include/kernel/signaldata/TcKeyReq.hpp +++ b/ndb/include/kernel/signaldata/TcKeyReq.hpp @@ -39,6 +39,7 @@ class TcKeyReq { friend class NdbOperation; friend class NdbIndexOperation; friend class NdbScanOperation; + friend class NdbBlob; friend class DbUtil; /** diff --git a/ndb/include/ndbapi/NdbBlob.hpp b/ndb/include/ndbapi/NdbBlob.hpp index a04f4f72bc9..f2c215ba14d 100644 --- a/ndb/include/ndbapi/NdbBlob.hpp +++ b/ndb/include/ndbapi/NdbBlob.hpp @@ -275,6 +275,7 @@ private: bool isWriteOp(); bool isDeleteOp(); bool isScanOp(); + bool isTakeOverOp(); // computations Uint32 getPartNumber(Uint64 pos); Uint32 getPartCount(); diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index 416e983ec14..e595b4b6472 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -23,6 +23,7 @@ #include #include "NdbBlobImpl.hpp" #include +#include #ifdef NDB_BLOB_DEBUG #define DBG(x) \ @@ -290,6 +291,13 @@ NdbBlob::isScanOp() theNdbOp->theOperationType == NdbOperation::OpenRangeScanRequest; } +inline bool +NdbBlob::isTakeOverOp() +{ + return + TcKeyReq::getTakeOverScanFlag(theNdbOp->theScanInfo); +} + // computations (inline) inline Uint32 @@ -1218,8 +1226,22 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) if (isUpdateOp() || isWriteOp() || isDeleteOp()) { // add operation before this one to read head+inline NdbOperation* tOp = theNdbCon->getNdbOperation(theTable, theNdbOp); + /* + * If main op is from take over scan lock, the added read is done + * as committed read: + * + * In normal transactional case, the row is locked by us and + * committed read returns same as normal read. + * + * In current TRUNCATE TABLE, the deleting trans is committed in + * batches and then restarted with new trans id. A normal read + * would hang on the scan delete lock and then fail. + */ + NdbOperation::LockMode lockMode = + ! isTakeOverOp() ? + NdbOperation::LM_Read : NdbOperation::LM_CommittedRead; if (tOp == NULL || - tOp->readTuple() == -1 || + tOp->readTuple(lockMode) == -1 || setTableKeyValue(tOp) == -1 || getHeadInlineValue(tOp) == -1) { setErrorCode(tOp); diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp index 4c82f718788..05a462c12c6 100644 --- a/ndb/test/ndbapi/testBlobs.cpp +++ b/ndb/test/ndbapi/testBlobs.cpp @@ -45,6 +45,7 @@ struct Opt { bool m_dbg; bool m_dbgall; const char* m_dbug; + bool m_fac; bool m_full; unsigned m_loop; unsigned m_parts; @@ -73,6 +74,7 @@ struct Opt { m_dbg(false), m_dbgall(false), m_dbug(0), + m_fac(false), m_full(false), m_loop(1), m_parts(10), @@ -111,6 +113,7 @@ printusage() << " -dbg print debug" << endl << " -dbgall print also NDB API debug (if compiled in)" << endl << " -dbug opt dbug options" << endl + << " -fac fetch across commit in scan delete [" << d.m_fac << "]" << endl << " -full read/write only full blob values" << endl << " -loop N loop N times 0=forever [" << d.m_loop << "]" << endl << " -parts N max parts in blob value [" << d.m_parts << "]" << endl @@ -1260,23 +1263,11 @@ deleteScan(bool idx) CHK((ret = rs->nextResult(false)) == 0 || ret == 1 || ret == 2); if (++n == g_opt.m_batch || ret == 2) { DBG("execute batch: n=" << n << " ret=" << ret); - switch (0) { - case 0: // works normally + if (! g_opt.m_fac) { CHK(g_con->execute(NoCommit) == 0); - CHK(true || g_con->restart() == 0); - break; - case 1: // nonsense - g_con is invalid for 2nd batch - CHK(g_con->execute(Commit) == 0); - CHK(true || g_con->restart() == 0); - break; - case 2: // DBTC sendSignalErrorRefuseLab - CHK(g_con->execute(NoCommit) == 0); - CHK(g_con->restart() == 0); - break; - case 3: // 266 time-out + } else { CHK(g_con->execute(Commit) == 0); CHK(g_con->restart() == 0); - break; } n = 0; } @@ -1824,6 +1815,10 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) continue; } } + if (strcmp(arg, "-fac") == 0) { + g_opt.m_fac = true; + continue; + } if (strcmp(arg, "-full") == 0) { g_opt.m_full = true; continue; diff --git a/ndb/tools/delete_all.cpp b/ndb/tools/delete_all.cpp index d4a07fdf505..c1ab77cb39f 100644 --- a/ndb/tools/delete_all.cpp +++ b/ndb/tools/delete_all.cpp @@ -23,17 +23,21 @@ #include static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, - bool commit_across_open_cursor, int parallelism=240); + bool fetch_across_commit, int parallelism=240); NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; +static my_bool _transactional = false; static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", (gptr*) &_dbname, (gptr*) &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "transactional", 't', "Single transaction (may run out of operations)", + (gptr*) &_transactional, (gptr*) &_transactional, 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} }; static void usage() @@ -82,18 +86,11 @@ int main(int argc, char** argv){ ndbout << " Table " << argv[i] << " does not exist!" << endl; return NDBT_ProgramExit(NDBT_WRONGARGS); } - // Check if we have any blobs - bool commit_across_open_cursor = true; - for (int j = 0; j < pTab->getNoOfColumns(); j++) { - NdbDictionary::Column::Type t = pTab->getColumn(j)->getType(); - if (t == NdbDictionary::Column::Blob || - t == NdbDictionary::Column::Text) { - commit_across_open_cursor = false; - break; - } - } - ndbout << "Deleting all from " << argv[i] << "..."; - if(clear_table(&MyNdb, pTab, commit_across_open_cursor) == NDBT_FAILED){ + ndbout << "Deleting all from " << argv[i]; + if (! _transactional) + ndbout << " (non-transactional)"; + ndbout << " ..."; + if(clear_table(&MyNdb, pTab, ! _transactional) == NDBT_FAILED){ res = NDBT_FAILED; ndbout << "FAILED" << endl; } @@ -103,7 +100,7 @@ int main(int argc, char** argv){ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, - bool commit_across_open_cursor, int parallelism) + bool fetch_across_commit, int parallelism) { // Scan all records exclusive and delete // them one by one @@ -134,7 +131,7 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, } goto failed; } - + pOp = pTrans->getNdbScanOperation(pTab->getName()); if (pOp == NULL) { goto failed; @@ -165,7 +162,7 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, } while((check = rs->nextResult(false)) == 0); if(check != -1){ - if (commit_across_open_cursor) { + if (fetch_across_commit) { check = pTrans->execute(Commit); pTrans->restart(); // new tx id } else { @@ -196,7 +193,7 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, } goto failed; } - if (! commit_across_open_cursor && pTrans->execute(Commit) != 0) { + if (! fetch_across_commit && pTrans->execute(Commit) != 0) { err = pTrans->getNdbError(); goto failed; } From 66edfe285a208e651ddb7cae4cf193bcc493114b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 May 2006 17:43:32 +0500 Subject: [PATCH 11/15] merging fix --- sql/sql_table.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f6de9e34785..e9be44d7f24 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2570,7 +2570,7 @@ send_result_message: table->table->s->version=0; // Force close of table else if (open_for_modify) { - if (table->table->tmp_table) + if (table->table->s->tmp_table) table->table->file->info(HA_STATUS_CONST); else { From a1e9539b62bdda3651e5b152db21586bc7a3e47e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 May 2006 19:01:29 +0500 Subject: [PATCH 12/15] merging fix --- mysql-test/t/innodb.test | 6 ------ mysql-test/t/sp_notembedded.test | 1 - 2 files changed, 7 deletions(-) diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 703e3b311b9..e4c8bf89cca 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -2190,12 +2190,6 @@ SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; drop table t2, t1; -create table t2(a date, key(a)) engine=innodb; -insert into t1 values('2005-10-01'); -insert into t2 values('2005-10-01'); -select * from t1, t2 - where t2.a between t1.a - interval 2 day and t1.a + interval 2 day; -drop table t1, t2; # # Bug #15680 (SPATIAL key in innodb) diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index 893884b302f..0adbeb2d98b 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -265,4 +265,3 @@ drop view v1| drop table t3| delimiter ;| -drop table t3; From 812a82edfab6b2dcdbdd5536204e987656ae490e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 May 2006 09:58:03 +0500 Subject: [PATCH 13/15] test result fixed mysql-test/r/mysqltest.result: result fixed --- mysql-test/r/mysqltest.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 990f04e5ba9..091a3c0547d 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -1,6 +1,6 @@ -select -1 as "before_use_test" ; +select 0 as "before_use_test" ; before_use_test --1 +0 select otto from (select 1 as otto) as t1; otto 1 From 473ad8c9863ed21dfd5010d949998a55709eb3a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 May 2006 15:52:09 +0500 Subject: [PATCH 14/15] Fixed heap_btree test failure on 64-bit boxes. --- mysql-test/t/heap_btree.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index eadb1fec8ae..f1b9d290885 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -169,8 +169,10 @@ DROP TABLE t1; # CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory; INSERT INTO t1 VALUES(0); +--replace_result 37 21 SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1'; UPDATE t1 SET val=1; +--replace_result 37 21 SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1'; DROP TABLE t1; From 93db6d4aa2ec163f85fee5e630421419b6767aef Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 May 2006 15:30:38 +0300 Subject: [PATCH 15/15] Fixed memory leak in sql_parse.cc (lex_end() was not called) This caused sp-vars.test to fail sql/item_func.h: Removed compiler warning sql/sp.cc: Fixed memory leak in sql_parse.cc sql/sp_head.cc: Fixed memory leak in sql_parse.cc sql/sp_head.h: Fixed memory leak in sql_parse.cc --- sql/item_func.h | 1 + sql/sp.cc | 2 +- sql/sp_head.cc | 4 ++++ sql/sp_head.h | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sql/item_func.h b/sql/item_func.h index ed5924e8fe1..a91d93be8c6 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -284,6 +284,7 @@ class Item_func_connection_id :public Item_int_func longlong value; public: + Item_func_connection_id() {} const char *func_name() const { return "connection_id"; } void fix_length_and_dec(); bool fix_fields(THD *thd, Item **ref); diff --git a/sql/sp.cc b/sql/sp.cc index 7df22c92cb8..cae7a56fa57 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -269,7 +269,6 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, TABLE *table) static int db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) { - extern int MYSQLparse(void *thd); TABLE *table; const char *params, *returns, *body; int ret; @@ -478,6 +477,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, (*sphp)->optimize(); } end: + lex_end(thd->lex); thd->spcont= old_spcont; thd->variables.sql_mode= old_sql_mode; thd->variables.select_limit= old_select_limit; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 6b7cdb1ea98..6a7676c7bf2 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -671,6 +671,7 @@ sp_head::destroy() DBUG_ASSERT(m_lex.is_empty() || m_thd); while ((lex= (LEX *)m_lex.pop())) { + lex_end(m_thd->lex); delete m_thd->lex; m_thd->lex= lex; } @@ -1643,7 +1644,10 @@ sp_head::restore_lex(THD *thd) */ merge_table_list(thd, sublex->query_tables, sublex); if (! sublex->sp_lex_in_use) + { + lex_end(sublex); delete sublex; + } thd->lex= oldlex; DBUG_VOID_RETURN; } diff --git a/sql/sp_head.h b/sql/sp_head.h index 3ad81542ce7..6a9cf97d739 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -520,7 +520,10 @@ public: virtual ~sp_lex_keeper() { if (m_lex_resp) + { + lex_end(m_lex); delete m_lex; + } } /*