From 2506b70d393cae85e4fb89fc6ef982f352b6c1c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 30 Nov 2002 19:33:01 +0100 Subject: [PATCH 1/4] Fixed ambiguity between the row value syntax and INTERVAL syntax by making the ROW keyword mandatory (although it's optional in SQL-99). mysql-test/r/row_test.result: New results with the ROW syntax. mysql-test/t/row_test.test: Updated tests to use the ROW keyword. sql/sql_yacc.yy: Fixed ambiguity between the row value syntax and INTERVAL syntax by making the ROW keyword mandatory (although it's optional in SQL-99). The real problem might actually be INTERVAL, where the two rules "INTERVAL_SYM expr interval '+' expr" and "INTERVAL_SYM '(' expr ',' expr_list ')'" caused 40+ reduce/reduce conflicts with the rows value syntax. So possibly, the INTERVAL syntax should be fixed instead... --- mysql-test/r/row_test.result | 62 ++++++++++++++++++------------------ mysql-test/t/row_test.test | 38 +++++++++++----------- sql/sql_yacc.yy | 8 +++-- 3 files changed, 55 insertions(+), 53 deletions(-) diff --git a/mysql-test/r/row_test.result b/mysql-test/r/row_test.result index f5bf9856a60..f6e989789c7 100644 --- a/mysql-test/r/row_test.result +++ b/mysql-test/r/row_test.result @@ -1,60 +1,60 @@ -SELECT (1,2,3)=(1,2,3); -(1,2,3)=(1,2,3) +SELECT ROW(1,2,3)=ROW(1,2,3); +ROW(1,2,3)=ROW(1,2,3) 1 -SELECT (2,2,3)=(1+1,2,3); -(2,2,3)=(1+1,2,3) +SELECT ROW(2,2,3)=ROW(1+1,2,3); +ROW(2,2,3)=ROW(1+1,2,3) 1 -SELECT (1,2,3)=(1+1,2,3); -(1,2,3)=(1+1,2,3) +SELECT ROW(1,2,3)=ROW(1+1,2,3); +ROW(1,2,3)=ROW(1+1,2,3) 0 -SELECT (1,2,3)<(1+1,2,3); -(1,2,3)<(1+1,2,3) +SELECT ROW(1,2,3)(1+1,2,3); -(1,2,3)>(1+1,2,3) +SELECT ROW(1,2,3)>ROW(1+1,2,3); +ROW(1,2,3)>ROW(1+1,2,3) 0 -SELECT (1,2,3)<=(1+1,2,3); -(1,2,3)<=(1+1,2,3) +SELECT ROW(1,2,3)<=ROW(1+1,2,3); +ROW(1,2,3)<=ROW(1+1,2,3) 1 -SELECT (1,2,3)>=(1+1,2,3); -(1,2,3)>=(1+1,2,3) +SELECT ROW(1,2,3)>=ROW(1+1,2,3); +ROW(1,2,3)>=ROW(1+1,2,3) 0 -SELECT (1,2,3)<>(1+1,2,3); -(1,2,3)<>(1+1,2,3) +SELECT ROW(1,2,3)<>ROW(1+1,2,3); +ROW(1,2,3)<>ROW(1+1,2,3) 1 -SELECT (NULL,2,3)=(NULL,2,3); -(NULL,2,3)=(NULL,2,3) +SELECT ROW(NULL,2,3)=ROW(NULL,2,3); +ROW(NULL,2,3)=ROW(NULL,2,3) NULL -SELECT (NULL,2,3)<=>(NULL,2,3); -(NULL,2,3)<=>(NULL,2,3) +SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3); +ROW(NULL,2,3)<=>ROW(NULL,2,3) 1 -SELECT (1,2,(3,4,5))=(1,2,(3,4,5)); -(1,2,(3,4,5))=(1,2,(3,4,5)) +SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)); +ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)) 1 -SELECT ('test',2,3.33)=('test',2,3.33); -('test',2,3.33)=('test',2,3.33) +SELECT ROW('test',2,3.33)=ROW('test',2,3.33); +ROW('test',2,3.33)=ROW('test',2,3.33) 1 -SELECT ('test',2,3.33)=('test',2,3.33,4); +SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4); Cardinality error (more/less than 3 columns) drop table if exists t1; create table t1 ( a int, b int, c int); insert into t1 values (1,2,3), (2,3,1), (3,2,1); -select * from t1 where (1,2,3)=(a,b,c); +select * from t1 where ROW(1,2,3)=ROW(a,b,c); a b c 1 2 3 -select * from t1 where (0,2,3)=(a,b,c); +select * from t1 where ROW(0,2,3)=ROW(a,b,c); a b c -select * from t1 where (1,2,3)<(a,b,c); +select * from t1 where ROW(1,2,3)(1+1,2,3); -SELECT (1,2,3)<=(1+1,2,3); -SELECT (1,2,3)>=(1+1,2,3); -SELECT (1,2,3)<>(1+1,2,3); -SELECT (NULL,2,3)=(NULL,2,3); -SELECT (NULL,2,3)<=>(NULL,2,3); -SELECT (1,2,(3,4,5))=(1,2,(3,4,5)); -SELECT ('test',2,3.33)=('test',2,3.33); +SELECT ROW(1,2,3)=ROW(1,2,3); +SELECT ROW(2,2,3)=ROW(1+1,2,3); +SELECT ROW(1,2,3)=ROW(1+1,2,3); +SELECT ROW(1,2,3)ROW(1+1,2,3); +SELECT ROW(1,2,3)<=ROW(1+1,2,3); +SELECT ROW(1,2,3)>=ROW(1+1,2,3); +SELECT ROW(1,2,3)<>ROW(1+1,2,3); +SELECT ROW(NULL,2,3)=ROW(NULL,2,3); +SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3); +SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)); +SELECT ROW('test',2,3.33)=ROW('test',2,3.33); -- error 1239 -SELECT ('test',2,3.33)=('test',2,3.33,4); +SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4); drop table if exists t1; create table t1 ( a int, b int, c int); insert into t1 values (1,2,3), (2,3,1), (3,2,1); -select * from t1 where (1,2,3)=(a,b,c); -select * from t1 where (0,2,3)=(a,b,c); -select * from t1 where (1,2,3)<(a,b,c); +select * from t1 where ROW(1,2,3)=ROW(a,b,c); +select * from t1 where ROW(0,2,3)=ROW(a,b,c); +select * from t1 where ROW(1,2,3)push_front($2); - $$= new Item_row(*$4); + $5->push_front($3); + $$= new Item_row(*$5); } | EXISTS exists_subselect { $$= $2; } | singleval_subselect { $$= $1; } From 1941d9b597af4a80820c4a40020c2ee4764996ee Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Dec 2002 00:11:22 +0200 Subject: [PATCH 2/4] fix of error handling mysql-test/r/subselect.result: test of error handling with subselect mysql-test/t/subselect.test: test of error handling with subselect --- mysql-test/r/subselect.result | 22 ++++++++++++++++++++-- mysql-test/t/subselect.test | 22 ++++++++++++++++++++-- sql/sql_delete.cc | 8 +++++--- sql/sql_insert.cc | 13 +++++++------ sql/sql_parse.cc | 12 ++++++++++++ sql/sql_union.cc | 2 +- sql/sql_update.cc | 15 +++++++++------ 7 files changed, 74 insertions(+), 20 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 91a4087378f..34e74d4093d 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -413,6 +413,8 @@ a b 2 12 update t1 set b= (select b from t1); INSERT TABLE 't1' isn't allowed in FROM table list +update t1 set b= (select b from t2); +Subselect returns more than 1 record update t1 set b= (select b from t2 where t1.a = t2.a); select * from t1; a b @@ -434,6 +436,8 @@ a b 2 12 delete from t1 where b = (select b from t1); INSERT TABLE 't1' isn't allowed in FROM table list +delete from t1 where b = (select b from t2); +Subselect returns more than 1 record delete from t1 where b = (select b from t2 where t1.a = t2.a); select * from t1; a b @@ -459,6 +463,8 @@ a b 2 12 delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a); INSERT TABLE 't12' isn't allowed in FROM table list +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2); +Subselect returns more than 1 record delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a); select * from t11; a b @@ -471,9 +477,13 @@ a b drop table t11, t12, t2; CREATE TABLE t1 (x int); create table t2 (a int); +create table t3 (a int); insert into t2 values (1); +insert into t3 values (1),(2); INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); INSERT TABLE 't1' isn't allowed in FROM table list +INSERT INTO t1 (x) VALUES ((SELECT a FROM t3)); +Subselect returns more than 1 record INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; x @@ -501,14 +511,18 @@ x 3 3 0 -drop table t1, t2; +drop table t1, t2, t3; CREATE TABLE t1 (x int not null, y int, primary key (x)); create table t2 (a int); +create table t3 (a int); insert into t2 values (1); +insert into t3 values (1),(2); select * from t1; x y replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); INSERT TABLE 't1' isn't allowed in FROM table list +replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); +Subselect returns more than 1 record replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); select * from t1; x y @@ -533,7 +547,7 @@ x y 1 3 4 2 2 1 -drop table t1, t2; +drop table t1, t2, t3; SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT *); No tables used drop table if exists t; @@ -575,4 +589,8 @@ SELECT * FROM t; id 1 2 +CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 values (1),(1); +UPDATE t SET id=(SELECT * FROM t1); +Subselect returns more than 1 record drop table t; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index a82808d3391..f0aea9ea9b5 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -247,6 +247,8 @@ insert into t2 values (1, 21),(2, 22),(3, 23); select * from t1; -- error 1093 update t1 set b= (select b from t1); +-- error 1240 +update t1 set b= (select b from t2); update t1 set b= (select b from t2 where t1.a = t2.a); select * from t1; drop table t1, t2; @@ -260,6 +262,8 @@ select * from t1; select * from t1 where b = (select b from t2 where t1.a = t2.a); -- error 1093 delete from t1 where b = (select b from t1); +-- error 1240 +delete from t1 where b = (select b from t2); delete from t1 where b = (select b from t2 where t1.a = t2.a); select * from t1; drop table t1, t2; @@ -276,6 +280,8 @@ select * from t11; select * from t12; -- error 1093 delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a); +-- error 1240 +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2); delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a); select * from t11; select * from t12; @@ -284,9 +290,13 @@ drop table t11, t12, t2; #insert with subselects CREATE TABLE t1 (x int); create table t2 (a int); +create table t3 (a int); insert into t2 values (1); +insert into t3 values (1),(2); -- error 1093 INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); +-- error 1240 +INSERT INTO t1 (x) VALUES ((SELECT a FROM t3)); INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; insert into t2 values (1); @@ -300,15 +310,19 @@ INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); -- sleep 1 select * from t1; -drop table t1, t2; +drop table t1, t2, t3; #replace with subselects CREATE TABLE t1 (x int not null, y int, primary key (x)); create table t2 (a int); +create table t3 (a int); insert into t2 values (1); +insert into t3 values (1),(2); select * from t1; -- error 1093 replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); +-- error 1240 +replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); select * from t1; replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2)); @@ -321,7 +335,7 @@ replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2 select * from t1; replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2)); select * from t1; -drop table t1, t2; +drop table t1, t2, t3; -- error 1096 SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT *); @@ -339,4 +353,8 @@ SELECT * FROM t WHERE id IN (SELECT 5 UNION SELECT 2); -- error 1093 INSERT INTO t VALUES ((SELECT * FROM t)); SELECT * FROM t; +CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 values (1),(1); +-- error 1240 +UPDATE t SET id=(SELECT * FROM t1); drop table t; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index fe1a967f936..d35790da1b0 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -140,9 +140,11 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, deleted=0L; init_ftfuncs(thd, &thd->lex.select_lex, 1); thd->proc_info="updating"; - while (!(error=info.read_record(&info)) && !thd->killed) + while (!(error=info.read_record(&info)) && !thd->killed && + !thd->net.report_error) { - if (!(select && select->skipp_record())) + // thd->net.report_error is tested to disallow delete row on error + if (!(select && select->skipp_record())&& !thd->net.report_error ) { if (!(error=table->file->delete_row(table->record[0]))) { @@ -205,7 +207,7 @@ cleanup: thd->lock=0; } delete select; - if (error >= 0) // Fatal error + if (error >= 0 || thd->net.report_error) send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN: 0); else { diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 83b125ee630..9ee824d0e2c 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -235,9 +235,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List &fields, if (fields.elements || !value_count) { restore_record(table,2); // Get empty record - if (fill_record(fields,*values) || check_null_fields(thd,table)) + if (fill_record(fields,*values)|| thd->net.report_error || + check_null_fields(thd,table)) { - if (values_list.elements != 1) + if (values_list.elements != 1 && !thd->net.report_error) { info.records++; continue; @@ -252,9 +253,9 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List &fields, restore_record(table,2); // Get empty record else table->record[0][0]=table->record[2][0]; // Fix delete marker - if (fill_record(table->field,*values)) + if (fill_record(table->field,*values) || thd->net.report_error) { - if (values_list.elements != 1) + if (values_list.elements != 1 && ! thd->net.report_error) { info.records++; continue; @@ -1349,7 +1350,7 @@ bool select_insert::send_data(List &values) fill_record(*fields,values); else fill_record(table->field,values); - if (write_record(table,&info)) + if (thd->net.report_error || write_record(table,&info)) return 1; if (table->next_number_field) // Clear for next record { @@ -1463,7 +1464,7 @@ bool select_create::send_data(List &values) return 0; } fill_record(field,values); - if (write_record(table,&info)) + if (thd->net.report_error ||write_record(table,&info)) return 1; if (table->next_number_field) // Clear for next record { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7bdc6873e6f..23c727f8185 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1900,6 +1900,8 @@ mysql_execute_command(THD *thd) (ORDER *) select_lex->order_list.first, select_lex->select_limit, lex->duplicates); + if (thd->net.report_error) + res= -1; break; case SQLCOM_UPDATE_MULTI: if (check_access(thd,UPDATE_ACL,tables->db,&tables->grant.privilege)) @@ -1959,6 +1961,8 @@ mysql_execute_command(THD *thd) SELECT_NO_JOIN_CACHE, result, unit, select_lex, 0); delete result; + if (thd->net.report_error) + res= -1; } else res= -1; // Error is not sent @@ -1976,6 +1980,8 @@ mysql_execute_command(THD *thd) goto error; res = mysql_insert(thd,tables,lex->field_list,lex->many_values, lex->duplicates); + if (thd->net.report_error) + res= -1; break; } case SQLCOM_REPLACE_SELECT: @@ -2020,6 +2026,8 @@ mysql_execute_command(THD *thd) if ((result=new select_insert(tables->table,&lex->field_list, lex->duplicates))) res=handle_select(thd,lex,result); + if (thd->net.report_error) + res= -1; } else res= -1; @@ -2050,6 +2058,8 @@ mysql_execute_command(THD *thd) res = mysql_delete(thd,tables, select_lex->where, (ORDER*) select_lex->order_list.first, select_lex->select_limit, select_lex->options); + if (thd->net.report_error) + res= -1; break; } case SQLCOM_DELETE_MULTI: @@ -2122,6 +2132,8 @@ mysql_execute_command(THD *thd) select_lex->options | thd->options | SELECT_NO_JOIN_CACHE, result, unit, select_lex, 0); + if (thd->net.report_error) + res= -1; delete result; } else diff --git a/sql/sql_union.cc b/sql/sql_union.cc index d448a5204e2..e170f6c040e 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -76,7 +76,7 @@ bool select_union::send_data(List &values) return 0; } fill_record(table->field,values); - if ((write_record(table,&info))) + if (thd->net.report_error || write_record(table,&info)) { if (thd->net.last_errno == ER_RECORD_FILE_FULL) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4e15011c254..c3ae435d851 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -281,7 +281,7 @@ int mysql_update(THD *thd, if (!(select && select->skipp_record())) { store_record(table,1); - if (fill_record(fields,values)) + if (fill_record(fields,values) || thd->net.report_error) break; /* purecov: inspected */ found++; if (compare_record(table, query_id)) @@ -605,7 +605,7 @@ bool multi_update::send_data(List &values) // Only one table being updated receives a completely different treatment table->status|= STATUS_UPDATED; store_record(table,1); - if (fill_record(fields,real_values)) + if (fill_record(fields,real_values) || thd->net.report_error) return 1; found++; if (/* compare_record(table, query_id) && */ @@ -644,7 +644,8 @@ bool multi_update::send_data(List &values) { table->status|= STATUS_UPDATED; store_record(table,1); - if (fill_record(*fields_by_tables[0],values_by_table)) + if (fill_record(*fields_by_tables[0], values_by_table) || + thd->net.report_error) return 1; found++; if (/*compare_record(table, query_id) && */ @@ -667,8 +668,8 @@ bool multi_update::send_data(List &values) table->file->ref_length, system_charset_info)); fill_record(tmp_tables[secure_counter]->field,values_by_table); - error= write_record(tmp_tables[secure_counter], - &(infos[secure_counter])); + error= thd->net.report_error || + write_record(tmp_tables[secure_counter], &(infos[secure_counter])); if (error) { error=-1; @@ -774,8 +775,10 @@ int multi_update::do_updates (bool from_send_error) table->status|= STATUS_UPDATED; store_record(table,1); local_error= (fill_record(*fields_by_tables[counter + 1],list) || + thd->net.report_error || /* compare_record(table, query_id) || */ - table->file->update_row(table->record[1],table->record[0])); + table->file->update_row(table->record[1], + table->record[0])); if (local_error) { table->file->print_error(local_error,MYF(0)); From 86331f40ec122e05b0ab6acea7c896fa81279a3b Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Dec 2002 17:10:13 +0100 Subject: [PATCH 3/4] Got rid of the (previously) intentional SELECT/UNION reduce/reduce conflict. There should be no more reduce/reduce conflicts in sql_yacc.yy from now on! sql/sql_yacc.yy: Got rid of the (previously) intentional SELECT/UNION reduce/reduce conflict (in the optional_order_or_limit clause). --- sql/sql_yacc.yy | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8bfe076060d..4cdb608d700 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2682,7 +2682,11 @@ order_dir: opt_limit_clause: /* empty */ {} - | LIMIT + | limit_clause {} + ; + +limit_clause: + LIMIT { LEX *lex= Lex; if (lex->current_select->linkage != GLOBAL_OPTIONS_TYPE && @@ -4380,10 +4384,7 @@ union_opt: ; optional_order_or_limit: - /* empty - intentional reduce/reduce conflict here !!! - { code } below should not be executed - when neither ORDER BY nor LIMIT are used */ {} + /* Empty */ {} | { LEX *lex=Lex; @@ -4399,7 +4400,13 @@ optional_order_or_limit: lex->current_select->select_limit= lex->thd->variables.select_limit; } - opt_order_clause opt_limit_clause + order_or_limit + ; + +order_or_limit: + order_clause opt_limit_clause + | + limit_clause ; union_option: From 59dec1bcd20662f7a73d12c78b9b2e682a79e059 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Dec 2002 17:52:22 +0200 Subject: [PATCH 4/4] Fixed bug when creating keys in temporary HEAP tables. (This caused the DISTINCT test to fail) Removed one inline as this caused compiler problems heap/hp_create.c: Comment heap/hp_update.c: Indentation cleanup heap/hp_write.c: Indentation cleanup mysql-test/mysql-test-run.sh: Better options for valgrind sql/item_sum.cc: Removed inline as this caused compiler problems with gcc 3.2 (Was also non standard usage of inline) sql/item_sum.h: Removed inline as this caused compiler problems with gcc 3.2 sql/sql_class.cc: Fixed reference to uninitialized value sql/sql_lex.cc: Indentation cleanup sql/sql_select.cc: Fixed bug when creating keys in temporary HEAP tables. --- heap/hp_create.c | 1 + heap/hp_update.c | 6 ++++-- heap/hp_write.c | 2 +- mysql-test/mysql-test-run.sh | 6 +++--- sql/item_sum.cc | 2 +- sql/item_sum.h | 2 +- sql/sql_class.cc | 21 +++++++++++---------- sql/sql_lex.cc | 5 +++-- sql/sql_select.cc | 2 ++ 9 files changed, 27 insertions(+), 20 deletions(-) diff --git a/heap/hp_create.c b/heap/hp_create.c index 40b8202d94f..5265607ce53 100644 --- a/heap/hp_create.c +++ b/heap/hp_create.c @@ -140,6 +140,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, share->auto_key= create_info->auto_key; share->auto_key_type= create_info->auto_key_type; share->auto_increment= create_info->auto_increment; + /* Must be allocated separately for rename to work */ if (!(share->name= my_strdup(name,MYF(0)))) { my_free((gptr) share,MYF(0)); diff --git a/heap/hp_update.c b/heap/hp_update.c index dd7374f506c..b789ab82b84 100644 --- a/heap/hp_update.c +++ b/heap/hp_update.c @@ -62,7 +62,8 @@ int heap_update(HP_INFO *info, const byte *old, const byte *heap_new) /* we don't need to delete non-inserted key from rb-tree */ if ((*keydef->write_key)(info, keydef, old, pos)) { - if (++(share->records) == share->blength) share->blength+= share->blength; + if (++(share->records) == share->blength) + share->blength+= share->blength; DBUG_RETURN(my_errno); } keydef--; @@ -78,6 +79,7 @@ int heap_update(HP_INFO *info, const byte *old, const byte *heap_new) keydef--; } } - if (++(share->records) == share->blength) share->blength+= share->blength; + if (++(share->records) == share->blength) + share->blength+= share->blength; DBUG_RETURN(my_errno); } /* heap_update */ diff --git a/heap/hp_write.c b/heap/hp_write.c index 9edd897eb34..87211d4c224 100644 --- a/heap/hp_write.c +++ b/heap/hp_write.c @@ -155,7 +155,7 @@ static byte *next_free_record_pos(HP_SHARE *info) /* Write a hash-key to the hash-index */ int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, - const byte *record, byte *recpos) + const byte *record, byte *recpos) { HP_SHARE *share = info->s; int flag; diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index d585243c6bc..745cde325f9 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -19,7 +19,7 @@ TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work # Program Definitions #-- -PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11 +PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11:$PATH MASTER_40_ARGS="--rpl-recovery-rank=1 --init-rpl-role=master" # Standard functions @@ -319,8 +319,8 @@ while test $# -gt 0; do VALGRIND="valgrind --alignment=8 --leak-check=yes" EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc" - SLEEP_TIME_AFTER_RESTART=120 - SLEEP_TIME_FOR_DELETE=120 + SLEEP_TIME_AFTER_RESTART=60 + SLEEP_TIME_FOR_DELETE=60 ;; --valgrind-options=*) TMP=`$ECHO "$1" | $SED -e "s;--valgrind-options=;;"` diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 63329cd3823..fe7523a5fc5 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -41,7 +41,7 @@ Item_sum::Item_sum(List &list) list.empty(); // Fields are used } -inline void Item_sum::mark_as_sum_func() +void Item_sum::mark_as_sum_func() { current_thd->lex.current_select->with_sum_func= with_sum_func= 1; } diff --git a/sql/item_sum.h b/sql/item_sum.h index 56b36b615f4..23b8482d41a 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -34,7 +34,7 @@ public: uint arg_count; bool quick_group; /* If incremental update of fields */ - inline void mark_as_sum_func(); + void mark_as_sum_func(); Item_sum() : arg_count(0),quick_group(1) { mark_as_sum_func(); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9bca7245cba..57cd0e7a13d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -142,8 +142,6 @@ THD::THD():user_time(0), fatal_error(0), bzero((char*) &con_root,sizeof(con_root)); bzero((char*) &warn_root,sizeof(warn_root)); init_alloc_root(&warn_root, 1024, 0); - bzero((char*) warn_count, sizeof(warn_count)); - warn_list.empty(); user_connect=(USER_CONN *)0; hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0, (hash_get_key) get_var_key, @@ -187,17 +185,20 @@ THD::THD():user_time(0), fatal_error(0), void THD::init(void) { - server_status= SERVER_STATUS_AUTOCOMMIT; - update_lock_default= (variables.low_priority_updates ? - TL_WRITE_LOW_PRIORITY : - TL_WRITE); - options= thd_startup_options; - sql_mode=(uint) opt_sql_mode; - open_options=ha_open_options; pthread_mutex_lock(&LOCK_global_system_variables); variables= global_system_variables; pthread_mutex_unlock(&LOCK_global_system_variables); + server_status= SERVER_STATUS_AUTOCOMMIT; + options= thd_startup_options; + sql_mode=(uint) opt_sql_mode; + open_options=ha_open_options; + update_lock_default= (variables.low_priority_updates ? + TL_WRITE_LOW_PRIORITY : + TL_WRITE); session_tx_isolation= (enum_tx_isolation) variables.tx_isolation; + warn_list.empty(); + bzero((char*) warn_count, sizeof(warn_count)); + total_warn_count= 0; } /* @@ -228,6 +229,7 @@ void THD::cleanup(void) { DBUG_ENTER("THD::cleanup"); ha_rollback(this); + delete_tree(&prepared_statements); if (locked_tables) { lock=locked_tables; locked_tables=0; @@ -289,7 +291,6 @@ THD::~THD() free_root(&con_root,MYF(0)); free_root(&warn_root,MYF(0)); free_root(&transaction.mem_root,MYF(0)); - delete_tree(&prepared_statements); mysys_var=0; // Safety (shouldn't be needed) pthread_mutex_destroy(&LOCK_delete); #ifndef DBUG_OFF diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index d765c741932..54f28668644 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -458,7 +458,7 @@ int yylex(void *arg, void *yythd) LINT_INIT(c); for (;;) { - switch(state) { + switch (state) { case STATE_OPERATOR_OR_IDENT: // Next is operator or keyword case STATE_START: // Start of token // Skip startspace @@ -900,7 +900,8 @@ int yylex(void *arg, void *yythd) return((int) '@'); case STATE_HOSTNAME: // end '@' of user@hostname for (c=yyGet() ; - my_isalnum(system_charset_info,c) || c == '.' || c == '_' || c == '$'; + my_isalnum(system_charset_info,c) || c == '.' || c == '_' || + c == '$'; c= yyGet()) ; yylval->lex_str=get_token(lex,yyLength()); return(LEX_HOSTNAME); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c1f7e8272bc..50820b931b6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4115,6 +4115,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, keyinfo->usable_key_parts=keyinfo->key_parts= param->group_parts; keyinfo->key_length=0; keyinfo->rec_per_key=0; + keyinfo->algorithm= HA_KEY_ALG_UNDEF; for (; group ; group=group->next,key_part_info++) { Field *field=(*group->item)->tmp_table_field(); @@ -4191,6 +4192,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, keyinfo->flags=HA_NOSAME | HA_NULL_ARE_EQUAL; keyinfo->key_length=(uint16) reclength; keyinfo->name=(char*) "tmp"; + keyinfo->algorithm= HA_KEY_ALG_UNDEF; if (null_pack_length) { key_part_info->null_bit=0;