From 0f9725ad1fb99385ab0d184cf0851670fee37bbe Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Jun 2006 20:10:49 -0400 Subject: [PATCH 01/19] Bug#16180 Setting SQL_LOG_OFF without SUPER privilege is silently ignored mysql-test/r/grant2.result: Added results for bug#16180 mysql-test/t/grant2.test: Added test for bug# 16180 sql/set_var.cc: Verify user has appropiate rights before setting the sql_log_off system variable. --- mysql-test/r/grant2.result | 10 ++++++++++ mysql-test/t/grant2.test | 17 +++++++++++++++++ sql/set_var.cc | 3 ++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 85963705718..c047dc033c6 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -143,3 +143,13 @@ flush privileges; drop user mysqltest_3@host3; drop user mysqltest_1@host1, mysqltest_2@host2, mysqltest_4@host4, mysqltest_5@host5, mysqltest_6@host6, mysqltest_7@host7; +create database mysqltest_1; +grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost; +set sql_log_off = 1; +ERROR HY000: Access denied; you need the SUPER privilege for this operation +set sql_log_bin = 0; +ERROR HY000: Access denied; you need the SUPER privilege for this operation +delete from mysql.user where user like 'mysqltest\_1'; +delete from mysql.db where user like 'mysqltest\_1'; +drop database mysqltest_1; +flush privileges; diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index 79ea7f70712..9da95cd42da 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -238,5 +238,22 @@ connect (con9,127.0.0.1,root,,test,$MASTER_MYPORT,); disconnect con9; connection default; +# +# Bug# 16180 - Setting SQL_LOG_OFF without SUPER privilege is silently ignored +# +create database mysqltest_1; +grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost; +connect (con10,localhost,mysqltest_1,,); +connection con10; +--error 1227 +set sql_log_off = 1; +--error 1227 +set sql_log_bin = 0; +disconnect con10; +connection default; +delete from mysql.user where user like 'mysqltest\_1'; +delete from mysql.db where user like 'mysqltest\_1'; +drop database mysqltest_1; +flush privileges; # End of 4.1 tests diff --git a/sql/set_var.cc b/sql/set_var.cc index bf68a102537..920b153fadd 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -423,7 +423,8 @@ static sys_var_thd_bit sys_sql_big_tables("sql_big_tables", 0, static sys_var_thd_bit sys_big_selects("sql_big_selects", 0, set_option_bit, OPTION_BIG_SELECTS); -static sys_var_thd_bit sys_log_off("sql_log_off", 0, +static sys_var_thd_bit sys_log_off("sql_log_off", + check_log_update, set_option_bit, OPTION_LOG_OFF); static sys_var_thd_bit sys_log_update("sql_log_update", From f26639c9f261361df3215a19d4e19e4b9070f84e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Jun 2006 17:06:28 -0400 Subject: [PATCH 02/19] Bug#20328 mysql client: dumb about trailing spaces on help command. client/mysql.cc: Remove trailing spaces from help arguments in com_server_help. Disregard trailing spaces from command in com_help. mysql-test/r/mysql_client.result: Test trailing spaces on the help command. mysql-test/t/mysql_client.test: Result trailing spaces on the help command. --- client/mysql.cc | 17 +++++++++--- mysql-test/r/mysql_client.result | 44 ++++++++++++++++++++++++++++++++ mysql-test/t/mysql_client.test | 9 +++++++ 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 mysql-test/r/mysql_client.result create mode 100644 mysql-test/t/mysql_client.test diff --git a/client/mysql.cc b/client/mysql.cc index 2f9031b84b8..fa7961b4acd 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1725,7 +1725,14 @@ static int com_server_help(String *buffer __attribute__((unused)), if (help_arg[0] != '\'') { - (void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NullS); + char *end_arg= strend(help_arg); + if(--end_arg) + { + while (my_isspace(charset_info,*end_arg)) + end_arg--; + *++end_arg= '\0'; + } + (void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NullS); server_cmd= cmd_buf; } @@ -1811,9 +1818,13 @@ com_help(String *buffer __attribute__((unused)), { reg1 int i, j; char * help_arg= strchr(line,' '), buff[32], *end; - if (help_arg) - return com_server_help(buffer,line,help_arg+1); + { + while (my_isspace(charset_info,*help_arg)) + help_arg++; + if (*help_arg) + return com_server_help(buffer,line,help_arg); + } put_info("\nFor information about MySQL products and services, visit:\n" " http://www.mysql.com/\n" diff --git a/mysql-test/r/mysql_client.result b/mysql-test/r/mysql_client.result new file mode 100644 index 00000000000..62955775ec4 --- /dev/null +++ b/mysql-test/r/mysql_client.result @@ -0,0 +1,44 @@ +? (\?) Synonym for `help'. +clear (\c) Clear command. +connect (\r) Reconnect to the server. Optional arguments are db and host. +delimiter (\d) Set query delimiter. +edit (\e) Edit command with $EDITOR. +ego (\G) Send command to mysql server, display result vertically. +exit (\q) Exit mysql. Same as quit. +go (\g) Send command to mysql server. +help (\h) Display this help. +nopager (\n) Disable pager, print to stdout. +notee (\t) Don't write into outfile. +pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. +print (\p) Print current command. +prompt (\R) Change your mysql prompt. +quit (\q) Quit mysql. +rehash (\#) Rebuild completion hash. +source (\.) Execute an SQL script file. Takes a file name as an argument. +status (\s) Get status information from the server. +system (\!) Execute a system shell command. +tee (\T) Set outfile [to_outfile]. Append everything into given outfile. +use (\u) Use another database. Takes database name as argument. +charset_name(\C) Switch to another charset. Might be needed for processing binlog. +? (\?) Synonym for `help'. +clear (\c) Clear command. +connect (\r) Reconnect to the server. Optional arguments are db and host. +delimiter (\d) Set query delimiter. +edit (\e) Edit command with $EDITOR. +ego (\G) Send command to mysql server, display result vertically. +exit (\q) Exit mysql. Same as quit. +go (\g) Send command to mysql server. +help (\h) Display this help. +nopager (\n) Disable pager, print to stdout. +notee (\t) Don't write into outfile. +pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. +print (\p) Print current command. +prompt (\R) Change your mysql prompt. +quit (\q) Quit mysql. +rehash (\#) Rebuild completion hash. +source (\.) Execute an SQL script file. Takes a file name as an argument. +status (\s) Get status information from the server. +system (\!) Execute a system shell command. +tee (\T) Set outfile [to_outfile]. Append everything into given outfile. +use (\u) Use another database. Takes database name as argument. +charset_name(\C) Switch to another charset. Might be needed for processing binlog. diff --git a/mysql-test/t/mysql_client.test b/mysql-test/t/mysql_client.test new file mode 100644 index 00000000000..6ae4717de9c --- /dev/null +++ b/mysql-test/t/mysql_client.test @@ -0,0 +1,9 @@ +# This test should work in embedded server after we fix mysqltest +-- source include/not_embedded.inc + +# +# Bug #20328: mysql client interprets commands in comments +# +--exec echo 'help' | $MYSQL +--exec echo 'help ' | $MYSQL + From 06e218194fe77edd09d53e6b4ec9bf174fd291d7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Jul 2006 00:31:47 -0700 Subject: [PATCH 03/19] Fix for Bug #19364 "mysql --help gives old informations". Old option ordering in the help was confusing to some users. Changed ordering of deprecated options to be consistent, and added mention to entry for options with a "--no-option" variant mentioning the "--disable-option" variant. client/mysql.cc: Rearranged options for clarity. Deprecated "--no-X" options now follow the "--X" option, and all of the "--X" options that have a "--no-X" variant now mention the "--disable-X" variant. --- client/mysql.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 2f9031b84b8..2e1814d9b21 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -550,13 +550,13 @@ static struct my_option my_long_options[] = {"force", 'f', "Continue even if we get an sql error.", (gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"no-named-commands", 'g', - "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"named-commands", 'G', "Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default.", (gptr*) &named_cmds, (gptr*) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"no-named-commands", 'g', + "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.", @@ -575,13 +575,6 @@ static struct my_option my_long_options[] = NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-line-numbers", 'L', "Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef USE_POPEN - {"no-pager", OPT_NOPAGER, - "Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, -#endif - {"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead", 0, 0, 0, GET_NO_ARG, - NO_ARG, 0, 0, 0, 0, 0, 0}, {"unbuffered", 'n', "Flush buffer after each query.", (gptr*) &unbuffered, (gptr*) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"column-names", OPT_COLUMN_NAMES, "Write column names in results.", @@ -601,8 +594,11 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef USE_POPEN {"pager", OPT_PAGER, - "Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode.", + "Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"no-pager", OPT_NOPAGER, + "Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", @@ -643,8 +639,10 @@ static struct my_option my_long_options[] = {"debug-info", 'T', "Print some debug info at exit.", (gptr*) &info_flag, (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"tee", OPT_TEE, - "Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode.", + "Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead", 0, 0, 0, GET_NO_ARG, + NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE {"user", 'u', "User for login if not current user.", (gptr*) ¤t_user, (gptr*) ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, From e0b7bbc01d59a435536ba02bf64754b03ca103db Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Jul 2006 15:22:16 -0400 Subject: [PATCH 04/19] Bug #20721: mysql_install_db first line is blank. Minor script changes for uniformity. scripts/fill_func_tables.sh: Switched to standard !@PERL@ usage. Added Copyright and more specific original author information. scripts/mysql_install_db.sh: Removed leading empty line. --- scripts/fill_func_tables.sh | 11 ++++++++--- scripts/mysql_install_db.sh | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/fill_func_tables.sh b/scripts/fill_func_tables.sh index 459afee2fe1..b7bd3736392 100644 --- a/scripts/fill_func_tables.sh +++ b/scripts/fill_func_tables.sh @@ -1,7 +1,12 @@ -#!/usr/bin/perl +#!@PERL@ +# +# Copyright (C) 2003 MySQL AB +# For a more info consult the file COPYRIGHT distributed with this file. +# # fill_func_tables - parse ../Docs/manual.texi - -# Original version by vva +# +# Original version by Victor Vagin +# my $cat_name= ""; my $func_name= ""; diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 5c2bca9a393..56a432db741 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -1,4 +1,3 @@ - #!/bin/sh # Copyright (C) 2002-2003 MySQL AB # For a more info consult the file COPYRIGHT distributed with this file. From f794dc3aa1897961b916e74c9f9169ea69e47bfd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Jul 2006 17:39:53 -0400 Subject: [PATCH 05/19] Manual merge required. mysql-test/r/mysql_client.result: manual merge mysql-test/t/mysql_client.test: manual merge --- mysql-test/r/mysql_client.result | 44 ++++++++++++++++++++++++++++++++ mysql-test/t/mysql_client.test | 6 +++++ 2 files changed, 50 insertions(+) diff --git a/mysql-test/r/mysql_client.result b/mysql-test/r/mysql_client.result index 87d09428ff6..00d7b6df3cf 100644 --- a/mysql-test/r/mysql_client.result +++ b/mysql-test/r/mysql_client.result @@ -2,3 +2,47 @@ 1 ERROR 1064 (42000) at line 3: 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 '' at line 1 ERROR at line 1: USE must be followed by a database name +? (\?) Synonym for `help'. +clear (\c) Clear command. +connect (\r) Reconnect to the server. Optional arguments are db and host. +delimiter (\d) Set query delimiter. +edit (\e) Edit command with $EDITOR. +ego (\G) Send command to mysql server, display result vertically. +exit (\q) Exit mysql. Same as quit. +go (\g) Send command to mysql server. +help (\h) Display this help. +nopager (\n) Disable pager, print to stdout. +notee (\t) Don't write into outfile. +pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. +print (\p) Print current command. +prompt (\R) Change your mysql prompt. +quit (\q) Quit mysql. +rehash (\#) Rebuild completion hash. +source (\.) Execute an SQL script file. Takes a file name as an argument. +status (\s) Get status information from the server. +system (\!) Execute a system shell command. +tee (\T) Set outfile [to_outfile]. Append everything into given outfile. +use (\u) Use another database. Takes database name as argument. +charset_name(\C) Switch to another charset. Might be needed for processing binlog. +? (\?) Synonym for `help'. +clear (\c) Clear command. +connect (\r) Reconnect to the server. Optional arguments are db and host. +delimiter (\d) Set query delimiter. +edit (\e) Edit command with $EDITOR. +ego (\G) Send command to mysql server, display result vertically. +exit (\q) Exit mysql. Same as quit. +go (\g) Send command to mysql server. +help (\h) Display this help. +nopager (\n) Disable pager, print to stdout. +notee (\t) Don't write into outfile. +pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. +print (\p) Print current command. +prompt (\R) Change your mysql prompt. +quit (\q) Quit mysql. +rehash (\#) Rebuild completion hash. +source (\.) Execute an SQL script file. Takes a file name as an argument. +status (\s) Get status information from the server. +system (\!) Execute a system shell command. +tee (\T) Set outfile [to_outfile]. Append everything into given outfile. +use (\u) Use another database. Takes database name as argument. +charset_name(\C) Switch to another charset. Might be needed for processing binlog. diff --git a/mysql-test/t/mysql_client.test b/mysql-test/t/mysql_client.test index e4b6658b631..9cdf5aea64b 100644 --- a/mysql-test/t/mysql_client.test +++ b/mysql-test/t/mysql_client.test @@ -27,3 +27,9 @@ # client comment recognized, but parameter missing => error --exec echo "use" > $MYSQLTEST_VARDIR/tmp/bug20432.sql --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1 + +# +# Bug #20328: mysql client interprets commands in comments +# +--exec echo 'help' | $MYSQL +--exec echo 'help ' | $MYSQL From f4fb48bab0c61a769cd7efabfba41e0ca672abcd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Aug 2006 13:06:59 -0400 Subject: [PATCH 06/19] Bug#9719: DELETE with WHERE on HEAP table just deletes first row of matched set. (Ramil's patch, recreated.) heap/hp_delete.c: Reset info->lastkey_len for further heap_rnext/heap_rprev calls. mysql-test/r/heap_btree.result: Test for bug #9719: DELETE with WHERE on HEAP table just deletes first row of matched set. mysql-test/t/heap_btree.test: Test for bug #9719: DELETE with WHERE on HEAP table just deletes first row of matched set. --- heap/hp_delete.c | 3 +++ mysql-test/r/heap_btree.result | 35 ++++++++++++++++++++++++++++++++++ mysql-test/t/heap_btree.test | 20 ++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/heap/hp_delete.c b/heap/hp_delete.c index 90e537081d3..266a9da6ca3 100644 --- a/heap/hp_delete.c +++ b/heap/hp_delete.c @@ -73,7 +73,10 @@ int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, int res; if (flag) + { info->last_pos= NULL; /* For heap_rnext/heap_rprev */ + info->lastkey_len= 0; + } custom_arg.keyseg= keyinfo->seg; custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos); diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 5c60c97d674..91c3ec65a13 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -246,3 +246,38 @@ DELETE from t1 where a < 100; SELECT * from t1; a DROP TABLE t1; +create table t1(a int not null, key using btree(a)) engine=heap; +insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); +select a from t1 where a > 2; +a +3 +3 +3 +3 +delete from t1 where a < 4; +select a from t1; +a +insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); +select a from t1 where a > 4; +a +delete from t1 where a > 4; +select a from t1; +a +3 +3 +1 +3 +3 +1 +2 +2 +2 +select a from t1 where a > 3; +a +delete from t1 where a >= 2; +select a from t1; +a +1 +1 +drop table t1; +End of 4.1 tests diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index aea9e9486e5..f510f97fe9b 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -164,4 +164,22 @@ DELETE from t1 where a < 100; SELECT * from t1; DROP TABLE t1; -# End of 4.1 tests +# +# Bug #9719: problem with delete +# + +create table t1(a int not null, key using btree(a)) engine=heap; +insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); +select a from t1 where a > 2; +delete from t1 where a < 4; +select a from t1; +insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); +select a from t1 where a > 4; +delete from t1 where a > 4; +select a from t1; +select a from t1 where a > 3; +delete from t1 where a >= 2; +select a from t1; +drop table t1; + +--echo End of 4.1 tests From 74465080c617c27ee2f92fa64f131a46b895d6f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Aug 2006 14:03:08 +0500 Subject: [PATCH 07/19] BUG#7391 - Cross-database multi-table UPDATE uses active database privileges This problem is 4.1 specific. It doesn't affect 4.0 and was fixed in 5.x before. Having any mysql user who is allowed to issue multi table update statement and any column/table grants, allows this user to update any table on a server (mysql grant tables are not exception). check_grant() accepts number of tables (in table list) to be checked in 5-th param. While checking grants for multi table update, number of tables must be 1. It must never be 0 (actually we have DBUG_ASSERT(number > 0) in 5.x in grant_check() function). mysql-test/r/grant.result: Addition to test case for bug#7391: - Added grant statement to trigger this problem in 4.1. - Fixed error messages. mysql-test/t/grant.test: Addition to test case for bug#7391: - Added grant statement to trigger this problem in 4.1. - Fixed error messages. sql/sql_update.cc: check_grant() accepts number of tables (in table list) to be checked in 5-th param. For this particular check number of tables must be 1. It must never be 0 (actually we have DBUG_ASSERT(number > 0) in 5.x in grant_check() function). --- mysql-test/r/grant.result | 9 +++++---- mysql-test/t/grant.test | 10 ++++++---- sql/sql_update.cc | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index dffa4988ea7..1960f3a76b9 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -383,7 +383,7 @@ GRANT SELECT (c) ON `mysqltest_2`.`t1` TO 'mysqltest_3'@'localhost' update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1; ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for column 'q' in table 't1' update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1; -ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'd' in table 't2' +ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't1' update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1; ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1' update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2; @@ -402,6 +402,7 @@ revoke all on mysqltest_2.t1 from mysqltest_3@localhost; revoke all on mysqltest_2.t2 from mysqltest_3@localhost; grant all on mysqltest_2.* to mysqltest_3@localhost; grant select on *.* to mysqltest_3@localhost; +grant select on mysqltest_2.t1 to mysqltest_3@localhost; flush privileges; use mysqltest_1; update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600; @@ -409,11 +410,11 @@ update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for column 'a' in table 't1' use mysqltest_2; update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; -ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1' +ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1' update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200; -ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1' +ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't2' update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200; -ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1' +ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1' select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2; a q b r 10 2 1 2 diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 60b60547fcc..3365145650a 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -323,7 +323,7 @@ connection conn1; show grants for mysqltest_3@localhost; --error 1143 update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1; ---error 1143 +--error 1142 update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1; --error 1143 update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1; @@ -343,6 +343,8 @@ revoke all on mysqltest_2.t2 from mysqltest_3@localhost; #test the db/table level privileges grant all on mysqltest_2.* to mysqltest_3@localhost; grant select on *.* to mysqltest_3@localhost; +# Next grant is needed to trigger bug#7391. Do not optimize! +grant select on mysqltest_2.t1 to mysqltest_3@localhost; flush privileges; disconnect conn1; connect (conn2,localhost,mysqltest_3,,); @@ -354,11 +356,11 @@ update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600; update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; use mysqltest_2; #the following used to succeed, it must fail now. ---error 1044 +--error 1142 update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; ---error 1044 +--error 1142 update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200; ---error 1044 +--error 1142 update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200; #lets see the result connection master; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 089d0bf0660..af4ba8025f9 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -628,7 +628,7 @@ int mysql_multi_update_lock(THD *thd, if (!using_lock_tables) tl->table->reginfo.lock_type= tl->lock_type; if (check_access(thd, wants, tl->db, &tl->grant.privilege, 0, 0) || - (grant_option && check_grant(thd, wants, tl, 0, 0, 0))) + (grant_option && check_grant(thd, wants, tl, 0, 1, 0))) { tl->next= save; DBUG_RETURN(1); From 842ec2334118f67541c77bb824a7baffe5ba2b62 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Aug 2006 12:16:24 +0200 Subject: [PATCH 08/19] Bug#21419 test case lowercase_fs_off fails on Windows - Backport patch from 5.0 sql/mysqld.cc: Add else case to set "lower_case_file_system" also when lower_case_table_names are 1 --- sql/mysqld.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0de8f005247..74c7b1a4e4c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2646,6 +2646,11 @@ You should consider changing lower_case_table_names to 1 or 2", mysql_real_data_home); lower_case_table_names= 0; } + else + { + lower_case_file_system= + (test_if_case_insensitive(mysql_real_data_home) == 1); + } /* Reset table_alias_charset, now that lower_case_table_names is set. */ table_alias_charset= (lower_case_table_names ? From c34baab996b72ab818692a049b2d5c94f0f5265b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Aug 2006 00:06:03 +0400 Subject: [PATCH 09/19] sql_view.cc: Memory leak fix sql/sql_view.cc: Memory leak fix --- sql/sql_view.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 8aa93a7bbeb..5ceaf41158f 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -179,15 +179,23 @@ static bool fill_defined_view_parts (THD *thd, TABLE_LIST *view) { LEX *lex= thd->lex; - bool not_used; + bool free_view= 1; TABLE_LIST decoy; + if (view->view) + free_view= 0; memcpy (&decoy, view, sizeof (TABLE_LIST)); - if (!open_table(thd, &decoy, thd->mem_root, ¬_used, 0) && - !decoy.view) + if ((decoy.table= open_table(thd, &decoy, thd->mem_root, NULL, 0))) { + /* It's a table */ + my_free((gptr)decoy.table, MYF(0)); + my_error(ER_WRONG_OBJECT, MYF(0), view->db, view->table_name, "VIEW"); return TRUE; } + if (!decoy.view) + /* An error while opening the view occurs, caller will handle it */ + return FALSE; + if (!lex->definer) { view->definer.host= decoy.definer.host; @@ -199,6 +207,8 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) if (lex->create_view_suid == VIEW_SUID_DEFAULT) lex->create_view_suid= decoy.view_suid ? VIEW_SUID_DEFINER : VIEW_SUID_INVOKER; + if (free_view) + delete decoy.view; return FALSE; } From 55bd10965a62d1984bed8c967f6b463c39c68540 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Aug 2006 07:41:49 +0400 Subject: [PATCH 10/19] sql_view.cc: Memory leak fix sql/sql_view.cc: Memory leak fix --- sql/sql_view.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 6581297c72e..a987b9e7028 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -208,7 +208,10 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) lex->create_view_suid= decoy.view_suid ? VIEW_SUID_DEFINER : VIEW_SUID_INVOKER; if (free_view) + { delete decoy.view; + lex->cleanup_after_one_table_open(); + } return FALSE; } From 1e9ebd010a6b6c7a078d0caa13f9c8145dec1d50 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Aug 2006 00:05:42 +0400 Subject: [PATCH 11/19] sql_base.cc, unireg.h, sql_lex.h, table.cc, sql_view.h, sql_view.cc: Correct memory leak fix sql/unireg.h: Correct memory leak fix sql/table.cc: Correct memory leak fix sql/sql_view.h: Correct memory leak fix sql/sql_view.cc: Correct memory leak fix sql/sql_lex.h: Correct memory leak fix sql/sql_base.cc: Correct memory leak fix --- sql/sql_base.cc | 44 +++++++++++++++++++++++++++++++------------- sql/sql_lex.h | 2 +- sql/sql_view.cc | 11 ++++++++--- sql/sql_view.h | 3 ++- sql/table.cc | 2 ++ sql/unireg.h | 3 ++- 6 files changed, 46 insertions(+), 19 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7f9076bb46e..dd229204ce0 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -34,7 +34,8 @@ HASH open_cache; /* Used by mysql_test */ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, const char *name, const char *alias, - TABLE_LIST *table_list, MEM_ROOT *mem_root); + TABLE_LIST *table_list, MEM_ROOT *mem_root, + uint flags); static void free_cache_entry(TABLE *entry); static void mysql_rm_tmp_tables(void); static bool open_new_frm(THD *thd, const char *path, const char *alias, @@ -1108,7 +1109,7 @@ bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list) key_length=(uint) (strmov(strmov(key,db)+1,table_name)-key)+1; if (open_unireg_entry(thd, table, db, table_name, table_name, 0, - thd->mem_root) || + thd->mem_root, 0) || !(table->s->table_cache_key= memdup_root(&table->mem_root, (char*) key, key_length))) { @@ -1311,7 +1312,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, VOID(pthread_mutex_lock(&LOCK_open)); if (!open_unireg_entry(thd, table, table_list->db, table_list->table_name, - alias, table_list, mem_root)) + alias, table_list, mem_root, 0)) { DBUG_ASSERT(table_list->view != 0); VOID(pthread_mutex_unlock(&LOCK_open)); @@ -1391,6 +1392,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, else { TABLE_SHARE *share; + int error; /* Free cache if too big */ while (open_cache.records > table_cache_size && unused_tables) VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */ @@ -1401,9 +1403,12 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(NULL); } - if (open_unireg_entry(thd, table, table_list->db, table_list->table_name, - alias, table_list, mem_root) || - (!table_list->view && + error= open_unireg_entry(thd, table, table_list->db, + table_list->table_name, + alias, table_list, mem_root, + (flags & OPEN_VIEW_NO_PARSE)); + if ((error > 0) || + (!table_list->view && !error && !(table->s->table_cache_key= memdup_root(&table->mem_root, (char*) key, key_length)))) @@ -1413,8 +1418,15 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(NULL); } - if (table_list->view) + if (table_list->view || error < 0) { + /* + VIEW not really opened, only frm were read. + Set 1 as a flag here + */ + if (error < 0) + table_list->view= (st_lex*)1; + my_free((gptr)table, MYF(0)); VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(0); // VIEW @@ -1521,7 +1533,7 @@ bool reopen_table(TABLE *table,bool locked) safe_mutex_assert_owner(&LOCK_open); if (open_unireg_entry(table->in_use, &tmp, db, table_name, - table->alias, 0, table->in_use->mem_root)) + table->alias, 0, table->in_use->mem_root, 0)) goto end; free_io_cache(table); @@ -1851,6 +1863,8 @@ void abort_locked_tables(THD *thd,const char *db, const char *table_name) alias Alias name table_desc TABLE_LIST descriptor (used with views) mem_root temporary mem_root for parsing + flags the OPEN_VIEW_NO_PARSE flag to be passed to + openfrm()/open_new_frm() NOTES Extra argument for open is taken from thd->open_options @@ -1861,7 +1875,8 @@ void abort_locked_tables(THD *thd,const char *db, const char *table_name) */ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, const char *name, const char *alias, - TABLE_LIST *table_desc, MEM_ROOT *mem_root) + TABLE_LIST *table_desc, MEM_ROOT *mem_root, + uint flags) { char path[FN_REFLEN]; int error; @@ -1873,14 +1888,16 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX | HA_TRY_READ_ONLY | NO_ERR_ON_NEW_FRM), - READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD, + READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD | + (flags & OPEN_VIEW_NO_PARSE), thd->open_options, entry)) && (error != 5 || (fn_format(path, path, 0, reg_ext, MY_UNPACK_FILENAME), open_new_frm(thd, path, alias, db, name, (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX | HA_TRY_READ_ONLY), - READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD, + READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD | + (flags & OPEN_VIEW_NO_PARSE), thd->open_options, entry, table_desc, mem_root)))) { @@ -1962,7 +1979,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, } if (error == 5) - DBUG_RETURN(0); // we have just opened VIEW + DBUG_RETURN((flags & OPEN_VIEW_NO_PARSE)? -1 : 0); // we have just opened VIEW /* We can't mark all tables in 'mysql' database as system since we don't @@ -5374,7 +5391,8 @@ open_new_frm(THD *thd, const char *path, const char *alias, my_error(ER_WRONG_OBJECT, MYF(0), db, table_name, "BASE TABLE"); goto err; } - if (mysql_make_view(thd, parser, table_desc)) + if (mysql_make_view(thd, parser, table_desc, + (prgflag & OPEN_VIEW_NO_PARSE))) goto err; } else diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 897f6c25190..74d27809805 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -375,7 +375,7 @@ public: friend class st_select_lex_unit; friend bool mysql_new_select(struct st_lex *lex, bool move_down); friend bool mysql_make_view(THD *thd, File_parser *parser, - TABLE_LIST *table); + TABLE_LIST *table, uint flags); private: void fast_exclude(); }; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 8aa93a7bbeb..b402e7e0936 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -183,7 +183,7 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) TABLE_LIST decoy; memcpy (&decoy, view, sizeof (TABLE_LIST)); - if (!open_table(thd, &decoy, thd->mem_root, ¬_used, 0) && + if (!open_table(thd, &decoy, thd->mem_root, ¬_used, OPEN_VIEW_NO_PARSE) && !decoy.view) { return TRUE; @@ -815,13 +815,14 @@ loop_out: thd Thread handler parser parser object table TABLE_LIST structure for filling - + flags flags RETURN 0 ok 1 error */ -bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table) +bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, + uint flags) { SELECT_LEX *end, *view_select; LEX *old_lex, *lex; @@ -912,6 +913,10 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table) table->db, table->table_name); get_default_definer(thd, &table->definer); } + if (flags & OPEN_VIEW_NO_PARSE) + { + DBUG_RETURN(FALSE); + } /* Save VIEW parameters, which will be wiped out by derived table diff --git a/sql/sql_view.h b/sql/sql_view.h index cd61d7e9e71..b6c27a60eeb 100644 --- a/sql/sql_view.h +++ b/sql/sql_view.h @@ -19,7 +19,8 @@ bool mysql_create_view(THD *thd, enum_view_create_mode mode); -bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table); +bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, + uint flags); bool mysql_drop_view(THD *thd, TABLE_LIST *view, enum_drop_mode drop_mode); diff --git a/sql/table.cc b/sql/table.cc index e50b401df5f..16cbb6585dd 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -121,6 +121,8 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, // caller can't process new .frm goto err; } + if (prgflag & OPEN_VIEW_NO_PARSE) + goto err; share->blob_ptr_size= sizeof(char*); outparam->db_stat= db_stat; diff --git a/sql/unireg.h b/sql/unireg.h index b932a2f320c..dfebde01338 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -147,7 +147,8 @@ #define READ_SCREENS 1024 /* Read screens, info and helpfile */ #define DELAYED_OPEN 4096 /* Open table later */ #define NO_ERR_ON_NEW_FRM 8192 /* stop error sending on new format */ - +#define OPEN_VIEW_NO_PARSE 16384 /* Open frm only if it's a view, + but do not parse view itself */ #define SC_INFO_LENGTH 4 /* Form format constant */ #define TE_INFO_LENGTH 3 #define MTYP_NOEMPTY_BIT 128 From 4abe4b1717b099dbf3502e041c246b196622a23f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Aug 2006 06:46:06 +0400 Subject: [PATCH 12/19] sql_view.cc: After merge fix sql/sql_view.cc: After merge fix --- sql/sql_view.cc | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 8c4f188a840..16ee6505886 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -179,23 +179,16 @@ static bool fill_defined_view_parts (THD *thd, TABLE_LIST *view) { LEX *lex= thd->lex; - bool free_view= 1; + bool not_used; TABLE_LIST decoy; - if (view->view) - free_view= 0; memcpy (&decoy, view, sizeof (TABLE_LIST)); if (!open_table(thd, &decoy, thd->mem_root, ¬_used, OPEN_VIEW_NO_PARSE) && !decoy.view) { /* It's a table */ - my_free((gptr)decoy.table, MYF(0)); - my_error(ER_WRONG_OBJECT, MYF(0), view->db, view->table_name, "VIEW"); return TRUE; } - if (!decoy.view) - /* An error while opening the view occurs, caller will handle it */ - return FALSE; if (!lex->definer) { @@ -208,11 +201,6 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) if (lex->create_view_suid == VIEW_SUID_DEFAULT) lex->create_view_suid= decoy.view_suid ? VIEW_SUID_DEFINER : VIEW_SUID_INVOKER; - if (free_view) - { - delete decoy.view; - lex->cleanup_after_one_table_open(); - } return FALSE; } From a2a5f2b53622af0933de757660428ba61737cb98 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Aug 2006 14:28:39 +0500 Subject: [PATCH 13/19] BUG#20060 - mysqld option "--flush " doesn't work for update statement Problem described in this bug report affects MyISAM tables only. Running mysqld --flush instructs mysqld to sync all changes to disk after each SQL statement. It worked well for INSERT and DELETE statements, but it did sync for UPDATE only in case if there was index change (change of colum that has an index). If no updated column has an index, data wasn't synced to disk. This fix makes UPDATE statement to sync data to disk even if there is no index change (that is only data change) and mysqld is run with --flush option. myisam/mi_update.c: Every myisam function that updates myisam table must end with call to _mi_writeinfo(). If operation (second param of _mi_writeinfo()) is not 0 it sets share->changed to 1, that is flags that data has changed. If operation is 0, this function equals to no-op in this case. mi_update() must always pass !0 value as operation, since even if there is no index change there could be data change. --- myisam/mi_update.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/myisam/mi_update.c b/myisam/mi_update.c index 672c8407353..00eee18bfab 100644 --- a/myisam/mi_update.c +++ b/myisam/mi_update.c @@ -168,7 +168,17 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED | HA_STATE_AKTIV | key_changed); myisam_log_record(MI_LOG_UPDATE,info,newrec,info->lastpos,0); - VOID(_mi_writeinfo(info,key_changed ? WRITEINFO_UPDATE_KEYFILE : 0)); + /* + Every myisam function that updates myisam table must end with + call to _mi_writeinfo(). If operation (second param of + _mi_writeinfo()) is not 0 it sets share->changed to 1, that is + flags that data has changed. If operation is 0, this function + equals to no-op in this case. + + mi_update() must always pass !0 value as operation, since even if + there is no index change there could be data change. + */ + VOID(_mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE)); allow_break(); /* Allow SIGHUP & SIGINT */ if (info->invalidator != 0) { From 78c9885fe017db8b4cd58d8c5f76af8294541a29 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Aug 2006 01:02:31 -0400 Subject: [PATCH 14/19] Removed Iggy's accidentally-added files. From 12eb42acf98d1594b9e50dbbf0c77d82f95279ed Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Aug 2006 12:39:18 -0400 Subject: [PATCH 15/19] Merge updates. mysql-test/r/grant2.result: Merge update: Change between versions, it appears. mysql-test/r/heap_btree.result: Merge update: Add deterministic ordering of data, as the order is different between versions. mysql-test/r/mysql_client.result: Merge update: Help options changed between versions. mysql-test/t/heap_btree.test: Merge update: Add deterministic ordering of data, as the order is different between versions. BitKeeper/deleted/.del-bug20328.test~c76d766fe3e1eb5: Delete: mysql-test/t/bug20328.test BitKeeper/deleted/.del-bug20328.result~4fee68989442c2a3: Delete: mysql-test/r/bug20328.result --- mysql-test/r/bug20328.result | 44 -------------------------------- mysql-test/r/grant2.result | 4 +-- mysql-test/r/heap_btree.result | 20 +++++++-------- mysql-test/r/mysql_client.result | 12 ++++++--- mysql-test/t/bug20328.test | 9 ------- mysql-test/t/heap_btree.test | 12 ++++----- 6 files changed, 26 insertions(+), 75 deletions(-) delete mode 100644 mysql-test/r/bug20328.result delete mode 100644 mysql-test/t/bug20328.test diff --git a/mysql-test/r/bug20328.result b/mysql-test/r/bug20328.result deleted file mode 100644 index 62955775ec4..00000000000 --- a/mysql-test/r/bug20328.result +++ /dev/null @@ -1,44 +0,0 @@ -? (\?) Synonym for `help'. -clear (\c) Clear command. -connect (\r) Reconnect to the server. Optional arguments are db and host. -delimiter (\d) Set query delimiter. -edit (\e) Edit command with $EDITOR. -ego (\G) Send command to mysql server, display result vertically. -exit (\q) Exit mysql. Same as quit. -go (\g) Send command to mysql server. -help (\h) Display this help. -nopager (\n) Disable pager, print to stdout. -notee (\t) Don't write into outfile. -pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. -print (\p) Print current command. -prompt (\R) Change your mysql prompt. -quit (\q) Quit mysql. -rehash (\#) Rebuild completion hash. -source (\.) Execute an SQL script file. Takes a file name as an argument. -status (\s) Get status information from the server. -system (\!) Execute a system shell command. -tee (\T) Set outfile [to_outfile]. Append everything into given outfile. -use (\u) Use another database. Takes database name as argument. -charset_name(\C) Switch to another charset. Might be needed for processing binlog. -? (\?) Synonym for `help'. -clear (\c) Clear command. -connect (\r) Reconnect to the server. Optional arguments are db and host. -delimiter (\d) Set query delimiter. -edit (\e) Edit command with $EDITOR. -ego (\G) Send command to mysql server, display result vertically. -exit (\q) Exit mysql. Same as quit. -go (\g) Send command to mysql server. -help (\h) Display this help. -nopager (\n) Disable pager, print to stdout. -notee (\t) Don't write into outfile. -pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. -print (\p) Print current command. -prompt (\R) Change your mysql prompt. -quit (\q) Quit mysql. -rehash (\#) Rebuild completion hash. -source (\.) Execute an SQL script file. Takes a file name as an argument. -status (\s) Get status information from the server. -system (\!) Execute a system shell command. -tee (\T) Set outfile [to_outfile]. Append everything into given outfile. -use (\u) Use another database. Takes database name as argument. -charset_name(\C) Switch to another charset. Might be needed for processing binlog. diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index a24879e7bd0..2700426257b 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -121,9 +121,9 @@ mysqltest_5@host5, mysqltest_6@host6, mysqltest_7@host7; create database mysqltest_1; grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost; set sql_log_off = 1; -ERROR HY000: Access denied; you need the SUPER privilege for this operation +ERROR 42000: Access denied; you need the SUPER privilege for this operation set sql_log_bin = 0; -ERROR HY000: Access denied; you need the SUPER privilege for this operation +ERROR 42000: Access denied; you need the SUPER privilege for this operation delete from mysql.user where user like 'mysqltest\_1'; delete from mysql.db where user like 'mysqltest\_1'; drop database mysqltest_1; diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 81b16dc3dcb..c9d3db5e8e8 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -248,34 +248,34 @@ a DROP TABLE t1; create table t1(a int not null, key using btree(a)) engine=heap; insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); -select a from t1 where a > 2; +select a from t1 where a > 2 order by a; a 3 3 3 3 delete from t1 where a < 4; -select a from t1; +select a from t1 order by a; a insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); -select a from t1 where a > 4; +select a from t1 where a > 4 order by a; a delete from t1 where a > 4; -select a from t1; +select a from t1 order by a; a -3 -3 1 -3 -3 1 2 2 2 -select a from t1 where a > 3; +3 +3 +3 +3 +select a from t1 where a > 3 order by a; a delete from t1 where a >= 2; -select a from t1; +select a from t1 order by a; a 1 1 diff --git a/mysql-test/r/mysql_client.result b/mysql-test/r/mysql_client.result index c7663c55070..01a8c731bc9 100644 --- a/mysql-test/r/mysql_client.result +++ b/mysql-test/r/mysql_client.result @@ -5,7 +5,7 @@ ERROR at line 1: USE must be followed by a database name ? (\?) Synonym for `help'. clear (\c) Clear command. connect (\r) Reconnect to the server. Optional arguments are db and host. -delimiter (\d) Set query delimiter. +delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. @@ -23,11 +23,13 @@ status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. -charset_name(\C) Switch to another charset. Might be needed for processing binlog. +charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. +warnings (\W) Show warnings after every statement. +nowarning (\w) Don't show warnings after every statement. ? (\?) Synonym for `help'. clear (\c) Clear command. connect (\r) Reconnect to the server. Optional arguments are db and host. -delimiter (\d) Set query delimiter. +delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. @@ -45,7 +47,9 @@ status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. -charset_name(\C) Switch to another charset. Might be needed for processing binlog. +charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. +warnings (\W) Show warnings after every statement. +nowarning (\w) Don't show warnings after every statement. \ \\ '; diff --git a/mysql-test/t/bug20328.test b/mysql-test/t/bug20328.test deleted file mode 100644 index 6ae4717de9c..00000000000 --- a/mysql-test/t/bug20328.test +++ /dev/null @@ -1,9 +0,0 @@ -# This test should work in embedded server after we fix mysqltest --- source include/not_embedded.inc - -# -# Bug #20328: mysql client interprets commands in comments -# ---exec echo 'help' | $MYSQL ---exec echo 'help ' | $MYSQL - diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 71743d0d850..e74e9723ca6 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -170,16 +170,16 @@ DROP TABLE t1; create table t1(a int not null, key using btree(a)) engine=heap; insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); -select a from t1 where a > 2; +select a from t1 where a > 2 order by a; delete from t1 where a < 4; -select a from t1; +select a from t1 order by a; insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); -select a from t1 where a > 4; +select a from t1 where a > 4 order by a; delete from t1 where a > 4; -select a from t1; -select a from t1 where a > 3; +select a from t1 order by a; +select a from t1 where a > 3 order by a; delete from t1 where a >= 2; -select a from t1; +select a from t1 order by a; drop table t1; --echo End of 4.1 tests From f78ffbf96cf4983acb83cd2ecc73b2db976488ce Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Aug 2006 17:39:01 -0500 Subject: [PATCH 16/19] Some small cleanups that will help get mysql_client_test passing on Windows tests/mysql_client_test.c: set sql_mode to '' in a few places explicitly select myisam table type for fulltext use memcpy instead of strcpy since our src buffer is not zero terminated. --- tests/mysql_client_test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 2463840bd0c..a1208521e8d 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -3976,6 +3976,7 @@ static void test_fetch_date() c7 timestamp(6))"); myquery(rc); + rc= mysql_query(mysql, "SET SQL_MODE=''"); rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES('2002-01-02', \ '12:49:00', \ '2002-01-02 17:46:59', \ @@ -8350,6 +8351,7 @@ static void test_bug19671() int rc; myheader("test_bug19671"); + mysql_query(mysql, "set sql_mode=''"); rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); @@ -8920,7 +8922,7 @@ static void test_bug1500() rc= mysql_query(mysql, "DROP TABLE test_bg1500"); myquery(rc); - rc= mysql_query(mysql, "CREATE TABLE test_bg1500 (s VARCHAR(25), FULLTEXT(s))"); + rc= mysql_query(mysql, "CREATE TABLE test_bg1500 (s VARCHAR(25), FULLTEXT(s)) engine=MyISAM"); myquery(rc); rc= mysql_query(mysql, @@ -12020,6 +12022,7 @@ static void test_bug6096() rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); + mysql_query(mysql, "set sql_mode=''"); stmt_text= "create table t1 (c_tinyint tinyint, c_smallint smallint, " " c_mediumint mediumint, c_int int, " " c_bigint bigint, c_float float, " @@ -12904,7 +12907,9 @@ static void test_bug8378() /* No escaping should have actually happened. */ DIE_UNLESS(memcmp(out, TEST_BUG8378_OUT, len) == 0); - sprintf(buf, "SELECT '%s'", out); + strcpy(buf, "SELECT '"); + memcpy(buf+8, out, len); + buf[8+len] = '\''; rc=mysql_real_query(mysql, buf, strlen(buf)); myquery(rc); From 6071b686b179d1fcc96cd6ccce940d62bd509c70 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Aug 2006 14:41:07 +0500 Subject: [PATCH 17/19] Extended a test case for bug#7391. --- mysql-test/r/grant.result | 1 + mysql-test/t/grant.test | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 3f3325354ee..7ad2a5033e9 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -426,6 +426,7 @@ revoke all on mysqltest_2.t1 from mysqltest_3@localhost; revoke all on mysqltest_2.t2 from mysqltest_3@localhost; grant all on mysqltest_2.* to mysqltest_3@localhost; grant select on *.* to mysqltest_3@localhost; +grant select on mysqltest_2.t1 to mysqltest_3@localhost; flush privileges; use mysqltest_1; update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index a9d52f559ca..73857d8ab69 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -362,6 +362,8 @@ revoke all on mysqltest_2.t2 from mysqltest_3@localhost; #test the db/table level privileges grant all on mysqltest_2.* to mysqltest_3@localhost; grant select on *.* to mysqltest_3@localhost; +# Next grant is needed to trigger bug#7391. Do not optimize! +grant select on mysqltest_2.t1 to mysqltest_3@localhost; flush privileges; disconnect conn1; connect (conn2,localhost,mysqltest_3,,); From f6d7985a5b4a5c7d94cb04ba003dfa411cf0d3f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Aug 2006 17:05:02 +0500 Subject: [PATCH 18/19] BUG#18874 - Setting myisam_repair_threads > 1, index cardinality always 1 Fixed by moving update_key_parts() down to be after write_index(). myisam/sort.c: write_index() collects index statistic which is further used in update_key_parts(). Thus update_key_parts() must be called after write_index(). mysql-test/r/repair.result: Test case for bug#18874. mysql-test/t/repair.test: Test case for bug#18874. --- myisam/sort.c | 12 +++++------- mysql-test/r/repair.result | 11 +++++++++++ mysql-test/t/repair.test | 11 +++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/myisam/sort.c b/myisam/sort.c index 96b55d599c8..1a3dc147cd9 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -480,13 +480,6 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) if (!got_error) { share->state.key_map|=(ulonglong) 1 << sinfo->key; - if (param->testflag & T_STATISTICS) - update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique, - param->stats_method == MI_STATS_METHOD_IGNORE_NULLS? - sinfo->notnull: NULL, - (ulonglong) info->state->records); - - if (!sinfo->buffpek.elements) { if (param->testflag & T_VERBOSE) @@ -498,6 +491,11 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) flush_ft_buf(sinfo) || flush_pending_blocks(sinfo)) got_error=1; } + if (!got_error && param->testflag & T_STATISTICS) + update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique, + param->stats_method == MI_STATS_METHOD_IGNORE_NULLS? + sinfo->notnull: NULL, + (ulonglong) info->state->records); } my_free((gptr) sinfo->sort_keys,MYF(0)); my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff), diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index dbca5c39a6c..e0849452399 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -37,3 +37,14 @@ Table Op Msg_type Msg_text test.t1 repair warning Number of rows changed from 0 to 1 test.t1 repair status OK drop table t1; +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES(1),(2),(3),(4),(5); +SET myisam_repair_threads=2; +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A 5 NULL NULL YES BTREE +SET myisam_repair_threads=@@global.myisam_repair_threads; +DROP TABLE t1; diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index 5e39e0b6a50..f086d5b0c2a 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -34,4 +34,15 @@ repair table t1; repair table t1 use_frm; drop table t1; +# +# BUG#18874 - Setting myisam_repair_threads > 1, index cardinality always 1 +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES(1),(2),(3),(4),(5); +SET myisam_repair_threads=2; +REPAIR TABLE t1; +SHOW INDEX FROM t1; +SET myisam_repair_threads=@@global.myisam_repair_threads; +DROP TABLE t1; + # End of 4.1 tests From cabca09fe585223fc5e7b65cd67d27d79d559b64 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Aug 2006 20:48:37 +0200 Subject: [PATCH 19/19] My previous change of replacing the call to sprintf with some memcpy type routines was not correct. This patch reverts that. mysql_client_test.c: reverting my previous change tests/mysql_client_test.c: reverting my previous change --- tests/mysql_client_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index a1208521e8d..8a8aae01dab 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -12907,9 +12907,8 @@ static void test_bug8378() /* No escaping should have actually happened. */ DIE_UNLESS(memcmp(out, TEST_BUG8378_OUT, len) == 0); - strcpy(buf, "SELECT '"); - memcpy(buf+8, out, len); - buf[8+len] = '\''; + sprintf(buf, "SELECT '%s'", out); + rc=mysql_real_query(mysql, buf, strlen(buf)); myquery(rc);