From 63d4c1677e7e9d9652ee450e9abe1e877db91093 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Feb 2006 15:47:46 +0100 Subject: [PATCH 1/6] Bug #17325 HA Testing: Node failed takeover for failed node (Array index out of range) wrong arrGuard, see MAX_REPLICAS+1 0n row 6457 + changed all 4 constants to MAX_REPLICAS + moved some arrGuards out of loops for optim reasons --- ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index d7232030c41..c3f0794c569 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -3045,7 +3045,7 @@ void Dbtc::tckeyreq050Lab(Signal* signal) /* NODE IF POSSIBLE TO AVOID UNNECESSARY COMMUNICATION */ /* WITH SIMPLE READS. */ /*-------------------------------------------------------------*/ - arrGuard(tnoOfBackup, 4); + arrGuard(tnoOfBackup, MAX_REPLICAS); UintR Tindex; UintR TownNode = cownNodeid; for (Tindex = 1; Tindex <= tnoOfBackup; Tindex++) { @@ -6302,7 +6302,7 @@ void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr) jam(); tcConnectptr.i = apiConnectptr.p->currentTcConnect; ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord); - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo]; ptrCheckGuard(hostptr, chostFilesize, hostRecord); if (hostptr.p->hostStatus == HS_ALIVE) { @@ -6328,7 +6328,7 @@ void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr) jam(); tcConnectptr.i = apiConnectptr.p->currentTcConnect; ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord); - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo]; ptrCheckGuard(hostptr, chostFilesize, hostRecord); if (hostptr.p->hostStatus == HS_ALIVE) { @@ -6354,7 +6354,7 @@ void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr) jam(); tcConnectptr.i = apiConnectptr.p->currentTcConnect; ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord); - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo]; ptrCheckGuard(hostptr, chostFilesize, hostRecord); if (hostptr.p->hostStatus == HS_ALIVE) { @@ -6491,7 +6491,7 @@ void Dbtc::sendAbortedAfterTimeout(Signal* signal, int Tcheck) // in time to the ABORT signal we will declare it as dead. /*------------------------------------------------------------------*/ UintR Ti = 0; - arrGuard(tcConnectptr.p->noOfNodes, 4); + arrGuard(tcConnectptr.p->noOfNodes, MAX_REPLICAS+1); for (Ti = 0; Ti < tcConnectptr.p->noOfNodes; Ti++) { jam(); if (tcConnectptr.p->tcNodedata[Ti] != 0) { @@ -7548,7 +7548,7 @@ void Dbtc::execABORTCONF(Signal* signal) warningReport(signal, 18); return; }//if - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] != tnodeid) { warningReport(signal, 19); @@ -7564,7 +7564,7 @@ void Dbtc::toAbortHandlingLab(Signal* signal) do { if (tcurrentReplicaNo != (Uint8)Z8NIL) { jam(); - arrGuard(tcurrentReplicaNo, 4); + arrGuard(tcurrentReplicaNo, MAX_REPLICAS); const LqhTransConf::OperationStatus stat = (LqhTransConf::OperationStatus) tcConnectptr.p->failData[tcurrentReplicaNo]; @@ -7698,7 +7698,7 @@ void Dbtc::execCOMMITCONF(Signal* signal) warningReport(signal, 10); return; }//if - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] != tnodeid) { warningReport(signal, 11); @@ -7718,7 +7718,7 @@ void Dbtc::toCommitHandlingLab(Signal* signal) do { if (tcurrentReplicaNo != (Uint8)Z8NIL) { jam(); - arrGuard(tcurrentReplicaNo, 4); + arrGuard(tcurrentReplicaNo, MAX_REPLICAS); switch (tcConnectptr.p->failData[tcurrentReplicaNo]) { case LqhTransConf::InvalidStatus: jam(); @@ -7843,7 +7843,7 @@ void Dbtc::execCOMPLETECONF(Signal* signal) warningReport(signal, 14); return; }//if - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] != tnodeid) { warningReport(signal, 15); @@ -7863,7 +7863,7 @@ void Dbtc::toCompleteHandlingLab(Signal* signal) do { if (tcurrentReplicaNo != (Uint8)Z8NIL) { jam(); - arrGuard(tcurrentReplicaNo, 4); + arrGuard(tcurrentReplicaNo, MAX_REPLICAS); switch (tcConnectptr.p->failData[tcurrentReplicaNo]) { case LqhTransConf::InvalidStatus: jam(); @@ -8152,6 +8152,7 @@ void Dbtc::setupFailData(Signal* signal) case OS_PREPARED: case OS_COMMITTING: jam(); + arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS); for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) { jam(); /*------------------------------------------------------------------- @@ -8159,13 +8160,13 @@ void Dbtc::setupFailData(Signal* signal) * IN THIS CASE ALL LQH'S ARE PREPARED AND WAITING FOR * COMMIT/ABORT DECISION. *------------------------------------------------------------------*/ - arrGuard(tindex, 4); tcConnectptr.p->failData[tindex] = LqhTransConf::Prepared; }//for break; case OS_COMMITTED: case OS_COMPLETING: jam(); + arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS); for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) { jam(); /*------------------------------------------------------------------- @@ -8173,19 +8174,18 @@ void Dbtc::setupFailData(Signal* signal) * IN THIS CASE ALL LQH'S ARE COMMITTED AND WAITING FOR * COMPLETE MESSAGE. *------------------------------------------------------------------*/ - arrGuard(tindex, 4); tcConnectptr.p->failData[tindex] = LqhTransConf::Committed; }//for break; case OS_COMPLETED: jam(); + arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS); for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) { jam(); /*------------------------------------------------------------------- * KEYDATA IS USED TO KEEP AN INDICATION OF STATE IN LQH. * IN THIS CASE ALL LQH'S ARE COMPLETED. *-------------------------------------------------------------------*/ - arrGuard(tindex, 4); tcConnectptr.p->failData[tindex] = LqhTransConf::InvalidStatus; }//for break; From 5ef6e903a462cd2f662d7c7ff9f8993431ec3974 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Mar 2006 21:26:17 -0800 Subject: [PATCH 2/6] Fixed bug #16504. Multiple equalities were not adjusted after reading constant tables. It resulted in neglecting good index based methods that could be used to access of other tables. mysql-test/r/having.result: Adjusted a test case results after fix for bug #16504. mysql-test/r/select.result: Added a test case for bug #16504. mysql-test/r/subselect.result: Adjusted a test case results after fix for bug #16504. mysql-test/r/varbinary.result: Adjusted a test case results after fix for bug #16504. mysql-test/t/select.test: Added a test case for bug #16504. sql/item.cc: Fixed bug #16504. An Item_equal object may contain only a constant member. It may happen after reading constant tables. sql/item_cmpfunc.cc: Fixed bug #16504. Added method Item_equal::check_const that check appearance of new constant items in a multiple equality. sql/item_cmpfunc.h: Fixed bug #16504. Added method Item_equal::check_const that check appearance of new constant items in a multiple equality. sql/sql_select.cc: Fixed bug #16504. Adjusted multiple equalities after reading constant tables. Fixed a few typo in comments. --- mysql-test/r/having.result | 2 +- mysql-test/r/select.result | 19 +++++++++ mysql-test/r/subselect.result | 2 +- mysql-test/r/varbinary.result | 2 +- mysql-test/t/select.test | 23 +++++++++++ sql/item.cc | 2 +- sql/item_cmpfunc.cc | 37 ++++++++++++++++- sql/item_cmpfunc.h | 1 + sql/sql_select.cc | 78 +++++++++++++++++++++++++++++++---- 9 files changed, 151 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index e54f6d7f2a4..225d5a475ff 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -12,7 +12,7 @@ explain extended select count(a) as b from t1 where a=0 having b >=0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 0) having (count(`test`.`t1`.`a`) >= 0) +Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where 0 having (count(`test`.`t1`.`a`) >= 0) drop table t1; CREATE TABLE t1 ( raw_id int(10) NOT NULL default '0', diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index df68cdfff53..02f27423f99 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3371,3 +3371,22 @@ NULL a NULL drop table t1,t2; select * from (select * left join t on f1=f2) tt; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 6 Using where +DROP TABLE t1,t2; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index d8561915564..bd0fa5ae661 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -547,7 +547,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numreponse` = (select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = _latin1'1'))) and (`test`.`t1`.`numeropost` = _latin1'1')) +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = _latin1'1')) drop table t1; CREATE TABLE t1 (a int(1)); INSERT INTO t1 VALUES (1); diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result index e55e6b35915..e62051df5cd 100644 --- a/mysql-test/r/varbinary.result +++ b/mysql-test/r/varbinary.result @@ -15,7 +15,7 @@ explain extended select * from t1 where UNIQ=0x38afba1d73e6a18a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const UNIQ UNIQ 8 const 1 Warnings: -Note 1003 select `test`.`t1`.`ID` AS `ID`,`test`.`t1`.`UNIQ` AS `UNIQ` from `test`.`t1` where (`test`.`t1`.`UNIQ` = 4084688022709641610) +Note 1003 select `test`.`t1`.`ID` AS `ID`,`test`.`t1`.`UNIQ` AS `UNIQ` from `test`.`t1` where 1 drop table t1; select x'hello'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1 diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 01d5f2eb4d1..c4fe1906cbc 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2848,3 +2848,26 @@ drop table t1,t2; # --error 1064 select * from (select * left join t on f1=f2) tt; + +# +# Bug #16504: re-evaluation of Item_equal object after reading const table +# + +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); + +INSERT INTO t1 VALUES + (10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); + +INSERT INTO t2 VALUES + (10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), + (50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); + +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr + FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr + FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); + + +DROP TABLE t1,t2; diff --git a/sql/item.cc b/sql/item.cc index 8ffe7a6b2fd..e14367c7de1 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3744,7 +3744,7 @@ Item *Item_field::replace_equal_field(byte *arg) if (item_equal) { Item_field *subst= item_equal->get_first(); - if (!field->eq(subst->field)) + if (subst && !field->eq(subst->field)) return subst; } return this; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 2d74ea9c518..53efb65e1cb 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -3602,7 +3602,8 @@ void Item_equal::add(Item *c) Item_func_eq *func= new Item_func_eq(c, const_item); func->set_cmp_func(); func->quick_fix_field(); - cond_false = !(func->val_int()); + if ((cond_false= !func->val_int())) + const_item_cache= 1; } void Item_equal::add(Item_field *f) @@ -3734,13 +3735,45 @@ void Item_equal::sort(Item_field_cmpfunc cmp, void *arg) } while (swap); } + +/* + Check appearance of new constant items in the multiple equality object + + SYNOPSIS + check() + + DESCRIPTION + The function checks appearance of new constant items among + the members of multiple equalities. Each new constant item is + compared with the designated constant item if there is any in the + multiple equality. If there is none the first new constant item + becomes designated. + + RETURN VALUES + none +*/ + +void Item_equal::check_const() +{ + List_iterator it(fields); + Item *item; + while ((item= it++)) + { + if (item->const_item()) + { + it.remove(); + add(item); + } + } +} + bool Item_equal::fix_fields(THD *thd, Item **ref) { List_iterator_fast li(fields); Item *item; not_null_tables_cache= used_tables_cache= 0; const_item_cache= 0; - while ((item=li++)) + while ((item= li++)) { table_map tmp_table_map; used_tables_cache|= item->used_tables(); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 89aafa5721e..3d94832412e 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1196,6 +1196,7 @@ public: bool contains(Field *field); Item_field* get_first() { return fields.head(); } void merge(Item_equal *item); + void check_const(); enum Functype functype() const { return MULT_EQUAL_FUNC; } longlong val_int(); const char *func_name() const { return "multiple equal"; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3fa77a73e41..13e0381349a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -136,7 +136,7 @@ static enum_nested_loop_state end_write_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); static int test_if_group_changed(List &list); -static int join_read_const_table(JOIN_TAB *tab, POSITION *pos); +static int join_read_const_table(JOIN *join, JOIN_TAB *tab, POSITION *pos); static int join_read_system(JOIN_TAB *tab); static int join_read_const(JOIN_TAB *tab); static int join_read_key(JOIN_TAB *tab); @@ -2111,7 +2111,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, s= p_pos->table; s->type=JT_SYSTEM; join->const_table_map|=s->table->map; - if ((tmp=join_read_const_table(s, p_pos))) + if ((tmp=join_read_const_table(join, s, p_pos))) { if (tmp > 0) DBUG_RETURN(1); // Fatal error @@ -2148,7 +2148,8 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, s->type=JT_SYSTEM; join->const_table_map|=table->map; set_position(join,const_count++,s,(KEYUSE*) 0); - if ((tmp= join_read_const_table(s,join->positions+const_count-1))) + if ((tmp= join_read_const_table(join, s, + join->positions+const_count-1))) { if (tmp > 0) DBUG_RETURN(1); // Fatal error @@ -2200,7 +2201,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, if (create_ref_for_key(join, s, start_keyuse, found_const_table_map)) DBUG_RETURN(1); - if ((tmp=join_read_const_table(s, + if ((tmp=join_read_const_table(join, s, join->positions+const_count-1))) { if (tmp > 0) @@ -6796,8 +6797,8 @@ static COND *build_equal_items_for_cond(COND *cond, return item_equal; } /* - For each field reference in cond, not from equalitym predicates, - set a pointer to the multiple equality if belongs to (if there is any) + For each field reference in cond, not from equal item predicates, + set a pointer to the multiple equality it belongs to (if there is any) */ cond= cond->transform(&Item::equal_fields_propagator, (byte *) inherited); @@ -6982,7 +6983,7 @@ static int compare_fields_by_table_order(Item_field *field1, NOTES Before generating an equality function checks that it has not - been generated for multiple equalies of the upper levels. + been generated for multiple equalities of the upper levels. E.g. for the following where condition WHERE a=5 AND ((a=b AND b=c) OR c>4) the upper level AND condition will contain =(5,a), @@ -7155,7 +7156,7 @@ static COND* substitute_for_best_equal_field(COND *cond, { cond= eliminate_item_equal(cond, cond_equal->upper_levels, item_equal); // This occurs when eliminate_item_equal() founds that cond is - // always false and substitues it with Item_int 0. + // always false and substitutes it with Item_int 0. // Due to this, value of item_equal will be 0, so just return it. if (cond->type() != Item::COND_ITEM) break; @@ -7177,6 +7178,45 @@ static COND* substitute_for_best_equal_field(COND *cond, } +/* + Check appearance of new constant items in multiple equalities + of a condition after reading a constant table + + SYNOPSIS + check_const_equal_item() + cond condition whose multiple equalities are to be checked + table constant table that has been read + + DESCRIPTION + The function retrieves the cond condition and for each encountered + multiple equality checks whether new constants have appeared after + reading the constant (single row) table tab. If so it adjusts + the multiple equality appropriately. +*/ + +static void check_const_equal_items(COND *cond, + JOIN_TAB *tab) +{ + if (!(cond->used_tables() & tab->table->map)) + return; + + if (cond->type() == Item::COND_ITEM) + { + List *cond_list= ((Item_cond*) cond)->argument_list(); + List_iterator_fast li(*cond_list); + Item *item; + while ((item= li++)) + check_const_equal_items(item, tab); + } + else if (cond->type() == Item::FUNC_ITEM && + ((Item_cond*) cond)->functype() == Item_func::MULT_EQUAL_FUNC) + { + Item_equal *item_equal= (Item_equal *) cond; + item_equal->check_const(); + } +} + + /* change field = field to field = const for each found field = const in the and_level @@ -10099,7 +10139,7 @@ int safe_index_read(JOIN_TAB *tab) static int -join_read_const_table(JOIN_TAB *tab, POSITION *pos) +join_read_const_table(JOIN *join, JOIN_TAB *tab, POSITION *pos) { int error; DBUG_ENTER("join_read_const_table"); @@ -10151,6 +10191,26 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos) } if (!table->null_row) table->maybe_null=0; + + /* Check appearance of new constant items in Item_equal objects */ + if (join->conds) + check_const_equal_items(join->conds, tab); + TABLE_LIST *tbl; + for (tbl= join->select_lex->leaf_tables; tbl; tbl= tbl->next_leaf) + { + TABLE_LIST *embedded; + TABLE_LIST *embedding= tbl; + do + { + embedded= embedding; + if (embedded->on_expr) + check_const_equal_items(embedded->on_expr, tab); + embedding= embedded->embedding; + } + while (embedding && + embedding->nested_join->join_list.head() == embedded); + } + DBUG_RETURN(0); } From f0bfea2bb0789bd5bcd2a8d85c42dd310e245d1a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Mar 2006 23:12:05 -0800 Subject: [PATCH 3/6] Added a test case for bug #16504. Results changed after the bug fix. --- mysql-test/r/select.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 02f27423f99..9b9f67efeb5 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3388,5 +3388,5 @@ SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 6 Using where +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where DROP TABLE t1,t2; From 57cfa4d17c1e2e05fa71e19c126a59c8a6a03c81 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Apr 2006 11:54:09 -0400 Subject: [PATCH 4/6] .libs is no longer used when compiling netware netware/BUILD/compile-linux-tools: .libs/sql is no longer used when compiling netware --- netware/BUILD/compile-linux-tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netware/BUILD/compile-linux-tools b/netware/BUILD/compile-linux-tools index fab92b8d4df..14422ea5a3f 100755 --- a/netware/BUILD/compile-linux-tools +++ b/netware/BUILD/compile-linux-tools @@ -57,7 +57,7 @@ make cp extra/comp_err extra/comp_err.linux cp libmysql/conf_to_src libmysql/conf_to_src.linux #cp libmysql_r/conf_to_src libmysql_r/conf_to_src.linux -cp sql/.libs/gen_lex_hash sql/gen_lex_hash.linux +cp sql/gen_lex_hash sql/gen_lex_hash.linux cp strings/conf_to_src strings/conf_to_src.linux # Delete mysql_version.h From f545817ed1d19fb0656ed18650ea15072d8b03ad Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Apr 2006 21:02:40 -0700 Subject: [PATCH 5/6] Post review changes for the fix of bug #16504. --- sql/item_cmpfunc.cc | 4 ++-- sql/item_cmpfunc.h | 2 +- sql/sql_select.cc | 27 +++++++++++++-------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 53efb65e1cb..24075ac838d 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -3740,7 +3740,7 @@ void Item_equal::sort(Item_field_cmpfunc cmp, void *arg) Check appearance of new constant items in the multiple equality object SYNOPSIS - check() + update_const() DESCRIPTION The function checks appearance of new constant items among @@ -3753,7 +3753,7 @@ void Item_equal::sort(Item_field_cmpfunc cmp, void *arg) none */ -void Item_equal::check_const() +void Item_equal::update_const() { List_iterator it(fields); Item *item; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 3d94832412e..67f0a5f5e2e 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1196,7 +1196,7 @@ public: bool contains(Field *field); Item_field* get_first() { return fields.head(); } void merge(Item_equal *item); - void check_const(); + void update_const(); enum Functype functype() const { return MULT_EQUAL_FUNC; } longlong val_int(); const char *func_name() const { return "multiple equal"; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 13e0381349a..0211539e784 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -136,7 +136,7 @@ static enum_nested_loop_state end_write_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); static int test_if_group_changed(List &list); -static int join_read_const_table(JOIN *join, JOIN_TAB *tab, POSITION *pos); +static int join_read_const_table(JOIN_TAB *tab, POSITION *pos); static int join_read_system(JOIN_TAB *tab); static int join_read_const(JOIN_TAB *tab); static int join_read_key(JOIN_TAB *tab); @@ -2111,7 +2111,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, s= p_pos->table; s->type=JT_SYSTEM; join->const_table_map|=s->table->map; - if ((tmp=join_read_const_table(join, s, p_pos))) + if ((tmp=join_read_const_table(s, p_pos))) { if (tmp > 0) DBUG_RETURN(1); // Fatal error @@ -2148,8 +2148,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, s->type=JT_SYSTEM; join->const_table_map|=table->map; set_position(join,const_count++,s,(KEYUSE*) 0); - if ((tmp= join_read_const_table(join, s, - join->positions+const_count-1))) + if ((tmp= join_read_const_table(s, join->positions+const_count-1))) { if (tmp > 0) DBUG_RETURN(1); // Fatal error @@ -2201,8 +2200,8 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, if (create_ref_for_key(join, s, start_keyuse, found_const_table_map)) DBUG_RETURN(1); - if ((tmp=join_read_const_table(join, s, - join->positions+const_count-1))) + if ((tmp=join_read_const_table(s, + join->positions+const_count-1))) { if (tmp > 0) DBUG_RETURN(1); // Fatal error @@ -7183,7 +7182,7 @@ static COND* substitute_for_best_equal_field(COND *cond, of a condition after reading a constant table SYNOPSIS - check_const_equal_item() + update_const_equal_items() cond condition whose multiple equalities are to be checked table constant table that has been read @@ -7194,8 +7193,7 @@ static COND* substitute_for_best_equal_field(COND *cond, the multiple equality appropriately. */ -static void check_const_equal_items(COND *cond, - JOIN_TAB *tab) +static void update_const_equal_items(COND *cond, JOIN_TAB *tab) { if (!(cond->used_tables() & tab->table->map)) return; @@ -7206,13 +7204,13 @@ static void check_const_equal_items(COND *cond, List_iterator_fast li(*cond_list); Item *item; while ((item= li++)) - check_const_equal_items(item, tab); + update_const_equal_items(item, tab); } else if (cond->type() == Item::FUNC_ITEM && ((Item_cond*) cond)->functype() == Item_func::MULT_EQUAL_FUNC) { Item_equal *item_equal= (Item_equal *) cond; - item_equal->check_const(); + item_equal->update_const(); } } @@ -10139,7 +10137,7 @@ int safe_index_read(JOIN_TAB *tab) static int -join_read_const_table(JOIN *join, JOIN_TAB *tab, POSITION *pos) +join_read_const_table(JOIN_TAB *tab, POSITION *pos) { int error; DBUG_ENTER("join_read_const_table"); @@ -10193,8 +10191,9 @@ join_read_const_table(JOIN *join, JOIN_TAB *tab, POSITION *pos) table->maybe_null=0; /* Check appearance of new constant items in Item_equal objects */ + JOIN *join= tab->join; if (join->conds) - check_const_equal_items(join->conds, tab); + update_const_equal_items(join->conds, tab); TABLE_LIST *tbl; for (tbl= join->select_lex->leaf_tables; tbl; tbl= tbl->next_leaf) { @@ -10204,7 +10203,7 @@ join_read_const_table(JOIN *join, JOIN_TAB *tab, POSITION *pos) { embedded= embedding; if (embedded->on_expr) - check_const_equal_items(embedded->on_expr, tab); + update_const_equal_items(embedded->on_expr, tab); embedding= embedded->embedding; } while (embedding && From 9cc49085b0e83040817e824c74cdd3d0940718ba Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Apr 2006 11:34:31 +0200 Subject: [PATCH 6/6] Bug #18349 Wrong error message "Array index out of bounds... --- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 33736bcb4cf..6d4599cdb00 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -11803,7 +11803,8 @@ void Dbdih::newCrashedReplica(Uint32 nodeId, ReplicaRecordPtr ncrReplicaPtr) /* THAT THE NEW REPLICA IS NOT STARTED YET AND REPLICA_LAST_GCI IS*/ /* SET TO -1 TO INDICATE THAT IT IS NOT DEAD YET. */ /*----------------------------------------------------------------------*/ - arrGuard(ncrReplicaPtr.p->noCrashedReplicas + 1, 8); + arrGuardErr(ncrReplicaPtr.p->noCrashedReplicas + 1, 8, + NDBD_EXIT_MAX_CRASHED_REPLICAS); ncrReplicaPtr.p->replicaLastGci[ncrReplicaPtr.p->noCrashedReplicas] = SYSFILE->lastCompletedGCI[nodeId]; ncrReplicaPtr.p->noCrashedReplicas = ncrReplicaPtr.p->noCrashedReplicas + 1;