From 7a51e36929f62d6b63e3daf8cd8d5f82b837637a Mon Sep 17 00:00:00 2001 From: "kostja@oak.local" <> Date: Fri, 29 Aug 2003 14:38:39 +0400 Subject: [PATCH 01/27] removed stale comment 13:58 konstantin: the comment is missplaced (probably after merge). You can remove it --- BitKeeper/etc/logging_ok | 1 + sql/sql_parse.cc | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 3ee214e6760..ffc7baf242c 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -46,6 +46,7 @@ jcole@sarvik.tfr.cafe.ee jcole@tetra.spaceapes.com jorge@linux.jorge.mysql.com kaj@work.mysql.com +kostja@oak.local lenz@kallisto.mysql.com lenz@mysql.com miguel@hegel.(none) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d7d7469ceed..663567acfbd 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -533,7 +533,6 @@ check_connections(THD *thd) thd->ip= 0; bzero((char*) &thd->remote,sizeof(struct sockaddr)); } - /* Ensure that wrong hostnames doesn't cause buffer overflows */ vio_keepalive(net->vio, TRUE); ulong pkt_len=0; From 735b5ca49de4897cdb8a85cafbebb53861554cb6 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 29 Aug 2003 19:14:42 +0200 Subject: [PATCH 02/27] - Fixed BUG 1162 (removed macro names from the changelog) - Really fixed BUG 998 (disable the checking for installed but unpackaged files) --- support-files/mysql.spec.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 0a33ae397e4..8ae1c999f91 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -3,6 +3,10 @@ %define mysqld_user mysql %define server_suffix -standard +# We don't package all files installed into the build root by intention - +# See BUG#998 for details. +%_unpackaged_files_terminate_build 0 + %define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com Name: MySQL @@ -561,18 +565,26 @@ fi %files embedded %attr(644, root, root) %{_libdir}/mysql/libmysqld.a +# The spec file changelog only includes changes made to the spec file +# itself %changelog +* Fri Aug 29 2003 Lenz Grimmer + +- Fixed BUG 1162 (removed macro names from the changelog) +- Really fixed BUG 998 (disable the checking for installed but + unpackaged files) + * Tue Aug 05 2003 Lenz Grimmer -- Fixed BUG#959 (libmysqld not being compiled properly) -- Fixed BUG#998 (RPM build errors): added missing files to the +- Fixed BUG 959 (libmysqld not being compiled properly) +- Fixed BUG 998 (RPM build errors): added missing files to the distribution (mysql_fix_extensions, mysql_tableinfo, mysqldumpslow, - mysql_fix_privilege_tables.1), removed "-n" from %install section. + mysql_fix_privilege_tables.1), removed "-n" from install section. * Wed Jul 09 2003 Lenz Grimmer - removed the GIF Icon (file was not included in the sources anyway) -- removed unused variable %shared_lib_version +- removed unused variable shared_lib_version - do not run automake before building the standard binary (should not be necessary) - add server suffix '-standard' to standard binary (to be in line @@ -593,7 +605,7 @@ fi * Mon Mar 10 2003 Lenz Grimmer - added missing file mysql_secure_installation to server subpackage - (bug #141) + (BUG 141) * Tue Feb 11 2003 Lenz Grimmer From a37142ca9237e49ea33b4cbf3cc7905cdd84ac43 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Mon, 1 Sep 2003 12:25:39 +0200 Subject: [PATCH 03/27] - added a missing %define in the RPM spec file (thanks to Haakon Innerdal for spotting this one) --- support-files/mysql.spec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 8ae1c999f91..ffc74c7559d 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -5,7 +5,7 @@ # We don't package all files installed into the build root by intention - # See BUG#998 for details. -%_unpackaged_files_terminate_build 0 +%define _unpackaged_files_terminate_build 0 %define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com From b2c83e7f033088a9bc1a0058c57a093396ab3eba Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Mon, 1 Sep 2003 14:18:27 +0200 Subject: [PATCH 04/27] workaround for IN's special treatment of first argument. Not for 4.1 --- mysql-test/r/range.result | 6 ++++++ mysql-test/t/range.test | 3 +++ sql/sql_select.cc | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 5da6f6c30e1..a02da87b0e9 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -253,4 +253,10 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; table type possible_keys key key_len ref rows Extra t1 ref y y 5 const 1 Using where t2 range x x 5 NULL 2 Using where +explain select count(*) from t1 where x in (1); +table type possible_keys key key_len ref rows Extra +t1 range x x 5 NULL 1 Using where; Using index +explain select count(*) from t1 where x in (1,2); +table type possible_keys key key_len ref rows Extra +t1 range x x 5 NULL 2 Using where; Using index drop table t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 521709eddee..3e749682475 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -198,5 +198,8 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1 # equation propagation explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +# testing IN +explain select count(*) from t1 where x in (1); +explain select count(*) from t1 where x in (1,2); drop table t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d48e809966c..153b083b3ef 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1556,7 +1556,13 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, if (cond_func->key_item()->type() == Item::FIELD_ITEM) add_key_field(key_fields,*and_level, ((Item_field*) (cond_func->key_item()))->field, 0, +#ifndef TO_BE_REMOVED_IN_4_1 + /* special treatment for IN. Not necessary in 4.1 */ + cond_func->arguments() + (cond_func->functype() != Item_func::IN_FUNC), + cond_func->argument_count() - (cond_func->functype() != Item_func::IN_FUNC), +#else cond_func->arguments()+1, cond_func->argument_count()-1, +#endif usable_tables); break; case Item_func::OPTIMIZE_OP: From c297aa934edc2c8c39f0916e07d7e5928d87d111 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 2 Sep 2003 08:37:27 +0200 Subject: [PATCH 05/27] s/\t/ / in command-line help text --- myisam/myisampack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 4fc84ac5657..800203a30e2 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -243,7 +243,7 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', - "Force packing of table even if it gets bigger or if tempfile exists.", + "Force packing of table even if it gets bigger or if tempfile exists.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"join", 'j', "Join all given tables into 'new_table_name'. All tables MUST have identical layouts.", From 48e2d1536900ead75d56db686424122128b1a602 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 2 Sep 2003 11:18:13 +0200 Subject: [PATCH 06/27] bug #928 - arbitrary table grant was used, sort-order wasn't honored --- sql/sql_acl.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 554417322a4..56884ad9dd1 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1204,6 +1204,7 @@ class GRANT_TABLE :public Sql_alloc public: char *host,*db,*user,*tname, *hash_key; uint privs, cols, key_length; + ulong sort; HASH hash_columns; GRANT_TABLE (const char *h, const char *d,const char *u, const char *t, uint p,uint c) @@ -1212,6 +1213,7 @@ public: host = strdup_root(&memex,h); db = strdup_root(&memex,d); user = strdup_root(&memex,u); + sort= get_sort(3,host,db,user); tname= strdup_root(&memex,t); key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3; hash_key = (char*) alloc_root(&memex,key_length); @@ -1227,6 +1229,7 @@ public: host = get_field(&memex,form,0); db = get_field(&memex,form,1); user = get_field(&memex,form,2); if (!user) user=(char*) ""; + sort= get_sort(3,host,db,user); tname = get_field(&memex,form,3); if (!host || !db || !tname) { @@ -1324,9 +1327,10 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip, } else { - if ((host && !wild_case_compare(host,grant_table->host)) || - (ip && !wild_case_compare(ip,grant_table->host))) - found=grant_table; // Host ok + if (((host && !wild_case_compare(host,grant_table->host)) || + (ip && !wild_case_compare(ip,grant_table->host))) && + (!found || found->sort < grant_table->sort)) + found=grant_table; } } return found; From 15b650fe7244bee9a3bd39214b7f9b9cf1e1005c Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 2 Sep 2003 16:49:00 +0200 Subject: [PATCH 07/27] more sanity checks for compressed files, BUG#770 --- myisam/mi_packrec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index 7557bb8749f..1bd39aa900b 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -743,6 +743,12 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, { ulong length=get_bits(bit_buff,rec->space_length_bits); uint pack_length=(uint) (end-to)-mi_portable_sizeof_char_ptr; + if (bit_buff->blob_pos+length > bit_buff->end) + { + bit_buff->error=1; + bzero((byte*) to,(end-to)); + return; + } decode_bytes(rec,bit_buff,bit_buff->blob_pos,bit_buff->blob_pos+length); _my_store_blob_length((byte*) to,pack_length,length); memcpy_fixed((char*) to+pack_length,(char*) &bit_buff->blob_pos, From dc554ab989890b7b5305967973b432fca5fa5c3f Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Tue, 2 Sep 2003 12:09:27 -0400 Subject: [PATCH 08/27] fixed bug #1174 --- libmysql/get_password.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysql/get_password.c b/libmysql/get_password.c index e6221ea556e..0e3b2dcb0ae 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -78,7 +78,7 @@ char *get_tty_password(char *opt_message) char *pos=to,*end=to+sizeof(to)-1; int i=0; DBUG_ENTER("get_tty_password"); - fprintf(stdout,opt_message ? opt_message : "Enter password: "); + _cputs(opt_message ? opt_message : "Enter password: "); for (;;) { char tmp; From 5e6d8dd7fe5fd68a6e322fa4d83fe0d2ca39c6aa Mon Sep 17 00:00:00 2001 From: "ram@mysql.r18.ru" <> Date: Tue, 2 Sep 2003 21:09:28 +0500 Subject: [PATCH 09/27] Fix for the bug #971: ORDER BY DESC doesn't return correct num of rows with BDB and an indexed column. --- mysql-test/r/bdb.result | 31 +++++++++++++++++++++++++++++++ mysql-test/t/bdb.test | 13 +++++++++++++ sql/ha_berkeley.cc | 3 +++ 3 files changed, 47 insertions(+) diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index eb97d19136d..ebc2866183c 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1123,3 +1123,34 @@ a b select * from t2; a b drop table t1,t2; +create table t1 (x int not null, index(x)) type=bdb; +insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +select * from t1 where x <= 10 and x >= 7; +x +7 +8 +9 +10 +select * from t1 where x <= 10 and x >= 7 order by x; +x +7 +8 +9 +10 +select * from t1 where x <= 10 and x >= 7 order by x desc; +x +10 +9 +8 +7 +select * from t1 where x <= 8 and x >= 5 order by x desc; +x +8 +7 +6 +5 +select * from t1 where x < 8 and x > 5 order by x desc; +x +7 +6 +drop table t1; diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index 608d4bf5042..d0cc63a9389 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -783,3 +783,16 @@ select * from t1; select * from t2; select * from t2; drop table t1,t2; + +# +# The bug #971 +# + +create table t1 (x int not null, index(x)) type=bdb; +insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +select * from t1 where x <= 10 and x >= 7; +select * from t1 where x <= 10 and x >= 7 order by x; +select * from t1 where x <= 10 and x >= 7 order by x desc; +select * from t1 where x <= 8 and x >= 5 order by x desc; +select * from t1 where x < 8 and x > 5 order by x desc; +drop table t1; diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 2154fbd7a32..78704a18052 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -1420,6 +1420,8 @@ int ha_berkeley::index_read(byte * buf, const byte * key, bzero((char*) &row,sizeof(row)); if (key_len == key_info->key_length) { + if (find_flag == HA_READ_AFTER_KEY) + key_info->handler.bdb_return_if_eq= 1; error=read_row(cursor->c_get(cursor, pack_key(&last_key, active_index, key_buff, @@ -1428,6 +1430,7 @@ int ha_berkeley::index_read(byte * buf, const byte * key, (find_flag == HA_READ_KEY_EXACT ? DB_SET : DB_SET_RANGE)), (char*) buf, active_index, &row, (DBT*) 0, 0); + key_info->handler.bdb_return_if_eq= 0; } else { From 04112b9f89d9623920211da9aa602446b486be4c Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 2 Sep 2003 18:30:34 +0200 Subject: [PATCH 10/27] proper obligatory quoting of identifiers in mysqldump<->server communication (unrelated from command-line options) --- client/mysqldump.c | 52 ++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index a1c369e0a97..9b8fda71677 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -639,7 +639,7 @@ static uint getTableStructure(char *table, char* db) MYSQL_ROW row; my_bool init=0; uint numFields; - char *strpos, *table_name; + char *strpos, *result_table; const char *delayed; char name_buff[NAME_LEN+3],table_buff[NAME_LEN+3]; FILE *sql_file = md_result_file; @@ -651,7 +651,7 @@ static uint getTableStructure(char *table, char* db) fprintf(stderr, "-- Retrieving table structure for table %s...\n", table); sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", opt_quoted); - table_name=quote_name(table,table_buff); + result_table=quote_name(table,table_buff); if (!mysql_query(sock,insert_pat)) { /* using SHOW CREATE statement */ @@ -687,7 +687,7 @@ static uint getTableStructure(char *table, char* db) fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n", table); if (opt_drop) - fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); + fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",result_table); tableRes=mysql_store_result(sock); row=mysql_fetch_row(tableRes); @@ -695,7 +695,7 @@ static uint getTableStructure(char *table, char* db) fprintf(sql_file, "%s;\n", row[1]); mysql_free_result(tableRes); } - sprintf(insert_pat,"show fields from %s",table_name); + sprintf(insert_pat,"show fields from `%s`",table); if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) { fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", @@ -707,10 +707,10 @@ static uint getTableStructure(char *table, char* db) } if (cFlag) - sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name); + sprintf(insert_pat, "INSERT %sINTO %s (", delayed, result_table); else { - sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name); + sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, result_table); if (!extended_insert) strcat(insert_pat,"("); } @@ -735,7 +735,7 @@ static uint getTableStructure(char *table, char* db) /* fprintf(stderr, "%s: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", my_progname, mysql_error(sock)); */ - sprintf(insert_pat,"show fields from %s",table_name); + sprintf(insert_pat,"show fields from `%s`",result_table); if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) { fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", @@ -765,14 +765,14 @@ static uint getTableStructure(char *table, char* db) fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n", table); if (opt_drop) - fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); - fprintf(sql_file, "CREATE TABLE %s (\n", table_name); + fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",result_table); + fprintf(sql_file, "CREATE TABLE %s (\n", result_table); } if (cFlag) - sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name); + sprintf(insert_pat, "INSERT %sINTO %s (", delayed, result_table); else { - sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name); + sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, result_table); if (!extended_insert) strcat(insert_pat,"("); } @@ -794,7 +794,7 @@ static uint getTableStructure(char *table, char* db) if (!tFlag) { if (opt_keywords) - fprintf(sql_file, " %s.%s %s", table_name, + fprintf(sql_file, " %s.%s %s", result_table, quote_name(row[SHOW_FIELDNAME],name_buff), row[SHOW_TYPE]); else fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME], @@ -817,7 +817,7 @@ static uint getTableStructure(char *table, char* db) /* Make an sql-file, if path was given iow. option -T was given */ char buff[20+FN_REFLEN]; uint keynr,primary_key; - sprintf(buff,"show keys from %s",table_name); + sprintf(buff,"show keys from `%s`",table); if (mysql_query(sock, buff)) { fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n", @@ -877,7 +877,7 @@ static uint getTableStructure(char *table, char* db) /* Get MySQL specific create options */ if (create_options) { - sprintf(buff,"show table status like '%s'",table); + sprintf(buff,"show table status like `%s`",table); if (mysql_query(sock, buff)) { if (mysql_errno(sock) != ER_PARSE_ERROR) @@ -909,7 +909,7 @@ static uint getTableStructure(char *table, char* db) } } if (opt_disable_keys) - fprintf(sql_file,"\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n",table_name); + fprintf(sql_file,"\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n",result_table); if (cFlag) { strpos=strmov(strpos,") VALUES "); @@ -978,7 +978,7 @@ static char *field_escape(char *to,const char *from,uint length) */ static void dumpTable(uint numFields, char *table) { - char query[1024], *end, buff[256],table_buff[NAME_LEN+3]; + char query[1024], *end, buff[256],table_buff[NAME_LEN+3], *result_table; MYSQL_RES *res; MYSQL_FIELD *field; MYSQL_ROW row; @@ -986,6 +986,7 @@ static void dumpTable(uint numFields, char *table) if (verbose) fprintf(stderr, "-- Sending SELECT query...\n"); + result_table=quote_name(table,table_buff); if (path) { char filename[FN_REFLEN], tmp_path[FN_REFLEN]; @@ -1012,7 +1013,7 @@ static void dumpTable(uint numFields, char *table) end= add_load_option(end, lines_terminated, " LINES TERMINATED BY"); *end= '\0'; - sprintf(buff," FROM %s",quote_name(table,table_buff)); + sprintf(buff," FROM `%s`",table); end= strmov(end,buff); if (where) end= strxmov(end, " WHERE ",where,NullS); @@ -1027,7 +1028,7 @@ static void dumpTable(uint numFields, char *table) if (!opt_xml) fprintf(md_result_file,"\n--\n-- Dumping data for table '%s'\n--\n", table); - sprintf(query, "SELECT * FROM %s", quote_name(table,table_buff)); + sprintf(query, "SELECT * FROM `%s`", table); if (where) { if (!opt_xml) @@ -1061,8 +1062,7 @@ static void dumpTable(uint numFields, char *table) } if (opt_lock) - fprintf(md_result_file,"LOCK TABLES %s WRITE;\n", - quote_name(table,table_buff)); + fprintf(md_result_file,"LOCK TABLES %s WRITE;\n", result_table); total_length=net_buffer_length; /* Force row break */ row_break=0; @@ -1227,7 +1227,7 @@ static void dumpTable(uint numFields, char *table) } if (opt_disable_keys) fprintf(md_result_file,"\n/*!40000 ALTER TABLE %s ENABLE KEYS */;\n", - quote_name(table,table_buff)); + result_table); if (opt_lock) fputs("UNLOCK TABLES;\n", md_result_file); if (opt_autocommit) @@ -1361,8 +1361,9 @@ static int dump_all_tables_in_db(char *database) init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); for (numrows=0 ; (table = getTableName(1)) ; numrows++) { - dynstr_append(&query, quote_name(table, table_buff)); - dynstr_append(&query, " READ /*!32311 LOCAL */,"); + dynstr_append(&query, "`"); + dynstr_append(&query, table); + dynstr_append(&query, "` READ /*!32311 LOCAL */,"); } if (numrows && mysql_real_query(sock, query.str, query.length-1)) DBerror(sock, "when using LOCK TABLES"); @@ -1403,8 +1404,9 @@ static int dump_selected_tables(char *db, char **table_names, int tables) init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); for (i=0 ; i < tables ; i++) { - dynstr_append(&query, quote_name(table_names[i], table_buff)); - dynstr_append(&query, " READ /*!32311 LOCAL */,"); + dynstr_append(&query, "`"); + dynstr_append(&query, table_names[i]); + dynstr_append(&query, "` READ /*!32311 LOCAL */,"); } if (mysql_real_query(sock, query.str, query.length-1)) DBerror(sock, "when doing LOCK TABLES"); From 7005115e97b3986a7ec1ba59ff6ece82bcc1a2f2 Mon Sep 17 00:00:00 2001 From: "gerberb@ou800.zenez.com" <> Date: Wed, 3 Sep 2003 08:07:58 -0600 Subject: [PATCH 11/27] Change set for gcc patch on OpenUNIX and UnixWare SCO is the OS vendor. --- BitKeeper/etc/logging_ok | 1 + configure.in | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index ffc7baf242c..348ed8d24df 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -17,6 +17,7 @@ bk@admin.bk davida@isil.mysql.com dlenev@build.mysql.com dlenev@mysql.com +gerberb@ou800.zenez.com gluh@gluh.(none) gluh@gluh.mysql.r18.ru greg@gcw.ath.cx diff --git a/configure.in b/configure.in index f894cb5cb2a..0538199e8e1 100644 --- a/configure.in +++ b/configure.in @@ -1339,7 +1339,12 @@ then if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so then MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK - with_named_thread="-Kthread -lsocket -lnsl" + if expr "$CC" : ".*gcc.*" + then + with_named_thread="-pthread -lsocket -lnsl" + else + with_named_thread="-Kthread -lsocket -lnsl" + fi if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null then AC_DEFINE(HAVE_UNIXWARE7_THREADS) @@ -1375,7 +1380,12 @@ then if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so then MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK - with_named_thread="-Kthread -lsocket -lnsl" + if expr "$CC" : ".*gcc.*" + then + with_named_thread="-pthread -lsocket -lnsl" + else + with_named_thread="-Kthread -lsocket -lnsl" + fi if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null then AC_DEFINE(HAVE_UNIXWARE7_THREADS) From a6e3ee6bef48ea0b7b3f14f629587120f5471d87 Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Wed, 3 Sep 2003 18:48:10 +0300 Subject: [PATCH 12/27] Better quoting patch for mysqldump --- client/mysqldump.c | 155 +++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 70 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 9b8fda71677..93b75a70320 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -35,7 +35,7 @@ ** and adapted to mysqldump 05/11/01 by Jani Tolonen */ -#define DUMP_VERSION "8.22" +#define DUMP_VERSION "8.23" #include #include @@ -165,7 +165,7 @@ static int dump_all_tables_in_db(char *db); static int init_dumping(char *); static int dump_databases(char **); static int dump_all_databases(); -static char *quote_name(char *name, char *buff); +static char *quote_name(const char *name, char *buff, my_bool force); static void print_quoted_xml(FILE *output, char *fname, char *str, uint len); static void print_version(void) @@ -615,33 +615,43 @@ static my_bool test_if_special_chars(const char *str) return 0; } /* test_if_special_chars */ -static char *quote_name(char *name, char *buff) + +static char *quote_name(const char *name, char *buff, my_bool force) { - char *end; - if (!opt_quoted && !test_if_special_chars(name)) - return name; - buff[0]=QUOTE_CHAR; - end=strmov(buff+1,name); - end[0]=QUOTE_CHAR; - end[1]=0; + char *to= buff; + if (!force && !opt_quoted && !test_if_special_chars(name)) + return (char*) name; + *to++= QUOTE_CHAR; + while (*name) + { + if (*name == QUOTE_CHAR) + *to= QUOTE_CHAR; + *to++= *name++; + } + to[0]=QUOTE_CHAR; + to[1]=0; return buff; } /* quote_name */ /* -** getStructure -- retrievs database structure, prints out corresponding -** CREATE statement and fills out insert_pat. -** Return values: number of fields in table, 0 if error + getStructure -- retrievs database structure, prints out corresponding + CREATE statement and fills out insert_pat. + + RETURN + number of fields in table, 0 if error */ + static uint getTableStructure(char *table, char* db) { MYSQL_RES *tableRes; MYSQL_ROW row; my_bool init=0; uint numFields; - char *strpos, *result_table; + char *strpos, *result_table, *opt_quoted_table; const char *delayed; - char name_buff[NAME_LEN+3],table_buff[NAME_LEN+3]; + char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3]; + char table_buff2[NAME_LEN*2+3]; FILE *sql_file = md_result_file; DBUG_ENTER("getTableStructure"); @@ -651,7 +661,8 @@ static uint getTableStructure(char *table, char* db) fprintf(stderr, "-- Retrieving table structure for table %s...\n", table); sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", opt_quoted); - result_table=quote_name(table,table_buff); + result_table= quote_name(table, table_buff, 1); + opt_quoted_table= quote_name(table, table_buff2, 0); if (!mysql_query(sock,insert_pat)) { /* using SHOW CREATE statement */ @@ -660,11 +671,11 @@ static uint getTableStructure(char *table, char* db) /* Make an sql-file, if path was given iow. option -T was given */ char buff[20+FN_REFLEN]; - sprintf(buff,"show create table `%s`",table); + sprintf(buff,"show create table %s", result_table); if (mysql_query(sock, buff)) { - fprintf(stderr, "%s: Can't get CREATE TABLE for table '%s' (%s)\n", - my_progname, table, mysql_error(sock)); + fprintf(stderr, "%s: Can't get CREATE TABLE for table %s (%s)\n", + my_progname, result_table, mysql_error(sock)); safe_exit(EX_MYSQLERR); DBUG_RETURN(0); } @@ -684,10 +695,10 @@ static uint getTableStructure(char *table, char* db) write_header(sql_file, db); } if (!opt_xml) - fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n", - table); + fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n", + result_table); if (opt_drop) - fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",result_table); + fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", opt_quoted_table); tableRes=mysql_store_result(sock); row=mysql_fetch_row(tableRes); @@ -695,11 +706,11 @@ static uint getTableStructure(char *table, char* db) fprintf(sql_file, "%s;\n", row[1]); mysql_free_result(tableRes); } - sprintf(insert_pat,"show fields from `%s`",table); + sprintf(insert_pat,"show fields from %s", result_table); if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) { - fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", - my_progname, table, mysql_error(sock)); + fprintf(stderr, "%s: Can't get info about table: %s\nerror: %s\n", + my_progname, result_table, mysql_error(sock)); if (path) my_fclose(sql_file, MYF(MY_WME)); safe_exit(EX_MYSQLERR); @@ -707,10 +718,11 @@ static uint getTableStructure(char *table, char* db) } if (cFlag) - sprintf(insert_pat, "INSERT %sINTO %s (", delayed, result_table); + sprintf(insert_pat, "INSERT %sINTO %s (", delayed, opt_quoted_table); else { - sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, result_table); + sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, + opt_quoted_table); if (!extended_insert) strcat(insert_pat,"("); } @@ -725,7 +737,7 @@ static uint getTableStructure(char *table, char* db) } init=1; if (cFlag) - strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff)); + strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME], name_buff, 0)); } numFields = (uint) mysql_num_rows(tableRes); mysql_free_result(tableRes); @@ -735,11 +747,11 @@ static uint getTableStructure(char *table, char* db) /* fprintf(stderr, "%s: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", my_progname, mysql_error(sock)); */ - sprintf(insert_pat,"show fields from `%s`",result_table); + sprintf(insert_pat,"show fields from %s", result_table); if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) { - fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", - my_progname, table, mysql_error(sock)); + fprintf(stderr, "%s: Can't get info about table: %s\nerror: %s\n", + my_progname, result_table, mysql_error(sock)); safe_exit(EX_MYSQLERR); DBUG_RETURN(0); } @@ -762,8 +774,8 @@ static uint getTableStructure(char *table, char* db) write_header(sql_file, db); } if (!opt_xml) - fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n", - table); + fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n", + result_table); if (opt_drop) fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",result_table); fprintf(sql_file, "CREATE TABLE %s (\n", result_table); @@ -790,15 +802,17 @@ static uint getTableStructure(char *table, char* db) } init=1; if (cFlag) - strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff)); + strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME], name_buff, 0)); if (!tFlag) { if (opt_keywords) fprintf(sql_file, " %s.%s %s", result_table, - quote_name(row[SHOW_FIELDNAME],name_buff), row[SHOW_TYPE]); + quote_name(row[SHOW_FIELDNAME],name_buff, 0), + row[SHOW_TYPE]); else fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME], - name_buff), row[SHOW_TYPE]); + name_buff, 0), + row[SHOW_TYPE]); if (row[SHOW_DEFAULT]) { fputs(" DEFAULT ", sql_file); @@ -817,11 +831,11 @@ static uint getTableStructure(char *table, char* db) /* Make an sql-file, if path was given iow. option -T was given */ char buff[20+FN_REFLEN]; uint keynr,primary_key; - sprintf(buff,"show keys from `%s`",table); + sprintf(buff,"show keys from %s", result_table); if (mysql_query(sock, buff)) { - fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n", - my_progname, table, mysql_error(sock)); + fprintf(stderr, "%s: Can't get keys for table %s (%s)\n", + my_progname, result_table, mysql_error(sock)); if (path) my_fclose(sql_file, MYF(MY_WME)); safe_exit(EX_MYSQLERR); @@ -858,15 +872,15 @@ static uint getTableStructure(char *table, char* db) putc(')', sql_file); if (atoi(row[1])) /* Test if duplicate key */ /* Duplicate allowed */ - fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff)); + fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff,0)); else if (keynr == primary_key) fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */ else - fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff)); + fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff,0)); } else putc(',', sql_file); - fputs(quote_name(row[4],name_buff), sql_file); + fputs(quote_name(row[4], name_buff, 0), sql_file); if (row[7]) fprintf(sql_file, " (%s)",row[7]); /* Sub key */ } @@ -877,23 +891,23 @@ static uint getTableStructure(char *table, char* db) /* Get MySQL specific create options */ if (create_options) { - sprintf(buff,"show table status like `%s`",table); + sprintf(buff,"show table status like %s",result_table); if (mysql_query(sock, buff)) { if (mysql_errno(sock) != ER_PARSE_ERROR) { /* If old MySQL version */ if (verbose) fprintf(stderr, - "-- Warning: Couldn't get status information for table '%s' (%s)\n", - table,mysql_error(sock)); + "-- Warning: Couldn't get status information for table %s (%s)\n", + result_table,mysql_error(sock)); } } else if (!(tableRes=mysql_store_result(sock)) || !(row=mysql_fetch_row(tableRes))) { fprintf(stderr, - "Error: Couldn't read status information for table '%s' (%s)\n", - table,mysql_error(sock)); + "Error: Couldn't read status information for table %s (%s)\n", + result_table,mysql_error(sock)); } else { @@ -909,7 +923,8 @@ static uint getTableStructure(char *table, char* db) } } if (opt_disable_keys) - fprintf(sql_file,"\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n",result_table); + fprintf(sql_file, "\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n", + result_table); if (cFlag) { strpos=strmov(strpos,") VALUES "); @@ -979,6 +994,7 @@ static char *field_escape(char *to,const char *from,uint length) static void dumpTable(uint numFields, char *table) { char query[1024], *end, buff[256],table_buff[NAME_LEN+3], *result_table; + char table_buff2[NAME_LEN*2+3], *opt_quoted_table; MYSQL_RES *res; MYSQL_FIELD *field; MYSQL_ROW row; @@ -986,7 +1002,8 @@ static void dumpTable(uint numFields, char *table) if (verbose) fprintf(stderr, "-- Sending SELECT query...\n"); - result_table=quote_name(table,table_buff); + result_table= quote_name(table,table_buff, 1); + opt_quoted_table= quote_name(table, table_buff2, 0); if (path) { char filename[FN_REFLEN], tmp_path[FN_REFLEN]; @@ -1013,7 +1030,7 @@ static void dumpTable(uint numFields, char *table) end= add_load_option(end, lines_terminated, " LINES TERMINATED BY"); *end= '\0'; - sprintf(buff," FROM `%s`",table); + sprintf(buff," FROM %s", result_table); end= strmov(end,buff); if (where) end= strxmov(end, " WHERE ",where,NullS); @@ -1026,9 +1043,9 @@ static void dumpTable(uint numFields, char *table) else { if (!opt_xml) - fprintf(md_result_file,"\n--\n-- Dumping data for table '%s'\n--\n", - table); - sprintf(query, "SELECT * FROM `%s`", table); + fprintf(md_result_file,"\n--\n-- Dumping data for table %s\n--\n", + result_table); + sprintf(query, "SELECT * FROM %s", result_table); if (where) { if (!opt_xml) @@ -1055,14 +1072,14 @@ static void dumpTable(uint numFields, char *table) fprintf(stderr, "-- Retrieving rows...\n"); if (mysql_num_fields(res) != numFields) { - fprintf(stderr,"%s: Error in field count for table: '%s' ! Aborting.\n", - my_progname,table); + fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n", + my_progname, result_table); safe_exit(EX_CONSCHECK); return; } if (opt_lock) - fprintf(md_result_file,"LOCK TABLES %s WRITE;\n", result_table); + fprintf(md_result_file,"LOCK TABLES %s WRITE;\n", opt_quoted_table); total_length=net_buffer_length; /* Force row break */ row_break=0; @@ -1090,8 +1107,8 @@ static void dumpTable(uint numFields, char *table) { if (!(field = mysql_fetch_field(res))) { - sprintf(query,"%s: Not enough fields from table '%s'! Aborting.\n", - my_progname,table); + sprintf(query,"%s: Not enough fields from table %s! Aborting.\n", + my_progname, result_table); fputs(query,stderr); safe_exit(EX_CONSCHECK); return; @@ -1215,19 +1232,19 @@ static void dumpTable(uint numFields, char *table) fflush(md_result_file); if (mysql_errno(sock)) { - sprintf(query,"%s: Error %d: %s when dumping table '%s' at row: %ld\n", + sprintf(query,"%s: Error %d: %s when dumping table %s at row: %ld\n", my_progname, mysql_errno(sock), mysql_error(sock), - table, + result_table, rownr); fputs(query,stderr); safe_exit(EX_CONSCHECK); return; } if (opt_disable_keys) - fprintf(md_result_file,"\n/*!40000 ALTER TABLE %s ENABLE KEYS */;\n", - result_table); + fprintf(md_result_file, "\n/*!40000 ALTER TABLE %s ENABLE KEYS */;\n", + result_table); if (opt_lock) fputs("UNLOCK TABLES;\n", md_result_file); if (opt_autocommit) @@ -1351,7 +1368,7 @@ static int dump_all_tables_in_db(char *database) { char *table; uint numrows; - char table_buff[NAME_LEN+3]; + char table_buff[NAME_LEN*2+3]; if (init_dumping(database)) return 1; @@ -1361,9 +1378,8 @@ static int dump_all_tables_in_db(char *database) init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); for (numrows=0 ; (table = getTableName(1)) ; numrows++) { - dynstr_append(&query, "`"); - dynstr_append(&query, table); - dynstr_append(&query, "` READ /*!32311 LOCAL */,"); + dynstr_append(&query, quote_name(table, table_buff, 1)); + dynstr_append(&query, " READ /*!32311 LOCAL */,"); } if (numrows && mysql_real_query(sock, query.str, query.length-1)) DBerror(sock, "when using LOCK TABLES"); @@ -1392,7 +1408,7 @@ static int dump_all_tables_in_db(char *database) static int dump_selected_tables(char *db, char **table_names, int tables) { uint numrows; - char table_buff[NAME_LEN+3]; + char table_buff[NAME_LEN*+3]; if (init_dumping(db)) return 1; @@ -1404,9 +1420,8 @@ static int dump_selected_tables(char *db, char **table_names, int tables) init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); for (i=0 ; i < tables ; i++) { - dynstr_append(&query, "`"); - dynstr_append(&query, table_names[i]); - dynstr_append(&query, "` READ /*!32311 LOCAL */,"); + dynstr_append(&query, quote_name(table_names[i], table_buff, 1)); + dynstr_append(&query, " READ /*!32311 LOCAL */,"); } if (mysql_real_query(sock, query.str, query.length-1)) DBerror(sock, "when doing LOCK TABLES"); From be96cc09849ebff35af1c2b68e7ec10b5708468e Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Wed, 3 Sep 2003 22:27:04 +0200 Subject: [PATCH 13/27] bug #1172 - crash on force index() and SEL_ARG::MAYBE_KEY --- mysql-test/r/range.result | 13 +++++++++++++ mysql-test/t/range.test | 11 +++++++++++ sql/opt_range.cc | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index a02da87b0e9..2bd80cbfba3 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -260,3 +260,16 @@ explain select count(*) from t1 where x in (1,2); table type possible_keys key key_len ref rows Extra t1 range x x 5 NULL 2 Using where; Using index drop table t1; +CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1), KEY i2 (key1)); +INSERT INTO t1 VALUES (0),(0),(1),(1); +CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); +INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); +explain select * from t1, t2 where (t1.key1 type == SEL_ARG::MAYBE_KEY || (*key)->maybe_flag) - needed_reg|= (key_map) 1 << keynr; + needed_reg|= (key_map) 1 << keynr; found_records=check_quick_select(¶m, idx, *key); if (found_records != HA_POS_ERROR && found_records > 2 && @@ -716,7 +716,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables, param.range_count, found_records)+ (double) found_records / TIME_FOR_COMPARE); - if (read_time > found_read_time) + if (read_time > found_read_time && found_records != HA_POS_ERROR) { read_time=found_read_time; records=found_records; From b450f654900f95bc22fe67d8b23f500e9e66e8cd Mon Sep 17 00:00:00 2001 From: "greg@mysql.com" <> Date: Thu, 4 Sep 2003 12:56:02 -0400 Subject: [PATCH 14/27] Provide mysql_fix_privilege_tables.sql for Windows users to update grant tables (BUG #948) Fix make_win_src_distribution --- scripts/make_win_src_distribution.sh | 49 ++++++-- scripts/mysql_fix_privilege_tables.sql | 159 +++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 13 deletions(-) create mode 100644 scripts/mysql_fix_privilege_tables.sql diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 9b310722886..b0d63f1d6d8 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -13,8 +13,8 @@ DEBUG=0 SILENT=0 SUFFIX="" DIRNAME="" -OUTTAR=0 -OUTZIP=0 +OUTTAR="0" +OUTZIP="0" # # This script must run from MySQL top directory @@ -114,16 +114,37 @@ done # Convert argument file from unix to DOS text # -unix_to_dos() -{ - for arg do - print_debug "Replacing LF -> CRLF from '$arg'" +if [ `which recode` ] +then - sed -e 's/$/\r/' $arg > $arg.tmp - rm -f $arg - mv $arg.tmp $arg - done -} + print_debug "Using 'recode' to convert from unix to dos text" + + unix_to_dos() + { + for arg do + print_debug "Replacing LF -> CRLF from '$arg'" + + chmod u+w $arg + recode lat1..ibmpc $arg + done + } + +else + + print_debug "Using 'sed' to convert from unix to dos text" + + unix_to_dos() + { + for arg do + print_debug "Replacing LF -> CRLF from '$arg'" + + sed -e 's/$/\r/' $arg > $arg.tmp + rm -f $arg + mv $arg.tmp $arg + done + } + +fi # @@ -363,8 +384,10 @@ which_1 () # Create the result zip/tar file # -if [ [ "$OUTTAR" = "0" ] && [ "$OUTZIP" = "0" ] ]; then - OUTZIP=1 +if [ "$OUTTAR" = "0" ]; then + if [ "$OUTZIP" = "0" ]; then + OUTZIP=1 + fi fi set_tarzip_options() diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql new file mode 100644 index 00000000000..aca9a9c21d4 --- /dev/null +++ b/scripts/mysql_fix_privilege_tables.sql @@ -0,0 +1,159 @@ +-- This scripts updates the mysql.user, mysql.db, mysql.host and the +-- mysql.func tables to MySQL 3.22.14 and above. + +-- This is needed if you want to use the new GRANT functions, +-- CREATE AGGREGATE FUNCTION or want to use the more secure passwords in 3.23 + +-- If you get 'Access denied' errors, you should run this script again +-- and give the MySQL root user password as an argument! + + +-- Converting all privilege tables to MyISAM format +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; + + +-- Fix old password format, add File_priv and func table + +-- If your tables are already up to date or partially up to date you will +-- get some warnings about 'Duplicated column name'. You can safely ignore these! + +alter table user change password password char(16) 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, + ret tinyint(1) DEFAULT '0' NOT NULL, + dl char(128) DEFAULT '' NOT NULL, + type enum ('function','aggregate') NOT NULL, + PRIMARY KEY (name) +); + +-- Add the new grant colums + +-- Creating Grant Alter and Index privileges if they don't exists +-- You can ignore any Duplicate column errors +alter table user add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL; +alter table host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL; +alter table db add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL; + +-- If the new grant columns didn't exists, copy File -> Grant +-- and Create -> Alter, Index, References + +-- Setting default privileges for the new grant, index and alter privileges + UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv; + UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv; + UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv; + +-- +-- The second alter changes ssl_type to new 4.0.2 format + +-- Adding columns needed by GRANT .. REQUIRE (openssl)" +-- You can ignore any Duplicate column errors" +ALTER TABLE user +ADD ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL, +ADD ssl_cipher BLOB NOT NULL, +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 +-- + +-- Creating the new table and column privilege tables" + +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, + 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, + Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, + PRIMARY KEY (Host,Db,User,Table_name) +); +CREATE TABLE IF NOT EXISTS columns_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, + Column_name char(59) DEFAULT '' NOT NULL, + Timestamp timestamp(14), + Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, + PRIMARY KEY (Host,Db,User,Table_name,Column_name) +); + +-- +-- Name change of Type -> Column_priv from MySQL 3.22.12 +-- + +-- Changing name of columns_priv.Type -> columns_priv.Column_priv +-- You can ignore any Unknown column errors from this + + +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. +-- + +-- Fixing the func table +-- You can ignore any Duplicate column errors + +alter table func add type enum ('function','aggregate') NOT NULL; + + +-- +-- Change the user,db and host tables to MySQL 4.0 format +-- + +-- Adding new fields used by MySQL 4.0.2 to the privilege tables +-- You can ignore any Duplicate column errors + + +alter table user +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, +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; + + +-- Convert privileges so that users have similar privileges as before + +-- Updating new privileges in MySQL 4.0.2 from old ones + + 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<>""; + + +-- 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; +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; + From 088406deb97d5e7671b7d4b12214786f675cdee3 Mon Sep 17 00:00:00 2001 From: "greg@mysql.com" <> Date: Thu, 4 Sep 2003 16:00:05 -0400 Subject: [PATCH 15/27] Windows fix to avoid VC++ 6.0 compiler bug, which prevents compilation when function calls are present inside an expanded inline function --- innobase/fsp/fsp0fsp.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/innobase/fsp/fsp0fsp.c b/innobase/fsp/fsp0fsp.c index 20bf4972f64..8727c5156e4 100644 --- a/innobase/fsp/fsp0fsp.c +++ b/innobase/fsp/fsp0fsp.c @@ -2656,7 +2656,13 @@ fseg_free_page_low( ulint not_full_n_used; ulint state; ulint i; - char errbuf[200]; + char errbuf[200]; + +#ifdef __WIN__ + dulint desm; + dulint segm; +#endif + ut_ad(seg_inode && mtr); ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == @@ -2736,7 +2742,10 @@ fseg_free_page_low( fprintf(stderr, "InnoDB: Dump of the segment inode: %s\n", errbuf); - fprintf(stderr, + +#ifndef __WIN__ + + fprintf(stderr, "InnoDB: Serious error: InnoDB is trying to free space %lu page %lu,\n" "InnoDB: which does not belong to segment %lu %lu but belongs\n" "InnoDB: to segment %lu %lu.\n", @@ -2750,6 +2759,26 @@ fseg_free_page_low( ut_dulint_get_low( mtr_read_dulint(seg_inode + FSEG_ID, MLOG_8BYTES, mtr))); +#else + +/* More pedantic usage to avoid VC++ 6.0 compiler errors due to inline + function expansion issues */ + + desm = mtr_read_dulint(descr + XDES_ID, MLOG_8BYTES, mtr); + segm = mtr_read_dulint(seg_inode + FSEG_ID, MLOG_8BYTES, mtr); + + fprintf(stderr, +"InnoDB: Serious error: InnoDB is trying to free space %lu page %lu,\n" +"InnoDB: which does not belong to segment %lu %lu but belongs\n" +"InnoDB: to segment %lu %lu.\n", + space, page, + ut_dulint_get_high(desm), + ut_dulint_get_low(desm), + ut_dulint_get_high(segm), + ut_dulint_get_low(segm)); + +#endif + fprintf(stderr, "InnoDB: If the InnoDB recovery crashes here, see section 6.1\n" "InnoDB: of http://www.innodb.com/ibman.html about forcing recovery.\n"); From 75b2c4a62f5e6501500fa46348b47e4d9d2f2881 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Fri, 5 Sep 2003 06:42:55 +0300 Subject: [PATCH 16/27] Fixed rare bug in MYISAM introduced in 4.0.3 where the index file header was not updated directly after an UPDATE of split dynamic rows. --- myisam/mi_locking.c | 6 ++++-- myisam/mi_open.c | 9 +++++---- myisam/mi_update.c | 32 +++++++++++++++++++++++++------- mysql-test/r/myisam.result | 22 ++++++++++++++++++++++ mysql-test/t/myisam.test | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 13 deletions(-) diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 18daebffa85..a707eb294a9 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -76,6 +76,8 @@ int mi_lock_database(MI_INFO *info, int lock_type) } if (!count) { + DBUG_PRINT("info",("changed: %u w_locks: %u", + (uint) share->changed, share->w_locks)); if (share->changed && !share->w_locks) { share->state.process= share->last_process=share->this_process; @@ -352,6 +354,8 @@ int _mi_writeinfo(register MI_INFO *info, uint operation) int error,olderror; MYISAM_SHARE *share=info->s; DBUG_ENTER("_mi_writeinfo"); + DBUG_PRINT("info",("operation: %u tot_locks: %u", operation, + share->tot_locks)); error=0; if (share->tot_locks == 0) @@ -379,9 +383,7 @@ int _mi_writeinfo(register MI_INFO *info, uint operation) my_errno=olderror; } else if (operation) - { share->changed= 1; /* Mark keyfile changed */ - } DBUG_RETURN(error); } /* _mi_writeinfo */ diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 857ca1486fd..580261d8078 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -730,6 +730,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite) uchar *ptr=buff; uint i, keys= (uint) state->header.keys, key_blocks=state->header.max_block_size; + DBUG_ENTER("mi_state_info_write"); memcpy_fixed(ptr,&state->header,sizeof(state->header)); ptr+=sizeof(state->header); @@ -780,10 +781,10 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite) } if (pWrite & 1) - return my_pwrite(file,(char*) buff, (uint) (ptr-buff), 0L, - MYF(MY_NABP | MY_THREADSAFE)); - else - return my_write(file, (char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); + DBUG_RETURN(my_pwrite(file,(char*) buff, (uint) (ptr-buff), 0L, + MYF(MY_NABP | MY_THREADSAFE))); + DBUG_RETURN(my_write(file, (char*) buff, (uint) (ptr-buff), + MYF(MY_NABP))); } diff --git a/myisam/mi_update.c b/myisam/mi_update.c index 1614d6ca19d..f9ed969d8b5 100644 --- a/myisam/mi_update.c +++ b/myisam/mi_update.c @@ -94,7 +94,14 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) if (_mi_ft_cmp(info,i,oldrec, newrec)) { if ((int) i == info->lastinx) + { + /* + We are changeing the index we are reading on. Mark that + the index data has changed and we need to do a full search + when doing read-next + */ key_changed|=HA_STATE_WRITTEN; + } changed|=((ulonglong) 1 << i); if (_mi_ft_update(info,i,(char*) old_key,oldrec,newrec,pos)) goto err; @@ -121,25 +128,36 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) } /* If we are running with external locking, we must update the index file - that something has changed + that something has changed. */ if (changed || !my_disable_locking) - key_changed|= HA_STATE_KEY_CHANGED; + key_changed|= HA_STATE_CHANGED; if (share->calc_checksum) { info->checksum=(*share->calc_checksum)(info,newrec); - key_changed|= HA_STATE_KEY_CHANGED; /* Must update index file */ + /* Store new checksum in index file header */ + key_changed|= HA_STATE_CHANGED; } { - /* Don't update index file if data file is not extended */ + /* + Don't update index file if data file is not extended and no status + information changed + */ MI_STATUS_INFO state; + ha_rows org_split; + my_off_t org_delete_link; + memcpy((char*) &state, (char*) info->state, sizeof(state)); + org_split= share->state.split; + org_delete_link= share->state.dellink; if ((*share->update_record)(info,pos,newrec)) goto err; if (!key_changed && - memcmp((char*) &state, (char*) info->state, sizeof(state))) - key_changed|= HA_STATE_KEY_CHANGED; /* Must update index file */ + (memcmp((char*) &state, (char*) info->state, sizeof(state)) || + org_split != share->state.split || + org_delete_link != share->state.dellink)) + key_changed|= HA_STATE_CHANGED; /* Must update index file */ } if (auto_key_changed) update_auto_increment(info,newrec); @@ -163,7 +181,7 @@ err: DBUG_PRINT("error",("key: %d errno: %d",i,my_errno)); save_errno=my_errno; if (changed) - key_changed|= HA_STATE_KEY_CHANGED; + key_changed|= HA_STATE_CHANGED; if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL) { info->errkey= (int) i; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index e78e12c01d5..3052af3499d 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -364,3 +364,25 @@ explain select * from t1 force index (a) where a=0 or a=2; table type possible_keys key key_len ref rows Extra t1 range a a 4 NULL 4 Using where drop table t1,t2; +create table t1 (a int not null auto_increment primary key, b varchar(255)); +insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100)); +update t1 set b=repeat(left(b,1),200) where a=1; +delete from t1 where (a & 1)= 0; +update t1 set b=repeat('e',200) where a=1; +flush tables; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +update t1 set b=repeat(left(b,1),255) where a between 1 and 5; +update t1 set b=repeat(left(b,1),10) where a between 32 and 43; +update t1 set b=repeat(left(b,1),2) where a between 64 and 66; +update t1 set b=repeat(left(b,1),65) where a between 67 and 70; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +insert into t1 (b) values (repeat('z',100)); +update t1 set b="test" where left(b,1) > 'n'; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 02c92109816..a5490153a17 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -352,3 +352,37 @@ explain select * from t1,t2 force index(c) where t1.a=t2.a; explain select * from t1 where a=0 or a=2; explain select * from t1 force index (a) where a=0 or a=2; drop table t1,t2; + +# +# Test bug when updating a split dynamic row where keys are not changed +# + +create table t1 (a int not null auto_increment primary key, b varchar(255)); +insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100)); +update t1 set b=repeat(left(b,1),200) where a=1; +delete from t1 where (a & 1)= 0; +update t1 set b=repeat('e',200) where a=1; +flush tables; +check table t1; + +# +# check updating with keys +# + +disable_query_log; +let $1 = 100; +while ($1) +{ + eval insert into t1 (b) values (repeat(char(($1 & 32)+65), $1)); + dec $1; +} +enable_query_log; +update t1 set b=repeat(left(b,1),255) where a between 1 and 5; +update t1 set b=repeat(left(b,1),10) where a between 32 and 43; +update t1 set b=repeat(left(b,1),2) where a between 64 and 66; +update t1 set b=repeat(left(b,1),65) where a between 67 and 70; +check table t1; +insert into t1 (b) values (repeat('z',100)); +update t1 set b="test" where left(b,1) > 'n'; +check table t1; +drop table t1; From 1d798954029f5901c55e63685218522bd59c3b38 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Fri, 5 Sep 2003 08:16:13 +0300 Subject: [PATCH 17/27] after merge fixes --- client/mysqldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index db109bc2d5c..6ef9d75249d 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1002,7 +1002,7 @@ static void dumpTable(uint numFields, char *table) } if (opt_disable_keys) - fprintf(sql_file, "\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n", + fprintf(md_result_file, "\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n", opt_quoted_table); if (opt_lock) fprintf(md_result_file,"LOCK TABLES %s WRITE;\n", opt_quoted_table); From 493d5f9504b38b8114ebdc788e597c1a4e773889 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 5 Sep 2003 11:42:21 +0200 Subject: [PATCH 18/27] bug#926 fix undone - it caused suboptimal execution plan for "range ON, no WHERE" query Another fix applied --- sql/sql_select.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 153b083b3ef..6f6d21f1f8b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -146,7 +146,7 @@ static void copy_sum_funcs(Item_sum **func_ptr); static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab); static void init_sum_functions(Item_sum **func); static bool update_sum_func(Item_sum **func); -static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, +static void select_describe(JOIN *join, bool need_tmp_table,bool need_order, bool distinct, const char *message=NullS); static void describe_info(JOIN *join, const char *info); @@ -2663,13 +2663,30 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) join->thd->select_limit < join->best_positions[i].records_read && !(join->select_options & OPTION_FOUND_ROWS))) { + /* Join with outer join condition */ + COND *orig_cond=sel->cond; + sel->cond=and_conds(sel->cond,tab->on_expr); if (sel->test_quick_select(tab->keys, used_tables & ~ current_map, (join->select_options & OPTION_FOUND_ROWS ? HA_POS_ERROR : join->thd->select_limit)) < 0) - DBUG_RETURN(1); // Impossible range + { /* before reporting "Impossible WHERE" for the whole query + we have to check isn't it only "impossible ON" instead */ + sel->cond=orig_cond; + if (!tab->on_expr || + sel->test_quick_select(tab->keys, + used_tables & ~ current_map, + (join->select_options & + OPTION_FOUND_ROWS ? + HA_POS_ERROR : + join->thd->select_limit)) < 0) + DBUG_RETURN(1); // Impossible WHERE + } + else + sel->cond=orig_cond; + /* Fix for EXPLAIN */ if (sel->quick) join->best_positions[i].records_read= sel->quick->records; From e0d04fd22bd708a69909a298247af73bf789532a Mon Sep 17 00:00:00 2001 From: "carsten@tsort.bitbybit.dk" <> Date: Fri, 5 Sep 2003 14:44:21 +0200 Subject: [PATCH 19/27] Add QUICK as mysql-recover option in mysqld --help --- BitKeeper/etc/logging_ok | 1 + sql/mysqld.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 348ed8d24df..d55ab57a458 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -14,6 +14,7 @@ bar@bar.udmsearch.izhnet.ru bell@laptop.sanja.is.com.ua bell@sanja.is.com.ua bk@admin.bk +carsten@tsort.bitbybit.dk davida@isil.mysql.com dlenev@build.mysql.com dlenev@mysql.com diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 10d7955f13b..bcf115feccc 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3492,7 +3492,7 @@ Does nothing yet.", (gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"myisam-recover", OPT_MYISAM_RECOVER, - "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP or FORCE.", + "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP, FORCE or QUICK.", (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"memlock", OPT_MEMLOCK, "Lock mysqld in memory", (gptr*) &locked_in_memory, From d45ff0e31426dce6cce849a87aa09e2a29156ffb Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Sat, 6 Sep 2003 15:06:08 -0400 Subject: [PATCH 20/27] added space after first '--' in the long '----....' comment line in mysqldump just to make it compatible with the manual (fixed bug #1056) --- client/mysqldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index f1425faf0ed..68af4fd6953 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -307,7 +307,7 @@ static void write_header(FILE *sql_file, char *db_name) fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION); fprintf(sql_file, "-- Host: %s Database: %s\n", current_host ? current_host : "localhost", db_name ? db_name : ""); - fputs("---------------------------------------------------------\n", + fputs("-- ------------------------------------------------------\n", sql_file); fprintf(sql_file, "-- Server version\t%s\n", mysql_get_server_info(&mysql_connection)); From 2ef05e37470eca69702f681c34d7c0834ab964c2 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Sat, 6 Sep 2003 18:59:04 -0400 Subject: [PATCH 21/27] fixed Bug #1184 (change type of opt_ignore_lines to longlong) --- client/mysqlimport.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/mysqlimport.c b/client/mysqlimport.c index d7f6c4c0368..c72e32dd2a7 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -46,7 +46,7 @@ static char *opt_password=0, *current_user=0, *escaped=0, *opt_columns=0, *default_charset; static uint opt_mysql_port=0; static my_string opt_mysql_unix_port=0; -static my_string opt_ignore_lines=0; +static longlong opt_ignore_lines= -1; #include static struct my_option my_long_options[] = @@ -90,7 +90,7 @@ static struct my_option my_long_options[] = {"ignore", 'i', "If duplicate unique key was found, keep old row.", (gptr*) &ignore, (gptr*) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.", - (gptr*) &opt_ignore_lines, (gptr*) &opt_ignore_lines, 0, GET_STR, + (gptr*) &opt_ignore_lines, (gptr*) &opt_ignore_lines, 0, GET_LL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, @@ -290,8 +290,9 @@ static int write_to_table(char *filename, MYSQL *sock) " OPTIONALLY ENCLOSED BY"); end= add_load_option(end, escaped, " ESCAPED BY"); end= add_load_option(end, lines_terminated, " LINES TERMINATED BY"); - if (opt_ignore_lines) - end= strmov(strmov(strmov(end, " IGNORE "), opt_ignore_lines), " LINES"); + if (opt_ignore_lines >= 0) + end= strmov(longlong10_to_str(opt_ignore_lines, + strmov(end, " IGNORE "),10), " LINES"); if (opt_columns) end= strmov(strmov(strmov(end, " ("), opt_columns), ")"); *end= '\0'; From 95bf984d1552e4bc19395b5bc85f3ef054784436 Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Mon, 8 Sep 2003 13:02:19 +0500 Subject: [PATCH 22/27] Fix for #1210 i fixed this in 4.1 in slightly different way --- libmysqld/lib_sql.cc | 7 ++++--- libmysqld/libmysqld.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index eddb326f6c4..52ff08b8787 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -306,7 +306,8 @@ char **copy_arguments(int argc, char **argv) extern "C" { -static my_bool inited, org_my_init_done; +static my_bool org_my_init_done; +my_bool server_inited; ulong max_allowed_packet, net_buffer_length; char ** copy_arguments_ptr= 0; @@ -338,9 +339,9 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups) my_umask_dir=0700; // Default umask for new directories /* Only call MY_INIT() if it hasn't been called before */ - if (!inited) + if (!server_inited) { - inited=1; + server_inited=1; org_my_init_done=my_init_done; } if (!org_my_init_done) diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 782731d4765..20dde620131 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -74,6 +74,8 @@ static int send_file_to_server(MYSQL *mysql,const char *filename); static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, const char *from, ulong length); +extern char server_inited; + #define init_sigpipe_variables #define set_sigpipe(mysql) #define reset_sigpipe(mysql) @@ -802,6 +804,17 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, db ? db : "(Null)", user ? user : "(Null)")); + /* + Check mysql_server_init was called. + This code shouldn't be merged to 4.1 + */ + if (!server_inited) + { + net->last_errno=CR_UNKNOWN_ERROR; + strmov(net->last_error,ER(net->last_errno)); + goto error; + } + net->vio = 0; /* If something goes wrong */ /* use default options */ if (mysql->options.my_cnf_file || mysql->options.my_cnf_group) From 05f53a0422f4aef00a1c061894aba945fc92c4f3 Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Mon, 8 Sep 2003 14:46:44 +0500 Subject: [PATCH 23/27] fix for #1211 --- sql/sql_parse.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 663567acfbd..4482342f4ce 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1499,6 +1499,8 @@ mysql_execute_command(void) res = mysql_restore_table(thd, tables); break; } + +#ifndef EMBEDDED_LIBRARY case SQLCOM_CHANGE_MASTER: { if (check_global_access(thd, SUPER_ACL)) @@ -1535,6 +1537,8 @@ mysql_execute_command(void) else res = load_master_data(thd); break; + +#endif /*!EMBEDDED_LIBRARY*/ #ifdef HAVE_INNOBASE_DB case SQLCOM_SHOW_INNODB_STATUS: @@ -1546,6 +1550,7 @@ mysql_execute_command(void) } #endif +#ifndef EMBEDDED_LIBRARY case SQLCOM_LOAD_MASTER_TABLE: { if (!tables->db) @@ -1572,6 +1577,8 @@ mysql_execute_command(void) UNLOCK_ACTIVE_MI; break; } +#endif /*!EMBEDDED_LIBRARY*/ + case SQLCOM_CREATE_TABLE: { ulong want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ? @@ -1676,6 +1683,7 @@ mysql_execute_command(void) res = mysql_create_index(thd, tables, lex->key_list); break; +#ifndef EMBEDDED_LIBRARY case SQLCOM_SLAVE_START: { LOCK_ACTIVE_MI; @@ -1708,6 +1716,8 @@ mysql_execute_command(void) UNLOCK_ACTIVE_MI; break; } +#endif /*!EMBEDDED_LIBRARY*/ + case SQLCOM_ALTER_TABLE: #if defined(DONT_ALLOW_SHOW_COMMANDS) send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ From 99490870e6fbc26208d044d712e28b1095f0aada Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Tue, 9 Sep 2003 20:06:50 +0300 Subject: [PATCH 24/27] Cleaned up last bug fixes Fix bug in SHOW GRANTS when there is a column privilege but no table privilege --- include/mysql.h | 2 + libmysqld/libmysqld.c | 2 - mysql-test/r/grant.result | 54 +++---- mysql-test/r/mix_innodb_myisam_binlog.result | 162 +++++++++---------- mysql-test/t/grant.test | 32 ++-- mysql-test/t/mix_innodb_myisam_binlog.test | 137 ++++++++-------- sql/sql_acl.cc | 6 +- sql/sql_parse.cc | 12 +- 8 files changed, 206 insertions(+), 201 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index fb650343399..b27d98e7e57 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -424,6 +424,8 @@ int simple_command(MYSQL *mysql,enum enum_server_command command, unsigned long net_safe_read(MYSQL* mysql); void mysql_once_init(void); +extern my_bool server_inited; + #ifdef __NETWARE__ #pragma pack(pop) /* restore alignment */ #endif diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 20dde620131..70ac4ce46c5 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -74,8 +74,6 @@ static int send_file_to_server(MYSQL *mysql,const char *filename); static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, const char *from, ulong length); -extern char server_inited; - #define init_sigpipe_variables #define set_sigpipe(mysql) #define reset_sigpipe(mysql) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 6ed5445233c..1a968fa4f2f 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -91,39 +91,39 @@ show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' GRANT SELECT, INSERT, INSERT (a), REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost' -REVOKE insert,insert (a) on t1 from mysqltest_1@localhost; -GRANT references on t1 to mysqltest_1@localhost; +REVOKE select,update,insert,insert (a) on t1 from mysqltest_1@localhost; show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' -GRANT SELECT, REFERENCES, REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost' +GRANT REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost' +GRANT select,references on t1 to mysqltest_1@localhost; select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; table_priv column_priv Select,References References -grant all on test.* to user1@localhost with grant option; -revoke all on test.* from user1@localhost; -show grants for user1@localhost; -Grants for user1@localhost -GRANT USAGE ON *.* TO 'user1'@'localhost' -GRANT USAGE ON `test`.* TO 'user1'@'localhost' WITH GRANT OPTION -revoke grant option on test.* from user1@localhost; -show grants for user1@localhost; -Grants for user1@localhost -GRANT USAGE ON *.* TO 'user1'@'localhost' -grant all on test.t1 to user2@localhost with grant option; -revoke all on test.t1 from user2@localhost; -show grants for user2@localhost; -Grants for user2@localhost -GRANT USAGE ON *.* TO 'user2'@'localhost' -GRANT USAGE ON `test`.`t1` TO 'user2'@'localhost' WITH GRANT OPTION -revoke grant option on test.t1 from user2@localhost; -show grants for user2@localhost; -Grants for user2@localhost -GRANT USAGE ON *.* TO 'user2'@'localhost' -delete from mysql.user where user='mysqltest_1'; -delete from mysql.db where user='mysqltest_1'; -delete from mysql.tables_priv where user='mysqltest_1'; -delete from mysql.columns_priv where user='mysqltest_1'; +grant all on test.* to mysqltest_3@localhost with grant option; +revoke all on test.* from mysqltest_3@localhost; +show grants for mysqltest_3@localhost; +Grants for mysqltest_3@localhost +GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost' +GRANT USAGE ON `test`.* TO 'mysqltest_3'@'localhost' WITH GRANT OPTION +revoke grant option on test.* from mysqltest_3@localhost; +show grants for mysqltest_3@localhost; +Grants for mysqltest_3@localhost +GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost' +grant all on test.t1 to mysqltest_2@localhost with grant option; +revoke all on test.t1 from mysqltest_2@localhost; +show grants for mysqltest_2@localhost; +Grants for mysqltest_2@localhost +GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost' +GRANT USAGE ON `test`.`t1` TO 'mysqltest_2'@'localhost' WITH GRANT OPTION +revoke grant option on test.t1 from mysqltest_2@localhost; +show grants for mysqltest_2@localhost; +Grants for mysqltest_2@localhost +GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost' +delete from mysql.user where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.db where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.tables_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; flush privileges; drop table t1; GRANT FILE on mysqltest.* to mysqltest_1@localhost; diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index 8a3415a81d0..cd96584b6a4 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -1,180 +1,180 @@ -drop table if exists ti, tm; -create table ti (a int) type=innodb; -create table tm (a int) type=myisam; +drop table if exists t1, t2; +create table t1 (a int) type=innodb; +create table t2 (a int) type=myisam; reset master; begin; -insert into ti values(1); -insert into tm select * from ti; +insert into t1 values(1); +insert into t2 select * from t1; commit; 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; BEGIN -master-bin.001 119 Query 1 79 use test; insert into ti values(1) -master-bin.001 178 Query 1 79 use test; insert into tm select * from ti +master-bin.001 119 Query 1 79 use test; insert into t1 values(1) +master-bin.001 178 Query 1 79 use test; insert into t2 select * from t1 master-bin.001 244 Query 1 244 use test; COMMIT -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(2); -insert into tm select * from ti; +insert into t1 values(2); +insert into t2 select * from t1; rollback; Warning: Some non-transactional changed tables couldn't be rolled back 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; BEGIN -master-bin.001 119 Query 1 79 use test; insert into ti values(2) -master-bin.001 178 Query 1 79 use test; insert into tm select * from ti +master-bin.001 119 Query 1 79 use test; insert into t1 values(2) +master-bin.001 178 Query 1 79 use test; insert into t2 select * from t1 master-bin.001 244 Query 1 244 use test; ROLLBACK -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(3); +insert into t1 values(3); savepoint my_savepoint; -insert into ti values(4); -insert into tm select * from ti; +insert into t1 values(4); +insert into t2 select * from t1; rollback to savepoint my_savepoint; Warning: Some non-transactional changed tables couldn't be rolled back commit; 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; BEGIN -master-bin.001 119 Query 1 79 use test; insert into ti values(3) +master-bin.001 119 Query 1 79 use test; insert into t1 values(3) master-bin.001 178 Query 1 79 use test; savepoint my_savepoint -master-bin.001 235 Query 1 79 use test; insert into ti values(4) -master-bin.001 294 Query 1 79 use test; insert into tm select * from ti +master-bin.001 235 Query 1 79 use test; insert into t1 values(4) +master-bin.001 294 Query 1 79 use test; insert into t2 select * from t1 master-bin.001 360 Query 1 79 use test; rollback to savepoint my_savepoint master-bin.001 429 Query 1 429 use test; COMMIT -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(5); +insert into t1 values(5); savepoint my_savepoint; -insert into ti values(6); -insert into tm select * from ti; +insert into t1 values(6); +insert into t2 select * from t1; rollback to savepoint my_savepoint; Warning: Some non-transactional changed tables couldn't be rolled back -insert into ti values(7); +insert into t1 values(7); commit; -select a from ti order by a; +select a from t1 order by a; a 5 7 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; BEGIN -master-bin.001 119 Query 1 79 use test; insert into ti values(5) +master-bin.001 119 Query 1 79 use test; insert into t1 values(5) master-bin.001 178 Query 1 79 use test; savepoint my_savepoint -master-bin.001 235 Query 1 79 use test; insert into ti values(6) -master-bin.001 294 Query 1 79 use test; insert into tm select * from ti +master-bin.001 235 Query 1 79 use test; insert into t1 values(6) +master-bin.001 294 Query 1 79 use test; insert into t2 select * from t1 master-bin.001 360 Query 1 79 use test; rollback to savepoint my_savepoint -master-bin.001 429 Query 1 79 use test; insert into ti values(7) +master-bin.001 429 Query 1 79 use test; insert into t1 values(7) master-bin.001 488 Query 1 488 use test; COMMIT -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; select get_lock("a",10); get_lock("a",10) 1 begin; -insert into ti values(8); -insert into tm select * from ti; +insert into t1 values(8); +insert into t2 select * from t1; select get_lock("a",10); get_lock("a",10) 1 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; BEGIN -master-bin.001 119 Query 1 79 use test; insert into ti values(8) -master-bin.001 178 Query 1 79 use test; insert into tm select * from ti +master-bin.001 119 Query 1 79 use test; insert into t1 values(8) +master-bin.001 178 Query 1 79 use test; insert into t2 select * from t1 master-bin.001 244 Query 1 244 use test; ROLLBACK -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; -insert into ti values(9); -insert into tm select * from ti; +insert into t1 values(9); +insert into t2 select * from t1; 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; insert into ti values(9) -master-bin.001 138 Query 1 138 use test; insert into tm select * from ti -delete from ti; -delete from tm; +master-bin.001 79 Query 1 79 use test; insert into t1 values(9) +master-bin.001 138 Query 1 138 use test; insert into t2 select * from t1 +delete from t1; +delete from t2; reset master; -insert into ti values(10); +insert into t1 values(10); begin; -insert into tm select * from ti; +insert into t2 select * from t1; 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; insert into ti values(10) -master-bin.001 139 Query 1 139 use test; insert into tm select * from ti -insert into ti values(11); +master-bin.001 79 Query 1 79 use test; insert into t1 values(10) +master-bin.001 139 Query 1 139 use test; insert into t2 select * from t1 +insert into t1 values(11); commit; 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; insert into ti values(10) -master-bin.001 139 Query 1 139 use test; insert into tm select * from ti +master-bin.001 79 Query 1 79 use test; insert into t1 values(10) +master-bin.001 139 Query 1 139 use test; insert into t2 select * from t1 master-bin.001 205 Query 1 205 use test; BEGIN -master-bin.001 245 Query 1 205 use test; insert into ti values(11) +master-bin.001 245 Query 1 205 use test; insert into t1 values(11) master-bin.001 305 Query 1 305 use test; COMMIT -alter table tm type=INNODB; -delete from ti; -delete from tm; +alter table t2 type=INNODB; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(12); -insert into tm select * from ti; +insert into t1 values(12); +insert into t2 select * from t1; commit; 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; BEGIN -master-bin.001 119 Query 1 79 use test; insert into ti values(12) -master-bin.001 179 Query 1 79 use test; insert into tm select * from ti +master-bin.001 119 Query 1 79 use test; insert into t1 values(12) +master-bin.001 179 Query 1 79 use test; insert into t2 select * from t1 master-bin.001 245 Query 1 245 use test; COMMIT -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(13); -insert into tm select * from ti; +insert into t1 values(13); +insert into t2 select * from t1; rollback; show binlog events from 79; Log_name Pos Event_type Server_id Orig_log_pos Info -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(14); +insert into t1 values(14); savepoint my_savepoint; -insert into ti values(15); -insert into tm select * from ti; +insert into t1 values(15); +insert into t2 select * from t1; rollback to savepoint my_savepoint; commit; 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; BEGIN -master-bin.001 119 Query 1 79 use test; insert into ti values(14) +master-bin.001 119 Query 1 79 use test; insert into t1 values(14) master-bin.001 179 Query 1 179 use test; COMMIT -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(16); +insert into t1 values(16); savepoint my_savepoint; -insert into ti values(17); -insert into tm select * from ti; +insert into t1 values(17); +insert into t2 select * from t1; rollback to savepoint my_savepoint; -insert into ti values(18); +insert into t1 values(18); commit; -select a from ti order by a; +select a from t1 order by a; a 16 18 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; BEGIN -master-bin.001 119 Query 1 79 use test; insert into ti values(16) -master-bin.001 179 Query 1 79 use test; insert into ti values(18) +master-bin.001 119 Query 1 79 use test; insert into t1 values(16) +master-bin.001 179 Query 1 79 use test; insert into t1 values(18) master-bin.001 239 Query 1 239 use test; COMMIT -drop table ti,tm; +drop table t1,t2; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 9b670b36f2c..598a7186a6e 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -62,24 +62,24 @@ show grants for mysqltest_1@localhost; select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; REVOKE select (a), update on t1 from mysqltest_1@localhost; show grants for mysqltest_1@localhost; -REVOKE insert,insert (a) on t1 from mysqltest_1@localhost; -GRANT references on t1 to mysqltest_1@localhost; +REVOKE select,update,insert,insert (a) on t1 from mysqltest_1@localhost; show grants for mysqltest_1@localhost; +GRANT select,references on t1 to mysqltest_1@localhost; select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; -grant all on test.* to user1@localhost with grant option; -revoke all on test.* from user1@localhost; -show grants for user1@localhost; -revoke grant option on test.* from user1@localhost; -show grants for user1@localhost; -grant all on test.t1 to user2@localhost with grant option; -revoke all on test.t1 from user2@localhost; -show grants for user2@localhost; -revoke grant option on test.t1 from user2@localhost; -show grants for user2@localhost; -delete from mysql.user where user='mysqltest_1'; -delete from mysql.db where user='mysqltest_1'; -delete from mysql.tables_priv where user='mysqltest_1'; -delete from mysql.columns_priv where user='mysqltest_1'; +grant all on test.* to mysqltest_3@localhost with grant option; +revoke all on test.* from mysqltest_3@localhost; +show grants for mysqltest_3@localhost; +revoke grant option on test.* from mysqltest_3@localhost; +show grants for mysqltest_3@localhost; +grant all on test.t1 to mysqltest_2@localhost with grant option; +revoke all on test.t1 from mysqltest_2@localhost; +show grants for mysqltest_2@localhost; +revoke grant option on test.t1 from mysqltest_2@localhost; +show grants for mysqltest_2@localhost; +delete from mysql.user where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.db where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.tables_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; flush privileges; drop table t1; diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 240aaefb349..be45c2c3133 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -1,83 +1,86 @@ # Check that binlog is ok when a transaction mixes updates to InnoDB and -# MyISAM. It would be nice to make this a replication test, but in 4.0 the slave -# is always with --skip-innodb in the testsuite. I (Guilhem) however did some -# tests manually on a slave; tables are replicated fine and Exec_master_log_pos -# advances as expected. +# MyISAM. +# It would be nice to make this a replication test, but in 4.0 the +# slave is always with --skip-innodb in the testsuite. I (Guilhem) however +# did some tests manually on a slave; tables are replicated fine and +# Exec_master_log_pos advances as expected. -- source include/have_innodb.inc +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + connect (con1,localhost,root,,); connect (con2,localhost,root,,); connection con1; - -drop table if exists ti, tm; -create table ti (a int) type=innodb; -create table tm (a int) type=myisam; +create table t1 (a int) type=innodb; +create table t2 (a int) type=myisam; reset master; begin; -insert into ti values(1); -insert into tm select * from ti; +insert into t1 values(1); +insert into t2 select * from t1; commit; show binlog events from 79; -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(2); -insert into tm select * from ti; -# should say some changes to non-transactional tables couldn't be rolled back +insert into t1 values(2); +insert into t2 select * from t1; +# should say some changes to non-transact1onal tables couldn't be rolled back --error 1196 rollback; show binlog events from 79; -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(3); +insert into t1 values(3); savepoint my_savepoint; -insert into ti values(4); -insert into tm select * from ti; +insert into t1 values(4); +insert into t2 select * from t1; --error 1196 rollback to savepoint my_savepoint; commit; show binlog events from 79; -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(5); +insert into t1 values(5); savepoint my_savepoint; -insert into ti values(6); -insert into tm select * from ti; +insert into t1 values(6); +insert into t2 select * from t1; --error 1196 rollback to savepoint my_savepoint; -insert into ti values(7); +insert into t1 values(7); commit; -select a from ti order by a; # check that savepoints work :) +select a from t1 order by a; # check that savepoints work :) show binlog events from 79; # and when ROLLBACK is not explicit? -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; select get_lock("a",10); begin; -insert into ti values(8); -insert into tm select * from ti; +insert into t1 values(8); +insert into t2 select * from t1; disconnect con1; connection con2; @@ -89,87 +92,87 @@ connection con2; select get_lock("a",10); show binlog events from 79; -# and when not in a transaction? -delete from ti; -delete from tm; +# and when not in a transact1on? +delete from t1; +delete from t2; reset master; -insert into ti values(9); -insert into tm select * from ti; +insert into t1 values(9); +insert into t2 select * from t1; show binlog events from 79; -# Check that when the query updating the MyISAM table is the first in the -# transaction, we log it immediately. -delete from ti; -delete from tm; +# Check that when the query updat1ng the MyISAM table is the first in the +# transact1on, we log it immediately. +delete from t1; +delete from t2; reset master; -insert into ti values(10); # first make ti non-empty +insert into t1 values(10); # first make t1 non-empty begin; -insert into tm select * from ti; +insert into t2 select * from t1; show binlog events from 79; -insert into ti values(11); +insert into t1 values(11); commit; show binlog events from 79; -# Check that things work like before this BEGIN/ROLLBACK code was added, when tm -# is INNODB +# Check that things work like before this BEGIN/ROLLBACK code was added, +# when t2 is INNODB -alter table tm type=INNODB; +alter table t2 type=INNODB; -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(12); -insert into tm select * from ti; +insert into t1 values(12); +insert into t2 select * from t1; commit; show binlog events from 79; -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(13); -insert into tm select * from ti; +insert into t1 values(13); +insert into t2 select * from t1; rollback; show binlog events from 79; -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(14); +insert into t1 values(14); savepoint my_savepoint; -insert into ti values(15); -insert into tm select * from ti; +insert into t1 values(15); +insert into t2 select * from t1; rollback to savepoint my_savepoint; commit; show binlog events from 79; -delete from ti; -delete from tm; +delete from t1; +delete from t2; reset master; begin; -insert into ti values(16); +insert into t1 values(16); savepoint my_savepoint; -insert into ti values(17); -insert into tm select * from ti; +insert into t1 values(17); +insert into t2 select * from t1; rollback to savepoint my_savepoint; -insert into ti values(18); +insert into t1 values(18); commit; -select a from ti order by a; # check that savepoints work :) +select a from t1 order by a; # check that savepoints work :) show binlog events from 79; -drop table ti,tm; +drop table t1,t2; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b76bbe8c730..0dbbb1cee70 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3091,17 +3091,19 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) if ((table_access | grant_table->cols) != 0) { String global(buff,sizeof(buff)); + ulong test_access= (table_access | grant_table->cols) & ~GRANT_ACL; + global.length(0); global.append("GRANT ",6); if (test_all_bits(table_access, (TABLE_ACLS & ~GRANT_ACL))) global.append("ALL PRIVILEGES",14); - else if (!(table_access & ~GRANT_ACL)) + else if (!test_access) global.append("USAGE",5); else { int found= 0; - ulong j,test_access= (table_access | grant_table->cols) & ~GRANT_ACL; + ulong j; for (counter= 0, j= SELECT_ACL; j <= TABLE_ACLS; counter++, j<<= 1) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4482342f4ce..4d010ac9a4b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1500,7 +1500,7 @@ mysql_execute_command(void) break; } -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION case SQLCOM_CHANGE_MASTER: { if (check_global_access(thd, SUPER_ACL)) @@ -1538,7 +1538,7 @@ mysql_execute_command(void) res = load_master_data(thd); break; -#endif /*!EMBEDDED_LIBRARY*/ +#endif /* HAVE_REPLICATION */ #ifdef HAVE_INNOBASE_DB case SQLCOM_SHOW_INNODB_STATUS: @@ -1550,7 +1550,7 @@ mysql_execute_command(void) } #endif -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION case SQLCOM_LOAD_MASTER_TABLE: { if (!tables->db) @@ -1577,7 +1577,7 @@ mysql_execute_command(void) UNLOCK_ACTIVE_MI; break; } -#endif /*!EMBEDDED_LIBRARY*/ +#endif /* HAVE_REPLICATION */ case SQLCOM_CREATE_TABLE: { @@ -1683,7 +1683,7 @@ mysql_execute_command(void) res = mysql_create_index(thd, tables, lex->key_list); break; -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION case SQLCOM_SLAVE_START: { LOCK_ACTIVE_MI; @@ -1716,7 +1716,7 @@ mysql_execute_command(void) UNLOCK_ACTIVE_MI; break; } -#endif /*!EMBEDDED_LIBRARY*/ +#endif /* HAVE_REPLICATION */ case SQLCOM_ALTER_TABLE: #if defined(DONT_ALLOW_SHOW_COMMANDS) From 57290ee65f17cfac996e02203bbe03e3898f8a0d Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 10 Sep 2003 16:48:57 +0200 Subject: [PATCH 25/27] - Updated version number to 4.0.16 now that 4.0.15 has been released - tagged ChangeSet 1.1556 as mysql-4.0.15 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 0538199e8e1..fb573f0030f 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.0.15) +AM_INIT_AUTOMAKE(mysql, 4.0.16) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 541189e746bd89d56657438bd7c9d14910857c2b Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 10 Sep 2003 17:48:43 +0200 Subject: [PATCH 26/27] - Added option "--skip-name-resolve" to mysql_install_db to be able to use the local machine's IP address instead of the host name when building the initial grant tables if "skip-name-resolve" has been specified in my.cnf. This can be helpful on FreeBSD to avoid thread-safety problems with the FreeBSD resolver libraries. (Thanks to Jeremy Zawodny for the patch) --- scripts/mysql_install_db.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 920bd27cc88..0e685ba38e4 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -37,6 +37,7 @@ parse_arguments() { --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --skip-name-resolve) ip_only=1 ;; *) if test -n "$pick_args" then @@ -135,6 +136,12 @@ then fi fi +if test "$ip_only" -eq 1 +then + ip=`echo "$resolved" | awk '/ /{print $6}'` + hostname=$ip +fi + # Create database directories mysql & test if test ! -d $ldata; then mkdir $ldata; chmod 700 $ldata ; fi if test ! -d $ldata/mysql; then mkdir $ldata/mysql; chmod 700 $ldata/mysql ; fi From 223a9667638e320565eabf0a59378473ed96e8ba Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Thu, 11 Sep 2003 06:09:34 +0300 Subject: [PATCH 27/27] Remove not used define (my_strxfrm) --- include/m_ctype.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/m_ctype.h b/include/m_ctype.h index fc983d1d580..b3e50cec58f 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -142,7 +142,6 @@ extern const char *compiled_charset_name(uint charset_number); #define MY_STRXFRM_MULTIPLY (default_charset_info->strxfrm_multiply) #define my_strnxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c), (d))) #define my_strnncoll(s, a, b, c, d) ((s)->strnncoll((a), (b), (c), (d))) -#define my_strxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c))) #define my_strcoll(s, a, b) ((s)->strcoll((a), (b))) #define my_like_range(s, a, b, c, d, e, f, g, h) \ ((s)->like_range((a), (b), (c), (d), (e), (f), (g), (h)))