From 81882f7127b9d52cd46c92006e1a2231a70c8849 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Oct 2005 23:31:32 +0400 Subject: [PATCH 01/22] Fix for BUG#13814: in mi_pack_key(), when processing NULL value for TINYBLOB key segment, do advance the source pointer over 2 bytes that specify value length. myisam/mi_key.c: Fix for BUG#13814: in mi_pack_key(), when processing NULL value for TINYBLOB key segment, do advance the source pointer over 2 bytes that specify value length (for NULL value the format is: null_marker 0x01, value length 0x00 0x00, data: 0x00 keyseg->length times). We need to advance over 2 bytes separately as keyseg->length doesn't include them. mysql-test/r/myisam.result: Testcase for BUG#13814 mysql-test/t/myisam.test: Testcase for BUG#13814 --- myisam/mi_key.c | 3 +++ mysql-test/r/myisam.result | 18 ++++++++++++++++++ mysql-test/t/myisam.test | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 9df22889b22..f4b92f969db 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -217,7 +217,10 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, { k_length-=length; if (keyseg->flag & (HA_VAR_LENGTH | HA_BLOB_PART)) + { + old+= 2; k_length-=2; /* Skip length */ + } continue; /* Found NULL */ } } diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 17dba82dc00..55504e8e75b 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -702,3 +702,21 @@ t1 1 a 2 b A 0 NULL NULL YES BTREE t1 1 a 3 c A 0 NULL NULL YES BTREE t1 1 a 4 d A 0 NULL NULL YES BTREE set myisam_stats_method=DEFAULT; +drop table t1; +create table t1( +cip INT NOT NULL, +time TIME NOT NULL, +score INT NOT NULL DEFAULT 0, +bob TINYBLOB +); +insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03'); +insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'), +(6, 'c', '00:06'); +select * from t1 where bob is null and cip=1; +cip time score bob +1 00:01:00 0 NULL +create index bug on t1 (bob(22), cip, time); +select * from t1 where bob is null and cip=1; +cip time score bob +1 00:01:00 0 NULL +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index fbde658660d..8e9862015bc 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -656,4 +656,22 @@ analyze table t1; show index from t1; set myisam_stats_method=DEFAULT; +drop table t1; + +# BUG#13814 - key value packed incorrectly for TINYBLOBs + +create table t1( + cip INT NOT NULL, + time TIME NOT NULL, + score INT NOT NULL DEFAULT 0, + bob TINYBLOB +); + +insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03'); +insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'), + (6, 'c', '00:06'); +select * from t1 where bob is null and cip=1; +create index bug on t1 (bob(22), cip, time); +select * from t1 where bob is null and cip=1; +drop table t1; # End of 4.1 tests From 04fcd58e09082f8fbe80744ab7aa6ae71f00e400 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Oct 2005 15:56:52 -0800 Subject: [PATCH 02/22] Fix harmless typo in mysql_fix_privilege_tables.sql (Bug #14469) scripts/mysql_fix_privilege_tables.sql: Remove extra leading - in comment --- scripts/mysql_fix_privilege_tables.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 0d7d32fd6a9..a72bd2799aa 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -29,7 +29,7 @@ ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,a ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; ---- Fix privileges for old tables +-- Fix privileges for old tables UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; From a2370730b3ec287807c8920131b2ee1c554fa8f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2005 11:48:55 -0800 Subject: [PATCH 03/22] Avoid possible race condition in accessing slave statistics during shutdown. (Bug #11796) sql/sql_show.cc: Check that active_mi is not NULL before accessing its members. --- sql/sql_show.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d6ceca5f23c..268292022e4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1890,7 +1890,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, case SHOW_SLAVE_RUNNING: { pthread_mutex_lock(&LOCK_active_mi); - end= strmov(buff, (active_mi->slave_running && + end= strmov(buff, (active_mi && active_mi->slave_running && active_mi->rli.slave_running) ? "ON" : "OFF"); pthread_mutex_unlock(&LOCK_active_mi); break; @@ -1902,9 +1902,12 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, SLAVE STATUS, and have the sum over all lines here. */ pthread_mutex_lock(&LOCK_active_mi); - pthread_mutex_lock(&active_mi->rli.data_lock); - end= int10_to_str(active_mi->rli.retried_trans, buff, 10); - pthread_mutex_unlock(&active_mi->rli.data_lock); + if (active_mi) + { + pthread_mutex_lock(&active_mi->rli.data_lock); + end= int10_to_str(active_mi->rli.retried_trans, buff, 10); + pthread_mutex_unlock(&active_mi->rli.data_lock); + } pthread_mutex_unlock(&LOCK_active_mi); break; } From 8355bce65862d3effea30f20f12186c8000b0247 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Nov 2005 18:29:06 -0800 Subject: [PATCH 04/22] Don't add optimization flags to CFLAGS if the user specified their own CFLAGS (ditto for CXXFLAGS). (Bug #12640) configure.in: Only add optimization flags when no CFLAGS (and/or CXXFLAGS) were specified. --- configure.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure.in b/configure.in index 40a3e8ea5d4..f10c7b7a96e 100644 --- a/configure.in +++ b/configure.in @@ -1672,6 +1672,19 @@ if expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null; then OPTIMIZE_CXXFLAGS="$OPTIMIZE_CXXFLAGS -DNDEBUG" fi +# If the user specified CFLAGS, we won't add any optimizations +if test -n "$SAVE_CFLAGS" +then + OPTIMIZE_CFLAGS="" + DEBUG_OPTIMIZE_CC="" +fi +# Ditto for CXXFLAGS +if test -n "$SAVE_CXXFLAGS" +then + OPTIMIZE_CXXFLAGS="" + DEBUG_OPTIMIZE_CXX="" +fi + AC_ARG_WITH(debug, [ --without-debug Build a production version without debugging code], [with_debug=$withval], From 7d183320b0e9b271efe6017986b904b694d32310 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Nov 2005 18:24:12 +0100 Subject: [PATCH 05/22] Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash Version for 4.0. It fixes two problems: 1. The cause of the bug was that we did not check the table version for the HANDLER ... READ commands. We did not notice when a table was replaced by a new one. This can happen during ALTER TABLE, REPAIR TABLE, and OPTIMIZE TABLE (there might be more cases). I call the fix for this problem "the primary bug fix". 2. mysql_ha_flush() was not always called with a locked LOCK_open. Though the function comment clearly said it must. I changed the code so that the locking is done when required. I call the fix for this problem "the secondary fix". mysql-test/r/handler.result: Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash The test result. mysql-test/t/handler.test: Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash The test case. sql/mysql_priv.h: Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash Changed a definition for the secondary fix. sql/sql_base.cc: Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash Changed function calls for the secondary fix. sql/sql_class.cc: Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash Changed a function call for the secondary fix. sql/sql_handler.cc: Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash The first two diffs make the primary bug fix. The rest is for the secondary fix. sql/sql_table.cc: Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash Changed function calls for the secondary fix. --- mysql-test/r/handler.result | 18 ++++++++++++++ mysql-test/t/handler.test | 29 ++++++++++++++++++++++ sql/mysql_priv.h | 3 ++- sql/sql_base.cc | 7 +++--- sql/sql_class.cc | 2 +- sql/sql_handler.cc | 49 ++++++++++++++++++++++++++++++++++--- sql/sql_table.cc | 6 ++--- 7 files changed, 102 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/handler.result b/mysql-test/r/handler.result index 5af153930d5..3a61236ea14 100644 --- a/mysql-test/r/handler.result +++ b/mysql-test/r/handler.result @@ -447,3 +447,21 @@ drop table t2; drop table t3; drop table t4; drop table t5; +create table t1 (c1 int); +insert into t1 values (1); +handler t1 open; +handler t1 read first; +c1 +1 +send the below to another connection, do not wait for the result + optimize table t1; +proceed with the normal connection +handler t1 read next; +c1 +1 +handler t1 close; +read the result from the other connection +Table Op Msg_type Msg_text +test.t1 optimize status OK +proceed with the normal connection +drop table t1; diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test index 53fe8c0a059..d91587b8070 100644 --- a/mysql-test/t/handler.test +++ b/mysql-test/t/handler.test @@ -339,3 +339,32 @@ drop table t2; drop table t3; drop table t4; drop table t5; + +# +# Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash +# +create table t1 (c1 int); +insert into t1 values (1); +# client 1 +handler t1 open; +handler t1 read first; +# client 2 +connect (con2,localhost,root,,); +connection con2; +--exec echo send the below to another connection, do not wait for the result +send optimize table t1; +--sleep 1 +# client 1 +--exec echo proceed with the normal connection +connection default; +handler t1 read next; +handler t1 close; +# client 2 +--exec echo read the result from the other connection +connection con2; +reap; +# client 1 +--exec echo proceed with the normal connection +connection default; +drop table t1; + diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 9b9edd905ad..526b79cd73a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -547,7 +547,8 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen= 0); int mysql_ha_close(THD *thd, TABLE_LIST *tables); int mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *, List *,enum ha_rkey_function,Item *,ha_rows,ha_rows); -int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags); +int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags, + bool is_locked); /* mysql_ha_flush mode_flags bits */ #define MYSQL_HA_CLOSE_FINAL 0x00 #define MYSQL_HA_REOPEN_ON_USAGE 0x01 diff --git a/sql/sql_base.cc b/sql/sql_base.cc index bc2ad9fff50..4f52904a61e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -390,7 +390,8 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh, thd->proc_info="Flushing tables"; close_old_data_files(thd,thd->open_tables,1,1); - mysql_ha_flush(thd, tables, MYSQL_HA_REOPEN_ON_USAGE | MYSQL_HA_FLUSH_ALL); + mysql_ha_flush(thd, tables, MYSQL_HA_REOPEN_ON_USAGE | MYSQL_HA_FLUSH_ALL, + TRUE); bool found=1; /* Wait until all threads has closed all the tables we had locked */ DBUG_PRINT("info", ("Waiting for others threads to close their open tables")); @@ -863,7 +864,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, } /* close handler tables which are marked for flush */ - mysql_ha_flush(thd, (TABLE_LIST*) NULL, MYSQL_HA_REOPEN_ON_USAGE); + mysql_ha_flush(thd, (TABLE_LIST*) NULL, MYSQL_HA_REOPEN_ON_USAGE, TRUE); for (table=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ; table && table->in_use ; @@ -1262,7 +1263,7 @@ bool wait_for_tables(THD *thd) { thd->some_tables_deleted=0; close_old_data_files(thd,thd->open_tables,0,dropping_tables != 0); - mysql_ha_flush(thd, (TABLE_LIST*) NULL, MYSQL_HA_REOPEN_ON_USAGE); + mysql_ha_flush(thd, (TABLE_LIST*) NULL, MYSQL_HA_REOPEN_ON_USAGE, TRUE); if (!table_is_used(thd->open_tables,1)) break; (void) pthread_cond_wait(&COND_refresh,&LOCK_open); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9dd75b32d5d..66d23ada163 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -217,7 +217,7 @@ void THD::cleanup(void) close_thread_tables(this); } mysql_ha_flush(this, (TABLE_LIST*) 0, - MYSQL_HA_CLOSE_FINAL | MYSQL_HA_FLUSH_ALL); + MYSQL_HA_CLOSE_FINAL | MYSQL_HA_FLUSH_ALL, FALSE); hash_free(&handler_tables_hash); close_temporary_tables(this); hash_free(&user_vars); diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index fcdb2aeb668..28e94d1a477 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -357,6 +357,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ha_rows select_limit,ha_rows offset_limit) { TABLE_LIST *hash_tables; + TABLE **table_ptr; TABLE *table; int err; int keyno=-1; @@ -379,6 +380,27 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' tab %p", hash_tables->db, hash_tables->real_name, hash_tables->alias, table)); + /* Table might have been flushed. */ + if (table && (table->version != refresh_version)) + { + /* + We must follow the thd->handler_tables chain, as we need the + address of the 'next' pointer referencing this table + for close_thread_table(). + */ + for (table_ptr= &(thd->handler_tables); + *table_ptr && (*table_ptr != table); + table_ptr= &(*table_ptr)->next) + {} + VOID(pthread_mutex_lock(&LOCK_open)); + if (close_thread_table(thd, table_ptr)) + { + /* Tell threads waiting for refresh that something has happened */ + VOID(pthread_cond_broadcast(&COND_refresh)); + } + VOID(pthread_mutex_unlock(&LOCK_open)); + table= hash_tables->table= NULL; + } if (!table) { /* @@ -593,6 +615,7 @@ err0: MYSQL_HA_REOPEN_ON_USAGE mark for reopen. MYSQL_HA_FLUSH_ALL flush all tables, not only those marked for flush. + is_locked If LOCK_open is locked. DESCRIPTION The list of HANDLER tables may be NULL, in which case all HANDLER @@ -600,7 +623,6 @@ err0: If 'tables' is NULL and MYSQL_HA_FLUSH_ALL is not set, all HANDLER tables marked for flush are closed. Broadcasts a COND_refresh condition, for every table closed. - The caller must lock LOCK_open. NOTE Since mysql_ha_flush() is called when the base table has to be closed, @@ -610,10 +632,12 @@ err0: 0 ok */ -int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags) +int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags, + bool is_locked) { TABLE_LIST *tmp_tables; TABLE **table_ptr; + bool did_lock= FALSE; DBUG_ENTER("mysql_ha_flush"); DBUG_PRINT("enter", ("tables: %p mode_flags: 0x%02x", tables, mode_flags)); @@ -637,6 +661,12 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags) (*table_ptr)->table_cache_key, (*table_ptr)->real_name, (*table_ptr)->table_name)); + /* The first time it is required, lock for close_thread_table(). */ + if (! did_lock && ! is_locked) + { + VOID(pthread_mutex_lock(&LOCK_open)); + did_lock= TRUE; + } mysql_ha_flush_table(thd, table_ptr, mode_flags); continue; } @@ -655,6 +685,12 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags) if ((mode_flags & MYSQL_HA_FLUSH_ALL) || ((*table_ptr)->version != refresh_version)) { + /* The first time it is required, lock for close_thread_table(). */ + if (! did_lock && ! is_locked) + { + VOID(pthread_mutex_lock(&LOCK_open)); + did_lock= TRUE; + } mysql_ha_flush_table(thd, table_ptr, mode_flags); continue; } @@ -662,6 +698,10 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags) } } + /* Release the lock if it was taken by this function. */ + if (did_lock) + VOID(pthread_mutex_unlock(&LOCK_open)); + DBUG_RETURN(0); } @@ -693,8 +733,8 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags) table->table_name, mode_flags)); if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, - (byte*) (*table_ptr)->table_name, - strlen((*table_ptr)->table_name) + 1))) + (byte*) table->table_name, + strlen(table->table_name) + 1))) { if (! (mode_flags & MYSQL_HA_REOPEN_ON_USAGE)) { @@ -708,6 +748,7 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags) } } + safe_mutex_assert_owner(&LOCK_open); if (close_thread_table(thd, table_ptr)) { /* Tell threads waiting for refresh that something has happened */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4c269e6830f..987d12ccb40 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -179,7 +179,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, { char *db=table->db; uint flags; - mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL); + mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL, TRUE); if (!close_temporary_table(thd, db, table->real_name)) { tmp_table_deleted=1; @@ -1239,7 +1239,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, if (send_fields(thd, field_list, 1)) DBUG_RETURN(-1); - mysql_ha_flush(thd, tables, MYSQL_HA_CLOSE_FINAL); + mysql_ha_flush(thd, tables, MYSQL_HA_CLOSE_FINAL, FALSE); for (table = tables; table; table = table->next) { char table_name[NAME_LEN*2+2]; @@ -1500,7 +1500,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, } used_fields=create_info->used_fields; - mysql_ha_flush(thd, table_list, MYSQL_HA_CLOSE_FINAL); + mysql_ha_flush(thd, table_list, MYSQL_HA_CLOSE_FINAL, FALSE); if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ))) DBUG_RETURN(-1); From 1b65c7041383073eee99deebe8569399f06e83ee Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 5 Nov 2005 15:08:15 +0300 Subject: [PATCH 06/22] Fix Bug#13894 Server crashes on update of CSV table mysql-test/r/csv.result: update result file mysql-test/t/csv.test: Add test for a bug sql/examples/ha_tina.cc: sort function should return reverted values for chains to be sorted in the right orded. don't do a strange memmove --- mysql-test/r/csv.result | 20 ++++++++++++++++++++ mysql-test/t/csv.test | 18 ++++++++++++++++++ sql/examples/ha_tina.cc | 19 +++++++++---------- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index ea0d34271b5..78a1f34636c 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -4929,3 +4929,23 @@ Warnings: Note 1051 Unknown table 't2' Note 1051 Unknown table 't3' Note 1051 Unknown table 't4' +DROP TABLE IF EXISTS bug13894; +CREATE TABLE bug13894 ( val integer ) ENGINE = CSV; +INSERT INTO bug13894 VALUES (5); +INSERT INTO bug13894 VALUES (10); +INSERT INTO bug13894 VALUES (11); +INSERT INTO bug13894 VALUES (10); +SELECT * FROM bug13894; +val +5 +10 +11 +10 +UPDATE bug13894 SET val=6 WHERE val=10; +SELECT * FROM bug13894; +val +5 +11 +6 +6 +DROP TABLE bug13894; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 2ac46d75f9a..61b4f9607a5 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1314,4 +1314,22 @@ select period from t1; drop table if exists t1,t2,t3,t4; +# +# Bug #13894 Server crashes on update of CSV table +# + +--disable_warnings +DROP TABLE IF EXISTS bug13894; +--enable_warnings + +CREATE TABLE bug13894 ( val integer ) ENGINE = CSV; +INSERT INTO bug13894 VALUES (5); +INSERT INTO bug13894 VALUES (10); +INSERT INTO bug13894 VALUES (11); +INSERT INTO bug13894 VALUES (10); +SELECT * FROM bug13894; +UPDATE bug13894 SET val=6 WHERE val=10; +SELECT * FROM bug13894; +DROP TABLE bug13894; + # End of 4.1 tests diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 8a9aa91c680..f4544670ed9 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -58,12 +58,16 @@ static int tina_init= 0; ** TINA tables *****************************************************************************/ -/* - Used for sorting chains. +/* + Used for sorting chains with qsort(). */ int sort_set (tina_set *a, tina_set *b) { - return ( a->begin > b->begin ? 1 : ( a->begin < b->begin ? -1 : 0 ) ); + /* + We assume that intervals do not intersect. So, it is enought to compare + any two points. Here we take start of intervals for comparison. + */ + return ( a->begin > b->begin ? -1 : ( a->begin < b->begin ? 1 : 0 ) ); } static byte* tina_get_key(TINA_SHARE *share,uint *length, @@ -739,13 +743,8 @@ int ha_tina::rnd_end() qsort(chain, (size_t)(chain_ptr - chain), sizeof(tina_set), (qsort_cmp)sort_set); for (ptr= chain; ptr < chain_ptr; ptr++) { - /* We peek a head to see if this is the last chain */ - if (ptr+1 == chain_ptr) - memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end, - length - (size_t)ptr->end); - else - memmove((caddr_t)share->mapped_file + ptr->begin, (caddr_t)share->mapped_file + ptr->end, - (size_t)((ptr++)->begin - ptr->end)); + memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end, + length - (size_t)ptr->end); length= length - (size_t)(ptr->end - ptr->begin); } From b0829011b8053058f0419aee48da03970654cbc6 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 6 Nov 2005 02:11:12 +0300 Subject: [PATCH 07/22] Fix Bug#14672 Bug in deletion mysql-test/r/csv.result: correct result file mysql-test/t/csv.test: Add test for a bug sql/examples/ha_tina.cc: Add O_APPEND flag to my_open. We should always add rows to the end of file --- mysql-test/r/csv.result | 27 +++++++++++++++++++++++++++ mysql-test/t/csv.test | 19 +++++++++++++++++++ sql/examples/ha_tina.cc | 3 ++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 78a1f34636c..2e3d11ad461 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -4949,3 +4949,30 @@ val 6 6 DROP TABLE bug13894; +DROP TABLE IF EXISTS bug14672; +CREATE TABLE bug14672 (c1 integer) engine = CSV; +INSERT INTO bug14672 VALUES (1), (2), (3); +SELECT * FROM bug14672; +c1 +1 +2 +3 +DELETE FROM bug14672 WHERE c1 = 2; +SELECT * FROM bug14672; +c1 +1 +3 +INSERT INTO bug14672 VALUES (4); +SELECT * FROM bug14672; +c1 +1 +3 +4 +INSERT INTO bug14672 VALUES (5); +SELECT * FROM bug14672; +c1 +1 +3 +4 +5 +DROP TABLE bug14672; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 61b4f9607a5..5b693335a43 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1332,4 +1332,23 @@ UPDATE bug13894 SET val=6 WHERE val=10; SELECT * FROM bug13894; DROP TABLE bug13894; +# +# Bug #14672 Bug in deletion +# + +--disable_warnings +DROP TABLE IF EXISTS bug14672; +--enable_warnings + +CREATE TABLE bug14672 (c1 integer) engine = CSV; +INSERT INTO bug14672 VALUES (1), (2), (3); +SELECT * FROM bug14672; +DELETE FROM bug14672 WHERE c1 = 2; +SELECT * FROM bug14672; +INSERT INTO bug14672 VALUES (4); +SELECT * FROM bug14672; +INSERT INTO bug14672 VALUES (5); +SELECT * FROM bug14672; +DROP TABLE bug14672; + # End of 4.1 tests diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index f4544670ed9..91e42bfea31 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -166,7 +166,8 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); - if ((share->data_file= my_open(data_file_name, O_RDWR, MYF(0))) == -1) + if ((share->data_file= my_open(data_file_name, O_RDWR|O_APPEND, + MYF(0))) == -1) goto error2; /* We only use share->data_file for writing, so we scan to the end to append */ From 467deb4cb7aeb456086838cadcdf10b25b667a36 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Nov 2005 09:23:43 +0300 Subject: [PATCH 08/22] BUG#14480, attempt2: In CREATE ... SELECT ..., don't count the same field twice when calculating table->null_fields. mysql-test/r/create.result: Testcase for BUG#14480 mysql-test/t/create.test: Testcase for BUG#14480 sql/sql_table.cc: BUG#14480: For CREATE ... SELECT ... a field list passed to mysql_prepare_table() contains instances of create_field for both create-list and select-list. mysql_prepare_table() matches elements that refer to the same field, and joins them together. When the "join" is performed, both of create_field structures has already been counted in "null_fields". This fix makes sure that "null_fields" contains the correct value after two create_field structures have been joined. --- mysql-test/r/create.result | 68 +++++++++++++++++++++++++++++++++++++- mysql-test/t/create.test | 64 ++++++++++++++++++++++++++++++++++- sql/sql_table.cc | 9 ++++- 3 files changed, 138 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 55ad6e3304a..0c3b7d5d5e7 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1,4 +1,4 @@ -drop table if exists t1,t2,t3; +drop table if exists t1,t2,t3,t4,t5; drop database if exists mysqltest; create table t1 (b char(0)); insert into t1 values (""),(null); @@ -632,3 +632,69 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +CREATE TABLE t2 ( +a int(11) default NULL +); +insert into t2 values(111); +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int not null, primary key (a) +) select a, 1 as b from t2 ; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) character set utf8 collate utf8_bin NOT NULL default '', + `b` int(11) NOT NULL default '0', + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int not null, primary key (a) +) select 'a' as a , 1 as b from t2 ; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) character set utf8 collate utf8_bin NOT NULL default '', + `b` int(11) NOT NULL default '0', + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin, +b int not null, primary key (a) +) select 'a' as a , 1 as b from t2 ; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) character set utf8 collate utf8_bin NOT NULL default '', + `b` int(11) NOT NULL default '0', + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 ( +a1 int not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +); +insert into t1 values (1,1,1, 1,1,1, 1,1,1); +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, +primary key (a1) +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +drop table t2; +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1; +drop table t1, t2; +create table t1 ( +a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +); +insert into t1 values (1,1,1, 1,1,1, 1,1,1); +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, +primary key (a1) +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +drop table t1, t2; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 966be8b58a3..3bdc970027b 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -3,7 +3,7 @@ # --disable_warnings -drop table if exists t1,t2,t3; +drop table if exists t1,t2,t3,t4,t5; drop database if exists mysqltest; --enable_warnings @@ -534,4 +534,66 @@ create table t1 ( show create table t1; drop table t1; +# +# BUG#14480: assert failure in CREATE ... SELECT because of wrong +# calculation of number of NULLs. +# +CREATE TABLE t2 ( + a int(11) default NULL +); +insert into t2 values(111); + +create table t1 ( + a varchar(12) charset utf8 collate utf8_bin not null, + b int not null, primary key (a) +) select a, 1 as b from t2 ; +show create table t1; +drop table t1; + +create table t1 ( + a varchar(12) charset utf8 collate utf8_bin not null, + b int not null, primary key (a) +) select 'a' as a , 1 as b from t2 ; +show create table t1; +drop table t1; + +create table t1 ( + a varchar(12) charset utf8 collate utf8_bin, + b int not null, primary key (a) +) select 'a' as a , 1 as b from t2 ; +show create table t1; +drop table t1, t2; + +create table t1 ( + a1 int not null, + a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +); +insert into t1 values (1,1,1, 1,1,1, 1,1,1); + +create table t2 ( + a1 varchar(12) charset utf8 collate utf8_bin not null, + a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, + primary key (a1) +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +drop table t2; + +create table t2 ( + a1 varchar(12) charset utf8 collate utf8_bin, + a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1; + +drop table t1, t2; +create table t1 ( + a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +); +insert into t1 values (1,1,1, 1,1,1, 1,1,1); + +create table t2 ( + a1 varchar(12) charset utf8 collate utf8_bin not null, + a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, + primary key (a1) +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; + +drop table t1, t2; + # End of 4.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dcbc2018b49..40777682251 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -647,8 +647,15 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->pack_length= dup_field->pack_length; sql_field->create_length_to_internal_length(); sql_field->decimals= dup_field->decimals; - sql_field->flags= dup_field->flags; sql_field->unireg_check= dup_field->unireg_check; + /* + We're making one field from two, the result field will have + dup_field->flags as flags. If we've incremented null_fields + because of sql_field->flags, decrement it back. + */ + if (!(sql_field->flags & NOT_NULL_FLAG)) + null_fields--; + sql_field->flags= dup_field->flags; it2.remove(); // Remove first (create) definition select_field_pos--; break; From 5412ee4f299a4a2d71db1b7e5f3e62132032fb00 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Nov 2005 12:16:49 +0100 Subject: [PATCH 09/22] Bug#14616 - Freshly imported table returns error 124 when using LIMIT Initialized usable_keys from table->keys_in_use instead of ~0 in test_if_skip_sort_order(). It was possible that a disabled index was used for sorting. mysql-test/r/myisam.result: Bug#14616 - Freshly imported table returns error 124 when using LIMIT The test result. mysql-test/t/myisam.test: Bug#14616 - Freshly imported table returns error 124 when using LIMIT The test case. --- mysql-test/r/myisam.result | 10 ++++++++++ mysql-test/t/myisam.test | 12 ++++++++++++ sql/sql_select.cc | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index c55bacdd371..e6df3499eb5 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -462,3 +462,13 @@ select count(*) from t1 where a is null; count(*) 2 drop table t1; +create table t1 ( +c1 varchar(32), +key (c1) +) engine=myisam; +alter table t1 disable keys; +insert into t1 values ('a'), ('b'); +select c1 from t1 order by c1 limit 1; +c1 +a +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 57b64e30bac..a502002d30e 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -446,3 +446,15 @@ explain select count(*) from t1 where a is null; select count(*) from t1 where a is null; drop table t1; +# +# Bug#14616 - Freshly imported table returns error 124 when using LIMIT +# +create table t1 ( + c1 varchar(32), + key (c1) +) engine=myisam; +alter table t1 disable keys; +insert into t1 values ('a'), ('b'); +select c1 from t1 order by c1 limit 1; +drop table t1; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 46f0139a608..6dd68a60f88 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6003,8 +6003,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, key_map usable_keys; DBUG_ENTER("test_if_skip_sort_order"); - /* Check which keys can be used to resolve ORDER BY */ - usable_keys= ~(key_map) 0; + /* + Check which keys can be used to resolve ORDER BY. + We must not try to use disabled keys. + */ + usable_keys= table->keys_in_use; + for (ORDER *tmp_order=order; tmp_order ; tmp_order=tmp_order->next) { if ((*tmp_order->item)->type() != Item::FIELD_ITEM) From 3004c8de2dfc822375202a16e07c3cad196301d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Nov 2005 15:09:35 -0700 Subject: [PATCH 10/22] fix for BUG#7947 - failure to log DO RELEASE_LOCK() if we disconnect in the middle of transaction while holding the lock. Also test to make sure other binlogging issues reported in the bug have been addressed. sql/item_func.cc: fix for BUG#7947 mysql-test/r/rpl_bug7947.result: New BitKeeper file ``mysql-test/r/rpl_bug7947.result'' mysql-test/t/rpl_bug7947.test: New BitKeeper file ``mysql-test/t/rpl_bug7947.test'' --- mysql-test/r/rpl_bug7947.result | 48 +++++++++++++++++++++++++++++++++ mysql-test/t/rpl_bug7947.test | 22 +++++++++++++++ sql/item_func.cc | 2 +- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/rpl_bug7947.result create mode 100644 mysql-test/t/rpl_bug7947.test diff --git a/mysql-test/r/rpl_bug7947.result b/mysql-test/r/rpl_bug7947.result new file mode 100644 index 00000000000..8053f47d7d5 --- /dev/null +++ b/mysql-test/r/rpl_bug7947.result @@ -0,0 +1,48 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +begin; +create temporary table ti (a int) engine=innodb; +rollback; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +insert into ti values(1); +set autocommit=0; +create temporary table t1 (a int) type=myisam; +Warnings: +Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead +commit; +insert t1 values (1); +rollback; +create table t0 (n int); +insert t0 select * from t1; +set autocommit=1; +insert into t0 select GET_LOCK("lock1",null); +set autocommit=0; +create table t2 (n int) engine=innodb; +insert into t2 values (3); +select get_lock("lock1",null); +get_lock("lock1",null) +1 +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.000001 79 Query 1 79 use `test`; BEGIN +master-bin.000001 119 Query 1 79 use `test`; create temporary table ti (a int) engine=innodb +master-bin.000001 201 Query 1 201 use `test`; ROLLBACK +master-bin.000001 244 Query 1 244 use `test`; insert into ti values(1) +master-bin.000001 303 Query 1 303 use `test`; BEGIN +master-bin.000001 343 Query 1 303 use `test`; create temporary table t1 (a int) type=myisam +master-bin.000001 423 Query 1 423 use `test`; COMMIT +master-bin.000001 464 Query 1 464 use `test`; create table t0 (n int) +master-bin.000001 522 Query 1 522 use `test`; insert t0 select * from t1 +master-bin.000001 583 Query 1 583 use `test`; insert into t0 select GET_LOCK("lock1",null) +master-bin.000001 662 Query 1 662 use `test`; create table t2 (n int) engine=innodb +master-bin.000001 734 Query 1 734 use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti` +master-bin.000001 835 Query 1 835 use `test`; DO RELEASE_LOCK("lock1") +select release_lock("lock1"); +release_lock("lock1") +1 +drop table t0,t2; diff --git a/mysql-test/t/rpl_bug7947.test b/mysql-test/t/rpl_bug7947.test new file mode 100644 index 00000000000..15630ebea04 --- /dev/null +++ b/mysql-test/t/rpl_bug7947.test @@ -0,0 +1,22 @@ +--source include/master-slave.inc +connection master; +begin; +create temporary table ti (a int) engine=innodb; +rollback; +insert into ti values(1); +set autocommit=0; +create temporary table t1 (a int) type=myisam; commit; +insert t1 values (1); rollback; +create table t0 (n int); +insert t0 select * from t1; +set autocommit=1; +insert into t0 select GET_LOCK("lock1",null); +set autocommit=0; +create table t2 (n int) engine=innodb; +insert into t2 values (3); +disconnect master; +connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock); +select get_lock("lock1",null); +show binlog events from 79; +select release_lock("lock1"); +drop table t0,t2; diff --git a/sql/item_func.cc b/sql/item_func.cc index aff4adb788a..d80eed4754a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1975,7 +1975,7 @@ void item_user_lock_release(User_level_lock *ull) tmp.copy(command, strlen(command), tmp.charset()); tmp.append(ull->key,ull->key_length); tmp.append("\")", 2); - Query_log_event qev(current_thd, tmp.ptr(), tmp.length(),1, FALSE); + Query_log_event qev(current_thd, tmp.ptr(), tmp.length(),0, FALSE); qev.error_code=0; // this query is always safe to run on slave mysql_bin_log.write(&qev); } From 232652e9d68d4d8c84d6183a69a0fdd9b6a88c8d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Nov 2005 20:51:30 -0700 Subject: [PATCH 11/22] changed select release_lock() to do release_lock() to avoid having to compare the non-deterministic result in the test case for BUG#7947 the bug fix for BUG#7947 now fixed the result of mix_innodb_myisam_binlog test, which in the past was missing DO RELEASE_LOCK() in the output of SHOW BINLOG EVENTS mysql-test/r/mix_innodb_myisam_binlog.result: DO RELEASE_LOCK() was supposed to be there from the very start mysql-test/r/rpl_bug7947.result: changed select release_lock() to do release_lock() to avoid having to compare the non-deterministic result mysql-test/t/rpl_bug7947.test: changed select release_lock() to do release_lock() to avoid having to compare the non-deterministic result --- mysql-test/r/mix_innodb_myisam_binlog.result | 1 + mysql-test/r/rpl_bug7947.result | 4 +--- mysql-test/t/rpl_bug7947.test | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index 72288d1027b..587209a26ae 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -93,6 +93,7 @@ master-bin.000001 79 Query 1 79 use `test`; BEGIN master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(8) master-bin.000001 178 Query 1 79 use `test`; insert into t2 select * from t1 master-bin.000001 244 Query 1 244 use `test`; ROLLBACK +master-bin.000001 287 Query 1 287 use `test`; DO RELEASE_LOCK("a") delete from t1; delete from t2; reset master; diff --git a/mysql-test/r/rpl_bug7947.result b/mysql-test/r/rpl_bug7947.result index 8053f47d7d5..117e71a63d5 100644 --- a/mysql-test/r/rpl_bug7947.result +++ b/mysql-test/r/rpl_bug7947.result @@ -42,7 +42,5 @@ master-bin.000001 583 Query 1 583 use `test`; insert into t0 select GET_LOCK("lo master-bin.000001 662 Query 1 662 use `test`; create table t2 (n int) engine=innodb master-bin.000001 734 Query 1 734 use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti` master-bin.000001 835 Query 1 835 use `test`; DO RELEASE_LOCK("lock1") -select release_lock("lock1"); -release_lock("lock1") -1 +do release_lock("lock1"); drop table t0,t2; diff --git a/mysql-test/t/rpl_bug7947.test b/mysql-test/t/rpl_bug7947.test index 15630ebea04..e802a311b6c 100644 --- a/mysql-test/t/rpl_bug7947.test +++ b/mysql-test/t/rpl_bug7947.test @@ -18,5 +18,5 @@ disconnect master; connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock); select get_lock("lock1",null); show binlog events from 79; -select release_lock("lock1"); +do release_lock("lock1"); drop table t0,t2; From f76ff56512e1e10856816d6e5031f2b44df0990f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Nov 2005 09:34:46 +0300 Subject: [PATCH 12/22] BUG#14480: post-fix: use the default field value from CREATE list too. --- mysql-test/r/create.result | 11 +++++++++++ mysql-test/t/create.test | 7 +++++++ sql/sql_table.cc | 1 + 3 files changed, 19 insertions(+) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 0c3b7d5d5e7..a933027cdb1 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -697,4 +697,15 @@ a1 varchar(12) charset utf8 collate utf8_bin not null, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, primary key (a1) ) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +drop table t2; +create table t2 ( a int default 3, b int default 3) +select a1,a2 from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) default '3', + `b` int(11) default '3', + `a1` int(11) default NULL, + `a2` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1, t2; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 3bdc970027b..c9d16916f8a 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -594,6 +594,13 @@ create table t2 ( primary key (a1) ) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +# Test the default value +drop table t2; + +create table t2 ( a int default 3, b int default 3) + select a1,a2 from t1; +show create table t2; + drop table t1, t2; # End of 4.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 40777682251..d6a7d76ac99 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -639,6 +639,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, else { /* Field redefined */ + sql_field->def= dup_field->def; sql_field->sql_type= dup_field->sql_type; sql_field->charset= (dup_field->charset ? dup_field->charset : From 6e56f7e0a9870aee1435a0eb2870472b2263b26d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Nov 2005 15:12:22 +0100 Subject: [PATCH 13/22] Declaring some class members public for BUG#12377: "Item_date_add_interval needs to have the int_type member as Public". As explained in the bug report, this change is is to help http://search.cpan.org/~philips/DBIx-MyParse-0.20/ So please keep those members public. sql/item_func.h: declaring some class members public for BUG#12377 sql/item_strfunc.h: declaring some class members public for BUG#12377 sql/item_timefunc.h: declaring some class members public for BUG#12377 --- sql/item_func.h | 4 ++-- sql/item_strfunc.h | 2 +- sql/item_timefunc.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sql/item_func.h b/sql/item_func.h index 5d6cc445317..2c4976d1152 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -938,7 +938,6 @@ class user_var_entry; class Item_func_set_user_var :public Item_func { enum Item_result cached_result_type; - LEX_STRING name; user_var_entry *entry; char buffer[MAX_FIELD_WIDTH]; String value; @@ -952,6 +951,7 @@ class Item_func_set_user_var :public Item_func public: + LEX_STRING name; // keep it public Item_func_set_user_var(LEX_STRING a,Item *b) :Item_func(b), cached_result_type(INT_RESULT), name(a) {} @@ -972,10 +972,10 @@ public: class Item_func_get_user_var :public Item_func { - LEX_STRING name; user_var_entry *var_entry; public: + LEX_STRING name; // keep it public Item_func_get_user_var(LEX_STRING a): Item_func(), name(a) {} double val(); diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 5525c046b95..87aee9ac25c 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -614,8 +614,8 @@ public: class Item_func_conv_charset :public Item_str_func { - CHARSET_INFO *conv_charset; public: + CHARSET_INFO *conv_charset; // keep it public Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a) { conv_charset=cs; } String *val_str(String *); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 16c64620369..ce9d6b0a7aa 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -607,12 +607,12 @@ enum interval_type class Item_date_add_interval :public Item_date_func { - const interval_type int_type; String value; - const bool date_sub_interval; enum_field_types cached_field_type; public: + const interval_type int_type; // keep it public + const bool date_sub_interval; // keep it public Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg) :Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {} String *val_str(String *); @@ -628,10 +628,10 @@ public: class Item_extract :public Item_int_func { - const interval_type int_type; String value; bool date_value; public: + const interval_type int_type; // keep it public Item_extract(interval_type type_arg, Item *a) :Item_int_func(a), int_type(type_arg) {} longlong val_int(); @@ -856,8 +856,8 @@ enum date_time_format class Item_func_get_format :public Item_str_func { - const timestamp_type type; public: + const timestamp_type type; // keep it public Item_func_get_format(timestamp_type type_arg, Item *a) :Item_str_func(a), type(type_arg) {} From 26eb2ecc1dc076331c118e2ab314ffad1ef9e687 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Nov 2005 15:23:04 -0800 Subject: [PATCH 14/22] Update out-of-date URLs in 'help' text of mysql client. (Bug #14801) client/mysql.cc: Update text, URLs in mysql client 'help' text --- client/mysql.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index d408e8a5423..1c4fbf8f06f 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1813,9 +1813,13 @@ com_help(String *buffer __attribute__((unused)), if (help_arg) return com_server_help(buffer,line,help_arg+1); - put_info("\nFor the complete MySQL Manual online, visit:\n http://www.mysql.com/documentation\n", INFO_INFO); - put_info("For info on technical support from MySQL developers, visit:\n http://www.mysql.com/support\n", INFO_INFO); - put_info("For info on MySQL books, utilities, consultants, etc., visit:\n http://www.mysql.com/portal\n", INFO_INFO); + put_info("\nFor information about MySQL products and services, visit:\n" + " http://www.mysql.com/\n" + "For developer information, including the MySQL Reference Manual, " + "visit:\n" + " http://dev.mysql.com/\n" + "To buy MySQL Network Support, training, or other products, visit:\n" + " https://shop.mysql.com/\n", INFO_INFO); put_info("List of all MySQL commands:", INFO_INFO); if (!named_cmds) put_info("Note that all text commands must be first on line and end with ';'",INFO_INFO); From dc44851352f68e240074ecc571216a8c2503ae0b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Nov 2005 11:25:14 +0400 Subject: [PATCH 15/22] Fix for BUG#5686 - #1034 - Incorrect key file for table - only utf8 myisam/ft_parser.c: word->len calculation correction. mysql-test/r/fulltext.result: Test case for bug#5686. mysql-test/t/fulltext.test: Test case for bug#5686. --- myisam/ft_parser.c | 4 +++- mysql-test/r/fulltext.result | 4 ++++ mysql-test/t/fulltext.test | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/myisam/ft_parser.c b/myisam/ft_parser.c index 0b1e68b0d70..8e4769ebc75 100644 --- a/myisam/ft_parser.c +++ b/myisam/ft_parser.c @@ -188,8 +188,10 @@ byte ft_simple_get_word(CHARSET_INFO *cs, byte **start, byte *end, for (word->pos=doc; doclen= (uint)(doc-word->pos) - mwc; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 8fa2df2e756..87551f96a13 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -428,4 +428,8 @@ REPAIR TABLE t1; Table Op Msg_type Msg_text test.t1 repair status OK SET myisam_repair_threads=@@global.myisam_repair_threads; +INSERT INTO t1 VALUES('testword\'\''); +SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE); +a +testword'' DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index fa63778c4c1..7c7927b638b 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -348,6 +348,12 @@ INSERT INTO t1 VALUES('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); SET myisam_repair_threads=2; REPAIR TABLE t1; SET myisam_repair_threads=@@global.myisam_repair_threads; + +# +# BUG#5686 - #1034 - Incorrect key file for table - only utf8 +# +INSERT INTO t1 VALUES('testword\'\''); +SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE); DROP TABLE t1; # End of 4.1 tests From 69fae29c589e92233cf63ae32bffb9c6023d3780 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Nov 2005 18:14:53 +0200 Subject: [PATCH 16/22] Test suite for BUG#13673 (the bug was fixed in the bugfix for BUG#14138) mysql-test/r/analyze.result: Test suite for BUG#13673 mysql-test/t/analyze.test: Test suite for BUG#13673 --- mysql-test/r/analyze.result | 7 +++++++ mysql-test/t/analyze.test | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/mysql-test/r/analyze.result b/mysql-test/r/analyze.result index 0b44a502b13..796b382f5d6 100644 --- a/mysql-test/r/analyze.result +++ b/mysql-test/r/analyze.result @@ -30,3 +30,10 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +CREATE TABLE t1 (a int); +prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()"; +execute stmt1; +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +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; diff --git a/mysql-test/t/analyze.test b/mysql-test/t/analyze.test index 3c3b3933bc3..5d653b65579 100644 --- a/mysql-test/t/analyze.test +++ b/mysql-test/t/analyze.test @@ -39,4 +39,13 @@ check table t1; drop table t1; +# +# procedure in PS BUG#13673 +# +CREATE TABLE t1 (a int); +prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()"; +execute stmt1; +execute stmt1; +deallocate prepare stmt1; + # End of 4.1 tests From 675226728c40b2b9c477b7628a867292b243351d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Nov 2005 18:01:30 +0100 Subject: [PATCH 17/22] Bug#14616 - Freshly imported table returns error 124 when using LIMIT After merge fix. --- mysql-test/r/myisam.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 352cc2fabb9..d2d0417f6e6 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -498,7 +498,6 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary 1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct drop table t1,t2; -drop table t1; create table t1 ( c1 varchar(32), key (c1) @@ -508,6 +507,7 @@ insert into t1 values ('a'), ('b'); select c1 from t1 order by c1 limit 1; c1 a +drop table t1; CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM; Got one of the listed errors create table t1 (a int, b varchar(200), c text not null) checksum=1; From 4b1cb9888811edc1d307b4926bc786b284c508a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Nov 2005 13:38:06 -0700 Subject: [PATCH 18/22] merged in the test case for BUG#7947 BitKeeper/deleted/.del-rpl_bug7947.result~1b40af7545a6c692: Delete: mysql-test/r/rpl_bug7947.result BitKeeper/deleted/.del-rpl_bug7947.test~20613cfdc560a16c: Delete: mysql-test/t/rpl_bug7947.test --- mysql-test/r/mix_innodb_myisam_binlog.result | 48 ++++++++++++++++++++ mysql-test/r/rpl_bug7947.result | 46 ------------------- mysql-test/t/mix_innodb_myisam_binlog.test | 28 +++++++++++- mysql-test/t/rpl_bug7947.test | 22 --------- 4 files changed, 75 insertions(+), 69 deletions(-) delete mode 100644 mysql-test/r/rpl_bug7947.result delete mode 100644 mysql-test/t/rpl_bug7947.test diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index 587209a26ae..a586ad93ce4 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -203,3 +203,51 @@ select (@after-@before) >= 2; (@after-@before) >= 2 1 drop table t1,t2; +commit; +begin; +create temporary table ti (a int) engine=innodb; +rollback; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +insert into ti values(1); +set autocommit=0; +create temporary table t1 (a int) engine=myisam; +commit; +insert t1 values (1); +rollback; +create table t0 (n int); +insert t0 select * from t1; +set autocommit=1; +insert into t0 select GET_LOCK("lock1",null); +set autocommit=0; +create table t2 (n int) engine=innodb; +insert into t2 values (3); +select get_lock("lock1",null); +get_lock("lock1",null) +0 +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.000001 79 Query 1 79 use `test`; BEGIN +master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(16) +master-bin.000001 179 Query 1 79 use `test`; insert into t1 values(18) +master-bin.000001 239 Query 1 239 use `test`; COMMIT +master-bin.000001 280 Query 1 280 use `test`; delete from t1 +master-bin.000001 329 Query 1 329 use `test`; delete from t2 +master-bin.000001 378 Query 1 378 use `test`; alter table t2 type=MyISAM +master-bin.000001 439 Query 1 439 use `test`; insert into t1 values (1) +master-bin.000001 499 Query 1 499 use `test`; insert into t2 values (20) +master-bin.000001 560 Query 1 560 use `test`; drop table t1,t2 +master-bin.000001 611 Query 1 611 use `test`; BEGIN +master-bin.000001 651 Query 1 611 use `test`; create temporary table ti (a int) engine=innodb +master-bin.000001 733 Query 1 733 use `test`; ROLLBACK +master-bin.000001 776 Query 1 776 use `test`; insert into ti values(1) +master-bin.000001 835 Query 1 835 use `test`; BEGIN +master-bin.000001 875 Query 1 835 use `test`; create temporary table t1 (a int) engine=myisam +master-bin.000001 957 Query 1 957 use `test`; COMMIT +master-bin.000001 998 Query 1 998 use `test`; create table t0 (n int) +master-bin.000001 1056 Query 1 1056 use `test`; insert t0 select * from t1 +master-bin.000001 1117 Query 1 1117 use `test`; DO RELEASE_LOCK("a") +master-bin.000001 1172 Query 1 1172 use `test`; insert into t0 select GET_LOCK("lock1",null) +master-bin.000001 1251 Query 1 1251 use `test`; create table t2 (n int) engine=innodb +do release_lock("lock1"); +drop table t0,t2; diff --git a/mysql-test/r/rpl_bug7947.result b/mysql-test/r/rpl_bug7947.result deleted file mode 100644 index 117e71a63d5..00000000000 --- a/mysql-test/r/rpl_bug7947.result +++ /dev/null @@ -1,46 +0,0 @@ -stop slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -reset master; -reset slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -start slave; -begin; -create temporary table ti (a int) engine=innodb; -rollback; -Warnings: -Warning 1196 Some non-transactional changed tables couldn't be rolled back -insert into ti values(1); -set autocommit=0; -create temporary table t1 (a int) type=myisam; -Warnings: -Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead -commit; -insert t1 values (1); -rollback; -create table t0 (n int); -insert t0 select * from t1; -set autocommit=1; -insert into t0 select GET_LOCK("lock1",null); -set autocommit=0; -create table t2 (n int) engine=innodb; -insert into t2 values (3); -select get_lock("lock1",null); -get_lock("lock1",null) -1 -show binlog events from 79; -Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.000001 79 Query 1 79 use `test`; BEGIN -master-bin.000001 119 Query 1 79 use `test`; create temporary table ti (a int) engine=innodb -master-bin.000001 201 Query 1 201 use `test`; ROLLBACK -master-bin.000001 244 Query 1 244 use `test`; insert into ti values(1) -master-bin.000001 303 Query 1 303 use `test`; BEGIN -master-bin.000001 343 Query 1 303 use `test`; create temporary table t1 (a int) type=myisam -master-bin.000001 423 Query 1 423 use `test`; COMMIT -master-bin.000001 464 Query 1 464 use `test`; create table t0 (n int) -master-bin.000001 522 Query 1 522 use `test`; insert t0 select * from t1 -master-bin.000001 583 Query 1 583 use `test`; insert into t0 select GET_LOCK("lock1",null) -master-bin.000001 662 Query 1 662 use `test`; create table t2 (n int) engine=innodb -master-bin.000001 734 Query 1 734 use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti` -master-bin.000001 835 Query 1 835 use `test`; DO RELEASE_LOCK("lock1") -do release_lock("lock1"); -drop table t0,t2; diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 6eb9eae2d99..a25ab9c368e 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -206,7 +206,33 @@ select (@after:=unix_timestamp())*0; # always give repeatable output # the bug, the reap would return immediately after the insert into t2. select (@after-@before) >= 2; -# cleanup drop table t1,t2; +commit; + +# test for BUG#7947 - DO RELEASE_LOCK() not written to binlog on rollback in the middle +# of a transaction + +connection con2; +begin; +create temporary table ti (a int) engine=innodb; +rollback; +insert into ti values(1); +set autocommit=0; +create temporary table t1 (a int) engine=myisam; commit; +insert t1 values (1); rollback; +create table t0 (n int); +insert t0 select * from t1; +set autocommit=1; +insert into t0 select GET_LOCK("lock1",null); +set autocommit=0; +create table t2 (n int) engine=innodb; +insert into t2 values (3); +disconnect con2; +connection con3; +select get_lock("lock1",null); +show binlog events from 79; +do release_lock("lock1"); +drop table t0,t2; + # End of 4.1 tests diff --git a/mysql-test/t/rpl_bug7947.test b/mysql-test/t/rpl_bug7947.test deleted file mode 100644 index e802a311b6c..00000000000 --- a/mysql-test/t/rpl_bug7947.test +++ /dev/null @@ -1,22 +0,0 @@ ---source include/master-slave.inc -connection master; -begin; -create temporary table ti (a int) engine=innodb; -rollback; -insert into ti values(1); -set autocommit=0; -create temporary table t1 (a int) type=myisam; commit; -insert t1 values (1); rollback; -create table t0 (n int); -insert t0 select * from t1; -set autocommit=1; -insert into t0 select GET_LOCK("lock1",null); -set autocommit=0; -create table t2 (n int) engine=innodb; -insert into t2 values (3); -disconnect master; -connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock); -select get_lock("lock1",null); -show binlog events from 79; -do release_lock("lock1"); -drop table t0,t2; From 517967de1ab922113a97d0dd19d0c2ea50978c67 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Nov 2005 18:26:30 +1100 Subject: [PATCH 19/22] WL#2779 ndb_size.pl fix some small bugs, slightly improve output, add --help ndb/tools/ndb_size.pl: Provide --help and --usage. Fix some bugs related to quoting table names. ndb/tools/ndb_size.tmpl: A NAME and A HREF to tables from the main list --- ndb/tools/ndb_size.pl | 30 +++++++++++++++++++----------- ndb/tools/ndb_size.tmpl | 6 +++--- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ndb/tools/ndb_size.pl b/ndb/tools/ndb_size.pl index 64a20423636..0203b0c1112 100644 --- a/ndb/tools/ndb_size.pl +++ b/ndb/tools/ndb_size.pl @@ -26,24 +26,33 @@ use HTML::Template; # BUGS # ---- # - enum/set is 0 byte storage! Woah - efficient! +# - DECIMAL is 0 byte storage. A bit too efficient. # - some float stores come out weird (when there's a comma e.g. 'float(4,1)') # - no disk data values # - computes the storage requirements of views (and probably MERGE) # - ignores character sets. my $template = HTML::Template->new(filename => 'ndb_size.tmpl', - die_on_bad_params => 0); + die_on_bad_params => 0) + or die "Could not open ndb_size.tmpl."; my $dbh; +if(@ARGV < 3 || $ARGV[0] eq '--usage' || $ARGV[0] eq '--help') +{ + print STDERR "Usage:\n"; + print STDERR "\tndb_size.pl database hostname user password\n\n"; + print STDERR "If you need to specify a port number, use host:port\n\n"; + exit(1); +} + { my $database= $ARGV[0]; my $hostname= $ARGV[1]; - my $port= $ARGV[2]; - my $user= $ARGV[3]; - my $password= $ARGV[4]; - my $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; - $dbh= DBI->connect($dsn, $user, $password); + my $user= $ARGV[2]; + my $password= $ARGV[3]; + my $dsn = "DBI:mysql:database=$database;host=$hostname"; + $dbh= DBI->connect($dsn, $user, $password) or exit(1); $template->param(db => $database); $template->param(dsn => $dsn); } @@ -68,9 +77,8 @@ foreach(@{$tables}) { my $table= @{$_}[0]; my @columns; - my $info= $dbh->selectall_hashref("describe ".$dbh->quote($table),"Field"); - my @count = $dbh->selectrow_array("select count(*) from " - .$dbh->quote($table)); + my $info= $dbh->selectall_hashref('describe `'.$table.'`',"Field"); + my @count = $dbh->selectrow_array('select count(*) from `'.$table.'`'); my %columnsize; # used for index calculations # We now work out the DataMemory usage @@ -132,7 +140,7 @@ foreach(@{$tables}) my $fixed= 1+$size; my @dynamic=$dbh->selectrow_array("select avg(length(" .$dbh->quote($name) - .")) from ".$dbh->quote($table)); + .")) from `".$table.'`'); $dynamic[0]=0 if !$dynamic[0]; @realsize= ($fixed,$fixed,ceil($dynamic[0])); } @@ -166,7 +174,7 @@ foreach(@{$tables}) # we can still connect to pre-5.0 mysqlds. my %indexes; { - my $sth= $dbh->prepare("show index from "$dbh->quote($table)); + my $sth= $dbh->prepare("show index from `".$table.'`'); $sth->execute; while(my $i = $sth->fetchrow_hashref) { diff --git a/ndb/tools/ndb_size.tmpl b/ndb/tools/ndb_size.tmpl index d83d5d2c6af..5d9fc8bf0c5 100644 --- a/ndb/tools/ndb_size.tmpl +++ b/ndb/tools/ndb_size.tmpl @@ -13,18 +13,18 @@ td,th { border: 1px solid black }

MySQL Cluster analysis for

This is an automated analysis of the database for migration into MySQL Cluster. No warranty is made to the accuracy of the information.

-

This information should be valid for MySQL 4.1

+

This information should be valid for MySQL 4.1 and 5.0. Since 5.1 is not a final release yet, the numbers should be used as a guide only.


-

+

">

From 74ae82f5c4ed135f4edbc0aa223a45fdd507cb3b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Nov 2005 19:47:03 +1100 Subject: [PATCH 20/22] WL#2779 ndb_size.pl Add display of minimum requirements for various cluster parameters e.g. DataMemory, IndexMemory, MaxNoOfTables, MaxNoOfAttributes etc and the memory usage because of them. ndb/tools/ndb_size.pl: Computer minimum parameter settings (MaxNoOfTables, Attributes, Indexes, Triggers) and the memory usage because of these settings. ndb/tools/ndb_size.tmpl: display parameters --- ndb/tools/ndb_size.pl | 57 ++++++++++++++++++++++++++++++++++++++++- ndb/tools/ndb_size.tmpl | 40 +++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/ndb/tools/ndb_size.pl b/ndb/tools/ndb_size.pl index 0203b0c1112..ece0901e0b2 100644 --- a/ndb/tools/ndb_size.pl +++ b/ndb/tools/ndb_size.pl @@ -64,6 +64,14 @@ my $tables = $dbh->selectall_arrayref("show tables"); my @table_size; +my @dbDataMemory; +my @dbIndexMemory; +my @NoOfAttributes; +my @NoOfIndexes; +my @NoOfTables; +$NoOfTables[$_]{val} = @{$tables} foreach 0..$#releases; + + sub align { my($to,@unaligned) = @_; my @aligned; @@ -147,7 +155,10 @@ foreach(@{$tables}) elsif($type =~ /binary/ || $type =~ /char/) {@realsize=($size,$size,$size)} elsif($type =~ /text/ || $type =~ /blob/) - {@realsize=(256,256,1)} # FIXME check if 5.1 is correct + { + @realsize=(256,256,1); + $NoOfTables[$_]{val} += 1 foreach 0..$#releases; # blob uses table + } # FIXME check if 5.1 is correct @realsize= align(4,@realsize); @@ -265,7 +276,51 @@ foreach(@{$tables}) IndexMemory=>\@IndexMemory, }; + + $dbDataMemory[$_]{val} += $DataMemory[$_]{val} foreach 0..$#releases; + $dbIndexMemory[$_]{val} += $IndexMemory[$_]{val} foreach 0..$#releases; + $NoOfAttributes[$_]{val} += @columns foreach 0..$#releases; + $NoOfIndexes[$_]{val} += @indexes foreach 0..$#releases; +} + +my @NoOfTriggers; +# for unique hash indexes +$NoOfTriggers[$_]{val} += $NoOfIndexes[$_]{val}*3 foreach 0..$#releases; +# for ordered index +$NoOfTriggers[$_]{val} += $NoOfIndexes[$_]{val} foreach 0..$#releases; + +my @ParamMemory; +foreach (0..$#releases) { + $ParamMemory[0]{releases}[$_]{val}= POSIX::ceil(200*$NoOfAttributes[$_]{val}/1024); + $ParamMemory[0]{name}= 'Attributes'; + + $ParamMemory[1]{releases}[$_]{val}= 20*$NoOfTables[$_]{val}; + $ParamMemory[1]{name}= 'Tables'; + + $ParamMemory[2]{releases}[$_]{val}= 10*$NoOfIndexes[$_]{val}; + $ParamMemory[2]{name}= 'OrderedIndexes'; + + $ParamMemory[3]{releases}[$_]{val}= 15*$NoOfIndexes[$_]{val}; + $ParamMemory[3]{name}= 'UniqueHashIndexes'; } $template->param(tables => \@table_size); +$template->param(Parameters => [{name=>'DataMemory (kb)', + releases=>\@dbDataMemory}, + {name=>'IndexMemory (kb)', + releases=>\@dbIndexMemory}, + {name=>'MaxNoOfTables', + releases=>\@NoOfTables}, + {name=>'MaxNoOfAttributes', + releases=>\@NoOfAttributes}, + {name=>'MaxNoOfOrderedIndexes', + releases=>\@NoOfIndexes}, + {name=>'MaxNoOfUniqueHashIndexes', + releases=>\@NoOfIndexes}, + {name=>'MaxNoOfTriggers', + releases=>\@NoOfTriggers} + ] + ); +$template->param(ParamMemory => \@ParamMemory); + print $template->output; diff --git a/ndb/tools/ndb_size.tmpl b/ndb/tools/ndb_size.tmpl index 5d9fc8bf0c5..dc02b5a5970 100644 --- a/ndb/tools/ndb_size.tmpl +++ b/ndb/tools/ndb_size.tmpl @@ -15,6 +15,46 @@ td,th { border: 1px solid black }

This information should be valid for MySQL 4.1 and 5.0. Since 5.1 is not a final release yet, the numbers should be used as a guide only.

+

Parameter Settings

+

NOTE the configuration parameters below do not take into account system tables and other requirements.

+
Column
+ + + + + + + + + + + + + + +
Parameter
+ +

Memory usage because of parameters

+ +

Usage is in kilobytes. Actual usage will vary as you should set the parameters larger than those listed in the table above.

+ + + + + + + + + + + + + + + +
Parameter
+ +

Table List

  • ">
  • From 563e5c8d7961c79106fcf3b83656942ece4b4cd4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Nov 2005 11:52:09 +0100 Subject: [PATCH 21/22] ndb - bug#14007 4.1 [re-commit for LenZ merge] mysql-test/r/ndb_charset.result: bug#14007 test [re-commit] mysql-test/t/ndb_charset.test: bug#14007 test [re-commit] ndb/include/kernel/AttributeDescriptor.hpp: bug#14007 4.1 need getSizeInBytes [re-commit] ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp: bug#14007 4.1 *** do not AUTOmerge to 5.0 *** [re-commit] --- mysql-test/r/ndb_charset.result | 22 +++++++++++++----- mysql-test/t/ndb_charset.test | 19 ++++++++------- ndb/include/kernel/AttributeDescriptor.hpp | 9 ++++++++ ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp | 23 ++++++++++++++++++- 4 files changed, 58 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/ndb_charset.result b/mysql-test/r/ndb_charset.result index 00bc36a7c0d..b8d881fca83 100644 --- a/mysql-test/r/ndb_charset.result +++ b/mysql-test/r/ndb_charset.result @@ -190,12 +190,22 @@ p a 6 AAA drop table t1; create table t1 ( -a varchar(10) primary key -) engine=ndb; -insert into t1 values ('jonas % '); -replace into t1 values ('jonas % '); -replace into t1 values ('jonas % '); +a char(10) primary key +) engine=ndbcluster default charset=latin1; +insert into t1 values ('aaabb'); select * from t1; a -jonas % +aaabb +replace into t1 set a = 'AAABB'; +select * from t1; +a +AAABB +replace into t1 set a = 'aAaBb'; +select * from t1; +a +aAaBb +replace into t1 set a = 'aaabb'; +select * from t1; +a +aaabb drop table t1; diff --git a/mysql-test/t/ndb_charset.test b/mysql-test/t/ndb_charset.test index 89f1ed17cfb..a885427f593 100644 --- a/mysql-test/t/ndb_charset.test +++ b/mysql-test/t/ndb_charset.test @@ -159,14 +159,17 @@ select * from t1 where a = 'AaA' order by p; select * from t1 where a = 'AAA' order by p; drop table t1; -# bug +# bug#14007 create table t1 ( - a varchar(10) primary key -) engine=ndb; -insert into t1 values ('jonas % '); -replace into t1 values ('jonas % '); -replace into t1 values ('jonas % '); + a char(10) primary key +) engine=ndbcluster default charset=latin1; + +insert into t1 values ('aaabb'); +select * from t1; +replace into t1 set a = 'AAABB'; +select * from t1; +replace into t1 set a = 'aAaBb'; +select * from t1; +replace into t1 set a = 'aaabb'; select * from t1; drop table t1; - -# End of 4.1 tests diff --git a/ndb/include/kernel/AttributeDescriptor.hpp b/ndb/include/kernel/AttributeDescriptor.hpp index 071d45e2607..9d7de21d904 100644 --- a/ndb/include/kernel/AttributeDescriptor.hpp +++ b/ndb/include/kernel/AttributeDescriptor.hpp @@ -36,6 +36,7 @@ private: static Uint32 getType(const Uint32 &); static Uint32 getSize(const Uint32 &); + static Uint32 getSizeInBytes(const Uint32 &); static Uint32 getSizeInWords(const Uint32 &); static Uint32 getArrayType(const Uint32 &); static Uint32 getArraySize(const Uint32 &); @@ -79,6 +80,7 @@ private: #define AD_SIZE_SHIFT (4) #define AD_SIZE_MASK (7) +#define AD_SIZE_IN_BYTES_SHIFT (3) #define AD_SIZE_IN_WORDS_OFFSET (31) #define AD_SIZE_IN_WORDS_SHIFT (5) @@ -185,6 +187,13 @@ AttributeDescriptor::getSize(const Uint32 & desc){ return (desc >> AD_SIZE_SHIFT) & AD_SIZE_MASK; } +inline +Uint32 +AttributeDescriptor::getSizeInBytes(const Uint32 & desc){ + return (getArraySize(desc) << getSize(desc)) + >> AD_SIZE_IN_BYTES_SHIFT; +} + inline Uint32 AttributeDescriptor::getSizeInWords(const Uint32 & desc){ diff --git a/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index cbb165c3eb1..7b642f90a17 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -700,6 +700,27 @@ Dbtup::checkUpdateOfPrimaryKey(Uint32* updateBuffer, Tablerec* const regTabPtr) Uint32 attrDescriptorIndex = regTabPtr->tabDescriptor + (attributeId << ZAD_LOG_SIZE); Uint32 attrDescriptor = tableDescriptor[attrDescriptorIndex].tabDescr; Uint32 attributeOffset = tableDescriptor[attrDescriptorIndex + 1].tabDescr; + + Uint32 xfrmBuffer[1 + MAX_KEY_SIZE_IN_WORDS * 1]; // strxfrm_multiply == 1 + Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attributeOffset); + if (charsetFlag) { + Uint32 csPos = AttributeOffset::getCharsetPos(attributeOffset); + CHARSET_INFO* cs = regTabPtr->charsetArray[csPos]; + Uint32 sizeInBytes = AttributeDescriptor::getSizeInBytes(attrDescriptor); + Uint32 sizeInWords = AttributeDescriptor::getSizeInWords(attrDescriptor); + const uchar* srcPtr = (uchar*)&updateBuffer[1]; + uchar* dstPtr = (uchar*)&xfrmBuffer[1]; + Uint32 n = + (*cs->coll->strnxfrm)(cs, dstPtr, sizeInBytes, srcPtr, sizeInBytes); + // pad with blanks (unlikely) and zeroes to match NDB API behaviour + while (n < sizeInBytes) + dstPtr[n++] = 0x20; + while (n < 4 * sizeInWords) + dstPtr[n++] = 0; + xfrmBuffer[0] = ahIn.m_value; + updateBuffer = xfrmBuffer; + } + ReadFunction f = regTabPtr->readFunctionArray[attributeId]; AttributeHeader::init(&attributeHeader, attributeId, 0); @@ -707,7 +728,7 @@ Dbtup::checkUpdateOfPrimaryKey(Uint32* updateBuffer, Tablerec* const regTabPtr) tMaxRead = MAX_KEY_SIZE_IN_WORDS; bool tmp = tXfrmFlag; - tXfrmFlag = false; + tXfrmFlag = true; ndbrequire((this->*f)(&keyReadBuffer[0], ahOut, attrDescriptor, attributeOffset)); tXfrmFlag = tmp; ndbrequire(tOutBufIndex == ahOut->getDataSize()); From 4d93df791452162f4ed54a4eb44178f1892b41ba Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Nov 2005 21:17:38 -0700 Subject: [PATCH 22/22] fixed the race condition in the test case for BUG#7947 --- mysql-test/r/mix_innodb_myisam_binlog.result | 8 +++++--- mysql-test/t/mix_innodb_myisam_binlog.test | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index a586ad93ce4..e9613bac833 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -222,9 +222,9 @@ insert into t0 select GET_LOCK("lock1",null); set autocommit=0; create table t2 (n int) engine=innodb; insert into t2 values (3); -select get_lock("lock1",null); -get_lock("lock1",null) -0 +select get_lock("lock1",60); +get_lock("lock1",60) +1 show binlog events from 79; Log_name Pos Event_type Server_id Orig_log_pos Info master-bin.000001 79 Query 1 79 use `test`; BEGIN @@ -249,5 +249,7 @@ master-bin.000001 1056 Query 1 1056 use `test`; insert t0 select * from t1 master-bin.000001 1117 Query 1 1117 use `test`; DO RELEASE_LOCK("a") master-bin.000001 1172 Query 1 1172 use `test`; insert into t0 select GET_LOCK("lock1",null) master-bin.000001 1251 Query 1 1251 use `test`; create table t2 (n int) engine=innodb +master-bin.000001 1323 Query 1 1323 use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti` +master-bin.000001 1424 Query 1 1424 use `test`; DO RELEASE_LOCK("lock1") do release_lock("lock1"); drop table t0,t2; diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index a25ab9c368e..4581736ac8c 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -218,8 +218,10 @@ create temporary table ti (a int) engine=innodb; rollback; insert into ti values(1); set autocommit=0; -create temporary table t1 (a int) engine=myisam; commit; -insert t1 values (1); rollback; +create temporary table t1 (a int) engine=myisam; +commit; +insert t1 values (1); +rollback; create table t0 (n int); insert t0 select * from t1; set autocommit=1; @@ -229,7 +231,7 @@ create table t2 (n int) engine=innodb; insert into t2 values (3); disconnect con2; connection con3; -select get_lock("lock1",null); +select get_lock("lock1",60); show binlog events from 79; do release_lock("lock1"); drop table t0,t2;