From 40e25a305d4a85252edb412057a28d9956414997 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Nov 2004 22:55:00 +0100 Subject: [PATCH 1/6] wrong constant fixed - boolean fulltext searches like "+something +smth*" were stopping at docid 0xffffffff --- myisam/ft_boolean_search.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 13f46849210..97dfb18e5f9 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -161,7 +161,7 @@ static void _ftb_parse_query(FTB *ftb, byte **start, byte *end, if (param.trunc) ftbw->flags|=FTB_FLAG_TRUNC; ftbw->weight=weight; ftbw->up=up; - ftbw->docid[0]=ftbw->docid[1]=HA_POS_ERROR; + ftbw->docid[0]=ftbw->docid[1]=HA_OFFSET_ERROR; ftbw->ndepth= (param.yesno<0) + depth; memcpy(ftbw->word+1, w.pos, w.len); ftbw->word[0]=w.len; @@ -177,7 +177,7 @@ static void _ftb_parse_query(FTB *ftb, byte **start, byte *end, ftbe->weight=weight; ftbe->up=up; ftbe->ythresh=ftbe->yweaks=0; - ftbe->docid[0]=ftbe->docid[1]=HA_POS_ERROR; + ftbe->docid[0]=ftbe->docid[1]=HA_OFFSET_ERROR; if ((ftbe->quot=param.quot)) ftb->with_scan|=2; if (param.yesno > 0) up->ythresh++; _ftb_parse_query(ftb, start, end, ftbe, depth+1); @@ -245,7 +245,7 @@ static void _ftb_init_index_search(FT_INFO *ftb) ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */ { FTB_EXPR *top_ftbe=ftbe->up->up; - ftbw->docid[0]=HA_POS_ERROR; + ftbw->docid[0]=HA_OFFSET_ERROR; for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) if (ftbe->flags & FTB_FLAG_YES) ftbe->yweaks++; @@ -319,7 +319,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, default_charset_info : info->s->keyinfo[keynr].seg->charset); ftb->with_scan=0; - ftb->lastpos=HA_POS_ERROR; + ftb->lastpos=HA_OFFSET_ERROR; bzero(& ftb->no_dupes, sizeof(TREE)); init_alloc_root(&ftb->mem_root, 1024, 1024); @@ -342,7 +342,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, ftbe->quot=0; ftbe->up=0; ftbe->ythresh=ftbe->yweaks=0; - ftbe->docid[0]=ftbe->docid[1]=HA_POS_ERROR; + ftbe->docid[0]=ftbe->docid[1]=HA_OFFSET_ERROR; ftb->root=ftbe; _ftb_parse_query(ftb, &query, query+query_len, ftbe, 0); ftb->list=(FTB_WORD **)alloc_root(&ftb->mem_root, @@ -496,7 +496,7 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record) while (ftb->state == INDEX_SEARCH && (curdoc=((FTB_WORD *)queue_top(& ftb->queue))->docid[0]) != - HA_POS_ERROR) + HA_OFFSET_ERROR) { while (curdoc==(ftbw=(FTB_WORD *)queue_top(& ftb->queue))->docid[0]) { @@ -521,7 +521,7 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record) } if (r) /* not found */ { - ftbw->docid[0]=HA_POS_ERROR; + ftbw->docid[0]=HA_OFFSET_ERROR; if (ftbw->flags&FTB_FLAG_YES && ftbw->up->up==0) { /* @@ -580,7 +580,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) const byte *end; my_off_t docid=ftb->info->lastpos; - if (docid == HA_POS_ERROR) + if (docid == HA_OFFSET_ERROR) return -2.0; if (!ftb->queue.elements) return 0; @@ -592,9 +592,9 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) for (i=0; i < ftb->queue.elements; i++) { - ftb->list[i]->docid[1]=HA_POS_ERROR; + ftb->list[i]->docid[1]=HA_OFFSET_ERROR; for (x=ftb->list[i]->up; x; x=x->up) - x->docid[1]=HA_POS_ERROR; + x->docid[1]=HA_OFFSET_ERROR; } } From 16d735adb0cc7776da40838dd11810a1817f76ff Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Nov 2004 20:37:42 +0200 Subject: [PATCH 2/6] ha_innodb.cc: Fix InnoDB bug #6287: if one uses INSERT IGNORE to insert several rows at a time, and the first inserts are ignored because of a duplicate key collision, then InnoDB in a replication slave assigns AUTO_INCREMENT values 1 bigger than in the master sql/ha_innodb.cc: Fix InnoDB bug #6287: if one uses INSERT IGNORE to insert several rows at a time, and the first inserts are ignored because of a duplicate key collision, then InnoDB in a replication slave assigns AUTO_INCREMENT values 1 bigger than in the master --- sql/ha_innodb.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index d57a9f73c91..91f92c8cadb 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2172,8 +2172,9 @@ ha_innobase::write_row( same SQL statement! */ if (auto_inc == 0 && user_thd->next_insert_id != 0) { - auto_inc = user_thd->next_insert_id; - auto_inc_counter_for_this_stat = auto_inc; + + auto_inc_counter_for_this_stat + = user_thd->next_insert_id; } if (auto_inc == 0 && auto_inc_counter_for_this_stat) { @@ -2181,14 +2182,14 @@ ha_innobase::write_row( this SQL statement with SET INSERT_ID. We must assign sequential values from the counter. */ - auto_inc_counter_for_this_stat++; - incremented_auto_inc_for_stat = TRUE; - auto_inc = auto_inc_counter_for_this_stat; /* We give MySQL a new value to place in the auto-inc column */ user_thd->next_insert_id = auto_inc; + + auto_inc_counter_for_this_stat++; + incremented_auto_inc_for_stat = TRUE; } if (auto_inc != 0) { From 835e0159b68e62656a549fb05549632f123fe98f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Nov 2004 13:38:35 +0100 Subject: [PATCH 3/6] test for bug#5528 --- mysql-test/r/fulltext.result | 9 +++++++++ mysql-test/t/fulltext.test | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 19bd355f537..31be1881897 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -298,3 +298,12 @@ t1_id name t2_id t1_id name select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode); t2_id t1_id name drop table t1,t2; +CREATE TABLE t1 (h text, FULLTEXT (h)); +INSERT INTO t1 VALUES ('Jesses Hasse Ling and his syncopators of Swing'); +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +select count(*) from t1; +count(*) +1 +drop table t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index bd887bc63ee..e46399bb876 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -240,3 +240,13 @@ select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode); drop table t1,t2; +# +# icc -ip bug (ip = interprocedural optimization) +# bug#5528 +# +CREATE TABLE t1 (h text, FULLTEXT (h)); +INSERT INTO t1 VALUES ('Jesses Hasse Ling and his syncopators of Swing'); +REPAIR TABLE t1; +select count(*) from t1; +drop table t1; + From ab51882b772b92876de8295ee6d0a09bf085c749 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Nov 2004 16:41:30 +0100 Subject: [PATCH 4/6] Fixes for compilation errors in Windows (casts from uint32* to uint*) in repl and charset code. Moving the part of user_var.test using UCS2 to ctype_ucs.test mysql-test/r/ctype_ucs.result: result update mysql-test/r/user_var.result: result update mysql-test/t/ctype_ucs.test: importing test piece from user_var.test mysql-test/t/user_var.test: using UCS2 in this test fails on non-USC2-capable binaries, so let's move this piece to ctype_ucs.test. sql/slave.cc: changing arg type to uint32* (as what is used in this arg is &thd->db_length which is uint32*) sql/slave.h: changing arg type to uint32* sql/sql_parse.cc: changing arg types to uint32, as what is used in these args is a create_field::length which is uint32. --- mysql-test/r/ctype_ucs.result | 14 ++++++++++++++ mysql-test/r/user_var.result | 13 +------------ mysql-test/t/ctype_ucs.test | 15 +++++++++++++++ mysql-test/t/user_var.test | 5 +---- sql/slave.cc | 4 ++-- sql/slave.h | 2 +- sql/sql_parse.cc | 8 ++++---- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 0e36b00a670..56830153fd0 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -487,3 +487,17 @@ prepare stmt1 from @str2; execute stmt1 using @ivar; ? 1234 +create table t2 (c char(30)) charset=ucs2; +set @v=convert('abc' using ucs2); +reset master; +insert into t2 values (@v); +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.000001 79 User var 1 79 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci +master-bin.000001 119 Query 1 119 use `test`; insert into t2 values (@v) +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +SET @`v`:=_ucs2 0x006100620063 COLLATE ucs2_general_ci; +use test; +SET TIMESTAMP=1100684975; +insert into t2 values (@v); +drop table t2; diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 659c392e153..4f521143d97 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -169,18 +169,12 @@ SET @`a b`='hello'; INSERT INTO t1 VALUES(@`a b`); set @var1= "';aaa"; insert into t1 values (@var1); -create table t2 (c char(30)) charset=ucs2; -set @v=convert('abc' using ucs2); -insert into t2 values (@v); show binlog events from 79; Log_name Pos Event_type Server_id Orig_log_pos Info master-bin.000001 79 User var 1 79 @`a b`=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci master-bin.000001 120 Query 1 120 use `test`; INSERT INTO t1 VALUES(@`a b`) master-bin.000001 184 User var 1 184 @`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci master-bin.000001 226 Query 1 226 use `test`; insert into t1 values (@var1) -master-bin.000001 290 Query 1 290 use `test`; create table t2 (c char(30)) charset=ucs2 -master-bin.000001 366 User var 1 366 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci -master-bin.000001 406 Query 1 406 use `test`; insert into t2 values (@v) /*!40019 SET @@session.max_insert_delayed_threads=0*/; SET @`a b`:=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci; use test; @@ -189,12 +183,7 @@ INSERT INTO t1 VALUES(@`a b`); SET @`var1`:=_latin1 0x273B616161 COLLATE latin1_swedish_ci; SET TIMESTAMP=10000; insert into t1 values (@var1); -SET TIMESTAMP=10000; -create table t2 (c char(30)) charset=ucs2; -SET @`v`:=_ucs2 0x006100620063 COLLATE ucs2_general_ci; -SET TIMESTAMP=10000; -insert into t2 values (@v); -drop table t1, t2; +drop table t1; set @var= NULL ; select FIELD( @var,'1it','Hit') as my_column; my_column diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 4c6d1bbebef..909638042c2 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -323,3 +323,18 @@ set @str1 = 'select ?'; set @str2 = convert(@str1 using ucs2); prepare stmt1 from @str2; execute stmt1 using @ivar; + +# +# Check correct binlogging of UCS2 user variables (BUG#3875) +# +create table t2 (c char(30)) charset=ucs2; +set @v=convert('abc' using ucs2); +reset master; +insert into t2 values (@v); +show binlog events from 79; +# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we +# absolutely need variables names to be quoted and strings to be +# escaped). +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +drop table t2; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 3816af42c55..d985be05b94 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -108,16 +108,13 @@ SET @`a b`='hello'; INSERT INTO t1 VALUES(@`a b`); set @var1= "';aaa"; insert into t1 values (@var1); -create table t2 (c char(30)) charset=ucs2; -set @v=convert('abc' using ucs2); -insert into t2 values (@v); show binlog events from 79; # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we # absolutely need variables names to be quoted and strings to be # escaped). --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 -drop table t1, t2; +drop table t1; # diff --git a/sql/slave.cc b/sql/slave.cc index b6ad35573ff..6bc977e8d41 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1032,7 +1032,7 @@ bool net_request_file(NET* net, const char* fname) } -const char *rewrite_db(const char* db, uint *new_len) +const char *rewrite_db(const char* db, uint32 *new_len) { if (replicate_rewrite_db.is_empty() || !db) return db; @@ -1043,7 +1043,7 @@ const char *rewrite_db(const char* db, uint *new_len) { if (!strcmp(tmp->key, db)) { - *new_len= strlen(tmp->val); + *new_len= (uint32)strlen(tmp->val); return tmp->val; } } diff --git a/sql/slave.h b/sql/slave.h index 97f197fb50a..c6cb81699a2 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -510,7 +510,7 @@ int add_table_rule(HASH* h, const char* table_spec); int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec); void init_table_rule_hash(HASH* h, bool* h_inited); void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited); -const char *rewrite_db(const char* db, uint *new_db_len); +const char *rewrite_db(const char* db, uint32 *new_db_len); const char *print_slave_db_safe(const char *db); int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int error_code); void skip_load_data_infile(NET* net); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7420f9de100..e066e447345 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4123,7 +4123,7 @@ bool mysql_test_parse_for_slave(THD *thd, char *inBuf, uint length) - SET uses tot_length. */ void calculate_interval_lengths(THD *thd, TYPELIB *interval, - uint *max_length, uint *tot_length) + uint32 *max_length, uint32 *tot_length) { const char **pos; uint *len; @@ -4135,7 +4135,7 @@ void calculate_interval_lengths(THD *thd, TYPELIB *interval, *len= (uint) strip_sp((char*) *pos); uint length= cs->cset->numchars(cs, *pos, *pos + *len); *tot_length+= length; - set_if_bigger(*max_length, length); + set_if_bigger(*max_length, (uint32)length); } } @@ -4454,7 +4454,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, if (new_field->pack_length > 4) new_field->pack_length=8; new_field->interval=interval; - uint dummy_max_length; + uint32 dummy_max_length; calculate_interval_lengths(thd, interval, &dummy_max_length, &new_field->length); new_field->length+= (interval->count - 1); @@ -4484,7 +4484,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, new_field->interval=interval; new_field->pack_length=interval->count < 256 ? 1 : 2; // Should be safe - uint dummy_tot_length; + uint32 dummy_tot_length; calculate_interval_lengths(thd, interval, &new_field->length, &dummy_tot_length); set_if_smaller(new_field->length,MAX_FIELD_WIDTH-1); From d1e4a1f1719a662166fb835ac018cd097cabd4bc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Nov 2004 17:06:24 +0100 Subject: [PATCH 5/6] time independent test mysql-test/r/ctype_ucs.result: result update mysql-test/t/ctype_ucs.test: time independent --- mysql-test/r/ctype_ucs.result | 3 ++- mysql-test/t/ctype_ucs.test | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 56830153fd0..6394bc28c6e 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -487,6 +487,7 @@ prepare stmt1 from @str2; execute stmt1 using @ivar; ? 1234 +SET TIMESTAMP=10000; create table t2 (c char(30)) charset=ucs2; set @v=convert('abc' using ucs2); reset master; @@ -498,6 +499,6 @@ master-bin.000001 119 Query 1 119 use `test`; insert into t2 values (@v) /*!40019 SET @@session.max_insert_delayed_threads=0*/; SET @`v`:=_ucs2 0x006100620063 COLLATE ucs2_general_ci; use test; -SET TIMESTAMP=1100684975; +SET TIMESTAMP=10000; insert into t2 values (@v); drop table t2; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 909638042c2..0b8678ef59b 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -327,6 +327,7 @@ execute stmt1 using @ivar; # # Check correct binlogging of UCS2 user variables (BUG#3875) # +SET TIMESTAMP=10000; create table t2 (c char(30)) charset=ucs2; set @v=convert('abc' using ucs2); reset master; From 2267ea3e029cb2b450a4ca6a67f0ae036ff709f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Nov 2004 08:42:26 +0000 Subject: [PATCH 6/6] ifdef'd unused table reorg code --- ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 12 ++++++++++-- ndb/src/kernel/blocks/dbdict/Dbdict.hpp | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index 882557daae1..2b9072ab042 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -239,7 +239,11 @@ Dbdict::packTableIntoPagesImpl(SimpleProperties::Writer & w, w.add(DictTabInfo::TableName, tablePtr.p->tableName); w.add(DictTabInfo::TableId, tablePtr.i); +#ifdef HAVE_TABLE_REORG w.add(DictTabInfo::SecondTableId, tablePtr.p->secondTable); +#else + w.add(DictTabInfo::SecondTableId, (Uint32)0); +#endif w.add(DictTabInfo::TableVersion, tablePtr.p->tableVersion); w.add(DictTabInfo::NoOfKeyAttr, tablePtr.p->noOfPrimkey); w.add(DictTabInfo::NoOfAttributes, tablePtr.p->noOfAttributes); @@ -1436,6 +1440,7 @@ Uint32 Dbdict::getFreeTableRecord(Uint32 primaryTableId) jam(); return RNIL; }//if +#ifdef HAVE_TABLE_REORG bool secondFound = false; for (tablePtr.i = firstTablePtr.i + 1; tablePtr.i < tabSize ; tablePtr.i++) { jam(); @@ -1455,6 +1460,7 @@ Uint32 Dbdict::getFreeTableRecord(Uint32 primaryTableId) firstTablePtr.p->tabState = TableRecord::NOT_DEFINED; return RNIL; }//if +#endif return firstTablePtr.i; }//Dbdict::getFreeTableRecord() @@ -4623,7 +4629,7 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it, jam(); tablePtr.p->tabState = TableRecord::DEFINING; }//if - +#ifdef HAVE_TABLE_REORG /* ---------------------------------------------------------------- */ // Get id of second table id and check that table doesn't already exist // and set up links between first and second table. @@ -4637,7 +4643,7 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it, secondTablePtr.p->tabState = TableRecord::REORG_TABLE_PREPARED; secondTablePtr.p->secondTable = tablePtr.i; tablePtr.p->secondTable = secondTablePtr.i; - +#endif /* ---------------------------------------------------------------- */ // Set table version /* ---------------------------------------------------------------- */ @@ -5535,10 +5541,12 @@ void Dbdict::releaseTableObject(Uint32 tableId, bool removeFromHash) nextAttrRecord = attrPtr.p->nextAttrInTable; c_attributeRecordPool.release(attrPtr); }//if +#ifdef HAVE_TABLE_REORG Uint32 secondTableId = tablePtr.p->secondTable; initialiseTableRecord(tablePtr); c_tableRecordPool.getPtr(tablePtr, secondTableId); initialiseTableRecord(tablePtr); +#endif return; }//releaseTableObject() diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.hpp b/ndb/src/kernel/blocks/dbdict/Dbdict.hpp index 19c03a86e22..af80bcf5f94 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.hpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.hpp @@ -151,10 +151,10 @@ public: /* Temporary record used during add/drop table */ Uint32 myConnect; - +#ifdef HAVE_TABLE_REORG /* Second table used by this table (for table reorg) */ Uint32 secondTable; - +#endif /* Next record in Pool */ Uint32 nextPool;