From 9d78adc16fa0141921395be232348af8ef8c9181 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Mar 2004 10:35:03 +0100 Subject: [PATCH 1/5] 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: result update mysql-test/t/rpl000009.test: adding a test for RESET SLAVE + LOAD DATA FROM MASTER sql/repl_failsafe.cc: LOAD DATA FROM MASTER udpates the master info in the slave, so needs to ensure that it is properly inited first (otherwise, after RESET SLAVE, we are flush_io_cache()ing an uninitialized IO_CACHE master.info). Note that it master info is already inited (active_mi->inited==1), init_master_info() will do nothing, which is what we want. --- 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 6fd2a7bcba2a8c91eb190878ee12f43c32212070 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Mar 2004 21:01:07 +0400 Subject: [PATCH 2/5] fixed structure error from last merge for bug #2874 BitKeeper/deleted/.del-system_mysql_db.test~f5a7ec0e9440c043: Delete: mysql-test/t/reserv/system_mysql_db.test BitKeeper/deleted/.del-system_mysql_db_fix.test~180b2fd4873a9c49: Delete: mysql-test/t/reserv/system_mysql_db_fix.test BitKeeper/deleted/.del-system_mysql_db_fix-master.opt~2897a9ebb17f930e: Delete: mysql-test/t/reserv/system_mysql_db_fix-master.opt BitKeeper/deleted/.del-system_mysql_db_refs.test~e5bffdb55190a23c: Delete: mysql-test/t/reserv/system_mysql_db_refs.test --- 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 c6a059964271c2b1cb7dc9905d9b708770d1278f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Mar 2004 20:04:50 +0300 Subject: [PATCH 3/5] WL #1510 "Implement support for "commercial" binaries on handshake", client library: - implemented 'check_license' function include/errmsg.h: WL #1510: new error code include/mysql_version.h.in: WL #1510: fallback define for LICENSE libmysql/errmsg.c: WL #1510: error message to print in case when client and server license mismatch. libmysql/libmysql.c: WL#1510: implementation of 'check_license' function sql/set_var.cc: removed unused variable 'license' --- 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 9935110b30fff7fb79bf3eebdfd310b86474d425 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Mar 2004 14:52:48 +0200 Subject: [PATCH 4/5] Portability fixes Removed \r from new tests Fixes to get new sustem_mysql_db... tests to work client/mysqltest.c: More debug information innobase/que/que0que.c: Fixed wrong usage of __attribute mysql-test/mysql-test-run.sh: Portability fix; Added CLIENT_BINDIR mysql-test/t/system_mysql_db_fix.test: Removed \r mysql-test/t/system_mysql_db_refs.test: Removed \r scripts/mysql_fix_privilege_tables.sh: Don't set root password from first option Added --bindir option --- 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 6b465557670093b038cb3d2be930e6a036292192 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Mar 2004 15:03:12 +0200 Subject: [PATCH 5/5] 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,