From caba34a1b4c2021ff99f4869f43587ea73fe3061 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Mon, 18 May 2009 12:52:51 -0700 Subject: [PATCH 01/15] The output of mysqldump --tab for views included a DROP TABLE statement without the IF EXISTS qualifier even though no temporary table is created as for all-in-one dumps including views. (Bug #37377) --- client/mysqldump.c | 3 ++- mysql-test/r/mysqldump.result | 39 +++++++++++++++++++++-------------- mysql-test/t/mysqldump.test | 23 +++++++++++++++++++++ 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index efcb1820be4..87b78cb41e1 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4802,7 +4802,8 @@ static my_bool get_view_structure(char *table, char* db) result_table); check_io(sql_file); } - fprintf(sql_file, "/*!50001 DROP TABLE %s*/;\n", opt_quoted_table); + /* Table might not exist if this view was dumped with --tab. */ + fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table); if (opt_drop) { fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 7e987df8166..b48b6c9d87f 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1991,7 +1991,7 @@ SET character_set_client = utf8; `a` varchar(30) ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; -/*!50001 DROP TABLE `v2`*/; +/*!50001 DROP TABLE IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -2085,7 +2085,7 @@ SET character_set_client = utf8; `a` int(11) ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; -/*!50001 DROP TABLE `v1`*/; +/*!50001 DROP TABLE IF EXISTS `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -2159,7 +2159,7 @@ SET character_set_client = utf8; `a` varchar(30) ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; -/*!50001 DROP TABLE `v2`*/; +/*!50001 DROP TABLE IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -2293,7 +2293,7 @@ SET character_set_client = utf8; `c` varchar(30) ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; -/*!50001 DROP TABLE `v1`*/; +/*!50001 DROP TABLE IF EXISTS `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -2307,7 +2307,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -/*!50001 DROP TABLE `v2`*/; +/*!50001 DROP TABLE IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -2321,7 +2321,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -/*!50001 DROP TABLE `v3`*/; +/*!50001 DROP TABLE IF EXISTS `v3`*/; /*!50001 DROP VIEW IF EXISTS `v3`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -3054,7 +3054,7 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; USE `test`; -/*!50001 DROP TABLE `v0`*/; +/*!50001 DROP TABLE IF EXISTS `v0`*/; /*!50001 DROP VIEW IF EXISTS `v0`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -3068,7 +3068,7 @@ USE `test`; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -/*!50001 DROP TABLE `v1`*/; +/*!50001 DROP TABLE IF EXISTS `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -3082,7 +3082,7 @@ USE `test`; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -/*!50001 DROP TABLE `v2`*/; +/*!50001 DROP TABLE IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -3320,7 +3320,7 @@ insert into t values(5, 51); create view v1 as select qty, price, qty*price as value from t; create view v2 as select qty from v1; mysqldump { -/*!50001 DROP TABLE `v1`*/; +/*!50001 DROP TABLE IF EXISTS `v1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -3335,7 +3335,7 @@ mysqldump { /*!50001 SET collation_connection = @saved_col_connection */; } mysqldump { -/*!50001 DROP TABLE `v2`*/; +/*!50001 DROP TABLE IF EXISTS `v2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -3434,7 +3434,7 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; USE `mysqldump_test_db`; -/*!50001 DROP TABLE `v1`*/; +/*!50001 DROP TABLE IF EXISTS `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -3496,7 +3496,7 @@ SET character_set_client = @saved_cs_client; USE `mysqldump_tables`; USE `mysqldump_views`; -/*!50001 DROP TABLE `nasishnasifu`*/; +/*!50001 DROP TABLE IF EXISTS `nasishnasifu`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -3885,7 +3885,7 @@ SET character_set_client = utf8; `c` int(11) ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; -/*!50001 DROP TABLE `v2`*/; +/*!50001 DROP TABLE IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -4304,7 +4304,7 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; USE `mysqldump_test_db`; -/*!50001 DROP TABLE `v1`*/; +/*!50001 DROP TABLE IF EXISTS `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -4430,6 +4430,15 @@ DROP DATABASE mysqldump_test_db; # -- End of test case for Bug#32538. +# +# Bug#37377 Incorrect DROP TABLE statement in dump of a VIEW using --tab +# +create table t1 (a int); +create view v1 as select a from t1; +drop view v1; +drop table t1; +drop view v1; +drop table t1; SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; # # End of 5.1 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 64d1036e264..6fc8d7bdfea 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1948,6 +1948,29 @@ DROP DATABASE mysqldump_test_db; --echo # -- End of test case for Bug#32538. --echo +--echo # +--echo # Bug#37377 Incorrect DROP TABLE statement in dump of a VIEW using --tab +--echo # + +create table t1 (a int); +create view v1 as select a from t1; + +--exec $MYSQL_DUMP --skip-comments --tab=$MYSQLTEST_VARDIR/tmp/ test t1 v1 + +drop view v1; +drop table t1; + +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/v1.sql + +drop view v1; +drop table t1; + +--remove_file $MYSQLTEST_VARDIR/tmp/t1.sql +--remove_file $MYSQLTEST_VARDIR/tmp/t1.txt +--remove_file $MYSQLTEST_VARDIR/tmp/v1.sql + + # We reset concurrent_inserts value to whatever it was at the start of the test # This line must be executed _after_ all test cases. SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; From c2fcd6b26dea5fe1bbcd860a5c3d508cb19f71b7 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Mon, 18 May 2009 14:19:18 -0700 Subject: [PATCH 02/15] mysqladmin did not have enough space allocated for tracking all variables when using --vertical or --relative with extended-status. (Bug #40395) This patch simply increases the buffer size and adds an assert to check that it is big enough -- a more comprehensive fix would dynamically allocate the appropriate buffers. --- client/mysqladmin.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 9865b67bb3b..09821d6a995 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -24,7 +24,7 @@ #include #define ADMIN_VERSION "8.42" -#define MAX_MYSQL_VAR 256 +#define MAX_MYSQL_VAR 512 #define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */ #define MAX_TRUNC_LENGTH 3 @@ -743,6 +743,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) mysql_error(mysql)); return -1; } + + DBUG_ASSERT(mysql_num_rows(res) < MAX_MYSQL_VAR); + if (!opt_vertical) print_header(res); else From 8b218c54d40f97e132f592a05473ec93ff8d52b9 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Mon, 18 May 2009 18:23:43 -0700 Subject: [PATCH 03/15] mysqlslap didn't correctly handle --csv with no argument. (Bug #44412) --- client/mysqlslap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 4cf8c7204ed..3c6a38228af 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -565,8 +565,7 @@ static struct my_option my_long_options[] = REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"csv", OPT_SLAP_CSV, "Generate CSV output to named file or to stdout if no file is named.", - (uchar**) &opt_csv_str, (uchar**) &opt_csv_str, 0, GET_STR, - OPT_ARG, 0, 0, 0, 0, 0, 0}, + NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit.", 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -740,6 +739,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), DBUG_PUSH(argument ? argument : default_dbug_option); debug_check_flag= 1; break; + case OPT_SLAP_CSV: + if (!argument) + argument= (char *)"-"; /* use stdout */ + opt_csv_str= argument; + break; #include case 'V': print_version(); From 00920ce29b42c7cf6c5e25cd17ec36b0c1a9f15b Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 19 May 2009 10:17:05 -0700 Subject: [PATCH 04/15] The mysql command-line client didn't implement the readline magic-space command, which bash does, which could result in a user accidentally disabling the use of the space key in the mysql command-line client. (Bug #27439) --- client/mysql.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/mysql.cc b/client/mysql.cc index 8de3cfee041..5752017bbff 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2296,8 +2296,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end); */ #if defined(USE_NEW_READLINE_INTERFACE) +static int fake_magic_space(int, int); extern "C" char *no_completion(const char*,int) #elif defined(USE_LIBEDIT_INTERFACE) +static int fake_magic_space(const char *, int); extern "C" int no_completion(const char*,int) #else extern "C" char *no_completion() @@ -2374,6 +2376,18 @@ static int not_in_history(const char *line) return 1; } + +#if defined(USE_NEW_READLINE_INTERFACE) +static int fake_magic_space(int, int) +#else +static int fake_magic_space(const char *, int) +#endif +{ + rl_insert(1, ' '); + return 0; +} + + static void initialize_readline (char *name) { /* Allow conditional parsing of the ~/.inputrc file. */ @@ -2383,12 +2397,15 @@ static void initialize_readline (char *name) #if defined(USE_NEW_READLINE_INTERFACE) rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion; rl_completion_entry_function= (rl_compentry_func_t*)&no_completion; + + rl_add_defun("magic-space", (rl_command_func_t *)&fake_magic_space, -1); #elif defined(USE_LIBEDIT_INTERFACE) #ifdef HAVE_LOCALE_H setlocale(LC_ALL,""); /* so as libedit use isprint */ #endif rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_completion_entry_function= &no_completion; + rl_add_defun("magic-space", (Function*)&fake_magic_space, -1); #else rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_completion_entry_function= &no_completion; From eb1261502c361df2ae60713785068d45c1689cb2 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 19 May 2009 10:39:03 -0700 Subject: [PATCH 05/15] mysql_upgrade ignored the --basedir and --datadir arguments as it has no use for them, but it did so silently. (Bug #36558) --- client/mysql_upgrade.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index cbc60d8acad..82bbf440bb4 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -251,8 +251,12 @@ get_one_option(int optid, const struct my_option *opt, break; case 'b': /* --basedir */ - case 'v': /* --verbose */ case 'd': /* --datadir */ + fprintf(stderr, "%s: the '--%s' option is always ignored\n", + my_progname, optid == 'b' ? "basedir" : "datadir"); + /* FALLTHROUGH */ + + case 'v': /* --verbose */ case 'f': /* --force */ add_option= FALSE; break; From 16aeb5ad3df92d4459e5c3e83b401e17a926d6b5 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 19 May 2009 15:26:57 -0700 Subject: [PATCH 06/15] Table identifiers and file names were not quoted and escaped correctly by mysqlimport. (Bug #28071) --- client/mysqlimport.c | 16 +++++++++++++--- mysql-test/r/mysqldump.result | 10 ++++++++++ mysql-test/t/mysqldump.test | 23 +++++++++++++++++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/client/mysqlimport.c b/client/mysqlimport.c index ec418244f3d..5a8fabd4da7 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -303,7 +303,8 @@ static int get_options(int *argc, char ***argv) static int write_to_table(char *filename, MYSQL *mysql) { char tablename[FN_REFLEN], hard_path[FN_REFLEN], - sql_statement[FN_REFLEN*16+256], *end; + escaped_name[FN_REFLEN * 2 + 1], + sql_statement[FN_REFLEN*16+256], *end, *pos; DBUG_ENTER("write_to_table"); DBUG_PRINT("enter",("filename: %s",filename)); @@ -338,15 +339,24 @@ static int write_to_table(char *filename, MYSQL *mysql) fprintf(stdout, "Loading data from SERVER file: %s into %s\n", hard_path, tablename); } + mysql_real_escape_string(mysql, escaped_name, hard_path, strlen(hard_path)); sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'", opt_low_priority ? "LOW_PRIORITY" : "", - opt_local_file ? "LOCAL" : "", hard_path); + opt_local_file ? "LOCAL" : "", escaped_name); end= strend(sql_statement); if (replace) end= strmov(end, " REPLACE"); if (ignore) end= strmov(end, " IGNORE"); - end= strmov(strmov(end, " INTO TABLE "), tablename); + end= strmov(end, " INTO TABLE `"); + /* Turn any ` into `` in table name. */ + for (pos= tablename; *pos; pos++) + { + if (*pos == '`') + *end++= '`'; + *end++= *pos; + } + end= strmov(end, "`"); if (fields_terminated || enclosed || opt_enclosed || escaped) end= strmov(end, " FIELDS"); diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index b48b6c9d87f..55a251a5b84 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -4439,6 +4439,16 @@ drop view v1; drop table t1; drop view v1; drop table t1; +# +# Bug#28071 mysqlimport does not quote or escape table name +# +drop table if exists `load`; +create table `load` (a varchar(255)); +test.load: Records: 70 Deleted: 0 Skipped: 0 Warnings: 0 +select count(*) from `load`; +count(*) +70 +drop table `load`; SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; # # End of 5.1 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 6fc8d7bdfea..2ac22fd72ce 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1971,8 +1971,27 @@ drop table t1; --remove_file $MYSQLTEST_VARDIR/tmp/v1.sql -# We reset concurrent_inserts value to whatever it was at the start of the test -# This line must be executed _after_ all test cases. +--echo # +--echo # Bug#28071 mysqlimport does not quote or escape table name +--echo # + +--disable_warnings +drop table if exists `load`; +--enable_warnings +create table `load` (a varchar(255)); + +--copy_file std_data/words.dat $MYSQLTEST_VARDIR/tmp/load.txt + +--exec $MYSQL_IMPORT --ignore test $MYSQLTEST_VARDIR/tmp/load.txt + +select count(*) from `load`; + +--remove_file $MYSQLTEST_VARDIR/tmp/load.txt + +drop table `load`; + +# We reset concurrent_inserts value to whatever it was at the start of the +# test This line must be executed _after_ all test cases. SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; From 8533206280e9423a91d51ee40e5b4569620a2837 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 20 May 2009 12:58:01 -0700 Subject: [PATCH 07/15] Fix warning in use of strlen(). --- client/mysqlimport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 5a8fabd4da7..38a6e5fa3e6 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -339,7 +339,8 @@ static int write_to_table(char *filename, MYSQL *mysql) fprintf(stdout, "Loading data from SERVER file: %s into %s\n", hard_path, tablename); } - mysql_real_escape_string(mysql, escaped_name, hard_path, strlen(hard_path)); + mysql_real_escape_string(mysql, escaped_name, hard_path, + (unsigned long) strlen(hard_path)); sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'", opt_low_priority ? "LOW_PRIORITY" : "", opt_local_file ? "LOCAL" : "", escaped_name); From 66f12372c1fbd915a83f4de2dc39081d5a556c06 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 20 May 2009 17:04:44 -0700 Subject: [PATCH 08/15] The mysql command-line client would include superfluous spaces at the end of some result set lines. (Bug #29622) --- client/mysql.cc | 5 +++- mysql-test/r/mysql.result | 36 ++++++++++++------------- mysql-test/r/parser_not_embedded.result | 18 ++++++------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 5752017bbff..5dbcc5eabba 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3319,6 +3319,9 @@ print_table_data(MYSQL_RES *result) uint visible_length; uint extra_padding; + if (off) + (void) tee_fputs(" ", PAGER); + if (cur[off] == NULL) { buffer= "NULL"; @@ -3353,7 +3356,7 @@ print_table_data(MYSQL_RES *result) else tee_print_sized_data(buffer, data_length, field_max_length+extra_padding, FALSE); } - tee_fputs(" | ", PAGER); + tee_fputs(" |", PAGER); } (void) tee_fputs("\n", PAGER); } diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index c53a2243811..101518289e9 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -64,28 +64,28 @@ drop table t1; +----------------------+------------+--------+ | concat('>',col1,'<') | col2 | col3 | +----------------------+------------+--------+ -| >a < | b | 123421 | -| >a < | 0123456789 | 4 | -| >abcd< | | 4 | +| >a < | b | 123421 | +| >a < | 0123456789 | 4 | +| >abcd< | | 4 | +----------------------+------------+--------+ +-------------------+ | __tañgè Ñãmé | +-------------------+ -| John Doe | +| John Doe | +-------------------+ +-------------------+ | John Doe | +-------------------+ -| __tañgè Ñãmé | +| __tañgè Ñãmé | +-------------------+ +------+------+---------------------------+ | i | j | k | +------+------+---------------------------+ -| 1 | NULL | NULL | -| NULL | NULL | <-----------------------> | -| NULL | NULL | <----- | -| NULL | NULL | Τη γλώσσα | -| NULL | NULL | ᛖᚴ ᚷᛖᛏ | +| 1 | NULL | NULL | +| NULL | NULL | <-----------------------> | +| NULL | NULL | <----- | +| NULL | NULL | Τη γλώσσα | +| NULL | NULL | ᛖᚴ ᚷᛖᛏ | +------+------+---------------------------+ i j k NULL 1 NULL @@ -96,14 +96,14 @@ k int(11) YES NULL +------+---+------+ | i | j | k | +------+---+------+ -| NULL | 1 | NULL | +| NULL | 1 | NULL | +------+---+------+ +-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ -| i | int(11) | YES | | NULL | | -| j | int(11) | NO | | NULL | | -| k | int(11) | YES | | NULL | | +| i | int(11) | YES | | NULL | | +| j | int(11) | NO | | NULL | | +| k | int(11) | YES | | NULL | | +-------+---------+------+-----+---------+-------+ i s1 1 x @@ -112,16 +112,16 @@ i s1 +------+------+ | i | s1 | +------+------+ -| 1 | x | -| 2 | NULL | -| 3 | | +| 1 | x | +| 2 | NULL | +| 3 | | +------+------+ unhex('zz') NULL +-------------+ | unhex('zz') | +-------------+ -| NULL | +| NULL | +-------------+ create table t1(a int, b varchar(255), c int); Field Type Null Key Default Extra diff --git a/mysql-test/r/parser_not_embedded.result b/mysql-test/r/parser_not_embedded.result index 871eb226cc4..140b13c9864 100644 --- a/mysql-test/r/parser_not_embedded.result +++ b/mysql-test/r/parser_not_embedded.result @@ -5,45 +5,45 @@ +----------+--------+ | expected | result | +----------+--------+ -| 2 | 2 | +| 2 | 2 | +----------+--------+ +----------+--------+ | expected | result | +----------+--------+ -| 1 | 1 | +| 1 | 1 | +----------+--------+ +----------+--------+ | expected | result | +----------+--------+ -| 3 | 3 | +| 3 | 3 | +----------+--------+ +----------+--------+ | expected | result | +----------+--------+ -| 2 | 2 | +| 2 | 2 | +----------+--------+ +----------+--------+ | expected | result | +----------+--------+ -| 7 | 7 | +| 7 | 7 | +----------+--------+ +----------+--------+ | expected | result | +----------+--------+ -| 8 | 8 | +| 8 | 8 | +----------+--------+ +----------+--------+ | expected | result | +----------+--------+ -| 7 | 7 | +| 7 | 7 | +----------+--------+ +----------+--------+ | expected | result | +----------+--------+ -| 4 | 4 | +| 4 | 4 | +----------+--------+ +----------+--------+ | expected | result | +----------+--------+ -| 4 | 4 | +| 4 | 4 | +----------+--------+ From 89a6be64380a7ea480c566474c6a103a799d7071 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 20 May 2009 17:25:10 -0700 Subject: [PATCH 09/15] mysqladmin --count=X --sleep=Y would always delay Y seconds after the last iteration before exiting. (Bug #42639) --- client/mysqladmin.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 09821d6a995..a4e7c5ad0c9 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -371,7 +371,7 @@ int main(int argc,char *argv[]) } else { - while (!interrupted && (!opt_count_iterations || nr_iterations)) + while (!interrupted) { new_line = 0; if ((error=execute_commands(&mysql,argc,commands))) @@ -395,11 +395,11 @@ int main(int argc,char *argv[]) } if (interval) { + if (opt_count_iterations && --nr_iterations == 0) + break; sleep(interval); if (new_line) puts(""); - if (opt_count_iterations) - nr_iterations--; } else break; From f8e24020847fe98660c15b03258d3a4f6453d819 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 20 May 2009 18:31:10 -0700 Subject: [PATCH 10/15] mysqlcheck failed to fix table names when using the --fix-table-names and --all-in-1 options together. (Bug #31821) --- client/mysqlcheck.c | 4 ++-- mysql-test/r/mysqlcheck.result | 14 ++++++++++++++ mysql-test/t/mysqlcheck.test | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1bdb28f5a11..83d2006b597 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -442,7 +442,7 @@ static int process_selected_tables(char *db, char **table_names, int tables) { if (use_db(db)) return 1; - if (opt_all_in_1) + if (opt_all_in_1 && what_to_do != DO_UPGRADE) { /* We need table list in form `a`, `b`, `c` @@ -536,7 +536,7 @@ static int process_all_tables_in_db(char *database) num_columns= mysql_num_fields(res); - if (opt_all_in_1) + if (opt_all_in_1 && what_to_do != DO_UPGRADE) { /* We need table list in form `a`, `b`, `c` diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index 704cd7ac3f4..5f1a0565b10 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -186,4 +186,18 @@ a 500 DROP DATABASE `a@b`; USE test; +# +# Bug #31821: --all-in-1 and --fix-table-names don't work together +# +drop table if exists `#mysql50#t1-1`; +create table `#mysql50#t1-1` (a int); +show tables like 't1-1'; +Tables_in_test (t1-1) +t1-1 +drop table `t1-1`; +create table `#mysql50#t1-1` (a int); +show tables like 't1-1'; +Tables_in_test (t1-1) +t1-1 +drop table `t1-1`; End of 5.1 tests diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index e834c60dcb5..986b5aba385 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -193,5 +193,22 @@ DROP DATABASE `a@b`; USE test; +--echo # +--echo # Bug #31821: --all-in-1 and --fix-table-names don't work together +--echo # + +--disable_warnings +drop table if exists `#mysql50#t1-1`; +--enable_warnings + +create table `#mysql50#t1-1` (a int); +--exec $MYSQL_CHECK --all-in-1 --fix-table-names --databases test +show tables like 't1-1'; +drop table `t1-1`; + +create table `#mysql50#t1-1` (a int); +--exec $MYSQL_CHECK --all-in-1 --fix-table-names test "#mysql50#t1-1" +show tables like 't1-1'; +drop table `t1-1`; --echo End of 5.1 tests From 54bdf78e250c48ff1ab57191cac109f16908971e Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Tue, 14 Jul 2009 20:07:29 +0500 Subject: [PATCH 11/15] Fix for bug#45998: database crashes when running "create as select" (innodb table) Problem: code constructing "CREATE TABLE..." statement doesn't take into account that current database is not set in some cases. That may lead to a server crash. Fix: check if current database is set. --- mysql-test/extra/binlog_tests/binlog.test | 12 ++++++++++++ mysql-test/suite/binlog/r/binlog_row_binlog.result | 11 +++++++++++ sql/sql_show.cc | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test index d72dc693cee..5d898d41a54 100644 --- a/mysql-test/extra/binlog_tests/binlog.test +++ b/mysql-test/extra/binlog_tests/binlog.test @@ -258,3 +258,15 @@ dec $it; } show master status /* must show new binlog index after rotating */; drop table t3; + +--echo # +--echo # Bug #45998: database crashes when running "create as select" +--echo # +CREATE DATABASE test1; +USE test1; +DROP DATABASE test1; +CREATE TABLE test.t1(a int); +INSERT INTO test.t1 VALUES (1), (2); +CREATE TABLE test.t2 SELECT * FROM test.t1; +USE test; +DROP TABLES t1, t2; diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result index 4baa47db129..f6b5392dbc8 100644 --- a/mysql-test/suite/binlog/r/binlog_row_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result @@ -1298,3 +1298,14 @@ show master status /* must show new binlog index after rotating */; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000002 106 drop table t3; +# +# Bug #45998: database crashes when running "create as select" +# +CREATE DATABASE test1; +USE test1; +DROP DATABASE test1; +CREATE TABLE test.t1(a int); +INSERT INTO test.t1 VALUES (1), (2); +CREATE TABLE test.t2 SELECT * FROM test.t1; +USE test; +DROP TABLES t1, t2; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d07e951bfd1..a1f6798244e 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1151,7 +1151,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, { const LEX_STRING *const db= table_list->schema_table ? &INFORMATION_SCHEMA_NAME : &table->s->db; - if (strcmp(db->str, thd->db) != 0) + if (!thd->db || strcmp(db->str, thd->db)) { append_identifier(thd, packet, db->str, db->length); packet->append(STRING_WITH_LEN(".")); From 7c670fc3e142ddb2c5fb948fc619dfbd6ccffaa8 Mon Sep 17 00:00:00 2001 From: Anurag Shekhar Date: Wed, 15 Jul 2009 15:00:58 +0530 Subject: [PATCH 12/15] Bug#37740 Server crashes on execute statement with full text search and match against. Server crashes when executing prepared statement with duplicating MATCH() function calls in SELECT and ORDER BY expressions, e.g.: SELECT MATCH(a) AGAINST('test') FROM t1 ORDER BY MATCH(a) AGAINST('test') This query gets optimized by the server, so the value returned by MATCH() from the SELECT list is reused for ORDER BY purposes. To make this optimization server is comparing items from SELECT and ORDER BY lists. We were getting server crash because comparision function for MATCH() item is not intended to be called at this point of execution. In 5.0 and 5.1 this problem is workarounded by resetting MATCH() item to the state as it was during PREPARE. In 6.0 correct comparision function will be implemented and duplicating MATCH() items from the ORDER BY list will be optimized. --- mysql-test/r/fulltext.result | 8 ++++++++ mysql-test/t/fulltext.test | 15 +++++++++++++++ sql/item_func.h | 1 + 3 files changed, 24 insertions(+) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 6ea17644f9d..b0197e0aec2 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -510,3 +510,11 @@ CREATE TABLE t1(a TEXT); SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN MODE); ERROR HY000: Incorrect arguments to AGAINST DROP TABLE t1; +CREATE TABLE t1 (col text, FULLTEXT KEY full_text (col)); +PREPARE s FROM +"SELECT MATCH (col) AGAINST('findme') FROM t1 ORDER BY MATCH (col) AGAINST('findme')" + ; +EXECUTE s; +MATCH (col) AGAINST('findme') +DEALLOCATE PREPARE s; +DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 76661ba4e63..9551c98f143 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -440,3 +440,18 @@ CREATE TABLE t1(a TEXT); --error ER_WRONG_ARGUMENTS SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN MODE); DROP TABLE t1; + +# +# BUG#37740 Server crashes on execute statement with full text search and match against +# + +CREATE TABLE t1 (col text, FULLTEXT KEY full_text (col)); + +PREPARE s FROM + "SELECT MATCH (col) AGAINST('findme') FROM t1 ORDER BY MATCH (col) AGAINST('findme')" + ; + +EXECUTE s; +DEALLOCATE PREPARE s; +DROP TABLE t1; + diff --git a/sql/item_func.h b/sql/item_func.h index 33aeddfe6e6..47a13559e90 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1456,6 +1456,7 @@ public: ft_handler->please->close_search(ft_handler); ft_handler= 0; concat_ws= 0; + table= 0; // required by Item_func_match::eq() DBUG_VOID_RETURN; } enum Functype functype() const { return FT_FUNC; } From bb4f24bf84e1ce8afcf9cf7fe6bee27c7f78b3d6 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Wed, 15 Jul 2009 15:25:44 +0500 Subject: [PATCH 13/15] Addition to #45998 fix, result adjusted. --- mysql-test/suite/binlog/r/binlog_stm_binlog.result | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result index d151e31269f..d05d3ccdb7a 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result @@ -773,3 +773,14 @@ show master status /* must show new binlog index after rotating */; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000002 106 drop table t3; +# +# Bug #45998: database crashes when running "create as select" +# +CREATE DATABASE test1; +USE test1; +DROP DATABASE test1; +CREATE TABLE test.t1(a int); +INSERT INTO test.t1 VALUES (1), (2); +CREATE TABLE test.t2 SELECT * FROM test.t1; +USE test; +DROP TABLES t1, t2; From 8acf778eaedf32ccfa73eb1b80b7eca17071b270 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 15 Jul 2009 16:46:25 +0300 Subject: [PATCH 14/15] Bug #45287: phase 1 : 32 bit compilation warnings Fixed the following problems: 1. cmake 2.6 warning because of a changed default on how the dependencies to libraries with a specified path are resolved. Fixed by requiring cmake 2.6. 2. Removed an obsolete pre-NT4 hack including defining Windows system defines to alter the behavior of windows.h. 3. Disabled warning C4065 on compiling sql_yacc.cc because of a know incompatibility in some of the newer bison binaries. --- CMakeLists.txt | 2 +- include/config-win.h | 9 --------- sql/sql_yacc.yy | 6 ++++++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91c3a804eea..9f53a9fb146 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR) PROJECT(MySql) diff --git a/include/config-win.h b/include/config-win.h index ab463a7c142..05bdfd2c226 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -15,15 +15,6 @@ /* Defines for Win32 to make it compatible for MySQL */ -#ifdef __WIN2000__ -/* We have to do this define before including windows.h to get the AWE API -functions */ -#define _WIN32_WINNT 0x0500 -#else -/* Get NT 4.0 functions */ -#define _WIN32_WINNT 0x0400 -#endif - #if defined(_MSC_VER) && _MSC_VER >= 1400 /* Avoid endless warnings about sprintf() etc. being unsafe. */ #define _CRT_SECURE_NO_DEPRECATE 1 diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 49b7fafcc0b..cde2e8dac3e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -41,6 +41,12 @@ #include #include +/* this is to get the bison compilation windows warnings out */ +#ifdef _MSC_VER +/* warning C4065: switch statement contains 'default' but no 'case' labels */ +#pragma warning (disable : 4065) +#endif + int yylex(void *yylval, void *yythd); const LEX_STRING null_lex_str={0,0}; From e601194cf75f20db6b102a917ab7e9da8913ca7b Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Wed, 15 Jul 2009 21:00:34 +0400 Subject: [PATCH 15/15] A fix for Bug#44495 "Prepared Statement: CALL p() - `thd->protocol == &thd->protocol_text' failed" Do not assume that SQL prepared statements always run in text protocol. When invoked from a stored procedure, which is itself invoked by means of prepared CALL statement, the protocol may be binary. Juggle with the protocol only when we want to change it to binary in COM_STMT_EXECUTE, COM_STMT_PREPARE. This is a backport from 5.4/6.0, where the bug was fixed as part of WL#4264 "Backup: Stabilize Service Interface" --- sql/sql_prepare.cc | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index e7e821dd4ae..c1839b7220f 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -127,12 +127,12 @@ class Prepared_statement: public Statement public: enum flag_values { - IS_IN_USE= 1 + IS_IN_USE= 1, + IS_SQL_PREPARE= 2 }; THD *thd; Select_fetch_protocol_binary result; - Protocol *protocol; Item_param **param_array; uint param_count; uint last_errno; @@ -148,7 +148,7 @@ public: List& varnames, String *expanded_query); public: - Prepared_statement(THD *thd_arg, Protocol *protocol_arg); + Prepared_statement(THD *thd_arg); virtual ~Prepared_statement(); void setup_set_params(); virtual Query_arena::Type type() const; @@ -156,7 +156,8 @@ public: bool set_name(LEX_STRING *name); inline void close_cursor() { delete cursor; cursor= 0; } inline bool is_in_use() { return flags & (uint) IS_IN_USE; } - inline bool is_protocol_text() const { return protocol == &thd->protocol_text; } + inline bool is_sql_prepare() const { return flags & (uint) IS_SQL_PREPARE; } + void set_sql_prepare() { flags|= (uint) IS_SQL_PREPARE; } bool prepare(const char *packet, uint packet_length); bool execute_loop(String *expanded_query, bool open_cursor, @@ -1358,7 +1359,7 @@ static int mysql_test_select(Prepared_statement *stmt, */ if (unit->prepare(thd, 0, 0)) goto error; - if (!lex->describe && !stmt->is_protocol_text()) + if (!lex->describe && !stmt->is_sql_prepare()) { /* Make copy of item list, as change_columns may change it */ List fields(lex->select_lex.item_list); @@ -1988,7 +1989,7 @@ static bool check_prepared_statement(Prepared_statement *stmt) break; } if (res == 0) - DBUG_RETURN(stmt->is_protocol_text() ? + DBUG_RETURN(stmt->is_sql_prepare() ? FALSE : (send_prep_stmt(stmt, 0) || thd->protocol->flush())); error: DBUG_RETURN(TRUE); @@ -2058,6 +2059,7 @@ static bool init_param_array(Prepared_statement *stmt) void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length) { + Protocol *save_protocol= thd->protocol; Prepared_statement *stmt; bool error; DBUG_ENTER("mysqld_stmt_prepare"); @@ -2067,7 +2069,7 @@ void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length) /* First of all clear possible warnings from the previous command */ mysql_reset_thd_for_next_command(thd); - if (! (stmt= new Prepared_statement(thd, &thd->protocol_binary))) + if (! (stmt= new Prepared_statement(thd))) DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */ if (thd->stmt_map.insert(thd, stmt)) @@ -2084,6 +2086,8 @@ void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length) sp_cache_flush_obsolete(&thd->sp_proc_cache); sp_cache_flush_obsolete(&thd->sp_func_cache); + thd->protocol= &thd->protocol_binary; + if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(),QUERY_PRIOR); @@ -2097,6 +2101,9 @@ void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length) /* Statement map deletes statement on erase */ thd->stmt_map.erase(stmt); } + + thd->protocol= save_protocol; + /* check_prepared_statemnt sends the metadata packet in case of success */ DBUG_VOID_RETURN; } @@ -2229,7 +2236,6 @@ void mysql_sql_stmt_prepare(THD *thd) const char *query; uint query_len= 0; DBUG_ENTER("mysql_sql_stmt_prepare"); - DBUG_ASSERT(thd->protocol == &thd->protocol_text); if ((stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name))) { @@ -2247,11 +2253,13 @@ void mysql_sql_stmt_prepare(THD *thd) } if (! (query= get_dynamic_sql_string(lex, &query_len)) || - ! (stmt= new Prepared_statement(thd, &thd->protocol_text))) + ! (stmt= new Prepared_statement(thd))) { DBUG_VOID_RETURN; /* out of memory */ } + stmt->set_sql_prepare(); + /* Set the name first, insert should know that this statement has a name */ if (stmt->set_name(name)) { @@ -2431,6 +2439,7 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length) String expanded_query; uchar *packet_end= packet + packet_length; Prepared_statement *stmt; + Protocol *save_protocol= thd->protocol; bool open_cursor; DBUG_ENTER("mysqld_stmt_execute"); @@ -2458,7 +2467,9 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length) open_cursor= test(flags & (ulong) CURSOR_TYPE_READ_ONLY); + thd->protocol= &thd->protocol_binary; stmt->execute_loop(&expanded_query, open_cursor, packet, packet_end); + thd->protocol= save_protocol; /* Close connection socket; for use with client testing (Bug#43560). */ DBUG_EXECUTE_IF("close_conn_after_stmt_execute", vio_close(thd->net.vio);); @@ -2814,12 +2825,11 @@ Select_fetch_protocol_binary::send_data(List &fields) Prepared_statement ****************************************************************************/ -Prepared_statement::Prepared_statement(THD *thd_arg, Protocol *protocol_arg) +Prepared_statement::Prepared_statement(THD *thd_arg) :Statement(NULL, &main_mem_root, INITIALIZED, ++thd_arg->statement_id_counter), thd(thd_arg), result(thd_arg), - protocol(protocol_arg), param_array(0), param_count(0), last_errno(0), @@ -3288,7 +3298,9 @@ Prepared_statement::reprepare() bool cur_db_changed; bool error; - Prepared_statement copy(thd, &thd->protocol_text); + Prepared_statement copy(thd); + + copy.set_sql_prepare(); /* To suppress sending metadata to the client. */ status_var_increment(thd->status_var.com_stmt_reprepare); @@ -3346,7 +3358,7 @@ bool Prepared_statement::validate_metadata(Prepared_statement *copy) return FALSE -- the metadata of the original SELECT, if any, has not been sent to the client. */ - if (is_protocol_text() || lex->describe) + if (is_sql_prepare() || lex->describe) return FALSE; if (lex->select_lex.item_list.elements != @@ -3409,7 +3421,6 @@ Prepared_statement::swap_prepared_statement(Prepared_statement *copy) DBUG_ASSERT(thd == copy->thd); last_error[0]= '\0'; last_errno= 0; - /* Do not swap protocols, the copy always has protocol_text */ } @@ -3550,8 +3561,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) thd->stmt_arena= this; reinit_stmt_before_use(thd, lex); - thd->protocol= protocol; /* activate stmt protocol */ - /* Go! */ if (open_cursor) @@ -3582,8 +3591,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) if (cur_db_changed) mysql_change_db(thd, &saved_cur_db_name, TRUE); - thd->protocol= &thd->protocol_text; /* use normal protocol */ - /* Assert that if an error, no cursor is open */ DBUG_ASSERT(! (error && cursor));