From 547f2676d7bdecc75b35f505c06549ff390619c4 Mon Sep 17 00:00:00 2001 From: "pem@mysql.com" <> Date: Tue, 15 Nov 2005 13:10:12 +0100 Subject: [PATCH 1/5] Fixed BUG#14723: Dumping of stored functions seems to cause corruption in the function body Changed the way the end of query was found from the lex state. The routine body was not extracted correctly when using the /*!version ... */ wrapper (in dump files); for some types of routines (e.g. with a label at the first begin), the trailing "*/" was not skipped. This is a recommit for the 5.0.16-release tree. --- mysql-test/r/sp.result | 31 +++++++++++++++++++++++++++++++ mysql-test/t/sp.test | 32 ++++++++++++++++++++++++++++++++ sql/sp_head.cc | 25 ++++++++++++++----------- 3 files changed, 77 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index d50e6dd3751..1e49f966bc4 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -3617,4 +3617,35 @@ count(*) drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| +drop function if exists bug14723| +drop procedure if exists bug14723| +/*!50003 create function bug14723() +returns bigint(20) +main_loop: begin +return 42; +end */;; +show create function bug14723;; +Function sql_mode Create Function +bug14723 CREATE FUNCTION `bug14723`() RETURNS bigint(20) +main_loop: begin +return 42; +end +select bug14723();; +bug14723() +42 +/*!50003 create procedure bug14723() +main_loop: begin +select 42; +end */;; +show create procedure bug14723;; +Procedure sql_mode Create Procedure +bug14723 CREATE PROCEDURE `bug14723`() +main_loop: begin +select 42; +end +call bug14723();; +42 +42 +drop function bug14723| +drop procedure bug14723| drop table t1,t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index eaf69c0ab03..362faec167c 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -4541,6 +4541,38 @@ drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| + +# +# BUG#1473: Dumping of stored functions seems to cause corruption in +# the function body +# +--disable_warnings +drop function if exists bug14723| +drop procedure if exists bug14723| +--enable_warnings + +delimiter ;;| +/*!50003 create function bug14723() + returns bigint(20) +main_loop: begin + return 42; +end */;; +show create function bug14723;; +select bug14723();; + +/*!50003 create procedure bug14723() +main_loop: begin + select 42; +end */;; +show create procedure bug14723;; +call bug14723();; + +delimiter |;; + +drop function bug14723| +drop procedure bug14723| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/sp_head.cc b/sql/sp_head.cc index abc66ce0b21..3073372cd00 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -476,7 +476,7 @@ void sp_head::init_strings(THD *thd, LEX *lex, sp_name *name) { DBUG_ENTER("sp_head::init_strings"); - uint n; /* Counter for nul trimming */ + uchar *endp; /* Used to trim the end */ /* During parsing, we must use thd->mem_root */ MEM_ROOT *root= thd->mem_root; @@ -509,17 +509,20 @@ sp_head::init_strings(THD *thd, LEX *lex, sp_name *name) (char *)m_param_begin, m_params.length); } - m_body.length= lex->ptr - m_body_begin; - /* Trim nuls at the end */ - n= 0; - while (m_body.length && m_body_begin[m_body.length-1] == '\0') - { - m_body.length-= 1; - n+= 1; - } + /* If ptr has overrun end_of_query then end_of_query is the end */ + endp= (lex->ptr > lex->end_of_query ? lex->end_of_query : lex->ptr); + /* + Trim "garbage" at the end. This is sometimes needed with the + "/ * ! VERSION... * /" wrapper in dump files. + */ + while (m_body_begin < endp && + (endp[-1] <= ' ' || endp[-1] == '*' || + endp[-1] == '/' || endp[-1] == ';')) + endp-= 1; + + m_body.length= endp - m_body_begin; m_body.str= strmake_root(root, (char *)m_body_begin, m_body.length); - m_defstr.length= lex->ptr - lex->buf; - m_defstr.length-= n; + m_defstr.length= endp - lex->buf; m_defstr.str= strmake_root(root, (char *)lex->buf, m_defstr.length); DBUG_VOID_RETURN; } From c753df999c259a74446244917e6226296dd376f7 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 2 Dec 2005 18:29:15 +0100 Subject: [PATCH 2/5] Bug #11731 mysqltest in multi-statement queries ignores errors in non-1st queries - Add tests to mysqltest.test - Problem no longer exists --- mysql-test/r/mysqltest.result | 22 +++++++++++++++++ mysql-test/t/mysqltest.test | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 54bdb1b45d8..56ee329fb28 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -391,3 +391,25 @@ root@localhost -------------------------------------------------------------------------------- this will be executed this will be executed +mysqltest: At line 2: query 'create table t1 (a int primary key); +insert into t1 values (1); +select 'select-me'; +insertz 'error query'' failed: 1064: 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 'insertz 'error query'' at line 1 +drop table t1; +drop table t1; +create table t1 (a int primary key); +insert into t1 values (1); +select 'select-me'; +insertz error query|||| +select-me +select-me +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 'insertz error query' at line 1 +drop table t1; +create table t1 (a int primary key); +insert into t1 values (1); +select 'select-me'; +insertz error query|||| +select-me +select-me +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 'insertz error query' at line 1 +drop table t1; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 3d9dff4d373..6e56fac2f86 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -945,3 +945,49 @@ select "this will not be executed"; --enable_parsing select "this will be executed"; --enable_query_log + + +# +# Bug #11731 mysqltest in multi-statement queries ignores errors in +# non-1st queries +# + +# Failing multi statement query +--exec echo "delimiter ||||;" > var/tmp/bug11731.sql +--exec echo "create table t1 (a int primary key);" >> var/tmp/bug11731.sql +--exec echo "insert into t1 values (1);" >> var/tmp/bug11731.sql +--exec echo "select 'select-me';" >> var/tmp/bug11731.sql +--exec echo "insertz 'error query'||||" >> var/tmp/bug11731.sql +--exec echo "delimiter ;||||" >> var/tmp/bug11731.sql + +--error 1 +--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql 2>&1 +drop table t1; + +--error 1 +--exec $MYSQL_TEST --record -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql -R $MYSQL_TEST_DIR/var/tmp/bug11731.out +# The .out file should be empty, cat will fail! +--error 1 +--exec cat $MYSQL_TEST_DIR/var/tmp/bug11731.out +drop table t1; + + +# Using expected error +--exec echo "delimiter ||||;" > var/tmp/bug11731.sql +--exec echo "--error 1064" >> var/tmp/bug11731.sql +--exec echo "create table t1 (a int primary key);" >> var/tmp/bug11731.sql +--exec echo "insert into t1 values (1);" >> var/tmp/bug11731.sql +--exec echo "select 'select-me';" >> var/tmp/bug11731.sql +--exec echo "insertz "error query"||||" >> var/tmp/bug11731.sql +--exec echo "delimiter ;||||" >> var/tmp/bug11731.sql + +# These two should work since the error is expected +--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql 2>&1 +drop table t1; + +--exec $MYSQL_TEST --record -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql -R $MYSQL_TEST_DIR/var/tmp/bug11731.out +--exec cat $MYSQL_TEST_DIR/var/tmp/bug11731.out +drop table t1; + + + From 9fd13ba93dbdd0e75710356975393cde88f76bc3 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Sat, 3 Dec 2005 20:52:34 +0100 Subject: [PATCH 3/5] my_global.h: Make __cxa_pure_virtual weak symbol --- include/my_global.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/my_global.h b/include/my_global.h index 851033cf366..e62f6c269aa 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -453,6 +453,17 @@ typedef unsigned short ushort; #define __attribute__(A) #endif +/* + Wen using the embedded library, users might run into link problems, + dupicate declaration of __cxa_pure_virtual, solved by declaring it a + weak symbol. +*/ +#ifdef USE_MYSYS_NEW +C_MODE_START +int __cxa_pure_virtual () __attribute__ ((weak)); +C_MODE_END +#endif + /* From old s-system.h */ /* From 669a12fdb0f66af4de8d0337ac15cd79707e5a37 Mon Sep 17 00:00:00 2001 From: "jani@a193-229-222-105.elisa-laajakaista.fi" <> Date: Sun, 4 Dec 2005 15:02:06 +0200 Subject: [PATCH 4/5] A set of Netware related patches. --- client/mysql.cc | 2 +- client/mysqladmin.c | 2 +- client/mysqlbinlog.cc | 2 +- client/mysqlcheck.c | 2 +- client/mysqldump.c | 2 +- client/mysqlimport.c | 2 +- client/mysqlshow.c | 2 +- isam/isamchk.c | 2 +- myisam/myisamchk.c | 2 +- myisam/myisampack.c | 2 +- sql/sql_parse.cc | 3 +++ 11 files changed, 13 insertions(+), 10 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index bbe3212be14..9e7ea4ec9d2 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -442,7 +442,7 @@ static struct my_option my_long_options[] = {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"auto-rehash", OPT_AUTO_REHASH, diff --git a/client/mysqladmin.c b/client/mysqladmin.c index 98e54b695b8..0f45ef174b0 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -107,7 +107,7 @@ static TYPELIB command_typelib= static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"count", 'c', diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 9ae280a997d..736fa5a0e83 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -402,7 +402,7 @@ static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif #ifndef DBUG_OFF diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 98ef59c19d8..1dc83a98db0 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -57,7 +57,7 @@ static struct my_option my_long_options[] = (gptr*) &opt_all_in_1, (gptr*) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"auto-repair", OPT_AUTO_REPAIR, diff --git a/client/mysqldump.c b/client/mysqldump.c index 145b84f3f45..d619abcf78c 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -112,7 +112,7 @@ static struct my_option my_long_options[] = "Allow creation of column names that are keywords.", (gptr*) &opt_keywords, (gptr*) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", OPT_CHARSETS_DIR, diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 4bf4974748b..0932cf7432a 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -53,7 +53,7 @@ static longlong opt_ignore_lines= -1; static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", OPT_CHARSETS_DIR, diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 35afc1f5780..936c4464447 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -139,7 +139,7 @@ int main(int argc, char **argv) static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", 'c', "Directory where character sets are", diff --git a/isam/isamchk.c b/isam/isamchk.c index d0c0ff68aef..32374f8b8d1 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -244,7 +244,7 @@ static struct my_option my_long_options[] = "Analyze distribution of keys. Will make some joins in MySQL faster.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", OPT_CHARSETS_DIR_IC, diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index c9f4c8b2b21..d4a4eb9760f 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -159,7 +159,7 @@ static struct my_option my_long_options[] = "Analyze distribution of keys. Will make some joins in MySQL faster. You can check the calculated distribution.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"block-search", 'b', diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 9f3c8f505f7..90a14f6207c 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -239,7 +239,7 @@ enum options_mp {OPT_CHARSETS_DIR_MP=256, OPT_AUTO_CLOSE}; static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"auto-close", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"backup", 'b', "Make a backup of the table as table_name.OLD", diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index aac442d35a2..15974fc1d63 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -503,6 +503,9 @@ check_connections(THD *thd) thd->thread_id)); DBUG_PRINT("info",("New connection received on %s", vio_description(net->vio))); +#ifdef SIGNAL_WITH_VIO_CLOSE + thd->set_active_vio(net->vio); +#endif if (!thd->host) // If TCP/IP connection { From 4f6a321bb80034215d04bec3c33ddba28a83ce1f Mon Sep 17 00:00:00 2001 From: "jani@a193-229-222-105.elisa-laajakaista.fi" <> Date: Sun, 4 Dec 2005 15:39:44 +0200 Subject: [PATCH 5/5] Fixes multi_statement test case on NetWare. --- netware/mysql_test_run.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netware/mysql_test_run.c b/netware/mysql_test_run.c index 37800c5d79b..c23264cdbbd 100644 --- a/netware/mysql_test_run.c +++ b/netware/mysql_test_run.c @@ -347,6 +347,8 @@ void start_master() add_arg(&al, "--character-sets-dir=%s", char_dir); add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); add_arg(&al, "--language=%s", lang_dir); + add_arg(&al, "--log-slow-queries"); + add_arg(&al, "--log-queries-not-using-indexes"); #ifdef DEBUG //only for debug builds add_arg(&al, "--debug"); #endif @@ -520,6 +522,8 @@ void start_slave() add_arg(&al, "--master-retry-count=10"); add_arg(&al, "-O"); add_arg(&al, "slave_net_timeout=10"); + add_arg(&al, "--log-slow-queries"); + add_arg(&al, "--log-queries-not-using-indexes"); #ifdef DEBUG //only for debug builds add_arg(&al, "--debug"); #endif