diff options
author | unknown <monty@mysql.com> | 2004-03-19 18:33:38 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-03-19 18:33:38 +0200 |
commit | 28813a9ea9b5149b7c370f616232ea60dadf852c (patch) | |
tree | 7b70c20edffefc6a9a26014ddd3c8956f5248a2d | |
parent | 67ea8aac5e9e9ae98a22aff063c48053ea68e5de (diff) | |
download | mariadb-git-28813a9ea9b5149b7c370f616232ea60dadf852c.tar.gz |
Added test to show bug in current union implementation
After merge fixes
Portability fixes
client/mysqltest.c:
Fixed that unget() is done properly (needed for QNX where one can't do many ungetc() in a row)
include/errmsg.h:
After merge fixes
mysql-test/mysql-test-run.sh:
merge fix
mysql-test/r/system_mysql_db.result:
Updated results for 4.1
mysql-test/r/union.result:
Added new test
mysql-test/t/derived.test:
Portability fix (for Mac OS X)
mysql-test/t/system_mysql_db_refs.test:
Remove warnings
mysql-test/t/union.test:
Added test to show bug in current union implementation (to be fixed in 4.1)
scripts/mysql_create_system_tables.sh:
Fix wrong column define
scripts/mysql_fix_privilege_tables.sh:
Fix for mysql-test-run
scripts/mysql_fix_privilege_tables.sql:
Merge with 4.0 to get comments.
Updated so that it works with privilege tables for MySQL 3.23.
sql/repl_failsafe.cc:
After merge fix
-rw-r--r-- | client/mysqltest.c | 75 | ||||
-rw-r--r-- | include/errmsg.h | 46 | ||||
-rw-r--r-- | mysql-test/mysql-test-run.sh | 2 | ||||
-rw-r--r-- | mysql-test/r/system_mysql_db.result | 24 | ||||
-rw-r--r-- | mysql-test/r/union.result | 15 | ||||
-rw-r--r-- | mysql-test/t/derived.test | 3 | ||||
-rw-r--r-- | mysql-test/t/system_mysql_db_refs.test | 12 | ||||
-rw-r--r-- | mysql-test/t/union.test | 13 | ||||
-rw-r--r-- | scripts/mysql_create_system_tables.sh | 2 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sh | 25 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sql | 65 | ||||
-rw-r--r-- | sql/repl_failsafe.cc | 5 |
12 files changed, 204 insertions, 83 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index 1db385b85cb..4bcfe93c278 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -109,6 +109,7 @@ MYSQL_MANAGER* manager=0; static char **default_argv; static const char *load_default_groups[]= { "mysqltest","client",0 }; +static char line_buffer[MAX_DELIMITER], *line_buffer_pos= line_buffer;; static FILE* file_stack[MAX_INCLUDE_DEPTH]; static FILE** cur_file; @@ -885,7 +886,10 @@ int do_exec(struct st_query* q) if (disable_result_log) { while (fgets(buf, sizeof(buf), res_file)) - {} + { + buf[strlen(buf)-1]=0; + DBUG_PRINT("exec_result",("%s", buf)); + } } else { @@ -1648,24 +1652,48 @@ int do_while(struct st_query* q) } -my_bool end_of_query(int c, char* p) +/* + Read characters from line buffer or file. This is needed to allow + my_ungetc() to buffer MAX_DELIMITER characters for a file + + NOTE: + This works as long as one doesn't change files (with 'source file_name') + when there is things pushed into the buffer. This should however not + happen for any tests in the test suite. +*/ + +char my_getc(FILE *file) +{ + if (line_buffer_pos == line_buffer) + return fgetc(file); + return line_buffer[--line_buffer_pos]; +} + +void my_ungetc(int c) +{ + line_buffer[line_buffer_pos++]= c; +} + + +my_bool end_of_query(int c) { - uint i, j; - int tmp[MAX_DELIMITER]= {0}; + uint i,j; + char tmp[MAX_DELIMITER]; + + if (c != *delimiter) + return 0; - for (i= 0; c == *(delimiter + i) && i < delimiter_length; - i++, c= fgetc(*cur_file)) + for (i= 1; i < delimiter_length && + (c= my_getc(*cur_file)) == *(delimiter + i); + i++) tmp[i]= c; - tmp[i]= c; - for (j= i; j > 0 && i != delimiter_length; j--) - ungetc(tmp[j], *cur_file); if (i == delimiter_length) - { - ungetc(tmp[i], *cur_file); - *p= 0; - return 1; - } + return 1; /* Found delimiter */ + + /* didn't find delimiter, push back things that we read */ + for (j = 1 ; j <= i ; j++) + my_ungetc(tmp[j]); return 0; } @@ -1683,7 +1711,7 @@ int read_line(char* buf, int size) for (; p < buf_end ;) { no_save= 0; - c= fgetc(*cur_file); + c= my_getc(*cur_file); if (feof(*cur_file)) { if ((*cur_file) != stdin) @@ -1698,8 +1726,11 @@ int read_line(char* buf, int size) switch(state) { case R_NORMAL: /* Only accept '{' in the beginning of a line */ - if (end_of_query(c, p)) + if (end_of_query(c)) + { + *p= 0; return 0; + } else if (c == '\'') state = R_Q1; else if (c == '"') @@ -1735,7 +1766,7 @@ int read_line(char* buf, int size) *buf= 0; return 0; } - else if (end_of_query(c, p) || c == '{') + else if (end_of_query(c) || c == '{') { *p= 0; return 0; @@ -1755,8 +1786,11 @@ int read_line(char* buf, int size) state= R_ESC_SLASH_Q1; break; case R_ESC_Q_Q1: - if (end_of_query(c, p)) + if (end_of_query(c)) + { + *p= 0; return 0; + } if (c != '\'') state= R_NORMAL; else @@ -1773,8 +1807,11 @@ int read_line(char* buf, int size) state= R_ESC_SLASH_Q2; break; case R_ESC_Q_Q2: - if (end_of_query(c, p)) + if (end_of_query(c)) + { + *p= 0; return 0; + } if (c != '"') state= R_NORMAL; else diff --git a/include/errmsg.h b/include/errmsg.h index 76a293f3dec..140ff531248 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -66,27 +66,27 @@ extern const char *client_errors[]; /* Error messages */ #define CR_WRONG_LICENSE 2028 /* new 4.1 error codes */ -#define CR_NULL_POINTER 2028 -#define CR_NO_PREPARE_STMT 2029 -#define CR_PARAMS_NOT_BOUND 2030 -#define CR_DATA_TRUNCATED 2031 -#define CR_NO_PARAMETERS_EXISTS 2032 -#define CR_INVALID_PARAMETER_NO 2033 -#define CR_INVALID_BUFFER_USE 2034 -#define CR_UNSUPPORTED_PARAM_TYPE 2035 +#define CR_NULL_POINTER 2029 +#define CR_NO_PREPARE_STMT 2030 +#define CR_PARAMS_NOT_BOUND 2031 +#define CR_DATA_TRUNCATED 2032 +#define CR_NO_PARAMETERS_EXISTS 2033 +#define CR_INVALID_PARAMETER_NO 2034 +#define CR_INVALID_BUFFER_USE 2035 +#define CR_UNSUPPORTED_PARAM_TYPE 2036 -#define CR_SHARED_MEMORY_CONNECTION 2036 -#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2037 -#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2038 -#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2039 -#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2040 -#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2041 -#define CR_SHARED_MEMORY_MAP_ERROR 2042 -#define CR_SHARED_MEMORY_EVENT_ERROR 2043 -#define CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR 2044 -#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2045 -#define CR_CONN_UNKNOW_PROTOCOL 2046 -#define CR_INVALID_CONN_HANDLE 2047 -#define CR_SECURE_AUTH 2048 -#define CR_FETCH_CANCELLED 2049 -#define CR_NO_DATA 2050 +#define CR_SHARED_MEMORY_CONNECTION 2037 +#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038 +#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039 +#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2040 +#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041 +#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042 +#define CR_SHARED_MEMORY_MAP_ERROR 2043 +#define CR_SHARED_MEMORY_EVENT_ERROR 2044 +#define CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR 2045 +#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046 +#define CR_CONN_UNKNOW_PROTOCOL 2047 +#define CR_INVALID_CONN_HANDLE 2048 +#define CR_SECURE_AUTH 2049 +#define CR_FETCH_CANCELLED 2050 +#define CR_NO_DATA 2051 diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 7827fe9791f..b041bfb8369 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -511,7 +511,7 @@ fi MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT" -MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --bindir=$CLIENT_BINDIR" +MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose=1" MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result index 257b3b13f08..8da46564619 100644 --- a/mysql-test/r/system_mysql_db.result +++ b/mysql-test/r/system_mysql_db.result @@ -3,6 +3,10 @@ Tables_in_db columns_priv db func +help_category +help_keyword +help_relation +help_topic host tables_priv user @@ -26,7 +30,7 @@ db CREATE TABLE `db` ( `Lock_tables_priv` enum('N','Y') NOT NULL default 'N', PRIMARY KEY (`Host`,`Db`,`User`), KEY `User` (`User`) -) TYPE=MyISAM COMMENT='Database privileges' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Database privileges' show create table host; Table Create Table host CREATE TABLE `host` ( @@ -45,13 +49,13 @@ host CREATE TABLE `host` ( `Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N', `Lock_tables_priv` enum('N','Y') NOT NULL default 'N', PRIMARY KEY (`Host`,`Db`) -) TYPE=MyISAM COMMENT='Host privileges; Merged with database privileges' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Host privileges; Merged with database privileges' show create table user; Table Create Table user CREATE TABLE `user` ( `Host` varchar(60) binary NOT NULL default '', `User` varchar(16) binary NOT NULL default '', - `Password` varchar(16) binary NOT NULL default '', + `Password` varchar(41) binary NOT NULL default '', `Select_priv` enum('N','Y') NOT NULL default 'N', `Insert_priv` enum('N','Y') NOT NULL default 'N', `Update_priv` enum('N','Y') NOT NULL default 'N', @@ -81,16 +85,16 @@ user CREATE TABLE `user` ( `max_updates` int(11) unsigned NOT NULL default '0', `max_connections` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`Host`,`User`) -) TYPE=MyISAM COMMENT='Users and global privileges' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Users and global privileges' show create table func; Table Create Table func CREATE TABLE `func` ( - `name` char(64) NOT NULL default '', + `name` char(64) binary NOT NULL default '', `ret` tinyint(1) NOT NULL default '0', `dl` char(128) NOT NULL default '', `type` enum('function','aggregate') NOT NULL default 'function', PRIMARY KEY (`name`) -) TYPE=MyISAM COMMENT='User defined functions' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='User defined functions' show create table tables_priv; Table Create Table tables_priv CREATE TABLE `tables_priv` ( @@ -99,12 +103,12 @@ tables_priv CREATE TABLE `tables_priv` ( `User` char(16) binary NOT NULL default '', `Table_name` char(64) binary NOT NULL default '', `Grantor` char(77) NOT NULL default '', - `Timestamp` timestamp(14) NOT NULL, + `Timestamp` timestamp NOT NULL, `Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') NOT NULL default '', `Column_priv` set('Select','Insert','Update','References') NOT NULL default '', PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`), KEY `Grantor` (`Grantor`) -) TYPE=MyISAM COMMENT='Table privileges' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Table privileges' show create table columns_priv; Table Create Table columns_priv CREATE TABLE `columns_priv` ( @@ -113,7 +117,7 @@ columns_priv CREATE TABLE `columns_priv` ( `User` char(16) binary NOT NULL default '', `Table_name` char(64) binary NOT NULL default '', `Column_name` char(64) binary NOT NULL default '', - `Timestamp` timestamp(14) NOT NULL, + `Timestamp` timestamp NOT NULL, `Column_priv` set('Select','Insert','Update','References') NOT NULL default '', PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`) -) TYPE=MyISAM COMMENT='Column privileges' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Column privileges' diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index f89d41aa982..5eb447ab223 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -907,3 +907,18 @@ n 9 10 drop table t1; +create table t1 (i int); +insert into t1 values (1); +select * from t1 UNION select * from t1; +i +1 +select * from t1 UNION ALL select * from t1; +i +1 +1 +select * from t1 UNION select * from t1 UNION ALL select * from t1; +i +1 +1 +1 +drop table t1; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index ddd2b36e78e..a13d5de40f0 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -157,7 +157,8 @@ UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; select * from t1; --- error 1288 +--error 1288 +--replace_result P2 p2 delete P1.*,P2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; -- error 1054 delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; diff --git a/mysql-test/t/system_mysql_db_refs.test b/mysql-test/t/system_mysql_db_refs.test index 49d6f198b32..62d6f3de944 100644 --- a/mysql-test/t/system_mysql_db_refs.test +++ b/mysql-test/t/system_mysql_db_refs.test @@ -10,27 +10,39 @@ set @name="This is a very long string, that mustn't find room in a system field create table test_db select * from mysql.db;
delete from test_db;
+--disable_warnings insert into test_db (Host,Db,User) values (@name,@name,@name);
+--enable_warnings create table test_host select * from mysql.host;
delete from test_host;
+--disable_warnings insert into test_host (Host,Db) values (@name,@name);
+--enable_warnings create table test_user select * from mysql.user;
delete from test_user;
+--disable_warnings insert into test_user (Host,User) values (@name,@name);
+--enable_warnings create table test_func select * from mysql.func;
delete from test_func;
+--disable_warnings insert into test_func (name) values (@name);
+--enable_warnings create table test_tables_priv select * from mysql.tables_priv;
delete from test_tables_priv;
+--disable_warnings insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name);
+--enable_warnings create table test_columns_priv select * from mysql.columns_priv;
delete from test_columns_priv;
+--disable_warnings insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name);
+--enable_warnings # 'Host' field must be the same for all the tables:
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 7d1818ab724..06110474992 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -483,3 +483,16 @@ select col1 n from t1 union select col2 n from t1 order by n; alter table t1 add index myindex (col2); select col1 n from t1 union select col2 n from t1 order by n; drop table t1; + +# +# Bug #1428, incorrect handling of UNION ALL +# NOTE: The current result is wrong, needs to be fixed! +# + +create table t1 (i int); +insert into t1 values (1); +select * from t1 UNION select * from t1; +select * from t1 UNION ALL select * from t1; +# The following should return 2 lines +select * from t1 UNION select * from t1 UNION ALL select * from t1; +drop table t1; diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index a65004bec4c..5129c028238 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -188,7 +188,7 @@ then c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL," c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL," c_t="$c_t User char(16) binary DEFAULT '' NOT NULL," - c_t="$c_t Table_name char(60) binary DEFAULT '' NOT NULL," + c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL," c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL," c_t="$c_t Timestamp timestamp(14)," c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL," diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 39a4554be77..69bf2bebaa8 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -56,21 +56,15 @@ parse_arguments() { # Get first arguments from the my.cfg file, groups [mysqld] and # [mysql_install_db], and then merge with the command line arguments -if test -x ./bin/my_print_defaults -then - print_defaults="./bin/my_print_defaults" -elif test -x @bindr@/my_print_defaults -then - print_defaults="@bindir@/my_print_defaults" -elif test -x @bindir@/mysql_print_defaults -then - print_defaults="@bindir@/mysql_print_defaults" -elif test -x extra/my_print_defaults -then - print_defaults="extra/my_print_defaults" -else - print_defaults="my_print_defaults" -fi + +for dir in ./bin @bindir@ @bindir@ extra $bindir/../bin $bindir/../extra +do + if test -x $dir/my_print_defaults + then + print_defaults="$dir/my_print_defaults" + break + fi +done parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables` parse_arguments PICK-ARGS-FROM-ARGV "$@" @@ -109,7 +103,6 @@ fi cmd="$bindir/mysql -f --user=$user --host=$host" if test -z "$password" ; then -else cmd="$cmd --password=$password" fi if test ! -z "$port"; then diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index de5779b9ac0..dabc653bcbb 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -7,19 +7,18 @@ -- On unix, you should use the mysql_fix_privilege_tables script to execute -- this sql script. --- On windows you should do 'mysql --force < mysql_fix_privilege_tables.sql' +-- On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' -USE mysql; ALTER TABLE user type=MyISAM; ALTER TABLE db type=MyISAM; ALTER TABLE host type=MyISAM; ALTER TABLE func type=MyISAM; ALTER TABLE columns_priv type=MyISAM; ALTER TABLE tables_priv type=MyISAM; -ALTER TABLE user change Password Password char(41) not null; +ALTER TABLE user change Password Password char(41) binary not null; ALTER TABLE user add File_priv enum('N','Y') NOT NULL; CREATE TABLE IF NOT EXISTS func ( - name char(64) DEFAULT '' NOT NULL, + name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') NOT NULL, @@ -39,6 +38,10 @@ UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Crea UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; +-- +-- The second alter changes ssl_type to new 4.0.2 format +-- Adding columns needed by GRANT .. REQUIRE (openssl)" + ALTER TABLE user ADD ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL, ADD ssl_cipher BLOB NOT NULL, @@ -46,11 +49,15 @@ ADD x509_issuer BLOB NOT NULL, ADD x509_subject BLOB NOT NULL; ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL; +-- +-- Create tables_priv and columns_priv if they don't exists +-- + CREATE TABLE IF NOT EXISTS tables_priv ( - Host char(60) DEFAULT '' NOT NULL, - Db char(60) DEFAULT '' NOT NULL, - User char(16) DEFAULT '' NOT NULL, - Table_name char(60) DEFAULT '' NOT NULL, + Host char(60) binary DEFAULT '' NOT NULL, + Db char(64) binary DEFAULT '' NOT NULL, + User char(16) binary DEFAULT '' NOT NULL, + Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL, @@ -69,16 +76,29 @@ CREATE TABLE IF NOT EXISTS columns_priv ( PRIMARY KEY (Host,Db,User,Table_name,Column_name) ); + +-- +-- Name change of Type -> Column_priv from MySQL 3.22.12 +-- + ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL; +-- +-- Add the new 'type' column to the func table. +-- + ALTER TABLE func add type enum ('function','aggregate') NOT NULL; +-- +-- Change the user,db and host tables to MySQL 4.0 format +-- + # Detect whether we had Show_db_priv SET @hadShowDbPriv:=0; SELECT @hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%'; ALTER TABLE user -ADD Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER alter_priv, +ADD Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Alter_priv, ADD Super_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Show_db_priv, ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Super_priv, ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv, @@ -86,13 +106,24 @@ ADD Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Lock_tables_priv, ADD Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Execute_priv, ADD Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Repl_slave_priv; -UPDATE user SET show_db_priv= select_priv, super_priv=process_priv, execute_priv=process_priv, create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=file_priv where user<>"" AND @hadShowDbPriv = 0; +-- Convert privileges so that users have similar privileges as before + +UPDATE user SET Show_db_priv= Select_priv, Super_priv=Process_priv, Execute_priv=Process_priv, Create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=File_priv where user<>"" AND @hadShowDbPriv = 0; + + +-- Add fields that can be used to limit number of questions and connections +-- for some users. ALTER TABLE user ADD max_questions int(11) NOT NULL AFTER x509_subject, ADD max_updates int(11) unsigned NOT NULL AFTER max_questions, ADD max_connections int(11) unsigned NOT NULL AFTER max_updates; + +-- +-- Add Create_tmp_table_priv and Lock_tables_priv to db and host +-- + ALTER TABLE db ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL; @@ -100,6 +131,20 @@ ALTER TABLE host ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL; +alter table db change Db Db char(64) binary DEFAULT '' NOT NULL; +alter table host change Db Db char(64) binary DEFAULT '' NOT NULL; +alter table user change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL; +alter table tables_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL; +alter table tables_priv add KEY Grantor (Grantor); +alter table columns_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL, change Column_name Column_name char(64) binary DEFAULT '' NOT NULL; + +alter table db comment='Database privileges'; +alter table host comment='Host privileges; Merged with database privileges'; +alter table user comment='Users and global privileges'; +alter table func comment='User defined functions'; +alter table tables_priv comment='Table privileges'; +alter table columns_priv comment='Column privileges'; + # # Create some possible missing tables # diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 78e4e3386b2..284444090bb 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -914,8 +914,9 @@ int load_master_data(THD* thd) setting active_mi, because init_master_info() sets active_mi with defaults. */ - if (init_master_info(active_mi, master_info_file, relay_log_info_file, 0)) - send_error(&thd->net, ER_MASTER_INFO); + if (init_master_info(active_mi, master_info_file, relay_log_info_file, + 0)) + send_error(thd, ER_MASTER_INFO); strmake(active_mi->master_log_name, row[0], sizeof(active_mi->master_log_name)); active_mi->master_log_pos = strtoull(row[1], (char**) 0, 10); |