Commit 7f2c50f7 authored by unknown's avatar unknown

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
parent 3946dcff
...@@ -109,6 +109,7 @@ MYSQL_MANAGER* manager=0; ...@@ -109,6 +109,7 @@ MYSQL_MANAGER* manager=0;
static char **default_argv; static char **default_argv;
static const char *load_default_groups[]= { "mysqltest","client",0 }; 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* file_stack[MAX_INCLUDE_DEPTH];
static FILE** cur_file; static FILE** cur_file;
...@@ -885,7 +886,10 @@ int do_exec(struct st_query* q) ...@@ -885,7 +886,10 @@ int do_exec(struct st_query* q)
if (disable_result_log) if (disable_result_log)
{ {
while (fgets(buf, sizeof(buf), res_file)) while (fgets(buf, sizeof(buf), res_file))
{} {
buf[strlen(buf)-1]=0;
DBUG_PRINT("exec_result",("%s", buf));
}
} }
else else
{ {
...@@ -1648,24 +1652,48 @@ int do_while(struct st_query* q) ...@@ -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; uint i,j;
int tmp[MAX_DELIMITER]= {0}; char tmp[MAX_DELIMITER];
if (c != *delimiter)
return 0;
for (i= 0; c == *(delimiter + i) && i < delimiter_length; for (i= 1; i < delimiter_length &&
i++, c= fgetc(*cur_file)) (c= my_getc(*cur_file)) == *(delimiter + i);
i++)
tmp[i]= c; tmp[i]= c;
tmp[i]= c;
for (j= i; j > 0 && i != delimiter_length; j--)
ungetc(tmp[j], *cur_file);
if (i == delimiter_length) if (i == delimiter_length)
{ return 1; /* Found delimiter */
ungetc(tmp[i], *cur_file);
*p= 0; /* didn't find delimiter, push back things that we read */
return 1; for (j = 1 ; j <= i ; j++)
} my_ungetc(tmp[j]);
return 0; return 0;
} }
...@@ -1683,7 +1711,7 @@ int read_line(char* buf, int size) ...@@ -1683,7 +1711,7 @@ int read_line(char* buf, int size)
for (; p < buf_end ;) for (; p < buf_end ;)
{ {
no_save= 0; no_save= 0;
c= fgetc(*cur_file); c= my_getc(*cur_file);
if (feof(*cur_file)) if (feof(*cur_file))
{ {
if ((*cur_file) != stdin) if ((*cur_file) != stdin)
...@@ -1698,8 +1726,11 @@ int read_line(char* buf, int size) ...@@ -1698,8 +1726,11 @@ int read_line(char* buf, int size)
switch(state) { switch(state) {
case R_NORMAL: case R_NORMAL:
/* Only accept '{' in the beginning of a line */ /* Only accept '{' in the beginning of a line */
if (end_of_query(c, p)) if (end_of_query(c))
{
*p= 0;
return 0; return 0;
}
else if (c == '\'') else if (c == '\'')
state = R_Q1; state = R_Q1;
else if (c == '"') else if (c == '"')
...@@ -1735,7 +1766,7 @@ int read_line(char* buf, int size) ...@@ -1735,7 +1766,7 @@ int read_line(char* buf, int size)
*buf= 0; *buf= 0;
return 0; return 0;
} }
else if (end_of_query(c, p) || c == '{') else if (end_of_query(c) || c == '{')
{ {
*p= 0; *p= 0;
return 0; return 0;
...@@ -1755,8 +1786,11 @@ int read_line(char* buf, int size) ...@@ -1755,8 +1786,11 @@ int read_line(char* buf, int size)
state= R_ESC_SLASH_Q1; state= R_ESC_SLASH_Q1;
break; break;
case R_ESC_Q_Q1: case R_ESC_Q_Q1:
if (end_of_query(c, p)) if (end_of_query(c))
{
*p= 0;
return 0; return 0;
}
if (c != '\'') if (c != '\'')
state= R_NORMAL; state= R_NORMAL;
else else
...@@ -1773,8 +1807,11 @@ int read_line(char* buf, int size) ...@@ -1773,8 +1807,11 @@ int read_line(char* buf, int size)
state= R_ESC_SLASH_Q2; state= R_ESC_SLASH_Q2;
break; break;
case R_ESC_Q_Q2: case R_ESC_Q_Q2:
if (end_of_query(c, p)) if (end_of_query(c))
{
*p= 0;
return 0; return 0;
}
if (c != '"') if (c != '"')
state= R_NORMAL; state= R_NORMAL;
else else
......
...@@ -66,27 +66,27 @@ extern const char *client_errors[]; /* Error messages */ ...@@ -66,27 +66,27 @@ extern const char *client_errors[]; /* Error messages */
#define CR_WRONG_LICENSE 2028 #define CR_WRONG_LICENSE 2028
/* new 4.1 error codes */ /* new 4.1 error codes */
#define CR_NULL_POINTER 2028 #define CR_NULL_POINTER 2029
#define CR_NO_PREPARE_STMT 2029 #define CR_NO_PREPARE_STMT 2030
#define CR_PARAMS_NOT_BOUND 2030 #define CR_PARAMS_NOT_BOUND 2031
#define CR_DATA_TRUNCATED 2031 #define CR_DATA_TRUNCATED 2032
#define CR_NO_PARAMETERS_EXISTS 2032 #define CR_NO_PARAMETERS_EXISTS 2033
#define CR_INVALID_PARAMETER_NO 2033 #define CR_INVALID_PARAMETER_NO 2034
#define CR_INVALID_BUFFER_USE 2034 #define CR_INVALID_BUFFER_USE 2035
#define CR_UNSUPPORTED_PARAM_TYPE 2035 #define CR_UNSUPPORTED_PARAM_TYPE 2036
#define CR_SHARED_MEMORY_CONNECTION 2036 #define CR_SHARED_MEMORY_CONNECTION 2037
#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2037 #define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038
#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2038 #define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039
#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2039 #define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2040
#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2040 #define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041
#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2041 #define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042
#define CR_SHARED_MEMORY_MAP_ERROR 2042 #define CR_SHARED_MEMORY_MAP_ERROR 2043
#define CR_SHARED_MEMORY_EVENT_ERROR 2043 #define CR_SHARED_MEMORY_EVENT_ERROR 2044
#define CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR 2044 #define CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR 2045
#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2045 #define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046
#define CR_CONN_UNKNOW_PROTOCOL 2046 #define CR_CONN_UNKNOW_PROTOCOL 2047
#define CR_INVALID_CONN_HANDLE 2047 #define CR_INVALID_CONN_HANDLE 2048
#define CR_SECURE_AUTH 2048 #define CR_SECURE_AUTH 2049
#define CR_FETCH_CANCELLED 2049 #define CR_FETCH_CANCELLED 2050
#define CR_NO_DATA 2050 #define CR_NO_DATA 2051
...@@ -511,7 +511,7 @@ fi ...@@ -511,7 +511,7 @@ fi
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" 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_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" 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 export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR
......
...@@ -3,6 +3,10 @@ Tables_in_db ...@@ -3,6 +3,10 @@ Tables_in_db
columns_priv columns_priv
db db
func func
help_category
help_keyword
help_relation
help_topic
host host
tables_priv tables_priv
user user
...@@ -26,7 +30,7 @@ db CREATE TABLE `db` ( ...@@ -26,7 +30,7 @@ db CREATE TABLE `db` (
`Lock_tables_priv` enum('N','Y') NOT NULL default 'N', `Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
PRIMARY KEY (`Host`,`Db`,`User`), PRIMARY KEY (`Host`,`Db`,`User`),
KEY `User` (`User`) KEY `User` (`User`)
) TYPE=MyISAM COMMENT='Database privileges' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Database privileges'
show create table host; show create table host;
Table Create Table Table Create Table
host CREATE TABLE `host` ( host CREATE TABLE `host` (
...@@ -45,13 +49,13 @@ host CREATE TABLE `host` ( ...@@ -45,13 +49,13 @@ host CREATE TABLE `host` (
`Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N', `Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N',
`Lock_tables_priv` enum('N','Y') NOT NULL default 'N', `Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
PRIMARY KEY (`Host`,`Db`) 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; show create table user;
Table Create Table Table Create Table
user CREATE TABLE `user` ( user CREATE TABLE `user` (
`Host` varchar(60) binary NOT NULL default '', `Host` varchar(60) binary NOT NULL default '',
`User` varchar(16) 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', `Select_priv` enum('N','Y') NOT NULL default 'N',
`Insert_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', `Update_priv` enum('N','Y') NOT NULL default 'N',
...@@ -81,16 +85,16 @@ user CREATE TABLE `user` ( ...@@ -81,16 +85,16 @@ user CREATE TABLE `user` (
`max_updates` int(11) unsigned NOT NULL default '0', `max_updates` int(11) unsigned NOT NULL default '0',
`max_connections` int(11) unsigned NOT NULL default '0', `max_connections` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`Host`,`User`) 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; show create table func;
Table Create Table Table Create Table
func CREATE TABLE `func` ( func CREATE TABLE `func` (
`name` char(64) NOT NULL default '', `name` char(64) binary NOT NULL default '',
`ret` tinyint(1) NOT NULL default '0', `ret` tinyint(1) NOT NULL default '0',
`dl` char(128) NOT NULL default '', `dl` char(128) NOT NULL default '',
`type` enum('function','aggregate') NOT NULL default 'function', `type` enum('function','aggregate') NOT NULL default 'function',
PRIMARY KEY (`name`) PRIMARY KEY (`name`)
) TYPE=MyISAM COMMENT='User defined functions' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='User defined functions'
show create table tables_priv; show create table tables_priv;
Table Create Table Table Create Table
tables_priv CREATE TABLE `tables_priv` ( tables_priv CREATE TABLE `tables_priv` (
...@@ -99,12 +103,12 @@ tables_priv CREATE TABLE `tables_priv` ( ...@@ -99,12 +103,12 @@ tables_priv CREATE TABLE `tables_priv` (
`User` char(16) binary NOT NULL default '', `User` char(16) binary NOT NULL default '',
`Table_name` char(64) binary NOT NULL default '', `Table_name` char(64) binary NOT NULL default '',
`Grantor` char(77) 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 '', `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 '', `Column_priv` set('Select','Insert','Update','References') NOT NULL default '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`), PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`) KEY `Grantor` (`Grantor`)
) TYPE=MyISAM COMMENT='Table privileges' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Table privileges'
show create table columns_priv; show create table columns_priv;
Table Create Table Table Create Table
columns_priv CREATE TABLE `columns_priv` ( columns_priv CREATE TABLE `columns_priv` (
...@@ -113,7 +117,7 @@ columns_priv CREATE TABLE `columns_priv` ( ...@@ -113,7 +117,7 @@ columns_priv CREATE TABLE `columns_priv` (
`User` char(16) binary NOT NULL default '', `User` char(16) binary NOT NULL default '',
`Table_name` char(64) binary NOT NULL default '', `Table_name` char(64) binary NOT NULL default '',
`Column_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 '', `Column_priv` set('Select','Insert','Update','References') NOT NULL default '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`) PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
) TYPE=MyISAM COMMENT='Column privileges' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Column privileges'
...@@ -907,3 +907,18 @@ n ...@@ -907,3 +907,18 @@ n
9 9
10 10
drop table t1; 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;
...@@ -157,7 +157,8 @@ UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) ...@@ -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; 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; 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; 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; 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 -- 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; 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;
......
...@@ -10,27 +10,39 @@ set @name="This is a very long string, that mustn't find room in a system field ...@@ -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; create table test_db select * from mysql.db;
delete from test_db; delete from test_db;
--disable_warnings
insert into test_db (Host,Db,User) values (@name,@name,@name); insert into test_db (Host,Db,User) values (@name,@name,@name);
--enable_warnings
create table test_host select * from mysql.host; create table test_host select * from mysql.host;
delete from test_host; delete from test_host;
--disable_warnings
insert into test_host (Host,Db) values (@name,@name); insert into test_host (Host,Db) values (@name,@name);
--enable_warnings
create table test_user select * from mysql.user; create table test_user select * from mysql.user;
delete from test_user; delete from test_user;
--disable_warnings
insert into test_user (Host,User) values (@name,@name); insert into test_user (Host,User) values (@name,@name);
--enable_warnings
create table test_func select * from mysql.func; create table test_func select * from mysql.func;
delete from test_func; delete from test_func;
--disable_warnings
insert into test_func (name) values (@name); insert into test_func (name) values (@name);
--enable_warnings
create table test_tables_priv select * from mysql.tables_priv; create table test_tables_priv select * from mysql.tables_priv;
delete from test_tables_priv; delete from test_tables_priv;
--disable_warnings
insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name); 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; create table test_columns_priv select * from mysql.columns_priv;
delete from test_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); 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: # 'Host' field must be the same for all the tables:
......
...@@ -483,3 +483,16 @@ select col1 n from t1 union select col2 n from t1 order by n; ...@@ -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); alter table t1 add index myindex (col2);
select col1 n from t1 union select col2 n from t1 order by n; select col1 n from t1 union select col2 n from t1 order by n;
drop table t1; 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;
...@@ -188,7 +188,7 @@ then ...@@ -188,7 +188,7 @@ then
c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL," 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 Db char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t User char(16) 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 Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14)," 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," c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
......
...@@ -56,21 +56,15 @@ parse_arguments() { ...@@ -56,21 +56,15 @@ parse_arguments() {
# Get first arguments from the my.cfg file, groups [mysqld] and # Get first arguments from the my.cfg file, groups [mysqld] and
# [mysql_install_db], and then merge with the command line arguments # [mysql_install_db], and then merge with the command line arguments
if test -x ./bin/my_print_defaults
then for dir in ./bin @bindir@ @bindir@ extra $bindir/../bin $bindir/../extra
print_defaults="./bin/my_print_defaults" do
elif test -x @bindr@/my_print_defaults if test -x $dir/my_print_defaults
then then
print_defaults="@bindir@/my_print_defaults" print_defaults="$dir/my_print_defaults"
elif test -x @bindir@/mysql_print_defaults break
then fi
print_defaults="@bindir@/mysql_print_defaults" done
elif test -x extra/my_print_defaults
then
print_defaults="extra/my_print_defaults"
else
print_defaults="my_print_defaults"
fi
parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables` parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
parse_arguments PICK-ARGS-FROM-ARGV "$@" parse_arguments PICK-ARGS-FROM-ARGV "$@"
...@@ -109,7 +103,6 @@ fi ...@@ -109,7 +103,6 @@ fi
cmd="$bindir/mysql -f --user=$user --host=$host" cmd="$bindir/mysql -f --user=$user --host=$host"
if test -z "$password" ; then if test -z "$password" ; then
else
cmd="$cmd --password=$password" cmd="$cmd --password=$password"
fi fi
if test ! -z "$port"; then if test ! -z "$port"; then
......
...@@ -7,19 +7,18 @@ ...@@ -7,19 +7,18 @@
-- On unix, you should use the mysql_fix_privilege_tables script to execute -- On unix, you should use the mysql_fix_privilege_tables script to execute
-- this sql script. -- 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 user type=MyISAM;
ALTER TABLE db type=MyISAM; ALTER TABLE db type=MyISAM;
ALTER TABLE host type=MyISAM; ALTER TABLE host type=MyISAM;
ALTER TABLE func type=MyISAM; ALTER TABLE func type=MyISAM;
ALTER TABLE columns_priv type=MyISAM; ALTER TABLE columns_priv type=MyISAM;
ALTER TABLE tables_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; ALTER TABLE user add File_priv enum('N','Y') NOT NULL;
CREATE TABLE IF NOT EXISTS func ( 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, ret tinyint(1) DEFAULT '0' NOT NULL,
dl char(128) DEFAULT '' NOT NULL, dl char(128) DEFAULT '' NOT NULL,
type enum ('function','aggregate') 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 ...@@ -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 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; 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 ALTER TABLE user
ADD ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL, ADD ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL,
ADD ssl_cipher BLOB NOT NULL, ADD ssl_cipher BLOB NOT NULL,
...@@ -46,11 +49,15 @@ ADD x509_issuer BLOB NOT NULL, ...@@ -46,11 +49,15 @@ ADD x509_issuer BLOB NOT NULL,
ADD x509_subject BLOB NOT NULL; ADD x509_subject BLOB NOT NULL;
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') 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 ( CREATE TABLE IF NOT EXISTS tables_priv (
Host char(60) DEFAULT '' NOT NULL, Host char(60) binary DEFAULT '' NOT NULL,
Db char(60) DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL,
User char(16) DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL,
Table_name char(60) DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL,
Grantor char(77) DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL,
Timestamp timestamp(14), Timestamp timestamp(14),
Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL, 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 ( ...@@ -69,16 +76,29 @@ CREATE TABLE IF NOT EXISTS columns_priv (
PRIMARY KEY (Host,Db,User,Table_name,Column_name) 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; 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; 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 # Detect whether we had Show_db_priv
SET @hadShowDbPriv:=0; SET @hadShowDbPriv:=0;
SELECT @hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%'; SELECT @hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%';
ALTER TABLE user 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 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 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, 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, ...@@ -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_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; 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 ALTER TABLE user
ADD max_questions int(11) NOT NULL AFTER x509_subject, ADD max_questions int(11) NOT NULL AFTER x509_subject,
ADD max_updates int(11) unsigned NOT NULL AFTER max_questions, ADD max_updates int(11) unsigned NOT NULL AFTER max_questions,
ADD max_connections int(11) unsigned NOT NULL AFTER max_updates; 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 ALTER TABLE db
ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
ADD Lock_tables_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 ...@@ -100,6 +131,20 @@ ALTER TABLE host
ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
ADD Lock_tables_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 # Create some possible missing tables
# #
......
...@@ -914,8 +914,9 @@ int load_master_data(THD* thd) ...@@ -914,8 +914,9 @@ int load_master_data(THD* thd)
setting active_mi, because init_master_info() sets active_mi with setting active_mi, because init_master_info() sets active_mi with
defaults. defaults.
*/ */
if (init_master_info(active_mi, master_info_file, relay_log_info_file, 0)) if (init_master_info(active_mi, master_info_file, relay_log_info_file,
send_error(&thd->net, ER_MASTER_INFO); 0))
send_error(thd, ER_MASTER_INFO);
strmake(active_mi->master_log_name, row[0], strmake(active_mi->master_log_name, row[0],
sizeof(active_mi->master_log_name)); sizeof(active_mi->master_log_name));
active_mi->master_log_pos = strtoull(row[1], (char**) 0, 10); active_mi->master_log_pos = strtoull(row[1], (char**) 0, 10);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment