From 8895218eb39c9f3ffeb8add83e9e651c0f7e4a1b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Dec 2005 21:40:50 +0100 Subject: [PATCH 01/11] compatibility fix for yassl --- extra/yassl/include/openssl/ssl.h | 1 + extra/yassl/src/ssl.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index 45e26fb56ee..1c8291c2f13 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -341,6 +341,7 @@ long SSL_CTX_sess_set_cache_size(SSL_CTX*, long); long SSL_CTX_set_tmp_dh(SSL_CTX*, DH*); void OpenSSL_add_all_algorithms(void); +void SSL_library_init(); void SSLeay_add_ssl_algorithms(void); diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 8cea205377e..94e783167b3 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -648,6 +648,10 @@ void OpenSSL_add_all_algorithms() // compatibility only {} +void SSL_library_init() // compatibility only +{} + + DH* DH_new(void) { DH* dh = new (ys) DH; From 17a024b05f8656c8b85c95da04019c82046e57fc Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Dec 2005 22:59:45 +0100 Subject: [PATCH 02/11] Bug#13012: REPAIR/BACKUP/RESTORE TABLE cause "packet out of order" in SP. Mark them properly as result-returning statements --- mysql-test/r/sp-error.result | 33 ++++++++++++++++++++++++++++++ mysql-test/r/sp.result | 22 ++++++++++++++++++-- mysql-test/t/sp-error.test | 39 +++++++++++++++++++++++++++++++++++- mysql-test/t/sp.test | 21 +++++++++++++++++++ sql/sp_head.cc | 3 +++ 5 files changed, 115 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 963f14820be..f1d65ada4bf 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -981,6 +981,8 @@ END | drop table t1| drop function bug_13627_f| drop function if exists bug12329; +Warnings: +Note 1305 FUNCTION bug12329 does not exist create table t1 as select 1 a; create table t2 as select 1 a; create function bug12329() returns int return (select a from t1); @@ -1055,3 +1057,34 @@ Db Name Type Definer Modified Created Security_type Comment mysqltest2 p1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER drop database mysqltest2; use test; +DROP FUNCTION IF EXISTS bug13012| +CREATE FUNCTION bug13012() RETURNS INT +BEGIN +REPAIR TABLE t1; +RETURN 1; +END| +ERROR 0A000: Not allowed to return a result set from a function +CREATE FUNCTION bug13012() RETURNS INT +BEGIN +BACKUP TABLE t1 TO '/tmp'; +RETURN 1; +END| +ERROR 0A000: Not allowed to return a result set from a function +CREATE FUNCTION bug13012() RETURNS INT +BEGIN +RESTORE TABLE t1 FROM '/tmp'; +RETURN 1; +END| +ERROR 0A000: Not allowed to return a result set from a function +create table t1 (a int)| +CREATE PROCEDURE bug13012_1() REPAIR TABLE t1| +CREATE FUNCTION bug13012_2() RETURNS INT +BEGIN +CALL bug13012_1(); +RETURN 1; +END| +SELECT bug13012_2()| +ERROR 0A000: Not allowed to return a result set from a function +drop table t1| +drop procedure bug13012_1| +drop function bug13012_2| diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 6f0a8623a4c..41279534007 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4100,8 +4100,6 @@ x 4711 drop procedure bug14376| drop procedure if exists p1| -Warnings: -Note 1305 PROCEDURE p1 does not exist drop table if exists t1| create table t1 (a varchar(255))| insert into t1 (a) values ("a - table column")| @@ -4153,4 +4151,24 @@ A local variable in a nested compound statement takes precedence over table colu a - local variable in a nested compound statement A local variable in a nested compound statement takes precedence over table column in cursors a - local variable in a nested compound statement +drop procedure p1| +drop procedure if exists bug13012| +create procedure bug13012() +BEGIN +REPAIR TABLE t1; +BACKUP TABLE t1 to '../tmp'; +DROP TABLE t1; +RESTORE TABLE t1 FROM '../tmp'; +END| +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +Table Op Msg_type Msg_text +test.t1 backup status OK +Table Op Msg_type Msg_text +test.t1 restore status OK +drop procedure bug13012| +select * from t1| +a +a - table column drop table t1,t2; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 69e5f73817b..ae13758a10e 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -1410,7 +1410,6 @@ delimiter ;| # BUG#12329: "Bogus error msg when executing PS with stored procedure after # SP was re-created". See also test for related bug#13399 in trigger.test ---disable_warnings drop function if exists bug12329; --enable_warnings create table t1 as select 1 a; @@ -1518,6 +1517,44 @@ show procedure status; drop database mysqltest2; use test; +# +# Bug#13012 "SP: REPAIR/BACKUP/RESTORE TABLE crashes the server" +# +delimiter |; +--disable_warnings +DROP FUNCTION IF EXISTS bug13012| +--enable_warnings +--error ER_SP_NO_RETSET +CREATE FUNCTION bug13012() RETURNS INT +BEGIN + REPAIR TABLE t1; + RETURN 1; +END| +--error ER_SP_NO_RETSET +CREATE FUNCTION bug13012() RETURNS INT +BEGIN + BACKUP TABLE t1 TO '/tmp'; + RETURN 1; +END| +--error ER_SP_NO_RETSET +CREATE FUNCTION bug13012() RETURNS INT +BEGIN + RESTORE TABLE t1 FROM '/tmp'; + RETURN 1; +END| +create table t1 (a int)| +CREATE PROCEDURE bug13012_1() REPAIR TABLE t1| +CREATE FUNCTION bug13012_2() RETURNS INT +BEGIN + CALL bug13012_1(); + RETURN 1; +END| +--error ER_SP_NO_RETSET +SELECT bug13012_2()| +drop table t1| +drop procedure bug13012_1| +drop function bug13012_2| +delimiter ;| # BUG#NNNN: New bug synopsis # diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 760110b0a64..fcd0fddb147 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -4908,8 +4908,10 @@ drop procedure bug14376| # variable declarations. In MySQL 5.0 it's vice versa. # +--disable_warnings drop procedure if exists p1| drop table if exists t1| +--enable_warnings create table t1 (a varchar(255))| insert into t1 (a) values ("a - table column")| create procedure p1(a varchar(255)) @@ -4944,6 +4946,25 @@ begin end; end| call p1("a - stored procedure parameter")| +drop procedure p1| + +# +# Bug#13012 "SP: REPAIR/BACKUP/RESTORE TABLE crashes the server" +# +--disable_warnings +drop procedure if exists bug13012| +--enable_warnings +create procedure bug13012() +BEGIN + REPAIR TABLE t1; + BACKUP TABLE t1 to '../tmp'; + DROP TABLE t1; + RESTORE TABLE t1 FROM '../tmp'; +END| +--replace_result ": 7" ": X" ": 17" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR +call bug13012()| +drop procedure bug13012| +select * from t1| # # BUG#NNNN: New bug synopsis diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 81e10e59a9b..13d503dfa28 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -107,6 +107,9 @@ sp_get_flags_for_command(LEX *lex) case SQLCOM_SHOW_WARNS: case SQLCOM_SHOW_PROC_CODE: case SQLCOM_SHOW_FUNC_CODE: + case SQLCOM_REPAIR: + case SQLCOM_BACKUP_TABLE: + case SQLCOM_RESTORE_TABLE: flags= sp_head::MULTI_RESULTS; break; /* From 33b58ea123fa474c8ab6c73cea1ac6bd37671587 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Dec 2005 23:01:21 +0100 Subject: [PATCH 03/11] german error messages --- sql/share/errmsg.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index f67ad3a9fd2..3eeb2053d9c 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -4590,7 +4590,7 @@ ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 21000 nla "De gebruikte SELECT commando's hebben een verschillend aantal kolommen" eng "The used SELECT statements have a different number of columns" est "Tulpade arv kasutatud SELECT lausetes ei kattu" - ger "Die verwendeten SELECT-Befehle liefern eine unterschiedliche Anzahl von Feldern zurück" + ger "Die verwendeten SELECT-Befehle liefern unterschiedliche Anzahlen von Feldern zurück" ita "La SELECT utilizzata ha un numero di colonne differente" por "Os comandos SELECT usados têm diferente número de colunas" rus "éÓÐÏÌØÚÏ×ÁÎÎÙÅ ÏÐÅÒÁÔÏÒÙ ×ÙÂÏÒËÉ (SELECT) ÄÁÀÔ ÒÁÚÎÏÅ ËÏÌÉÞÅÓÔ×Ï ÓÔÏÌÂÃÏ×" @@ -5274,7 +5274,7 @@ ER_VIEW_SELECT_TMPTABLE ukr "View SELECT ×ÉËÏÒÉÓÔÏ×Õ¤ ÔÉÍÞÁÓÏ×Õ ÔÁÂÌÉÃÀ '%-.64s'" ER_VIEW_WRONG_LIST eng "View's SELECT and view's field list have different column counts" - ger "SELECT- und Feldliste der Views haben eine unterschiedliche Anzahl von Spalten" + ger "SELECT- und Feldliste der Views haben unterschiedliche Anzahlen von Spalten" rus "View SELECT É ÓÐÉÓÏË ÐÏÌÅÊ view ÉÍÅÀÔ ÒÁÚÎÏÅ ËÏÌÉÞÅÓÔ×Ï ÓÔÏÌÂÃÏ×" ukr "View SELECT ¦ ÐÅÒÅÌ¦Ë ÓÔÏ×ÂÃ¦× view ÍÁÀÔØ Ò¦ÚÎÕ Ë¦ÌØ˦ÓÔØ ÓËÏ×Âæ×" ER_WARN_VIEW_MERGE @@ -5485,7 +5485,7 @@ ER_CANT_CREATE_GEOMETRY_OBJECT 22003 ger "Kann kein Geometrieobjekt aus den Daten machen, die Sie dem GEOMETRY-Feld übergeben haben" ER_FAILED_ROUTINE_BREAK_BINLOG eng "A routine failed and has neither NO SQL nor READS SQL DATA in its declaration and binary logging is enabled; if non-transactional tables were updated, the binary log will miss their changes" - ger "Eine Routine, die weder NO SQL noch READS SQL DATA in der Deklaration hat, schlug fehl und Binärlogging ist aktiv. Wenn Nicht-Transaktions-Tabellen atualisiert wurden, enthält das Binärlog ihre Änderungen nicht" + ger "Eine Routine, die weder NO SQL noch READS SQL DATA in der Deklaration hat, schlug fehl und Binärlogging ist aktiv. Wenn Nicht-Transaktions-Tabellen aktualisiert wurden, enthält das Binärlog ihre Änderungen nicht" ER_BINLOG_UNSAFE_ROUTINE eng "This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)" ger "Diese Routine hat weder DETERMINISTIC, NO SQL noch READS SQL DATA in der Deklaration und Binärlogging ist aktiv (*vielleicht* sollten Sie die weniger sichere Variable log_bin_trust_routine_creators verwenden)" @@ -5595,8 +5595,11 @@ ER_SP_BAD_VAR_SHADOW 42000 eng "Variable '%-.64s' must be quoted with `...`, or renamed" ger "Variable '%-.64s' muss mit `...` geschützt oder aber umbenannt werden" ER_TRG_NO_DEFINER - eng "No definer attribute for trigger '%-.64s'.'%-.64s'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger." + eng "No definer attribute for trigger '%-.64s'.'%-.64s'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger." + ger "Kein Definierer-Attribut für Trigger '%-.64s'.'%-.64s'. Der Trigger wird mit der Autorisierung des Aufrufers aktiviert, der möglicherweise keine zureichenden Berechtigungen hat. Bitte legen Sie den Trigger neu an." ER_OLD_FILE_FORMAT - eng "'%-.64s' has an old format, you should re-create the '%s' object(s)" + eng "'%-.64s' has an old format, you should re-create the '%s' object(s)" + ger "'%-.64s' hat altes Format, Sie sollten die '%s'-Objekt(e) neu erzeugen" ER_SP_RECURSION_LIMIT eng "Recursive limit %d (as set by the max_sp_recursion_depth variable) was exceeded for routine %.64s" + ger "Rekursionsgrenze %d (durch Variable max_sp_recursion_depth gegeben) wurde für Routine %.64s überschritten" From da8b9967a85ba2cbc96c144695ad9bed7e6aad53 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 3 Dec 2005 15:02:09 +0100 Subject: [PATCH 04/11] this has nothing to do with the bug#13012. it's about mysql_admin_commands not being reexecution-safe (and CHECK still isn't) mysql-test/r/sp-error.result: optimize is now allowed in SP mysql-test/r/sp.result: test repair/optimize/analyze in SP mysql-test/t/backup.test: clean up after itself mysql-test/t/sp-error.test: optimize is now allowed in SP mysql-test/t/sp.test: test repair/optimize/analyze in SP sql/sp_head.cc: all mysql_admin commands return result set sql/sql_parse.cc: all mysql_admin commands modify table list and we should restore it for SP sql/sql_table.cc: optimization - don't execute views when no view is expected/allowed sql/sql_yacc.yy: optimize is now allowed in SP --- mysql-test/r/sp-error.result | 2 +- mysql-test/r/sp.result | 63 ++++++++++++++++++++++++++++++++++++ mysql-test/t/backup.test | 1 + mysql-test/t/sp-error.test | 2 +- mysql-test/t/sp.test | 13 +++++++- sql/sp_head.cc | 4 +++ sql/sql_parse.cc | 13 +++++++- sql/sql_table.cc | 7 ++-- sql/sql_yacc.yy | 5 --- 9 files changed, 99 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index f1d65ada4bf..4ba097e3d9f 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -768,7 +768,7 @@ BEGIN OPTIMIZE TABLE t1; RETURN 1; END| -ERROR 0A000: OPTIMIZE TABLE is not allowed in stored procedures +ERROR 0A000: Not allowed to return a result set from a function DROP FUNCTION IF EXISTS bug12995| CREATE FUNCTION bug12995() RETURNS INT BEGIN diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 41279534007..bfc16c826a5 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4168,6 +4168,69 @@ test.t1 backup status OK Table Op Msg_type Msg_text test.t1 restore status OK drop procedure bug13012| +create view v1 as select * from t1| +create procedure bug13012() +BEGIN +REPAIR TABLE t1,t2,t3,v1; +OPTIMIZE TABLE t1,t2,t3,v1; +ANALYZE TABLE t1,t2,t3,v1; +END| +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair error Table 'test.t3' doesn't exist +test.v1 repair note Unknown table 'test.v1' +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize error Table 'test.t3' doesn't exist +test.v1 optimize note Unknown table 'test.v1' +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze error Table 'test.t3' doesn't exist +test.v1 analyze note Unknown table 'test.v1' +Warnings: +Error 1146 Table 'test.t3' doesn't exist +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair error Table 'test.t3' doesn't exist +test.v1 repair note Unknown table 'test.v1' +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize error Table 'test.t3' doesn't exist +test.v1 optimize note Unknown table 'test.v1' +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze error Table 'test.t3' doesn't exist +test.v1 analyze note Unknown table 'test.v1' +Warnings: +Error 1146 Table 'test.t3' doesn't exist +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair error Table 'test.t3' doesn't exist +test.v1 repair note Unknown table 'test.v1' +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize error Table 'test.t3' doesn't exist +test.v1 optimize note Unknown table 'test.v1' +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze error Table 'test.t3' doesn't exist +test.v1 analyze note Unknown table 'test.v1' +Warnings: +Error 1146 Table 'test.t3' doesn't exist +drop procedure bug13012| +drop view v1; select * from t1| a a - table column diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test index 3034129ad4b..40a9fa73b60 100644 --- a/mysql-test/t/backup.test +++ b/mysql-test/t/backup.test @@ -52,5 +52,6 @@ unlock tables; connection con1; reap; drop table t5; +--system rm $MYSQL_TEST_DIR/var/tmp/t?.* # End of 4.1 tests diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index ae13758a10e..b6c7d5476e7 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -1095,7 +1095,7 @@ delimiter |; --disable_warnings DROP FUNCTION IF EXISTS bug12953| --enable_warnings ---error ER_SP_BADSTATEMENT +--error ER_SP_NO_RETSET CREATE FUNCTION bug12953() RETURNS INT BEGIN OPTIMIZE TABLE t1; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index fcd0fddb147..22dd1285b75 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -4961,9 +4961,20 @@ BEGIN DROP TABLE t1; RESTORE TABLE t1 FROM '../tmp'; END| ---replace_result ": 7" ": X" ": 17" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR call bug13012()| drop procedure bug13012| +create view v1 as select * from t1| +create procedure bug13012() +BEGIN + REPAIR TABLE t1,t2,t3,v1; + OPTIMIZE TABLE t1,t2,t3,v1; + ANALYZE TABLE t1,t2,t3,v1; +END| +call bug13012()| +call bug13012()| +call bug13012()| +drop procedure bug13012| +drop view v1; select * from t1| # diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 13d503dfa28..a0a4e0a462f 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -72,7 +72,11 @@ sp_get_flags_for_command(LEX *lex) } /* fallthrough */ case SQLCOM_ANALYZE: + case SQLCOM_OPTIMIZE: + case SQLCOM_PRELOAD_KEYS: + case SQLCOM_ASSIGN_TO_KEYCACHE: case SQLCOM_CHECKSUM: + case SQLCOM_CHECK: case SQLCOM_HA_READ: case SQLCOM_SHOW_BINLOGS: case SQLCOM_SHOW_BINLOG_EVENTS: diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c05529da745..0cc45a09015 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2614,7 +2614,8 @@ mysql_execute_command(THD *thd) goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; res = mysql_backup_table(thd, first_table); - + (TABLE_LIST*) select_lex->table_list.first=first_table; + lex->query_tables=all_tables; break; } case SQLCOM_RESTORE_TABLE: @@ -2626,6 +2627,8 @@ mysql_execute_command(THD *thd) goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; res = mysql_restore_table(thd, first_table); + (TABLE_LIST*) select_lex->table_list.first=first_table; + lex->query_tables=all_tables; break; } case SQLCOM_ASSIGN_TO_KEYCACHE: @@ -3128,6 +3131,8 @@ end_with_restore_list: mysql_bin_log.write(&qinfo); } } + (TABLE_LIST*) select_lex->table_list.first=first_table; + lex->query_tables=all_tables; break; } case SQLCOM_CHECK: @@ -3138,6 +3143,8 @@ end_with_restore_list: goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; res = mysql_check_table(thd, first_table, &lex->check_opt); + (TABLE_LIST*) select_lex->table_list.first=first_table; + lex->query_tables=all_tables; break; } case SQLCOM_ANALYZE: @@ -3158,6 +3165,8 @@ end_with_restore_list: mysql_bin_log.write(&qinfo); } } + (TABLE_LIST*) select_lex->table_list.first=first_table; + lex->query_tables=all_tables; break; } @@ -3181,6 +3190,8 @@ end_with_restore_list: mysql_bin_log.write(&qinfo); } } + (TABLE_LIST*) select_lex->table_list.first=first_table; + lex->query_tables=all_tables; break; } case SQLCOM_UPDATE: diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ae7e618f5df..20186d781f9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2222,9 +2222,12 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, */ lex->query_tables= table; lex->query_tables_last= &table->next_global; - lex->query_tables_own_last= 0;; + lex->query_tables_own_last= 0; thd->no_warnings_for_error= no_warnings_for_error; - open_and_lock_tables(thd, table); + if (view_operator_func == NULL) + simple_open_n_lock_tables(thd, table); + else + open_and_lock_tables(thd, table); thd->no_warnings_for_error= 0; table->next_global= save_next_global; table->next_local= save_next_local; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3c478e6d52f..35449fc8398 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3779,11 +3779,6 @@ optimize: OPTIMIZE opt_no_write_to_binlog table_or_tables { LEX *lex=Lex; - if (lex->sphead) - { - my_error(ER_SP_BADSTATEMENT, MYF(0), "OPTIMIZE TABLE"); - YYABORT; - } lex->sql_command = SQLCOM_OPTIMIZE; lex->no_write_to_binlog= $2; lex->check_opt.init(); From d9c233ae76dc55469fdc65e8420be9ec334f796d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Dec 2005 12:08:30 +0100 Subject: [PATCH 05/11] better error for optimize/repair/etc a view --- mysql-test/r/sp.result | 24 ++++++++++++------------ mysql-test/r/view.result | 17 +++++++++++------ sql/sql_table.cc | 11 ++--------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index bfc16c826a5..e8f8439927e 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4180,55 +4180,55 @@ Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair error Table 'test.t3' doesn't exist -test.v1 repair note Unknown table 'test.v1' +test.v1 repair error 'test.v1' is not BASE TABLE Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize error Table 'test.t3' doesn't exist -test.v1 optimize note Unknown table 'test.v1' +test.v1 optimize error 'test.v1' is not BASE TABLE Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze error Table 'test.t3' doesn't exist -test.v1 analyze note Unknown table 'test.v1' +test.v1 analyze error 'test.v1' is not BASE TABLE Warnings: -Error 1146 Table 'test.t3' doesn't exist +Error 1347 'test.v1' is not BASE TABLE call bug13012()| Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair error Table 'test.t3' doesn't exist -test.v1 repair note Unknown table 'test.v1' +test.v1 repair error 'test.v1' is not BASE TABLE Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize error Table 'test.t3' doesn't exist -test.v1 optimize note Unknown table 'test.v1' +test.v1 optimize error 'test.v1' is not BASE TABLE Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze error Table 'test.t3' doesn't exist -test.v1 analyze note Unknown table 'test.v1' +test.v1 analyze error 'test.v1' is not BASE TABLE Warnings: -Error 1146 Table 'test.t3' doesn't exist +Error 1347 'test.v1' is not BASE TABLE call bug13012()| Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair error Table 'test.t3' doesn't exist -test.v1 repair note Unknown table 'test.v1' +test.v1 repair error 'test.v1' is not BASE TABLE Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize error Table 'test.t3' doesn't exist -test.v1 optimize note Unknown table 'test.v1' +test.v1 optimize error 'test.v1' is not BASE TABLE Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze error Table 'test.t3' doesn't exist -test.v1 analyze note Unknown table 'test.v1' +test.v1 analyze error 'test.v1' is not BASE TABLE Warnings: -Error 1146 Table 'test.t3' doesn't exist +Error 1347 'test.v1' is not BASE TABLE drop procedure bug13012| drop view v1; select * from t1| diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index ebb2c190eb1..315744c6878 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2383,20 +2383,25 @@ CREATE TABLE t1(id INT); CREATE VIEW v1 AS SELECT id FROM t1; OPTIMIZE TABLE v1; Table Op Msg_type Msg_text -test.v1 optimize note Unknown table 'test.v1' +test.v1 optimize error 'test.v1' is not BASE TABLE +Warnings: +Error 1347 'test.v1' is not BASE TABLE ANALYZE TABLE v1; Table Op Msg_type Msg_text -test.v1 analyze note Unknown table 'test.v1' +test.v1 analyze error 'test.v1' is not BASE TABLE +Warnings: +Error 1347 'test.v1' is not BASE TABLE REPAIR TABLE v1; Table Op Msg_type Msg_text -test.v1 repair note Unknown table 'test.v1' +test.v1 repair error 'test.v1' is not BASE TABLE +Warnings: +Error 1347 'test.v1' is not BASE TABLE DROP TABLE t1; OPTIMIZE TABLE v1; Table Op Msg_type Msg_text -test.v1 optimize note Unknown table 'test.v1' +test.v1 optimize error 'test.v1' is not BASE TABLE Warnings: -Error 1146 Table 'test.t1' doesn't exist -Error 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +Error 1347 'test.v1' is not BASE TABLE DROP VIEW v1; create definer = current_user() sql security invoker view v1 as select 1; show create view v1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 20186d781f9..ba4a606537f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2225,18 +2225,11 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, lex->query_tables_own_last= 0; thd->no_warnings_for_error= no_warnings_for_error; if (view_operator_func == NULL) - simple_open_n_lock_tables(thd, table); - else - open_and_lock_tables(thd, table); + table->required_type=FRMTYPE_TABLE; + open_and_lock_tables(thd, table); thd->no_warnings_for_error= 0; table->next_global= save_next_global; table->next_local= save_next_local; - /* if view are unsupported */ - if (table->view && view_operator_func == NULL) - { - result_code= HA_ADMIN_NOT_BASE_TABLE; - goto send_result; - } thd->open_options&= ~extra_open_options; if (prepare_func) From d7249025a0ed9e344c24cdd40e5dc2500ea33bd0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Dec 2005 20:47:15 +0100 Subject: [PATCH 06/11] compatibility define for Bug#15293 --- include/mysql.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/mysql.h b/include/mysql.h index c4b4e026e5b..f3244d4ba36 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -117,6 +117,9 @@ typedef unsigned long long my_ulonglong; #define MYSQL_COUNT_ERROR (~(my_ulonglong) 0) +/* backward compatibility define - to be removed eventually */ +#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED + typedef struct st_mysql_rows { struct st_mysql_rows *next; /* list of rows */ MYSQL_ROW data; From 835acc86759d2a4f6f1028713352652429533d38 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Dec 2005 14:07:23 +0100 Subject: [PATCH 07/11] - commit emails are now sent to commits@lists.mysql.com instead of internals@lists.mysql.com to reduce the noise on the internals list. --- BitKeeper/triggers/post-commit | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit index 4c28b408658..a2490946198 100755 --- a/BitKeeper/triggers/post-commit +++ b/BitKeeper/triggers/post-commit @@ -2,7 +2,7 @@ #shift FROM=$USER@mysql.com -INTERNALS=internals@lists.mysql.com +COMMITS=commits@lists.mysql.com DOCS=docs-commit@mysql.com LIMIT=10000 VERSION="4.0" @@ -60,14 +60,14 @@ EOF ) | head -n $LIMIT | /usr/sbin/sendmail -t #++ -# internals@ mail +# commits@ mail #-- - echo "Notifying internals list at $INTERNALS" + echo "Notifying commits list at $COMMITS" ( cat < From: $FROM -To: $INTERNALS +To: $COMMITS Subject: bk commit into $VERSION tree ($CHANGESET)$BS X-CSetKey: <$CSETKEY> $BH From c4b8823fc3abb24324f038b55484584e7f0bb77c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Dec 2005 12:43:32 +0100 Subject: [PATCH 08/11] Bump version number following 5.0.17 release clone-off configure.in: Bump version number following release clone-off --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 9f0867da68a..501757e3df1 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.17) +AM_INIT_AUTOMAKE(mysql, 5.0.18) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 6b2f13098a59d9ad520828dca4cb63da8c86b5e3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Dec 2005 17:01:17 +0300 Subject: [PATCH 09/11] Patch for WL#2894: Make stored routine variables work according to the standard. The idea is to use Field-classes to implement stored routines variables. Also, we should provide facade to Item-hierarchy by Item_field class (it is necessary, since SRVs take part in expressions). The patch fixes the following bugs: - BUG#8702: Stored Procedures: No Error/Warning shown for inappropriate data type matching; - BUG#8768: Functions: For any unsigned data type, -ve values can be passed and returned; - BUG#8769: Functions: For Int datatypes, out of range values can be passed and returned; - BUG#9078: STORED PROCDURE: Decimal digits are not displayed when we use DECIMAL datatype; - BUG#9572: Stored procedures: variable type declarations ignored; - BUG#12903: upper function does not work inside a function; - BUG#13705: parameters to stored procedures are not verified; - BUG#13808: ENUM type stored procedure parameter accepts non-enumerated data; - BUG#13909: Varchar Stored Procedure Parameter always BINARY string (ignores CHARACTER SET); - BUG#14161: Stored procedure cannot retrieve bigint unsigned; - BUG#14188: BINARY variables have no 0x00 padding; - BUG#15148: Stored procedure variables accept non-scalar values; mysql-test/r/ctype_ujis.result: Explicitly specify correct charset. mysql-test/r/schema.result: Drop our test database to not affect this test if some test left it cause of failure. mysql-test/r/show_check.result: Drop our test database to not affect this test if some test left it cause of failure. mysql-test/r/skip_name_resolve.result: Ignore columns with unpredictable values. mysql-test/r/sp-big.result: Add cleanup statement. mysql-test/r/sp-dynamic.result: Add cleanup statements. mysql-test/r/sp.result: Update result file. mysql-test/r/sum_distinct-big.result: Update result file. mysql-test/r/type_newdecimal-big.result: Update result file. mysql-test/t/ctype_ujis.test: Explicitly specify correct charset. mysql-test/t/schema.test: Drop our test database to not affect this test if some test left it cause of failure. mysql-test/t/show_check.test: Drop our test database to not affect this test if some test left it cause of failure. mysql-test/t/skip_name_resolve.test: Ignore columns with unpredictable values. mysql-test/t/sp-big.test: Add cleanup statement. mysql-test/t/sp-dynamic.test: Add cleanup statements. mysql-test/t/sp.test: Non-scalar values prohibited for assignment to SP-vars; polishing. mysql-test/t/type_newdecimal-big.test: Update type specification so that the variables can contain the large values used in the test. sql/field.cc: Extract create_field::init() to initialize an existing instance of create_field from new_create_field(). sql/field.h: Extract create_field::init() to initialize an existing instance of create_field from new_create_field(). sql/item.cc: - Introduce a new class: Item_sp_variable -- a base class of stored-routine-variables classes; - Introduce Item_case_expr -- an Item, which is used to access to the expression of CASE statement; sql/item.h: - Introduce a new class: Item_sp_variable -- a base class of stored-routine-variables classes; - Introduce Item_case_expr -- an Item, which is used to access to the expression of CASE statement; sql/item_func.cc: Pass the Field (instead of Item) for the return value of a function to the function execution routine. sql/item_func.h: Pass the Field (instead of Item) for the return value of a function to the function execution routine. sql/mysql_priv.h: Move create_virtual_tmp_table() out of sql_select.h. sql/sp.cc: Use create_result_field() instead of make_field(). sql/sp_head.cc: - Add a function to map enum_field_types to Item::Type; - Add sp_instr_push_case_expr instruction -- an instruction to push CASE expression into the active running context; - Add sp_instr_pop_case_expr instruction -- an instruction to pop CASE expression from the active running context; - Adapt the SP-execution code to using Fields instead of Items for SP-vars; - Use create_field structure for field description instead of a set of members. sql/sp_head.h: - Add a function to map enum_field_types to Item::Type; - Add sp_instr_push_case_expr instruction -- an instruction to push CASE expression into the active running context; - Add sp_instr_pop_case_expr instruction -- an instruction to pop CASE expression from the active running context; - Adapt the SP-execution code to using Fields instead of Items for SP-vars; - Use create_field structure for field description instead of a set of members. sql/sp_pcontext.cc: - Change rules to assign an index of SP-variable: use transparent index; - Add an operation to retrieve a list of defined SP-vars from the processing context recursively. sql/sp_pcontext.h: - Change rules to assign an index of SP-variable: use transparent index; - Add an operation to retrieve a list of defined SP-vars from the processing context recursively. sql/sp_rcontext.cc: - Change rules to assign an index of SP-variable: use transparent index; - Use a tmp virtual table to store SP-vars instead of Items; - Provide operations to work with CASE expresion. sql/sp_rcontext.h: - Change rules to assign an index of SP-variable: use transparent index; - Use a tmp virtual table to store SP-vars instead of Items; - Provide operations to work with CASE expresion. sql/sql_class.cc: - Reflect Item_splocal ctor changes; - Item_splocal::get_offset() has been renamed to get_var_idx(). sql/sql_class.h: Polishing. sql/sql_parse.cc: Extract create_field::init() to initialize an existing instance of create_field from new_create_field(). sql/sql_select.cc: Take care of BLOB columns in create_virtual_tmp_table(). sql/sql_select.h: Move create_virtual_tmp_table() out of sql_select.h. sql/sql_trigger.cc: Use boolean constants for boolean type instead of numerical ones. sql/sql_yacc.yy: Provide an instance of create_field for each SP-var. mysql-test/include/sp-vars.inc: The definitions of common-procedures, which are created under different circumstances. mysql-test/r/sp-vars.result: Result file for the SP-vars test. mysql-test/sp-vars.test: A new test for checking SP-vars functionality. --- mysql-test/include/sp-vars.inc | 122 +++ mysql-test/r/ctype_ujis.result | 2 +- mysql-test/r/schema.result | 1 + mysql-test/r/show_check.result | 1 + mysql-test/r/skip_name_resolve.result | 4 +- mysql-test/r/sp-big.result | 1 + mysql-test/r/sp-dynamic.result | 2 + mysql-test/r/sp-vars.result | 1077 +++++++++++++++++++ mysql-test/r/sp.result | 41 +- mysql-test/r/sum_distinct-big.result | 29 +- mysql-test/r/type_newdecimal-big.result | 31 +- mysql-test/sp-vars.test | 1273 +++++++++++++++++++++++ mysql-test/t/ctype_ujis.test | 2 +- mysql-test/t/schema.test | 6 + mysql-test/t/show_check.test | 1 + mysql-test/t/skip_name_resolve.test | 2 +- mysql-test/t/sp-big.test | 3 + mysql-test/t/sp-dynamic.test | 6 + mysql-test/t/sp.test | 9 +- mysql-test/t/type_newdecimal-big.test | 31 +- sql/field.cc | 347 ++++++ sql/field.h | 18 + sql/item.cc | 197 ++-- sql/item.h | 249 +++-- sql/item_func.cc | 51 +- sql/item_func.h | 4 +- sql/mysql_priv.h | 3 +- sql/sp.cc | 2 +- sql/sp_head.cc | 952 +++++++++-------- sql/sp_head.h | 61 +- sql/sp_pcontext.cc | 75 +- sql/sp_pcontext.h | 98 +- sql/sp_rcontext.cc | 304 +++++- sql/sp_rcontext.h | 148 +-- sql/sql_class.cc | 10 +- sql/sql_class.h | 2 +- sql/sql_parse.cc | 328 +----- sql/sql_select.cc | 13 + sql/sql_select.h | 1 - sql/sql_trigger.cc | 6 +- sql/sql_yacc.yy | 227 ++-- 41 files changed, 4486 insertions(+), 1254 deletions(-) create mode 100644 mysql-test/include/sp-vars.inc create mode 100644 mysql-test/r/sp-vars.result create mode 100644 mysql-test/sp-vars.test diff --git a/mysql-test/include/sp-vars.inc b/mysql-test/include/sp-vars.inc new file mode 100644 index 00000000000..3e02c9d1709 --- /dev/null +++ b/mysql-test/include/sp-vars.inc @@ -0,0 +1,122 @@ +delimiter |; + +--------------------------------------------------------------------------- + +CREATE PROCEDURE sp_vars_check_dflt() +BEGIN + DECLARE v1 TINYINT DEFAULT 1e200; + DECLARE v1u TINYINT UNSIGNED DEFAULT 1e200; + DECLARE v2 TINYINT DEFAULT -1e200; + DECLARE v2u TINYINT UNSIGNED DEFAULT -1e200; + DECLARE v3 TINYINT DEFAULT 300; + DECLARE v3u TINYINT UNSIGNED DEFAULT 300; + DECLARE v4 TINYINT DEFAULT -300; + DECLARE v4u TINYINT UNSIGNED DEFAULT -300; + + DECLARE v5 TINYINT DEFAULT 10 * 10 * 10; + DECLARE v5u TINYINT UNSIGNED DEFAULT 10 * 10 * 10; + DECLARE v6 TINYINT DEFAULT -10 * 10 * 10; + DECLARE v6u TINYINT UNSIGNED DEFAULT -10 * 10 * 10; + + DECLARE v7 TINYINT DEFAULT '10'; + DECLARE v8 TINYINT DEFAULT '10 '; + DECLARE v9 TINYINT DEFAULT ' 10 '; + DECLARE v10 TINYINT DEFAULT 'String 10 '; + DECLARE v11 TINYINT DEFAULT 'String10'; + DECLARE v12 TINYINT DEFAULT '10 String'; + DECLARE v13 TINYINT DEFAULT '10String'; + DECLARE v14 TINYINT DEFAULT concat('10', ' '); + DECLARE v15 TINYINT DEFAULT concat(' ', '10'); + DECLARE v16 TINYINT DEFAULT concat('Hello, ', 'world'); + + DECLARE v17 DECIMAL(64, 2) DEFAULT 12; + DECLARE v18 DECIMAL(64, 2) DEFAULT 12.123; + DECLARE v19 DECIMAL(64, 2) DEFAULT 11 + 1; + DECLARE v20 DECIMAL(64, 2) DEFAULT 12 + 0.123; + + SELECT v1, v1u, v2, v2u, v3, v3u, v4, v4u; + SELECT v5, v5u, v6, v6u; + SELECT v7, v8, v9, v10, v11, v12, v13, v14, v15, v16; + SELECT v17, v18, v19, v20; +END| + +--------------------------------------------------------------------------- + +CREATE PROCEDURE sp_vars_check_assignment() +BEGIN + DECLARE i1, i2, i3, i4 TINYINT; + DECLARE u1, u2, u3, u4 TINYINT UNSIGNED; + DECLARE d1, d2, d3 DECIMAL(64, 2); + + SET i1 = 1e200; + SET i2 = -1e200; + SET i3 = 300; + SET i4 = -300; + + SELECT i1, i2, i3, i4; + + SET i1 = 10 * 10 * 10; + SET i2 = -10 * 10 * 10; + SET i3 = sign(10 * 10) * 10 * 20; + SET i4 = sign(-10 * 10) * -10 * 20; + + SELECT i1, i2, i3, i4; + + SET u1 = 1e200; + SET u2 = -1e200; + SET u3 = 300; + SET u4 = -300; + + SELECT u1, u2, u3, u4; + + SET u1 = 10 * 10 * 10; + SET u2 = -10 * 10 * 10; + SET u3 = sign(10 * 10) * 10 * 20; + SET u4 = sign(-10 * 10) * -10 * 20; + + SELECT u1, u2, u3, u4; + + SET d1 = 1234; + SET d2 = 1234.12; + SET d3 = 1234.1234; + + SELECT d1, d2, d3; + + SET d1 = 12 * 100 + 34; + SET d2 = 12 * 100 + 34 + 0.12; + SET d3 = 12 * 100 + 34 + 0.1234; + + SELECT d1, d2, d3; +END| + +--------------------------------------------------------------------------- + +CREATE FUNCTION sp_vars_check_ret1() RETURNS TINYINT +BEGIN + RETURN 1e200; +END| + +--------------------------------------------------------------------------- + +CREATE FUNCTION sp_vars_check_ret2() RETURNS TINYINT +BEGIN + RETURN 10 * 10 * 10; +END| + +--------------------------------------------------------------------------- + +CREATE FUNCTION sp_vars_check_ret3() RETURNS TINYINT +BEGIN + RETURN 'Hello, world'; +END| + +--------------------------------------------------------------------------- + +CREATE FUNCTION sp_vars_check_ret4() RETURNS DECIMAL(64, 2) +BEGIN + RETURN 12 * 10 + 34 + 0.1234; +END| + +--------------------------------------------------------------------------- + +delimiter ;| diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result index 15de93440fc..2e14fe34430 100644 --- a/mysql-test/r/ctype_ujis.result +++ b/mysql-test/r/ctype_ujis.result @@ -2317,7 +2317,7 @@ CREATE TABLE t2(c2 char(2)) default charset = ujis; INSERT INTO t1 VALUES(_ujis 0xA4A2); CREATE PROCEDURE sp1() BEGIN -DECLARE a CHAR(1); +DECLARE a CHAR(2) CHARSET ujis; DECLARE cur1 CURSOR FOR SELECT c1 FROM t1; OPEN cur1; FETCH cur1 INTO a; diff --git a/mysql-test/r/schema.result b/mysql-test/r/schema.result index 48e6ebcfad2..538abd8d039 100644 --- a/mysql-test/r/schema.result +++ b/mysql-test/r/schema.result @@ -1,3 +1,4 @@ +drop database if exists mysqltest1; create schema foo; show create schema foo; Database Create Database diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index fdb0db602ff..61a820b4469 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -1,6 +1,7 @@ drop table if exists t1,t2; drop table if exists t1aa,t2aa; drop database if exists mysqltest; +drop database if exists mysqltest1; delete from mysql.user where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; delete from mysql.db where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; flush privileges; diff --git a/mysql-test/r/skip_name_resolve.result b/mysql-test/r/skip_name_resolve.result index a969c5c9ae0..8ef52e75238 100644 --- a/mysql-test/r/skip_name_resolve.result +++ b/mysql-test/r/skip_name_resolve.result @@ -10,5 +10,5 @@ user() # show processlist; Id User Host db Command Time State Info -# root # test Sleep # NULL -# root # test Query # NULL show processlist + root test