From 4edc7584de56a162a343c4166a06f74916bd80ff Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 5 Mar 2004 18:09:32 +0100 Subject: [PATCH 01/13] comment clarified --- mysys/mf_soundex.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysys/mf_soundex.c b/mysys/mf_soundex.c index 4f7aa7da601..6409caa356d 100644 --- a/mysys/mf_soundex.c +++ b/mysys/mf_soundex.c @@ -28,6 +28,10 @@ * * * As an extension if remove_garbage is set then all non- * * alpha characters are skipped * +* * +* Note, that this implementation corresponds to the * +* original version of the algorithm, not to the more * +* popular "enhanced" version, described by Knuth. * ****************************************************************/ #include "mysys_priv.h" From 0f3600d51eb8f9bc48ea4bd89730e21153627bc9 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Wed, 17 Mar 2004 10:35:03 +0100 Subject: [PATCH 02/13] Fix for BUG#2922 "Crash (signal11) after "load data from master"" with a testcase. We needed to init_master_info before we flush_master_info in LOAD DATA FROM MASTER. --- mysql-test/r/rpl000009.result | 12 ++++++++++++ mysql-test/t/rpl000009.test | 15 +++++++++++++++ sql/repl_failsafe.cc | 12 ++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/rpl000009.result b/mysql-test/r/rpl000009.result index 569dd301143..a4611cf7d42 100644 --- a/mysql-test/r/rpl000009.result +++ b/mysql-test/r/rpl000009.result @@ -111,6 +111,18 @@ n s 2 two bar 3 three bar 4 four bar +stop slave; +reset slave; +load data from master; +start slave; +insert into bar.t1 values (5, 'five bar'); +select * from bar.t1; +n s +1 one bar +2 two bar +3 three bar +4 four bar +5 five bar load table bar.t1 from master; Table 't1' already exists drop table bar.t1; diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test index e019e1fc3a7..4426cafe299 100644 --- a/mysql-test/t/rpl000009.test +++ b/mysql-test/t/rpl000009.test @@ -108,6 +108,21 @@ connection slave; sync_with_master; select * from bar.t1; +# Check that LOAD DATA FROM MASTER is able to create master.info +# if needed (if RESET SLAVE was used before), before writing to it (BUG#2922). + +stop slave; +reset slave; +load data from master; +start slave; +# see if replication coordinates were restored fine +connection master; +insert into bar.t1 values (5, 'five bar'); +save_master_pos; +connection slave; +sync_with_master; +select * from bar.t1; + # Check that LOAD DATA FROM MASTER reports the error if it can't drop a # table to be overwritten. # DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index e687b227946..1edf452d5f6 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -874,7 +874,7 @@ int load_master_data(THD* thd) cleanup_mysql_results(db_res, cur_table_res - 1, table_res); - // adjust position in the master + // adjust replication coordinates from the master if (master_status_res) { MYSQL_ROW row = mc_mysql_fetch_row(master_status_res); @@ -887,10 +887,18 @@ int load_master_data(THD* thd) */ if (row && row[0] && row[1]) { + /* + If the slave's master info is not inited, we init it, then we write + the new coordinates to it. Must call init_master_info() *before* + 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); 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); - // don't hit the magic number + // at least in recent versions, the condition below should be false if (active_mi->master_log_pos < BIN_LOG_HEADER_SIZE) active_mi->master_log_pos = BIN_LOG_HEADER_SIZE; active_mi->rli.pending = 0; From b42746f7eb7aaaffca198cb4160632f23302e088 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Wed, 17 Mar 2004 21:01:07 +0400 Subject: [PATCH 03/13] fixed structure error from last merge for bug #2874 --- mysql-test/t/reserv/system_mysql_db_fix.test | 14 -- .../t/{reserv => }/system_mysql_db.test | 16 +- .../system_mysql_db_fix-master.opt | 0 mysql-test/t/system_mysql_db_fix.test | 78 ++++++++ .../t/{reserv => }/system_mysql_db_refs.test | 179 +++++++++--------- 5 files changed, 176 insertions(+), 111 deletions(-) delete mode 100644 mysql-test/t/reserv/system_mysql_db_fix.test rename mysql-test/t/{reserv => }/system_mysql_db.test (95%) rename mysql-test/t/{reserv => }/system_mysql_db_fix-master.opt (100%) create mode 100644 mysql-test/t/system_mysql_db_fix.test rename mysql-test/t/{reserv => }/system_mysql_db_refs.test (97%) diff --git a/mysql-test/t/reserv/system_mysql_db_fix.test b/mysql-test/t/reserv/system_mysql_db_fix.test deleted file mode 100644 index bb2d37ee215..00000000000 --- a/mysql-test/t/reserv/system_mysql_db_fix.test +++ /dev/null @@ -1,14 +0,0 @@ -# -# This is the test for mysql_fix_privilege_tables -# - --- disable_query_log --- source include/create_old_system_tables.inc --- exec $MYSQL_FIX_SYSTEM_TABLES --database=test > nil 2>nil --- enable_query_log - --- source include/system_db_struct.inc - --- disable_query_log --- source include/drop_system_tables.inc --- enable_query_log diff --git a/mysql-test/t/reserv/system_mysql_db.test b/mysql-test/t/system_mysql_db.test similarity index 95% rename from mysql-test/t/reserv/system_mysql_db.test rename to mysql-test/t/system_mysql_db.test index 85a2f7f9bae..bd69297b739 100644 --- a/mysql-test/t/reserv/system_mysql_db.test +++ b/mysql-test/t/system_mysql_db.test @@ -1,8 +1,8 @@ -# -# This test must examine integrity of system database "mysql" -# - --- disable_query_log -use mysql; --- enable_query_log --- source include/system_db_struct.inc +# +# This test must examine integrity of system database "mysql" +# + +-- disable_query_log +use mysql; +-- enable_query_log +-- source include/system_db_struct.inc diff --git a/mysql-test/t/reserv/system_mysql_db_fix-master.opt b/mysql-test/t/system_mysql_db_fix-master.opt similarity index 100% rename from mysql-test/t/reserv/system_mysql_db_fix-master.opt rename to mysql-test/t/system_mysql_db_fix-master.opt diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test new file mode 100644 index 00000000000..3cb5d93e2f6 --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix.test @@ -0,0 +1,78 @@ +# +# This is the test for mysql_fix_privilege_tables +# + +-- disable_result_log +-- disable_query_log + +use test; + +# create system tables as in mysql-3.20 + +CREATE TABLE db ( + Host char(60) binary DEFAULT '' NOT NULL, + Db char(32) binary DEFAULT '' NOT NULL, + User char(16) binary DEFAULT '' NOT NULL, + Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, + PRIMARY KEY Host (Host,Db,User), + KEY User (User) +) +type=ISAM; + +INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); +INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y'); + +CREATE TABLE host ( + Host char(60) binary DEFAULT '' NOT NULL, + Db char(32) binary DEFAULT '' NOT NULL, + Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, + PRIMARY KEY Host (Host,Db) +) +type=ISAM; + +CREATE TABLE user ( + Host char(60) binary DEFAULT '' NOT NULL, + User char(16) binary DEFAULT '' NOT NULL, + Password char(16), + Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, + PRIMARY KEY Host (Host,User) +) +type=ISAM; + +INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y'); +INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N'); + +-- exec $MYSQL_FIX_SYSTEM_TABLES --database=test +-- enable_query_log +-- enable_result_log + +-- source include/system_db_struct.inc + +-- disable_query_log + +DROP TABLE db; +DROP TABLE host; +DROP TABLE user; +DROP TABLE func; +DROP TABLE tables_priv; +DROP TABLE columns_priv; + +-- enable_query_log diff --git a/mysql-test/t/reserv/system_mysql_db_refs.test b/mysql-test/t/system_mysql_db_refs.test similarity index 97% rename from mysql-test/t/reserv/system_mysql_db_refs.test rename to mysql-test/t/system_mysql_db_refs.test index d15141fdaa5..be47f1ba5bf 100644 --- a/mysql-test/t/reserv/system_mysql_db_refs.test +++ b/mysql-test/t/system_mysql_db_refs.test @@ -1,89 +1,90 @@ -# -# This test must examine integrity of current system database -# - -set @name="This is a very long string, that mustn't find room in a system field like Table_name. Thus it should be cut by the actual size of the field. So we can use this string to find out the actual length of the field and to use it in any compare queries"; - -# -# If this part is wrong, most likely you've done wrong modification of system database "mysql" -# - -create table test_db select * from mysql.db; -delete from test_db; -insert into test_db (Host,Db,User) values (@name,@name,@name); - -create table test_host select * from mysql.host; -delete from test_host; -insert into test_host (Host,Db) values (@name,@name); - -create table test_user select * from mysql.user; -delete from test_user; -insert into test_user (Host,User) values (@name,@name); - -create table test_func select * from mysql.func; -delete from test_func; -insert into test_func (name) values (@name); - -create table test_tables_priv select * from mysql.tables_priv; -delete from test_tables_priv; -insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name); - -create table test_columns_priv select * from mysql.columns_priv; -delete from test_columns_priv; -insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name); - -# 'Host' field must be the same for all the tables: - -select - if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host, - if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host, - if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host, - if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host, - if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host - -from test_db -left join test_host on test_db.Host=test_host.Host -left join test_user on test_db.Host=test_user.Host -left join test_tables_priv on test_db.Host=test_tables_priv.Host -left join test_columns_priv on test_db.Host=test_columns_priv.Host; - -# 'Db' field must be the same for all the tables: - -select - if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, - if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, - if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, - if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db - -from test_db -left join test_host on test_db.Db=test_host.Db -left join test_tables_priv on test_db.Db=test_tables_priv.Db -left join test_columns_priv on test_db.Db=test_columns_priv.Db; - -# 'User' field must be the same for all the tables: - -select - if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User, - if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User, - if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, - if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User - -from test_db -left join test_user on test_db.User=test_user.User -left join test_tables_priv on test_db.User=test_tables_priv.User -left join test_columns_priv on test_db.User=test_columns_priv.User; - -# 'Table_name' field must be the same for all the tables: - -select - if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, - if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User -from test_tables_priv -left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name; - -drop table test_columns_priv; -drop table test_tables_priv; -drop table test_func; -drop table test_host; -drop table test_user; -drop table test_db; +# +# This test must examine integrity of current system database +# + +set @name="This is a very long string, that mustn't find room in a system field like Table_name. Thus it should be cut by the actual size of the field. So we can use this string to find out the actual length of the field and to use it in any compare queries"; + +# +# If this part is wrong, most likely you've done wrong modification of system database "mysql" +# + +create table test_db select * from mysql.db; +delete from test_db; +insert into test_db (Host,Db,User) values (@name,@name,@name); + +create table test_host select * from mysql.host; +delete from test_host; +insert into test_host (Host,Db) values (@name,@name); + +create table test_user select * from mysql.user; +delete from test_user; +insert into test_user (Host,User) values (@name,@name); + +create table test_func select * from mysql.func; +delete from test_func; +insert into test_func (name) values (@name); + +create table test_tables_priv select * from mysql.tables_priv; +delete from test_tables_priv; +insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name); + +create table test_columns_priv select * from mysql.columns_priv; +delete from test_columns_priv; +insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name); + +# 'Host' field must be the same for all the tables: + +select + if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host, + if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host, + if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host, + if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host, + if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host + +from test_db +left join test_host on test_db.Host=test_host.Host +left join test_user on test_db.Host=test_user.Host +left join test_tables_priv on test_db.Host=test_tables_priv.Host +left join test_columns_priv on test_db.Host=test_columns_priv.Host; + +# 'Db' field must be the same for all the tables: + +select + if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, + if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, + if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, + if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db + +from test_db +left join test_host on test_db.Db=test_host.Db +left join test_tables_priv on test_db.Db=test_tables_priv.Db +left join test_columns_priv on test_db.Db=test_columns_priv.Db; + +# 'User' field must be the same for all the tables: + +select + if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User, + if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User, + if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, + if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User + +from test_db +left join test_user on test_db.User=test_user.User +left join test_tables_priv on test_db.User=test_tables_priv.User +left join test_columns_priv on test_db.User=test_columns_priv.User; + +# 'Table_name' field must be the same for all the tables: + +select + if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, + if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User +from test_tables_priv +left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name; + +drop table test_columns_priv; +drop table test_tables_priv; +drop table test_func; +drop table test_host; +drop table test_user; +drop table test_db; + From b9f51f7081a939132201689b98f180ab90245e0f Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Wed, 17 Mar 2004 20:04:50 +0300 Subject: [PATCH 04/13] WL #1510 "Implement support for "commercial" binaries on handshake", client library: - implemented 'check_license' function --- include/errmsg.h | 1 + include/mysql_version.h.in | 5 ++++ libmysql/errmsg.c | 9 ++++--- libmysql/libmysql.c | 54 ++++++++++++++++++++++++++++++++++++++ sql/set_var.cc | 4 +-- 5 files changed, 67 insertions(+), 6 deletions(-) diff --git a/include/errmsg.h b/include/errmsg.h index 5136af5b87a..24ebe24d786 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -63,4 +63,5 @@ extern const char *client_errors[]; /* Error messages */ #define CR_PROBE_MASTER_CONNECT 2025 #define CR_SSL_CONNECTION_ERROR 2026 #define CR_MALFORMED_PACKET 2027 +#define CR_WRONG_LICENSE 2028 diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in index 41d4ce081fb..de5294a82cf 100644 --- a/include/mysql_version.h.in +++ b/include/mysql_version.h.in @@ -26,4 +26,9 @@ #define MYSQL_CHARSET "@default_charset@" #endif /* MYSQL_CHARSET */ #endif /* _CUSTOMCONFIG_ */ + +#ifndef LICENSE +#define LICENSE "GPL" +#endif /* LICENSE */ + #endif /* _mysql_version_h */ diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 7accbf8f1d2..06d21cf36c3 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -51,7 +51,8 @@ const char *client_errors[]= "Error connecting to slave:", "Error connecting to master:", "SSL connection error", - "Malformed packet" + "Malformed packet", + "This client library is licensed only for use with MySQL servers having '%s' license" }; /* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */ @@ -86,7 +87,8 @@ const char *client_errors[]= "Error connecting to slave:", "Error connecting to master:", "SSL connection error", - "Malformed packet" + "Malformed packet", + "This client library is licensed only for use with MySQL servers having '%s' license" }; #else /* ENGLISH */ @@ -119,7 +121,8 @@ const char *client_errors[]= "Error connecting to slave:", "Error connecting to master:", "SSL connection error", - "Malformed packet" + "Malformed packet", + "This client library is licensed only for use with MySQL servers having '%s' license" }; #endif diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index f2d77d495c9..6a4189b6b18 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1612,6 +1612,56 @@ mysql_connect(MYSQL *mysql,const char *host, #endif +#ifdef CHECK_LICENSE +/* + Check server side variable 'license'. + If the variable does not exist or does not contain 'Commercial', + we're talking to non-commercial server from commercial client. + SYNOPSIS + check_license() + RETURN VALUE + 0 success + !0 network error or the server is not commercial. + Error code is saved in mysql->net.last_errno. +*/ + +static int check_license(MYSQL *mysql) +{ + MYSQL_ROW row; + MYSQL_RES *res; + NET *net= &mysql->net; + static const char query[]= "SELECT @@license"; + static const char required_license[]= LICENSE; + + if (mysql_real_query(mysql, query, sizeof(query)-1)) + { + if (net->last_errno == ER_UNKNOWN_SYSTEM_VARIABLE) + { + net->last_errno= CR_WRONG_LICENSE; + sprintf(net->last_error, ER(net->last_errno), required_license); + } + return 1; + } + if (!(res= mysql_use_result(mysql))) + return 1; + row= mysql_fetch_row(res); + /* + If no rows in result set, or column value is NULL (none of these + two is ever true for server variables now), or column value + mismatch, set wrong license error. + */ + if (!net->last_errno && + (!row || !row[0] || + strncmp(row[0], required_license, sizeof(required_license)))) + { + net->last_errno= CR_WRONG_LICENSE; + sprintf(net->last_error, ER(net->last_errno), required_license); + } + mysql_free_result(res); + return net->last_errno; +} +#endif /* CHECK_LICENSE */ + /* The following union is used to force a struct to be double allgined. This is to avoid warings with gethostname_r() on Linux itanium systems @@ -2048,6 +2098,10 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, net->compress=1; if (mysql->options.max_allowed_packet) net->max_packet_size= mysql->options.max_allowed_packet; +#ifdef CHECK_LICENSE + if (check_license(mysql)) + goto error; +#endif if (db && mysql_select_db(mysql,db)) goto error; if (mysql->options.init_command) diff --git a/sql/set_var.cc b/sql/set_var.cc index 71c0865dd91..eb94ad2ebf6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -334,14 +334,12 @@ static sys_var_rand_seed2 sys_rand_seed2("rand_seed2"); static sys_var_thd_ulong sys_default_week_format("default_week_format", &SV::default_week_format); -static const char license[]= "GPL"; /* Read only variables */ sys_var_const_str sys_os("version_compile_os", SYSTEM_TYPE); -sys_var_const_str sys_license("license", license); - /* Global read-only variable describing server license */ +sys_var_const_str sys_license("license", LICENSE); From b7fc7188d0959f59f0a59ce6c293ce156b8659e2 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 19 Mar 2004 14:52:48 +0200 Subject: [PATCH 05/13] Portability fixes Removed \r from new tests Fixes to get new sustem_mysql_db... tests to work --- client/mysqltest.c | 33 ++++++++++------- innobase/que/que0que.c | 8 ++--- mysql-test/mysql-test-run.sh | 49 +++++++++++++------------- mysql-test/t/system_mysql_db_fix.test | 8 ++--- mysql-test/t/system_mysql_db_refs.test | 11 +++--- scripts/mysql_fix_privilege_tables.sh | 15 ++++++-- 6 files changed, 70 insertions(+), 54 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 32fc9d9ac17..32fb44d178e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -861,18 +861,22 @@ int do_exec(struct st_query* q) char buf[1024]; FILE *res_file; char *cmd= q->first_argument; + DBUG_ENTER("do_exec"); while (*cmd && my_isspace(charset_info, *cmd)) cmd++; if (!*cmd) die("Missing argument in exec\n"); + DBUG_PRINT("info", ("Executing '%s'", cmd)); + + if (!(res_file= popen(cmd, "r")) && q->abort_on_error) + die("popen() failed\n"); + if (disable_result_log) { - if (!(res_file= popen(cmd, "r")) && q->abort_on_error) - die("popen() failed\n"); - while (fgets(buf, sizeof(buf), res_file)); - pclose(res_file); + while (fgets(buf, sizeof(buf), res_file)) + {} } else { @@ -884,11 +888,8 @@ int do_exec(struct st_query* q) else ds= &ds_res; - if (!(res_file= popen(cmd, "r")) && q->abort_on_error) - die("popen() failed\n"); while (fgets(buf, sizeof(buf), res_file)) replace_dynstr_append_mem(ds, buf, strlen(buf)); - pclose(res_file); if (glob_replace) free_replace(); @@ -907,8 +908,9 @@ int do_exec(struct st_query* q) if (ds == &ds_tmp) dynstr_free(&ds_tmp); } + pclose(res_file); - return error; + DBUG_RETURN(error); } int var_query_set(VAR* v, const char* p, const char** p_end) @@ -1043,7 +1045,7 @@ int do_system(struct st_query* q) eval_expr(&v, p, 0); /* NULL terminated */ if (v.str_val_len) { - char expr_buf[512]; + char expr_buf[1024]; if ((uint)v.str_val_len > sizeof(expr_buf) - 1) v.str_val_len = sizeof(expr_buf) - 1; memcpy(expr_buf, v.str_val, v.str_val_len); @@ -1774,11 +1776,12 @@ int read_query(struct st_query** q_ptr) char *p = read_query_buf, * p1 ; int expected_errno; struct st_query* q; + DBUG_ENTER("read_query_buf"); if (parser.current_line < parser.read_lines) { get_dynamic(&q_lines, (gptr) q_ptr, parser.current_line) ; - return 0; + DBUG_RETURN(0); } if (!(*q_ptr=q=(struct st_query*) my_malloc(sizeof(*q), MYF(MY_WME))) || insert_dynamic(&q_lines, (gptr) &q)) @@ -1797,7 +1800,7 @@ int read_query(struct st_query** q_ptr) q->type = Q_UNKNOWN; q->query_buf=q->query=0; if (read_line(read_query_buf, sizeof(read_query_buf))) - return 1; + DBUG_RETURN(1); if (*p == '#') { @@ -1851,7 +1854,7 @@ int read_query(struct st_query** q_ptr) q->first_argument=p; q->end = strend(q->query); parser.read_lines++; - return 0; + DBUG_RETURN(0); } @@ -2306,10 +2309,12 @@ void get_query_type(struct st_query* q) { char save; uint type; + DBUG_ENTER("get_query_type"); + if (*q->query == '}') { q->type = Q_END_BLOCK; - return; + DBUG_VOID_RETURN; } if (q->type != Q_COMMENT_WITH_COMMAND) q->type = Q_QUERY; @@ -2320,8 +2325,10 @@ void get_query_type(struct st_query* q) q->query[q->first_word_len]=save; if (type > 0) q->type=(enum enum_commands) type; /* Found command */ + DBUG_VOID_RETURN; } + static byte *get_var_key(const byte* var, uint* len, my_bool __attribute__((unused)) t) { diff --git a/innobase/que/que0que.c b/innobase/que/que0que.c index bff0fe61248..b90a5eb3a61 100644 --- a/innobase/que/que0que.c +++ b/innobase/que/que0que.c @@ -668,15 +668,15 @@ does nothing! */ void que_thr_handle_error( /*=================*/ - que_thr_t* thr __attribute((unused)), + que_thr_t* thr __attribute__((unused)), /* in: query thread */ - ulint err_no __attribute((unused)), + ulint err_no __attribute__((unused)), /* in: error number */ - byte* err_str __attribute((unused)), + byte* err_str __attribute__((unused)), /* in, own: error string or NULL; NOTE: the function will take care of freeing of the string! */ - ulint err_len __attribute((unused))) + ulint err_len __attribute__((unused))) /* in: error string length */ { /* Does nothing */ diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index a606a492058..4b171fafc06 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -10,7 +10,7 @@ # Access Definitions #-- DB=test -DBPASSWD= +DBPASSWD="" VERBOSE="" USE_MANAGER=0 MY_TZ=GMT-3 @@ -461,12 +461,13 @@ if [ x$SOURCE_DIST = x1 ] ; then MYSQL_TEST="strace -o $MYSQL_TEST_DIR/var/log/mysqltest.strace $MYSQL_TEST" fi - MYSQLADMIN="$BASEDIR/client/mysqladmin" + CLIENT_BINDIR="$BASEDIR/client" + MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" WAIT_PID="$BASEDIR/extra/mysql_waitpid" - MYSQL_MANAGER_CLIENT="$BASEDIR/client/mysqlmanagerc" + MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc" MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager" - MYSQL_MANAGER_PWGEN="$BASEDIR/client/mysqlmanager-pwgen" - MYSQL="$BASEDIR/client/mysql" + MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen" + MYSQL="$CLIENT_BINDIR/mysql" LANGUAGE="$BASEDIR/sql/share/english/" CHARSETSDIR="$BASEDIR/sql/share/charsets" INSTALL_DB="./install_test_db" @@ -478,17 +479,18 @@ else else MYSQLD="$VALGRIND $BASEDIR/bin/mysqld" fi - MYSQL_TEST="$BASEDIR/bin/mysqltest" - MYSQL_DUMP="$BASEDIR/bin/mysqldump" - MYSQL_BINLOG="$BASEDIR/bin/mysqlbinlog" - MYSQLADMIN="$BASEDIR/bin/mysqladmin" - WAIT_PID="$BASEDIR/bin/mysql_waitpid" - MYSQL_MANAGER="$BASEDIR/bin/mysqlmanager" - MYSQL_MANAGER_CLIENT="$BASEDIR/bin/mysqlmanagerc" - MYSQL_MANAGER_PWGEN="$BASEDIR/bin/mysqlmanager-pwgen" - MYSQL="$BASEDIR/bin/mysql" + CLIENT_BINDIR="$BASEDIR/bin" + MYSQL_TEST="$CLIENT_BINDIR/mysqltest" + MYSQL_DUMP="$CLIENT_BINDIR/mysqldump" + MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog" + MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" + WAIT_PID="$CLIENT_BINDIR/mysql_waitpid" + MYSQL_MANAGER="$CLIENT_BINDIR/mysqlmanager" + MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc" + MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen" + MYSQL="$CLIENT_BINDIR/mysql" INSTALL_DB="./install_test_db --bin" - MYSQL_FIX_SYSTEM_TABLES="$BASEDIR/bin/mysql_fix_privilege_tables" + MYSQL_FIX_SYSTEM_TABLES="$CLIENT_BINDIR/mysql_fix_privilege_tables" if test -d "$BASEDIR/share/mysql/english" then LANGUAGE="$BASEDIR/share/mysql/english/" @@ -499,14 +501,11 @@ else fi fi -MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK" +MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR" -MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=" -MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=" -export MYSQL -export MYSQL_DUMP -export MYSQL_BINLOG -export MYSQL_FIX_SYSTEM_TABLES +MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --bindir=$CLIENT_BINDIR" +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 if [ -z "$MASTER_MYSQLD" ] then @@ -534,9 +533,9 @@ fi if [ -w / ] then - # We are running as root; We need to add the --root argument - EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --user=root" - EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root" + # We are running as root; We need to add the --root argument + EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --user=root" + EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root" fi diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test index 3cb5d93e2f6..6f3979bf66e 100644 --- a/mysql-test/t/system_mysql_db_fix.test +++ b/mysql-test/t/system_mysql_db_fix.test @@ -23,10 +23,10 @@ CREATE TABLE db ( KEY User (User) ) type=ISAM; - + INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y'); - + CREATE TABLE host ( Host char(60) binary DEFAULT '' NOT NULL, Db char(32) binary DEFAULT '' NOT NULL, @@ -39,7 +39,7 @@ CREATE TABLE host ( PRIMARY KEY Host (Host,Db) ) type=ISAM; - + CREATE TABLE user ( Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, @@ -56,7 +56,7 @@ CREATE TABLE user ( PRIMARY KEY Host (Host,User) ) type=ISAM; - + INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y'); INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N'); diff --git a/mysql-test/t/system_mysql_db_refs.test b/mysql-test/t/system_mysql_db_refs.test index be47f1ba5bf..49d6f198b32 100644 --- a/mysql-test/t/system_mysql_db_refs.test +++ b/mysql-test/t/system_mysql_db_refs.test @@ -34,13 +34,13 @@ insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@nam # 'Host' field must be the same for all the tables: -select +select if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host, if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host, if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host, if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host, if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host - + from test_db left join test_host on test_db.Host=test_host.Host left join test_user on test_db.Host=test_user.Host @@ -49,12 +49,12 @@ left join test_columns_priv on test_db.Host=test_columns_priv.Host; # 'Db' field must be the same for all the tables: -select +select if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db - + from test_db left join test_host on test_db.Db=test_host.Db left join test_tables_priv on test_db.Db=test_tables_priv.Db @@ -67,7 +67,7 @@ select if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User, if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User - + from test_db left join test_user on test_db.User=test_user.User left join test_tables_priv on test_db.User=test_tables_priv.User @@ -87,4 +87,3 @@ drop table test_func; drop table test_host; drop table test_user; drop table test_db; - diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 5e3e4210aa4..1dac3ebc725 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -32,13 +32,23 @@ # --password= # --database= -root_password="$1" +root_password="" host="localhost" user="root" port="" socket="" comment="" database="mysql" +bindir="@bindir@" + +# Old format where there is only one argument and it's the password +if test "$#" == 1 +then + case "$1" in + --*) ;; + *) root_password="$1" ; shift ;; + esac +fi # read all the options parse_arguments() @@ -52,6 +62,7 @@ parse_arguments() --socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;; --password=*) root_password=`echo "$arg" | sed -e "s;--password=;;"` ;; --database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;; + --bindir=*) bindir=`echo "$arg" | sed -e "s;--bindir=;;"` ;; *) echo "Unknown argument '$arg'" exit 1 @@ -63,7 +74,7 @@ parse_arguments() parse_arguments "$@" if test -z "$cmd"; then - cmd="@bindir@/mysql -f --user=$user --host=$host" + cmd="$bindir/mysql -f --user=$user --host=$host" if test ! -z "$root_password"; then cmd="$cmd --password=$root_password" fi From f375eb50f86bee97281819d8360ab14f685ba12f Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 19 Mar 2004 15:03:12 +0200 Subject: [PATCH 06/13] Removed \r --- mysql-test/r/system_mysql_db_refs.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/system_mysql_db_refs.result b/mysql-test/r/system_mysql_db_refs.result index a08b46ffbbb..e15934b03ac 100644 --- a/mysql-test/r/system_mysql_db_refs.result +++ b/mysql-test/r/system_mysql_db_refs.result @@ -17,7 +17,7 @@ insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name create table test_columns_priv select * from mysql.columns_priv; delete from test_columns_priv; insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name); -select +select if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host, if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host, if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host, @@ -30,7 +30,7 @@ left join test_tables_priv on test_db.Host=test_tables_priv.Host left join test_columns_priv on test_db.Host=test_columns_priv.Host; test_db_Host test_host_Host test_user_Host test_tables_priv_Host test_columns_priv_Host ok ok ok ok ok -select +select if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, From b4577bc43a8b82cdf9071ee3dd4c2dbd53850c5b Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 19 Mar 2004 17:19:33 +0100 Subject: [PATCH 07/13] typo in mysql_install_db fixed --- scripts/mysql_install_db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 0c1502823af..012725265a1 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -118,7 +118,7 @@ then if [ $? -ne 0 ] then resolved=`$bindir/resolveip localhost 2>&1` - if [ $? -eq 0 ] + if [ $? -ne 0 ] then echo "Neither host '$hostname' and 'localhost' could not be looked up with" echo "$bindir/resolveip" From 9a1baf7d62270e659d22a60da5f9cd3eb624ff31 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 19 Mar 2004 18:26:02 +0200 Subject: [PATCH 08/13] Portability fixes Fixed some wrong column specifications in mysql_fix_privilege_tables --- mysql-test/mysql-test-run.sh | 2 +- mysql-test/r/func_math.result | 9 --------- mysql-test/r/rpl_error_ignored_table.result | 2 +- mysql-test/t/func_math.test | 7 ++++--- mysql-test/t/rpl_error_ignored_table.test | 2 +- scripts/mysql_fix_privilege_tables.sh | 2 +- scripts/mysql_fix_privilege_tables.sql | 12 ++++++------ 7 files changed, 14 insertions(+), 22 deletions(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 4b171fafc06..9fa5f72a2e2 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -17,7 +17,7 @@ MY_TZ=GMT-3 TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work # For query_cache test -case "$SYSTEM" in +case `uname` in SCO_SV | UnixWare | OpenUNIX ) # do nothing (Causes strange behavior) ;; diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 04dabcb5481..46ad7a14e25 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -59,12 +59,3 @@ ASIN(0.8+0.2) SELECT ASIN(1.2-0.2); ASIN(1.2-0.2) 1.570796 -select floor(log(4)/log(2)); -floor(log(4)/log(2)) -2 -select floor(log(8)/log(2)); -floor(log(8)/log(2)) -3 -select floor(log(16)/log(2)); -floor(log(16)/log(2)) -4 diff --git a/mysql-test/r/rpl_error_ignored_table.result b/mysql-test/r/rpl_error_ignored_table.result index 0e7ac72041c..329af301073 100644 --- a/mysql-test/r/rpl_error_ignored_table.result +++ b/mysql-test/r/rpl_error_ignored_table.result @@ -26,7 +26,7 @@ select (@id := id) - id from t3; 0 kill @id; drop table t2,t3; -Server shutdown in progress +Got one of the listed errors show binlog events from 79; Log_name Pos Event_type Server_id Orig_log_pos Info master-bin.001 79 Query 1 79 use `test`; create table t1 (a int primary key) diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 7057b0ca412..ca958253d14 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -33,6 +33,7 @@ SELECT ASIN(1.2-0.2); # Bug #3051 FLOOR returns invalid # -select floor(log(4)/log(2)); -select floor(log(8)/log(2)); -select floor(log(16)/log(2)); +# This can't be tested as it's not portable +#select floor(log(4)/log(2)); +#select floor(log(8)/log(2)); +#select floor(log(16)/log(2)); diff --git a/mysql-test/t/rpl_error_ignored_table.test b/mysql-test/t/rpl_error_ignored_table.test index c308d430f74..703e302c7b5 100644 --- a/mysql-test/t/rpl_error_ignored_table.test +++ b/mysql-test/t/rpl_error_ignored_table.test @@ -44,7 +44,7 @@ select (@id := id) - id from t3; kill @id; drop table t2,t3; connection master; ---error 1053; +--error 1053,0; reap; connection master1; show binlog events from 79; diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 1dac3ebc725..f5f641525cc 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -116,7 +116,7 @@ $cmd < Date: Fri, 19 Mar 2004 18:33:38 +0200 Subject: [PATCH 09/13] Added test to show bug in current union implementation After merge fixes Portability fixes --- client/mysqltest.c | 75 +++++++++++++++++++------- include/errmsg.h | 46 ++++++++-------- mysql-test/mysql-test-run.sh | 2 +- mysql-test/r/system_mysql_db.result | 24 +++++---- mysql-test/r/union.result | 15 ++++++ mysql-test/t/derived.test | 3 +- mysql-test/t/system_mysql_db_refs.test | 12 +++++ mysql-test/t/union.test | 13 +++++ scripts/mysql_create_system_tables.sh | 2 +- scripts/mysql_fix_privilege_tables.sh | 25 ++++----- scripts/mysql_fix_privilege_tables.sql | 65 ++++++++++++++++++---- 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) { - uint i, j; - int tmp[MAX_DELIMITER]= {0}; + if (line_buffer_pos == line_buffer) + return fgetc(file); + return line_buffer[--line_buffer_pos]; +} - for (i= 0; c == *(delimiter + i) && i < delimiter_length; - i++, c= fgetc(*cur_file)) +void my_ungetc(int c) +{ + line_buffer[line_buffer_pos++]= c; +} + + +my_bool end_of_query(int c) +{ + uint i,j; + char tmp[MAX_DELIMITER]; + + if (c != *delimiter) + return 0; + + 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); From 8c5d7e54904bfb171fdf26d5d4421277fd72672e Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 19 Mar 2004 18:49:14 +0100 Subject: [PATCH 10/13] - Do-pkg: PGK and DMG names now include the full arch name (e.g. "-apple-darwin7.3.0-powerpc") - this is needed as we now will provide Mac OS X 10.2.x and Mac OS X 10.3.x PGKs (and it's more in line of how we name all other packages) --- Build-tools/Do-pkg | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Build-tools/Do-pkg b/Build-tools/Do-pkg index 4d0f120c6e3..2fd1946ed0e 100755 --- a/Build-tools/Do-pkg +++ b/Build-tools/Do-pkg @@ -61,6 +61,12 @@ else } $PM= "/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"; +# Try another location on 10.3.3 +unless (-e "$PM") +{ + $PM= "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"; +} + $TMP= $ENV{TMPDIR}; $TMP eq "" ? $TMP= $TMP . "/PKGBUILD.$$": $TMP= "/tmp/PKGBUILD.$$"; $PKGROOT= "$TMP/PMROOT"; @@ -79,6 +85,9 @@ $BUILDDIR= "$PWD/$HOST"; $SRCBASEDIR= <$BUILDDIR/mysql*-$VERSION>; $SUPFILEDIR= <$SRCBASEDIR/support-files/MacOSX>; $TAR= <$BUILDDIR/$NAME-apple-darwin*-powerpc.tar.gz>; +$TAR =~ /.*\/$NAME(.*)\.tar\.gz$/; +$ARCH= $1; +$NAME= $NAME . $ARCH; $INFO= <$SUPFILEDIR/Info.plist>; $DESC= <$SUPFILEDIR/Description.plist>; $SI_INFO= <$SUPFILEDIR/StartupItem.Info.plist>; @@ -167,7 +176,7 @@ unless (-f "$RESOURCE_DIR/License.txt"); &logger("Extracting $TAR to $PKGROOT"); &run_command("gnutar zxf $TAR -C $PKGROOT", "Unable to extract $TAR!"); &run_command("cd $PKGROOT ; ln -s mysql* ./mysql", "Unable to create symlink!"); -&run_command("chown -R root.wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); +&run_command("chown -R root:wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); # Now build the PGK using PackageMaker # The "|| true" is a nasty hack to work around a problem with Package Maker @@ -196,7 +205,7 @@ unless ($opt_skip_si) copy("$SI_PARAMS", "$PKGROOT/MySQL/") or &abort("Error copying $SI_PARAMS!"); chmod(0644, "$PKGROOT/MySQL/" . basename("$SI_PARAMS")); - &run_command("chown -R root.wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); + &run_command("chown -R root:wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); copy("$SI_POST", "$RESOURCE_DIR/postinstall") or &abort("Error copying $SI_POST!"); chmod(0644, "$RESOURCE_DIR/postinstall"); From c9bbc83d11b56831658b03475b23306e3d48acca Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 19 Mar 2004 22:51:25 +0200 Subject: [PATCH 11/13] btr0btr.c: Improve space utilization if we have 3 kB - 8 kB rows to insert in the order of the primary key btr0cur.c: Fix bug: The row count and key cardinality estimate was grossly too small if each clustered index page only contained one record --- innobase/btr/btr0btr.c | 59 ++++++++++++++++++++---------------------- innobase/btr/btr0cur.c | 24 ++++++++++++++--- 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c index 71be6d81d7c..1c3e033a8d7 100644 --- a/innobase/btr/btr0btr.c +++ b/innobase/btr/btr0btr.c @@ -76,9 +76,6 @@ make them consecutive on disk if possible. From the other file segment we allocate pages for the non-leaf levels of the tree. */ -/* If this many inserts occur sequentially, it affects page split */ -#define BTR_PAGE_SEQ_INSERT_LIMIT 5 - /****************************************************************** Creates a new index page to the tree (not the root, and also not used in page reorganization). */ @@ -1086,18 +1083,18 @@ btr_page_get_split_rec_to_left( page = btr_cur_get_page(cursor); insert_point = btr_cur_get_rec(cursor); - if ((page_header_get_ptr(page, PAGE_LAST_INSERT) - == page_rec_get_next(insert_point)) - && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_LEFT) - && ((page_header_get_field(page, PAGE_N_DIRECTION) - >= BTR_PAGE_SEQ_INSERT_LIMIT) - || (page_header_get_field(page, PAGE_N_DIRECTION) + 1 - >= page_get_n_recs(page)))) { + if (page_header_get_ptr(page, PAGE_LAST_INSERT) + == page_rec_get_next(insert_point)) { infimum = page_get_infimum_rec(page); - - if ((infimum != insert_point) - && (page_rec_get_next(infimum) != insert_point)) { + + /* If the convergence is in the middle of a page, include also + the record immediately before the new insert to the upper + page. Otherwise, we could repeatedly move from page to page + lots of records smaller than the convergence point. */ + + if (infimum != insert_point + && page_rec_get_next(infimum) != insert_point) { *split_rec = insert_point; } else { @@ -1131,29 +1128,29 @@ btr_page_get_split_rec_to_right( page = btr_cur_get_page(cursor); insert_point = btr_cur_get_rec(cursor); - if ((page_header_get_ptr(page, PAGE_LAST_INSERT) == insert_point) - && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_RIGHT) - && ((page_header_get_field(page, PAGE_N_DIRECTION) - >= BTR_PAGE_SEQ_INSERT_LIMIT) - || (page_header_get_field(page, PAGE_N_DIRECTION) + 1 - >= page_get_n_recs(page)))) { + /* We use eager heuristics: if the new insert would be right after + the previous insert on the same page, we assume that there is a + pattern of sequential inserts here. */ + + if (page_header_get_ptr(page, PAGE_LAST_INSERT) == insert_point) { supremum = page_get_supremum_rec(page); - if ((page_rec_get_next(insert_point) != supremum) - && (page_rec_get_next(page_rec_get_next(insert_point)) - != supremum) - && (page_rec_get_next(page_rec_get_next( - page_rec_get_next(insert_point))) - != supremum)) { + if (page_rec_get_next(insert_point) != supremum + && page_rec_get_next(page_rec_get_next(insert_point)) + != supremum) { - /* If there are >= 3 user records up from the insert - point, split all but 2 off */ - - *split_rec = page_rec_get_next(page_rec_get_next( - page_rec_get_next(insert_point))); + /* If there are >= 2 user records up from the insert + point, split all but 1 off. We want to keep one because + then sequential inserts can use the adaptive hash + index, as they can do the necessary checks of the right + search position just by looking at the records on this + page. */ + + *split_rec = page_rec_get_next( + page_rec_get_next(insert_point)); } else { - /* Else split at inserted record */ + /* Else split at the new record to insert */ *split_rec = NULL; } diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index a9f92dbc181..e5c8762bdb9 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -2671,10 +2671,11 @@ btr_estimate_number_of_different_key_vals( btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, &cursor, &mtr); - /* Count the number of different key values minus one - for each prefix of the key on this index page: we subtract - one because otherwise our algorithm would give a wrong - estimate for an index where there is just one key value */ + /* Count the number of different key values for each prefix of + the key on this index page. If the prefix does not determine + the index record uniquely in te B-tree, then we subtract one + because otherwise our algorithm would give a wrong estimate + for an index where there is just one key value. */ page = btr_cur_get_page(&cursor); @@ -2696,6 +2697,9 @@ btr_estimate_number_of_different_key_vals( &matched_bytes); for (j = matched_fields + 1; j <= n_cols; j++) { + /* We add one if this index record has + a different prefix from the previous */ + n_diff[j]++; } @@ -2705,6 +2709,18 @@ btr_estimate_number_of_different_key_vals( rec = page_rec_get_next(rec); } + if (n_cols == dict_index_get_n_unique_in_tree(index)) { + /* We add one because we know that the first record + on the page certainly had a different prefix than the + last record on the previous index page in the + alphabetical order. Before this fix, if there was + just one big record on each clustered index page, the + algorithm grossly underestimated the number of rows + in the table. */ + + n_diff[n_cols]++; + } + total_external_size += btr_rec_get_externally_stored_len(rec); mtr_commit(&mtr); From a8da91f9fb480b52e5e376f8584bf809d922790e Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Sat, 20 Mar 2004 06:09:18 +0200 Subject: [PATCH 12/13] btr0btr.c: Correct previous bk commit comment about page splits: actually, in versions < 4.0.19 space utilization is very poor if 1500 - 8000 byte rows are inserted in the order of the primary key --- innobase/btr/btr0btr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c index 1c3e033a8d7..1d22d107b12 100644 --- a/innobase/btr/btr0btr.c +++ b/innobase/btr/btr0btr.c @@ -5,7 +5,7 @@ The B-tree Created 6/2/1994 Heikki Tuuri *******************************************************/ - + #include "btr0btr.h" #ifdef UNIV_NONINL From b6e5c23c26ca4980489bdb1c895f88761c8687a7 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Sat, 20 Mar 2004 12:48:14 +0200 Subject: [PATCH 13/13] Ensure that we use unix file format (no \r\n) for all new files Portability fixes --- BitKeeper/etc/config | 1 + client/mysqltest.c | 15 +++++++-------- mysql-test/r/derived.result | 4 ++-- mysql-test/r/rpl000009.result | 12 ++++++++++++ mysql-test/t/derived.test | 2 +- mysql-test/t/rpl000009.test | 4 ++-- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/BitKeeper/etc/config b/BitKeeper/etc/config index ea30f368b52..c609fcdbd49 100644 --- a/BitKeeper/etc/config +++ b/BitKeeper/etc/config @@ -71,3 +71,4 @@ hours: [arjen:]checkout:get [nick:]checkout:get checkout:edit +eoln:unix diff --git a/client/mysqltest.c b/client/mysqltest.c index 4bcfe93c278..741da982008 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1662,16 +1662,16 @@ int do_while(struct st_query* q) happen for any tests in the test suite. */ -char my_getc(FILE *file) +int my_getc(FILE *file) { if (line_buffer_pos == line_buffer) return fgetc(file); - return line_buffer[--line_buffer_pos]; + return *--line_buffer_pos; } void my_ungetc(int c) { - line_buffer[line_buffer_pos++]= c; + *line_buffer_pos++= (char) c; } @@ -1692,8 +1692,9 @@ my_bool end_of_query(int c) return 1; /* Found delimiter */ /* didn't find delimiter, push back things that we read */ - for (j = 1 ; j <= i ; j++) - my_ungetc(tmp[j]); + my_ungetc(c); + while (i > 1) + my_ungetc(tmp[--i]); return 0; } @@ -2396,9 +2397,6 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) } } - if (glob_replace) - free_replace(); - if (record) { if (!q->record_file[0] && !result_file) @@ -2419,6 +2417,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) mysql_error(mysql); end: + free_replace(); last_result=0; if (ds == &ds_tmp) dynstr_free(&ds_tmp); diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 7e5c519e108..f5754bb3332 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -271,8 +271,8 @@ delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Cou select * from t1; N M 3 0 -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 HY000: The target table P2 of the DELETE is not updatable +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 HY000: The target table p2 of the DELETE is not updatable 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; ERROR 42S22: Unknown column 'aaa' in 'field list' drop table t1; diff --git a/mysql-test/r/rpl000009.result b/mysql-test/r/rpl000009.result index 1f78a505280..bb82dcb1e6a 100644 --- a/mysql-test/r/rpl000009.result +++ b/mysql-test/r/rpl000009.result @@ -112,6 +112,18 @@ n s 2 two test 3 three test 4 four test +stop slave; +reset slave; +load data from master; +start slave; +insert into mysqltest.t1 values (5, 'five bar'); +select * from mysqltest.t1; +n s +1 one test +2 two test +3 three test +4 four test +5 five bar load table mysqltest.t1 from master; ERROR 42S01: Table 't1' already exists drop table mysqltest.t1; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index a13d5de40f0..f0d5a253bf4 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -157,8 +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 --replace_result P2 p2 +--error 1288 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/rpl000009.test b/mysql-test/t/rpl000009.test index 4b69fb3e31c..59451bc888d 100644 --- a/mysql-test/t/rpl000009.test +++ b/mysql-test/t/rpl000009.test @@ -127,11 +127,11 @@ load data from master; start slave; # see if replication coordinates were restored fine connection master; -insert into bar.t1 values (5, 'five bar'); +insert into mysqltest.t1 values (5, 'five bar'); save_master_pos; connection slave; sync_with_master; -select * from bar.t1; +select * from mysqltest.t1; # Check that LOAD DATA FROM MASTER reports the error if it can't drop a # table to be overwritten.